akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long MAX_N = 2e7;
long long min_factor[MAX_N] = {};
void InitFact(){
    for (long long i = 2; i < MAX_N;i++){
        if (min_factor[i] != 0) continue;
        for (long long j = i; j < MAX_N; j += i) {
            min_factor[j] = i;
        }
    }
    return;
}
void Fast_Factorize(long long n,map<long long,long long>&mp){
    while(n>1){
        mp[min_factor[n]]++;
        n /= min_factor[n];
    }
    return;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    ll gg = 0;
    map<ll, ll> ans;
    for (ll i = 0; i < n; i++) gg = gcd(gg, a[i]);
    bool flag1 = (gg == 1 ? true : false);
	InitFact();
    for (ll i = 0; i < n; i++) {
        Fast_Factorize(a[i], ans);
    }
    bool flag2 = true;
    for (ll i = 0; i < n; i++) {
        map<ll, ll> tmp;
        Fast_Factorize(a[i], tmp);
        for (auto i:tmp){
            if (i.second - ans[i.first] != 0) {
                flag2 = false;
                goto end;
            }
        }
    }
    end:
    if (flag2) cout << "pairwise coprime" << endl;
    else if(flag1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li k, n;
li a[200200];

int main() {
    cin >> k >> n;
    rin{
        cin >> a[i];
    }
    li ma = 0;
    rep(i, n - 1) {
        ma = max(ma, a[i + 1] - a[i]);
    }
    ma = max(ma, k - a[n - 1] + a[0]);
    cout << k - ma << endl;


    return 0;
}

Measured memory_bytes: 1792
x=int(input())
if(x<105):
    print ("0")
elif(x==105):
    print ("1")
else:
    f=1
    for j in range(107,x+1):
        if(j % 2 != 0):
            c=0
            for i in range(1, j + 1):
                if j % i == 0:
                    c=c+1
            if(c==8):
                f=f+1
    print(f)

Measured memory_bytes: 3064
a1, a2, a3 = map(int, input().split())
x = abs(a1 - a2) + abs(a2 - a3)
y = abs(a1 - a3) + abs(a1 - a2)
z = abs(a2 - a3) + abs(a1 - a3)
print(min(x, y, z))


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

using std::cin;
using std::cout;
using std::endl;
using std::vector;

void printLine(vector<int> line, int length);

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

    vector<int> line(length);
    for (auto i = 0; i < length; i++) {
        cin >> line.at(i);
    }
    printLine(line, length);

    int key;
    for (auto i = 1; i < length; i++) {
        key = line.at(i);

        auto j = i - 1;
        while (j >= 0 && line.at(j) > key) {
            line.at(j + 1) = line.at(j);
            j--;
        }
        line.at(j + 1) = key;

        printLine(line, length);
    }

    return 0;
}

void printLine(vector<int> line, int length)
{
    for (auto i = 0; i < length; i++) {
        if (i != 0) {
            cout << " ";
        }
        cout << line.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int x; cin >> x;
    int times = 1;
    while (true) {
        if (times * 360 % x == 0) {
            cout << times * 360 / x << endl;
            return 0;
        } else {
            times++;
        }
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];
    vector<int> idx(N);
    iota(ALL(idx), 0);
    sort(ALL(idx), [&](auto l, auto r) {return A[l] < A[r];});
    REP(i, 0, N) {
        cout << idx[i] + 1;
        if (i != N - 1) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    n, k, q = [int(x) for x in input().split()]
    points = [0] * n
    for i in range(q):
        ind = int(input()) - 1
        points[ind] += 1
    # print(points)
    for i in range(n):
        points[i] = -q + points[i]
        # print(points[i], end=" ")
        points[i] += k
        # print(points[i], end=" ")
        if points[i] > 0:
            print("Yes")
        else:
            print("No")
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 16796
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    int n = s.size();
    rep(i, n) {
        if(s[i] != s[n-i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, n/2) {
        if(s[i] != s[n/2 - i - 1]) {
            cout << "No" << endl;
            return 0;  
        }
    }
    Rep(i, n/2, n) {
        if(s[i] != s[n - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[MAX];
int n,Dep[MAX],Hight[MAX];

void setDepth(int u,int d){
  if(u==NIL) return;
  Dep[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0;
  int h2=0;
  if(T[u].left!=NIL) h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL) h2=setHeight(T[u].right)+1;
  return Hight[u]=(h1>h2 ? h1:h2);
}

int getSibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  int deg;
  printf("node %d: parent = %d, sibling = %d, ",u,T[u].parent,getSibling(u));
  deg=0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,Dep[u],Hight[u]);
  if(T[u].parent==NIL){printf("root\n");}
  else if(T[u].left==NIL && T[u].right==NIL){printf("leaf\n");}
  else {printf("internal node\n");}
}

int main(){
  int v,l,r,i,root=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].parent=NIL;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) {T[l].parent=v;}
    if(r!=NIL) {T[r].parent=v;}
  }
  for(i=0;i<n;i++) {if(T[i].parent==NIL) root=i;}
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++){print(i);}
  return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
    ll A, B, K;
    cin >> A >> B >> K;
    ll i = 0;
    while(K--) {
        if(i % 2 == 0) {
            if(A % 2 == 1) {
                --A;
            } else {

            }
            A /= 2;
            B += A;
        } else {
            if(B % 2 == 1) {
                --B;
            }
                B /= 2;
                A += B;
            
        }
        i++;
    }
    cout << A << " " << B << endl;
    return 0;
}

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  int c=0;
  int d=0;
  int e=0;
  for(int i=0;i<n;i++){
    if(s[i]=='a' && e<a+b){
      cout<<"Yes"<<"\n";
      e++;
    }else if(s[i]=='b' && d+1<=b && e<a+b){
      cout<<"Yes"<<"\n";
      d++;
      e++;
    }else if(s[i]=='c'){
      cout<<"No"<<"\n";
      c++;
    }else{
      cout<<"No"<<"\n";
    }
  }
}



Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() 
{
 ios_base::sync_with_stdio(false);
cin.tie(NULL);
map<char,ll> m;
m['R']=0;
m['W']=0;
ll N;
cin>>N;
vector<char> v(N+1);
for(ll i=1;i<=N;i++)
{
    char data;
    cin>>data;
    m[data]++;
    v[i]=data;
}
ll ans=0;
if(!(m['R'] && m['W']))
{
    cout<<ans<<endl;
    return(0);
}
for(ll i=1;i<=m['R'];i++)
{
    if(v[i]=='W')
    ans++;
}
cout<<ans<<endl;
return(0);
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2){
      cout << "No" << endl;
  } 
  else{
      string a,b;
    for(int i=0;i<n/2;i++){
      a += s.at(i);
    }
    for(int i=n/2;i<n;i++){
        b+= s.at(i);
    }
    if(a==b) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 256
A,B=map(int,input().split())
ans=0
for num in range(A,B+1):
    num=str(num)
    check=True
    for i in range(len(num)):
        if num[i]!=num[len(num)-1-i]:
            check=False
            break
    if check:
        ans+=1
print(ans)


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


int main(){


  long long n;
  cin>>n;
  
  vector<long long> mins(40);
  vector<long long> maxs(40);
  
  mins.at(0)=0;
  maxs.at(0)=1;
  
  for (int i=1;i<40;i++){
    if (i%2==1){
      mins.at(i)=4*mins.at(i-1)-2;
      maxs.at(i)=maxs.at(i-1);
    }
    
    if (i%2==0){
      maxs.at(i)=4*maxs.at(i-1)+1;
      mins.at(i)=mins.at(i-1);
    }
  }
  

  
  
  
  vector<int> indexes;
  
  
  while (n!=0){
    for (int i=0;i<40;i++){
      if (mins.at(i)<=n and n<=maxs.at(i)){
        indexes.push_back(i);
        n-=pow(-2,i);
        break;
      }
    }
  }
  
  if (indexes.size()!=0){
  
  int mysize=indexes.at(0);
  


  for (int i=0;i<=mysize;i++){
    if ( find(indexes.begin(),indexes.end(),mysize-i)!=indexes.end()){
      cout<<"1";
    }
    else {
      cout<<"0";
    }
    
  }
  
  cout<<endl;
    
  }
  
  if (indexes.size()==0){
    cout<<0<<endl;
  }
  
  
  
  
  


  
  
  
    
    
    

  
}

Measured memory_bytes: 256
def main():
    T, *tn = map(int, open(0).read().split()[1:])
    print(tn[-1] + T - sum(t2 - t1 - T
                           for t1, t2
                           in zip(tn[0:], tn[1:])
                           if t2 - t1 > T))
    return


main()


Measured memory_bytes: 25132
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
    for(int i = 1; i<=9; ++i){
        for(int j = 1; j<=9; ++j){
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

#define INF 1<<29

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	map<int, int>love;
	for (int i = 0; i < n; i++) {
		love.insert(make_pair(i + 1, a[i]));
	}
	int ans = 0;
	for (auto i = love.begin(); i != love.end(); i++) {
		if (love.at(i->second) == (i->first)) {
			ans++;
		}
	}
	cout << ans / 2;
	return 0;
}

Measured memory_bytes: 5376
N = int(input())

coordinates = []
for i in range(N):
    x, y = map(int, input().split())
    coordinates.append((x, y))

import itertools
paths = list(itertools.permutations(range(N)))

total_length = 0
for i in paths:
    for j in range(N - 1):
        x1, y1 = coordinates[i[j]]
        x2, y2 = coordinates[i[j + 1]]
        total_length += ((x1 - x2)**2 + (y1 - y2)**2)**0.5

average_length = total_length / len(paths)
print(average_length)


Measured memory_bytes: 8180
n = int(input())
a = list(map(int,input().split()))
count = 0
s = []

def find_i():
    for i in range(n):
        if a[i] == max(a):
            return i+1
        
def find_m():
    for i in range(n):
        if a[i] == min(a):
            return i+1
        
maxi = find_i()
mini = find_m()

if min(a) < 0:
    if abs(min(a)) <= abs(max(a)):
        for _ in range(n):
            a[_] += max(a)
            s.append(str(maxi) + ' ' + str(_+1))
            count += 1
        for i in range(n-1):
            a[i+1] += a[i]
            s.append(str(i+1) + ' ' + str(i+2))
            count += 1
            
    else:
        for _ in range(n):
            a[_] += min(a)
            s.append(str(mini) + ' ' + str(_+1))
            count += 1
        for i in range(n-2,-1,-1):
            a[i] += a[i+1]
            s.append(str(i+2) + ' ' + str(i+1))
            count += 1

else:
    for i in range(n-1):
        a[i+1] += a[i]
        s.append(str(i+1) + ' ' + str(i+2))
        count += 1
print(count)
for i in range(len(s)):
    print (s[i])

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



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

const int mod = 1000000007;
int a[1002][1002];
int dp[1002][1002];

int main()
{
    int n , m;

    cin >> n >> m;

    for(int i = 1; i<=n ; i++)
    {
        string s;

        cin >> s;

        for(int j = 1 ; j<=m ; j++)
        {
            char c = s[j-1];

            if(c=='.')
                a[i][j] = 1;
            else
                a[i][j] = 0;

        }
    }

    dp[1][1] = 1;

    for(int i = 1 ; i<=n ; i++)
    {
        for(int j = 1 ; j<=m ; j++)
        {
            if(i==1 && j==1)
                continue;
            if(a[i][j]==1)
            {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            }
            else
                dp[i][j] = 0;

        }
    }

    cout << dp[n][m];
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> s;
    int n = s.size();
    int ret = n;
    for (int i = 0;  i+1 < n; i++) {
        if (s[i] != s[i+1]) {
            ret = min(ret, max(i+1, n-i-1));
        }
    }
    cout << ret << endl;

}

Measured memory_bytes: 512
// Si = A0 + A1 + ... + A(i-1)として、
// (i < j)で Sj = Si となる(i,j)の組み合わせを求める。
// 要素{Si}の配列を作って、ソートして、Pj個の同じ値の要素について、
// (Pj-1)*Pj/2を足していく
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<long long> S(N + 1, 0);
    for (int i = 1; i <= N; ++i) {
        S[i] = S[i - 1] + A[i - 1];
    }
    /*
    for (auto p : S) cout << p << " ";
    cout << endl;
    */
    sort(S.begin(), S.end());
    /*
    for (auto p : S) cout << p << " ";
    cout << endl;
    */
    long long ans = 0;
    long long len = 1;
    for (int i = 0; i <= N; ++i) {
        if (i == N) {
            ans += len * (len - 1) / 2;
            continue;
        }
        if (S[i] != S[i + 1]) {
            ans += len * (len - 1) / 2;
            len = 1;
        } else {
            ++len;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    string a, b;
    cin >> a >> b;

    int sum = 0;
    for (int i = 0; i < 3; ++i)
    {
        if (a.at(i) == b.at(i))
        {
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0; --i)
typedef long long ll;
using namespace std;
int N;
const ll MOD = 1000000007LL;
ll ls, rs;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    priority_queue<ll, vector<ll>, greater<ll> > left_pque;
    priority_queue<ll> right_pque;


    cin >> N;

    ll a[3*N];
    ll left_sum[N+1];
    ll right_sum[N+1];
    
    rep(i, N){
      ll b;
      cin >> b;
      a[i] = b;
      ls+=b;
      left_pque.push(b);
    } 
    rep(i, N) cin >> a[N+i]; 
    rep(i, N){
      ll b;
      cin >> b;
      a[2*N+i] = b;
      rs+=b;
      right_pque.push(b);
    }

    left_sum[0] = ls;
    rep(i, N){
      int trgt =a[N+i];
      ls+= trgt;
      left_pque.push(trgt);
      ll c = left_pque.top();
      ls -= c;
      left_pque.pop();
      left_sum[i+1] = ls;
    }

    right_sum[N] = rs;
    rep_down(i, N){ // N-1から0へ。
      int trgt =a[N+i];
      rs+=trgt;
      right_pque.push(trgt);
      ll c = right_pque.top();
      rs -= c;
      right_pque.pop();
      right_sum[i] = rs;
    }

    ll ans = - (1LL << 60);
    rep(i, N+1) ans = max(ans, left_sum[i] - right_sum[i]);
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n, w;
    cin >> n >> w;
    vector<vector<int>> vec(n, vector<int>(2));
    for ( int i = 0; i < n; ++i){
        cin >> vec.at(i).at(0) >> vec.at(i).at(1);
    }

    vector<vector<long long>> dp(n+1, vector<long long>(w+1, 0));
    for ( int count = 0; count < n; ++count) {
        for ( int weight = 0; weight < w+1; ++weight) {
            if ( weight < vec.at(count).at(0)) {
                dp.at(count+1).at(weight) = dp.at(count).at(weight);
            }
            else {
                dp.at(count+1).at(weight) = max(dp.at(count).at(weight-vec.at(count).at(0)) + vec.at(count).at(1), dp.at(count).at(weight));
            }
        }
    }
    cout << dp.at(n).at(w) << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

const ll MAX_N = 101, MAX_V = 100001;
ll dp[MAX_N][MAX_V];

int main() {
  ll N, W;
  cin >> N >> W;
  ll w[N], v[N];
  rep(i, N) cin >> w[i] >> v[i];
  rep(i, MAX_N) rep(j, MAX_V) dp[i][j] = LINF;
  dp[0][0] = 0;
  rep(i, N) rep(j, MAX_V) {
    if (j + v[i] < MAX_V)
      dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
  }
  ll ans = 0;
  rep(i, MAX_V) {
    if (dp[N][i] <= W) ans = max(ans, (ll)i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 79104
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val nums = listOfInt()

    var count = 0
    for (i in 0..n-1) {
        if (nums[i] != i+1) {
            count++
        }
    }

    if (count == 0 || count == 2) {
        println("YES")
    } else {
        println("NO")
    }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

int main()
{
	int n;
	string s;
	string ans;

	cin >> n;
	cin >> s;

	for (size_t i = 0; i < s.length(); i++)
	{
		ans.push_back(((s[i] - 'A') + n) % 26 + 'A');
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
int main()
{
   fast ;
   ll n,k ;
   cin>>n>>k ;
   cout<<min((n%k),k-n%k) ;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        if (i % 5 == 0 || i % 3 == 0 || i % 15 == 0) continue;
        else sum += i;
    }
    out(sum);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e6 + 1;
int dp[maxn][2][2];
signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  const int mod = 1e9 + 7;
  int n;
  cin >> n;
  dp[0][0][0] = 1;
  for (int pos = 0; pos < n; ++pos) {
    for (int hasZero = 0; hasZero <= 1; ++hasZero) {
      for (int hasNine = 0; hasNine <= 1; ++hasNine) {
        if (hasZero && hasNine) {
          dp[pos + 1][1][1] = (dp[pos + 1][1][1] + dp[pos][1][1] * 10) % mod;
        }
        else if (!hasZero && !hasNine){
          dp[pos + 1][1][0] = (dp[pos + 1][1][0] + dp[pos][0][0]) % mod;
          dp[pos + 1][0][1] = (dp[pos + 1][0][1] + dp[pos][0][0]) % mod;
          dp[pos + 1][0][0] = (dp[pos + 1][0][0] + dp[pos][0][0] * 8) % mod;
        }
        else if (hasZero && !hasNine) {
          dp[pos + 1][1][0] = (dp[pos + 1][1][0] + dp[pos][1][0] * 9) % mod;
          dp[pos + 1][1][1] = (dp[pos + 1][1][1] + dp[pos][1][0]) % mod;
        }
        else if (!hasZero && hasNine) {
          dp[pos + 1][0][1] = (dp[pos + 1][0][1] + dp[pos][0][1] * 9) % mod;
          dp[pos + 1][1][1] = (dp[pos + 1][1][1] + dp[pos][0][1]) % mod;
        }
        else {
          assert(false);
        }
      }
    }
  }
  cout << dp[n][1][1];
}

Measured memory_bytes: 34824
#include <iostream>
    using namespace std;
bool primes[1000000];

void Sieve(){
 for(int i= 2; i < 1000000; i++){
   primes[i] = true;
 } 
 primes[1] = false;
 
 for(int i = 2; i <= 1000; i++){
   if(primes[i] == true)
     for(int j=i; j*i <= 1000000;j++){
       primes[j*i] = false;
     }
 }
}

bool IsPrime(int x){
 return primes[x];
}

int main(void){
    int k;
for(k = 1; k > 0; k++){
    Sieve();
    int n, c = 0;
    cin >> n;
    if(n == 0) break;
    else{
    for(int i = 0; i <= n/2; i++){
            if(IsPrime(i)==true){
                if(IsPrime(n - i)==true) c++;
            }
    }
 cout << c << endl;
 }
}
 
 return 0;
}



Measured memory_bytes: 4072
using System;
using System.Linq;

class F
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = a[0], k = a[1], n1 = (int)Math.Sqrt(n), n2 = n / n1 - 1;

		var w = new int[n1 + n2];
		var vl = w.Length;
		for (int i = 0; i < n1; i++) w[i] = 1;
		for (int i = 1, s = n; i <= n2; i++) s -= (w[vl - i] = s - n / (i + 1));

		Func<long[], long[]> next = x =>
		{
			var t = new long[vl];
			t[vl - 1] = x[0];
			for (var i = 1; i < vl; i++) t[vl - 1 - i] = (t[vl - i] + w[i] * x[i]) % 1000000007;
			return t;
		};

		var v = Enumerable.Repeat(1L, vl).ToArray();
		for (var i = 0; i < k; i++) v = next(v);
		Console.WriteLine(v[0]);
	}
}


Measured memory_bytes: 28844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

    int h, w, k; cin >> h >> w >> k;
    vector<vector<char>> g(h, vector<char>(k));

    int totalcnt = 0;

    for (int i = 0; i < h; i++) {
        string s; cin >> s;
        for (int j = 0; j < w; j++) {
            g[i][j] = s[j];
            if (s[j] == '#') totalcnt++;
        }
    }

    int ans = 0;

    for (unsigned int rows = 0; rows < 1<<(h); rows++) {
        for (unsigned int cols = 0; cols < 1<<(w); cols++) {
            vector<vector<bool>> m(h, vector<bool>(w, false));
            for (int r = 0; r < h; r++) {
                if (rows & (1<<r)) {
                    for (int j = 0; j < w; j++) m[r][j] = true;
                }
            }
            for (int c = 0; c < w; c++) {
                if (cols & (1<<c)) {
                    for (int i = 0; i < h; i++) m[i][c] = true;
                }
            }

            int remcnt = 0;
            for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) if (m[i][j] && g[i][j] == '#') remcnt++;

            if (totalcnt - remcnt == k) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (S == U)
	{
		--A;
	}
	else
	{
		--B;
	}

	cout << A << " " << B << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    string s; cin >> s;
    if (s.size() == 1){
        cout << s << endl;
        return 0;
    }
    int ans = 9*(s.size()-1);
    bool flg = true;
    for (int i = 1; i < s.size(); i++){
        if (s[i] != '9') flg = false;
    }
    if (flg){
        ans += (s[0]-'0');
    } else {
        ans += (s[0]-'0')-1;
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int n[] = {sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
		Arrays.sort(n);
		boolean b= false;
		if(n[0]==1) {
			if(n[1]==4) {
				if(n[2]==7) {
					if(n[3]==9)System.out.println("YES");
					b=true;
				}
			}
			
		}
		if(b==false)System.out.println("NO");

	}
}


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

int main() {
  ll h,w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = (h*w+1)/2;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(ll x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=2e5+5;
ll a[N],asum[N],xsum[N];
inline bool ok(int l,int r)
{
	return asum[r]-asum[l-1]==(xsum[r]^xsum[l-1]);
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n=ri(),i,l=1,r;
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		a[i]=ri();
		asum[i]=asum[i-1]+a[i];
		xsum[i]=xsum[i-1]^a[i];
	}
	for(r=1;r<=n;r++)
	{
		while(!ok(l,r))	l++;
		ans+=r-l+1;
	}
	wi(ans);putchar('\n');
	return 0;
}
/*
4
2 5 4 6



*/


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,k,l,n,m;
	cin>>n;
	m=((n/500)*1000);
//	cout<<m<<" ";
	n=(n-(n/500)*500);
	k=((n/5)*5);
	//cout<<k<<" ";
	
	cout<<m+k<<"\n";
	return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
#define MAX 3100000
#define MOD 1000000007

ll fac[MAX], finv[MAX], inv[MAX];
ll pv0[MAX], pv1[MAX];

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  pv0[0] = 1;
  pv0[1] = 25;
  pv1[0] = 1;
  pv1[1] = 26;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
    pv0[i] = (pv0[i-1]*25)%MOD;
    pv1[i] = (pv1[i-1]*26)%MOD;
  }
}

signed main(){
  COMinit();
  init_io();
  ll k,n,all=0,c=1,ans=0;
  string s;
  cin >> k >> s;
  n = s.size();
  all = n + k;
  for(ll i=all;i>=n;i--){
    ll tmp = (pv0[i-n]*pv1[all-i])%MOD;
    tmp *= COM(i-1,n-1);
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 125344
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let l = stdin.lock().lines().next().unwrap().unwrap();
    let mut ns = l.split_whitespace().map(|s| s.parse::<u8>().unwrap());
    let a = ns.next().unwrap();
    let b = ns.next().unwrap();
    println!("{}", (a+b)/2 + ((a+b)%2));
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
const int maxn = 10000001;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s[n] = {};
    f(n) {
        cin >> s[i];
    }
    int ans = 0;
    f(n) {
        int f = 0;
        fr(j,0,n) {
            fr(k,j+1,n) {
                if (s[j][k] != s[k][j]) {
                    f = 1;
                    break;
                }
            }
            if (f) {
                break;
            }
        }
        if (!f) {
            ans += n;
        }
        fr (j,0,n) {
            s[j] = s[j].substr(1) + s[j][0];
        }
    }
    cout << ans << '\n';
}  

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

const ll M = 1000000007;

int dis(int a1[],int a2[],int n){
    int i;
    int s=0;
    for(i = 0; i < n; i++){
        s+=(a1[i]-a2[i])*(a1[i]-a2[i]);
    }
    if (float(sqrt(s))==int(sqrt(s))) {return 1;}
    else return 0;
}


int main(void){
   ll n,d;
   int i;
   cin >> n >> d;
   ll ans=0;
   int a[n][d];
   for(i=0;i<n;i++){
       for(int j=0;j<d;j++){
           std::cin >>  a[i][j];
       }
       
   }
   for(i=0;i<n-1;i++){
       for(int j=i+1;j<n;j++){
           if(dis(a[i],a[j],d)==1){ans+=1;}
       }
       
   }
  
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string abc[3];
    for(int i=0; i<3; i++){
        cin >> abc[i];
    }
    char turn='a';
    char ans;
    bool fin=false;
    while(!fin){
        for(int i=0; i<3; i++){
            if(turn=='a'+i){
                if(abc[i].size()==0){
                    ans = 'A'+i;fin=true;continue;
                }
                turn=abc[i][0];
                abc[i].erase(abc[i].begin());
            }
        }
    }
    cout << ans << endl;
    return 0;
    
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;


class Program
{
    static void Main(string[] Args) {
        var lis = new List<string>(ReadLine().Split(' '));
        int A = Int32.Parse(lis[0]);
        int B = Int32.Parse(lis[2]);
        if (lis[1] == "-") B *= -1;

        WriteLine(A + B);

        ReadLine();
    }
}

Measured memory_bytes: 11220
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int d = int.Parse(input[1]);
    int x = int.Parse(input[2]);
    int[,] matrix = new int[d,n+1];//行列
    int answerMemo = x;
    int[,] dp = new int[n+2,100001];//x個見て、y円以下使った場合の、後の所持金の最大値
      
    for(int i = 0; i < d; i++)//それぞれの行
    {
    	int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    	for(int j = 0; j < n; j++) matrix[i,j] = nums[j];
      matrix[i,n] = 1;
    }

    for(int i = 0; i < d-1; i++)
    {
      for(int j = 0; j <= n+1; j++)
      {
        for(int k = 0; k <= answerMemo; k++)
        {
          dp[j,k] = 0;
        }
      }
      
      for(int j = 1; j <= n+1; j++)
      {
        for(int k = 1; k <= answerMemo; k++)
        {
          if(k-matrix[i,j-1] >= 0)
          {
            dp[j,k] = Math.Max(dp[j,k], dp[j,k-matrix[i,j-1]] + matrix[i+1,j-1]);
            dp[j,k] = Math.Max(dp[j,k], dp[j-1,k-matrix[i,j-1]] + matrix[i+1,j-1]);
          }
          dp[j,k] = Math.Max(dp[j,k],dp[j-1,k]);
        }
      }

      answerMemo = dp[n+1,answerMemo];
    }

		Console.WriteLine(answerMemo);
	}
}


Measured memory_bytes: 19532
// Problem : C - Pyramid
// Contest : Virtual Judge - Showdown
// URL : https://vjudge.net/contest/391413#problem/C
// Memory Limit : 1048 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀MOON｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 MANヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	vl X(N),Y(N),H(N);
	F0R(x,N)
		cin>>X[x]>>Y[x]>>H[x];
	vl ans={-1,-1,-1};
	F0R(x,101)
	{
		F0R(y,101)
		{
			ll l=0,r=1e14;
			while(l<=r)
			{
				bool flag=true;
				ll m=l+(r-l)/2;
				F0R(z,N)
				{
					if(max(m-abs(X[z]-x)-abs(Y[z]-y),0LL)!=H[z])
					{
						flag=false;
						if(max(m-abs(X[z]-x)-abs(Y[z]-y),0LL)>H[z])
							r=m-1;
						else
							l=m+1;
						break;
					}	
				}
				if(flag)
				{
					ans={x,y,m};
					r=m-1;
					// cout<<x<<' '<<y<<' '<<m;
					// return 0;	
				}
			}
		}
	}
	if(ans[0]!=-1)
		cout<<ans[0]<<' '<<ans[1]<<' '<<ans[2];
	else
	cout<<-1;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


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

namespace AtCoderABC123
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int X = int.Parse(s[0]);
            int Y = int.Parse(s[1]);
            int Z = int.Parse(s[2]);
            int K = int.Parse(s[3]);
            long[] A = new long[X];
            long[] B = new long[Y];
            long[] C = new long[Z];
            string[] s1 = Console.ReadLine().Split(' ');
            string[] s2 = Console.ReadLine().Split(' ');
            string[] s3 = Console.ReadLine().Split(' ');
            for (int i = 0; i < X; i++)
            {
                A[i] = long.Parse(s1[i]);
            }
            for (int i = 0; i < Y; i++)
            {
                B[i] = long.Parse(s2[i]);
            }
            for (int i = 0; i < Z; i++)
            {
                C[i] = long.Parse(s3[i]);
            }
            long[] D = new long[X * Y];
            for (int i = 0; i < X; i++)
            {
                for (int j = 0; j < Y; j++)
                {
                    D[i * Y + j] = A[i] + B[j];
                }
            }
            Array.Sort(D);
            int k = (X * Y < K)? X * Y: K;
            long[] newD = new long[k];
            for (int i = 0 ; i < k; i++) newD[i] = D[X * Y - 1 - i];
            long[] D2 = new long[k * Z];
            for (int i = 0; i < k; i++)
            {
                for (int j = 0; j < Z; j++)
                {
                    D2[i * Z + j] = newD[i] + C[j];
                }
            }
            Array.Sort(D2);
            for (int i = k * Z - 1; i >= k * Z - K; i--) Console.WriteLine(D2[i]);
        }
    }
}

Measured memory_bytes: 42720
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n ;
    cin >> n;
    int mnn = INT_MAX;
    int count = 0;
    for(int i = 0 ; i < n ;  i++){
        int x ;
        cin >> x;
        if(x <= mnn)count++;
        mnn = min(x , mnn);
    }
    cout << count << endl;
}


Measured memory_bytes: 3520
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def judge(n, m, v, p, nums, idx):
    if idx >= n - p:
        return True
    cur = nums[idx] + m
    cnt = 0
    for i in range(0, n):
        if idx == i:
            continue
        if i > n - p:
            break
        comp = nums[i]
        if comp > cur:
            return False
        cnt += min(m, cur - comp)
    # print(idx, cnt)
    if cnt >= m * (v - p):
        return True
    else:
        return False


def solve():
    n, m, v, p = getList()
    nums = getList()
    nums.sort()
    mn = 0
    mx = n-1
    while(mx - mn > 1):
        mid = (mx + mn) // 2
        if judge(n, m, v, p, nums, mid):
            mx = mid
        else:
            mn = mid

    if judge(n, m, v, p, nums, mn):
        ans = mn
    else:
        ans = mx
    # print(nums)
    # print(ans)
    print(n - ans )

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()







Measured memory_bytes: 90900
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX
 
using namespace std;
int MOD = 998244353;
 
int ar[250][250];
int gcd(int a,int b){
    if( ar[a][b] != 0 ) return ar[a][b];
    //assume a <= b
    if( b < a ) swap(a,b);
    if( a == 0 ) return ar[a][b] = b;
    return ar[a][b] = gcd( b%a, a );
}
 
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int N;
	cin >> N;
	ll ans = 0;
	for(int i = 1; i <= N; i++){
        for(int j=1; j <= N; j++){
            for(int k=1; k <= N; k++){
                ans += gcd(i, gcd(j,k) );
            }
        }
	}
    cout << ans;
 
 
 
 
}

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N;
	cin >> N;
	VLL A(N);
	ll sum = 0;
	for (ll n = 0; n < N; n++) {
		cin >> A[n];
		sum += A[n];
	}
	ll pre = 0;
	ll ans = LLONG_MAX;
	for (ll n = 0; n < N - 1; n++) {
		pre += A[n];
		ans = min(ans, abs(sum - 2 * pre));
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
# define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	ios::sync_with_stdio(0);
	cin.tie(0);

//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif

	int x,n,mini=INT_MAX,i,ans=0;
	cin>>x>>n;
	int a[102],b[102]={0};
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[a[i]]++;
	}
	for(i=0;i<=500;i++)
	{
		if(abs(i-x)<mini&&b[i]==0)
		{
			mini=abs(i-x);
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	int a,b,c,d,z;
	cin>>a>>b>>c>>d;	
	int x,y;
	x=max(a,c);
	y=min(b,d);
	z=y-x;
	if(z<0) z=0;
	cout<<z<<endl;
	return 0;
}
	

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

int main(){
    int S;
    cin >> S;
    
    int h = S / 3600;
    int m = ( S -h * 3600 ) / 60;
    int s = S - h * 3600 - m * 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<ll,ll,ll> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int N; cin >> N;
    bool flag = false;
    REP(_,N){
        int a; cin >> a;
        if(a%2) flag = true;
    }
    cout << (flag ? "first" : "second") << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3600
#include <cmath>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  // 四捨五入する
  ll b2 = (ll)llround((b * 100.0));
  cout << a * b2 / 100 << endl;
  return 0;
}


Measured memory_bytes: 3756