akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

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

  if (A <= C && C <= B) {
    cout << "Yes" << endl;
  } else if (B <= C && C <= A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;

const int maxn = 100001;

int dp[maxn], h[maxn], n;

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

    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    dp[1] = 0, dp[2] = abs(h[2]-h[1]);
    for(int i = 3; 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];

    return 0;
}


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

namespace AtCoder
{
    class ABC
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = n[0];
            int Y = n[1];

            for(int i = 0; i <= N; i++)
            {
                for(int j = 0; j <= N - i; j++)
                {
                    
                    
                        if(10000 * i + 5000 * j + 1000 * (N - i - j) == Y)
                        {
                            Console.WriteLine("{0} {1} {2}", i, j, N - i - j);
                            return;
                        }
                    
                }
            }

            Console.WriteLine("-1 -1 -1");
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13396
import sys
n = int(input())
lst=list(map(int,input().split()))
lst.append(10**9+1)

count = 0
for i in range(n):
 
    if lst[i+1]-lst[i]==-1:#1さがったとき
        if count==0:
            count=-1
            continue
        else:#count=-1
            print("No")
            sys.exit()
    elif lst[i]==lst[i+1]:#おなじとき
        continue
        
    elif lst[i]<lst[i+1]:#上がったとき
        count = 0
        continue
    
    else:#2以上下がったとき
        print("No")
        sys.exit()
        


print("Yes")


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

using namespace std;

int n, m;
vector<int> v;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < m-1; ++i) {
        v[i] = v[i+1] - v[i];
    }
    v.pop_back();
    sort(v.begin(), v.end());
    int ans = 0, sz = v.size() - n + 1;
    for (int i = 0; i < sz; ++i) {
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long int ll;
typedef long double ld;

ll binpow(ll a, int b) {
  ll z = 1LL;
  while (b) {
    if (b & 1) z *= a;
    a *= a;
    b>>=1;
  }
  return z;
}

int main() {
  int n; cin >> n;
  ll ans = 1;
  ld m = 1;
  int t = 0;
  bool zr = false;
  vector<ld> v(n);
  for (ld &x : v) {
    cin >> x;
    zr |= (x==0.0);
  }
  if (zr) {
    cout << "0\n";
    return 0;    
  }
  for (int i = 0; i < n; ++i) {
    ld x, y;
    x = v[i];
    y = x;
    int sz = to_string((ll)x).size()-1;
    t += sz;
    m *= (ld)x/(ld)binpow(10, sz);
    sz = to_string((ll)m).size()-1;
    t += sz;
    m = (ld)m/binpow(10, sz);
    if (t >= 18 && m > 1.0) {
      cout << "-1\n";
      return 0;
    }
    ans *= y;
  }
  
  cout << ans << "\n";
  
  return 0;
}

/*
2
1000000000 1000000000

3
101 9901 999999000001

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0
*/

Measured memory_bytes: 4792
from collections import Counter
import math

def combinations_count(n):
    return (n * (n - 1)) // 2

N = int(input())
A = list(map(int, input().split()))

combs = {}
dic = Counter(A)
for k, v in dic.items():
    combs[k] = combinations_count(v)
ans = sum(combs.values())

for i in range(N):
    a = A[i]
    ans_i = ans
    if combs[a] < 2:
        ans_i -= combs[a]
        print(ans_i)
    else:
        ans_i -= dic[a] - 1
        print(ans_i)


Measured memory_bytes: 34604
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<map>
#include<vector>
#include<ctime>
#include<stack>
#define mp make_pair
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ull unsigned long long

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (c<'0' || c>'9')
	{
		if (c=='-')	f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9')
	{
		sum=sum*10+c-'0';
		c=getchar();
	}
	return sum*f;
}
const int MAXN=20;
const int MAXM=1<<15;
int f[MAXM][MAXN][MAXN];
int a[MAXN][MAXN];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	memset(a,-1,sizeof(a));
	for (int i=1;i<=m;i++)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		u--,v--;
		a[u][v]=a[v][u]=w;
	}
	memset(f,inf,sizeof(f));
	for (int s=0;s<(1<<n);s++)
	{
		if (!(s&1)) continue;
		if ((s&(1<<(n-1))) && s!=(1<<n)-1) continue;
		for (int i=0;i<n;i++)
			f[s][i][i]=0;
		for (int ns=s-1;ns>0;ns=(ns-1)&s)
		{
			if (!(ns&1)) continue;
			int ss=ns^s;
			int tot=0;
			for (int i=0;i<n;i++)
				if (ns&(1<<i))
					for (int j=0;j<n;j++)
						if (ss&(1<<j) && a[i][j]>=0)
							tot+=a[i][j];
			for (int i=0;i<n;i++)
				if (ns&(1<<i))
					for (int j=0;j<n;j++)
						if (ns&(1<<j))
							for (int k=0;k<n;k++)
								if (ss&(1<<k) && a[j][k]>=0)
									f[s][i][k]=min(f[s][i][k],tot+f[ns][i][j]-a[j][k]);
		}
	}
	cout<<f[(1<<n)-1][0][n-1];
	return 0;
}


Measured memory_bytes: 51456
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX= 100010;
int n, a[MAX];

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];

    vector<int> dp(MAX, INF);
    rep(i, n) {
        *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }

    int ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
    cout << ans << endl;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

template <typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    } else {
        return false;
    }
}

template <typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    } else {
        return false;
    }
}

string s, t;
int n, m;
int dp[3010][3010];
pair<int, int> from[3010][3010];

signed main() {
    while (cin >> s >> t) {
        n = s.size();
        m = t.size();
        memset(dp, 0, sizeof dp);
        rep(i, n+1) rep(j, m+1) from[i][j] = make_pair(-1, -1);

        rep(i, n) rep(j, m) {
            if (s[i] == t[j]) {
                if (chmax(dp[i+1][j+1], dp[i][j]+1)) {
                    from[i+1][j+1] = make_pair(i, j);
                }
            }
            if (chmax(dp[i+1][j], dp[i][j])) {
                from[i+1][j] = make_pair(i, j);
            }
            if (chmax(dp[i][j+1], dp[i][j])) {
                from[i][j+1] = make_pair(i, j);
            }
        }

        // rep(i, n+1) {
        //     rep(j, m+1) cout << dp[i][j] << ' ';
        //     cout << endl;
        // }

        int ansi = -1, ansj = -1;
        int anslen = -1;
        rep(i, n+1) rep(j, m+1) {
            if (chmax(anslen, dp[i][j])) {
                ansi = i, ansj = j;
            }
        }

        // dump(ansi);
        // dump(ansj);
        // dump(anslen);

        string ans;
        int ci = ansi, cj = ansj;
        while (true) {
            int ni, nj;
            tie(ni, nj) = from[ci][cj];
            if (ni == -1 || nj == -1) break;
            if (ni != ci && nj != cj) {
                // dump(s[ni]);
                // dump(t[nj]);
                assert(s[ni] == t[nj]);
                ans += s[ni];
            }
            ci = ni;
            cj = nj;
        }
        // dump(ansi);
        // dump(ansj);

        reverse(all(ans));
        cout << ans << endl;
        // cout << dp[n][m] << endl;
        // break;
    }
}


Measured memory_bytes: 212608
#include <stdio.h>

int r[100][100];
int n;

int dijkstra(int start, int goal) {
  int i;
  int minimum, p;
  int d[100], f[100];

  for(i = 0; i < 100; i++) {
    d[i] = 100000;
    f[i] = 0;
  }
  d[start-1] = 1;
  while(1) {
    minimum = 100000;
    for(i = 0; i < n; i++) {
      if(d[i] < minimum && f[i] == 0) {
	minimum = d[i];
	p = i;
      }
    }
    if(minimum == 100000) break;
    f[p] = 1;

    for(i = 0; i < n; i++) {
      if(d[p] + r[p][i] < d[i]) {
	d[i] = d[p] + r[p][i];
      }
    }
  }

  return d[goal-1];
}

int main() {
  int i, j, r1, k1, p, s1, d1, v1, temp;

  for(i = 0; i < 100; i++)
    for(j = 0; j < 100; j++)
      r[i][j] = 100000;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d %d", &r1, &k1);
    for(j = 0; j < k1; j++) {
      scanf("%d", &temp);
      r[r1-1][temp-1] = 1;
    }
  }
  scanf("%d", &p);
  for(i = 0; i < p; i++) {
    scanf("%d %d %d", &s1, &d1, &v1);
    temp = dijkstra(s1, d1);
    if(v1 - temp < 0) {
      printf("NA\n");
    } else {
      printf("%d\n", temp);
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		int c,i=0;
		c=a+b;
		while(c!=0)
		{
			i++;
			c/=10;
		}
		cout<<i<<endl;
	}
        return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    if(S=="A"){
        cout<<"T"<<endl;
    }else if(S=="C"){
        cout<<"G"<<endl;
    }else if(S=="G"){
        cout<<"C"<<endl;
    }else{
        cout<<"A"<<endl;
    }
    return 0;
}

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

using vb=vector<bool>;
using vi=vector<int>;
using vvi=vector<vi>;
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vl>;
using si=set<int>;
using qi=queue<int>;
using pi=pair<int,int>;

void solve() {
    ll n; cin>>n;
    vl a(n+1);
    map<ll,ll> m;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    for(ll i=1;i<=n;i++){
        m[i-a[i]]++;
    }
    ll db=0;
    for(ll i=1;i<=n;i++){
        db+=m[a[i]+i];
    }
    cout<<db<<endl;
}

bool boosts=false, tests=false;

int main() {
    if(boosts) {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    int tcases=1;
    if(tests) {
        cin>>tcases;
    }
    for(int tcase=1; tcase<=tcases; tcase++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 27392
#include <iostream>
#include <string>
using namespace std;
int main() {
	bool good = false;

	string s;
	long long x;
	long long y = 0;
	cin >> s;

	char ch[1];
	for (int i = 0; i < s.size(); i++) {
		ch[0] = s[i];
		y += atoi(ch);
	}
	x = stoi(s);

	cout << ((0 == x%y) ? "Yes" : "No") << endl;

	return 0;
}


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

int main(){
    int v, e;
    cin >> v >> e;
    vector<vector<int>> d(v, vector<int>(v, 0));
    int s , t;
    while(e-- > 0){
        cin >> s >> t;
        d[s][t] = -1;
    }
    for(int k = 0; k < v; k++){
        for(int i = 0; i < v; i++){
            for(int j = 0; j < v; j++){
                if(d[i][k] == 0 || d[k][j] == 0)    continue;
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    bool nocycle = true;
    for(int i = 0; i < v; i++)  nocycle &= (d[i][i] == 0);
    cout << (nocycle ? 0 : 1) << endl;
    return 0;
}


Measured memory_bytes: 3192
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)

n,p=l()
A=l()
o=e=0
for i in range(n):
    if(A[i]%2):
        o+=1
    else:
        e+=1
if(o):
    print(2**(n-1))
else:
    if(p):
        print(0)
    else:
        print(2**n)





Measured memory_bytes: 5116
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
int n;
  cin >>n;
  cout <<(1000-(n%1000))%1000;

return 0;
}






ll gcd(ll a, ll b){

   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    ll n, m;
    cin >> n >> m;
    if (n == 1 || m == 1) {
        if (n == 1 && m == 1) {
            cout << 1 << endl;
            return 0;
        }
        cout << max(0LL, max(n, m) - 2) << endl;
        return 0;
    } else if (n == 2 || m == 2) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = (n - 2) * (m - 2);
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
x = [0] * n
u = ['string'] * n
for j in range(n):
    x[j], u[j] = input().split()
for j in range(n):
    if u[j] == 'JPY':
        x[j] = int(x[j])
    elif u[j] == 'BTC':
        x[j] = float(x[j]) * 380000
print(np.sum(x))

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

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

  cout << (N + 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<int,vector<int>,greter<int>>
using namespace std;
char c[500][500];
P x[500];
int y[500];
signed main(){
	int n,ans=1;
	cin>>n;
	f(i,n) x[i].S=i;
	f(i,n){
		f(j,n){
			cin>>c[i][j];
			if(c[i][j]=='#'){
				x[i].F++;
				y[j]++;
			}
		}
	}
	sort(x,x+n);
	f(j,n){
		if(y[j]!=n) ans++;
	}
	int z=n;
	do{
		z--;
		if(y[x[z].S]){
			ans--;
			break;
		}
		if(x[z].F==0){
			puts("-1");
			return 0;
		}
	}while(x[z].F==x[z-1].F);
	f(j,n){
		if(c[x[z].S][j]=='.') ans++;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int[][] target = new int[N][];
            bool[][] isHonest = new bool[N][];
            var testimonyCount = new int[N];
            for (int i = 0; i < N; i++)
            {
                testimonyCount[i] = int.Parse(Console.ReadLine());
                target[i] = new int[testimonyCount[i]];
                isHonest[i] = new bool[testimonyCount[i]];
                for (int j = 0; j < testimonyCount[i]; j++)
                {
                    var testimony = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                    target[i][j] = testimony[0];
                    isHonest[i][j] = (testimony[1] == 1);
                }
            }

            var result = 0;
            for (int hypothesis = (1 << N) - 1; hypothesis >= 0; hypothesis--)
            {
                var isHypothesisSatisfied = true;
                var honestCount = 0;
                for (int checkHonest = 0; checkHonest < N; checkHonest++)
                {
                    if (((1 << checkHonest) & hypothesis) > 0)
                    {
                        var isTestimonySatisfied = true;
                        for (int checkTestimony = 0; checkTestimony < testimonyCount[checkHonest]; checkTestimony++)
                        {
                            if ((((1 << (target[checkHonest][checkTestimony] - 1)) & hypothesis) > 0) != isHonest[checkHonest][checkTestimony])
                            {
                                isTestimonySatisfied = false;
                                break;
                            }
                        }
                        if (isTestimonySatisfied)
                        {
                            honestCount++;
                        }
                        else
                        {
                            isHypothesisSatisfied = false;
                            break;
                        }
                    }
                }
                if (isHypothesisSatisfied)
                {
                    result = Math.Max(result, honestCount);
                }
            }
            Console.WriteLine(result);
        }
    }
}


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

using namespace std;

const int N = 1e5 + 5;

int n, a[N], b[N], rmq[20][N];

int query (int u, int v) {
    int k = log2(v - u + 1);
    return min(rmq[k][u], rmq[k][v - (1 << k) + 1]);
}

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 2; i <= n; i++) b[i] = a[i - 1] - a[i];
    for (int i = 1; i <= n; i++) rmq[0][i] = b[i];
    for (int k = 1; k < 20; k++) {
        for (int i = 1; i + (1 << k) - 1 <= n; i++) {
            rmq[k][i] = min(rmq[k - 1][i], rmq[k - 1][i + (1 << (k - 1))]);
        }
    }

    int ans = 0;
    for (int i = 1; i <= n - 1; i++) {
        int l = i + 1, r = n;
        while (l <= r) {
            int mid = (l + r) / 2;
            if (query(i + 1, mid) < 0) r = mid - 1;
            else l = mid + 1;
        }

        ans = max(ans, r - i);
    }

    printf("%d", ans);
    return 0;
}


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

void solve()
{
	int n;
	cin >> n;
	vector<pair<int, int>> inp;
	int t1, t2;
	for (int i = 0; i < n; i++)
	{
		cin >> t1 >> t2;
		inp.push_back(make_pair(t1, t2));
	}
	vector<int> v1(n, 0), v2(n, 0);
	for (int i = 0; i < n; i++)
	{
		v1[i] = inp[i].first + inp[i].second;
		v2[i] = inp[i].first - inp[i].second;
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());

	cout << max(v1[n - 1] - v1[0], v2[n - 1] - v2[0]) << "\n";
}

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

	int t;
	// cin >> t;
	t = 1;
	for (int i = 1; i <= t; i++)
		solve();

	return 0;
}


Measured memory_bytes: 6296
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int a,b;cin >> a >> b;
  cout << a*b << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 3824
def solve():
    N = int(raw_input())
    t_now, x_now, y_now = 0, 0, 0
    for _ in xrange(N):
        t_next, x_next, y_next = map(int, raw_input().split())
        distance = abs(x_now - x_next) + abs(y_now - y_next)

        if distance > t_next - t_now or distance % 2 != (t_next - t_now) % 2:
            print "No"
            return
        t_now, x_now, y_now = t_next, x_next, y_next

    print "Yes"
    return


solve()



Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#define endl '\n'
#define ll unsigned long long
//#define mod 1000000007
#define NCONS 100001

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int N; cin >> N;
	cout << "ABC" << N;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, c;
    cin >> n >> c;
    vector<vector<P>> table(c);
    int ub = 0;
    for(int i = 0; i < n; ++i){
        int s, t, ch;
        cin >> s >> t >> ch;
        table[--ch].push_back(P(s, t));
        chmax(ub, t);
    }
    vector<int> sum(ub + 5, 0);
    for(int i = 0; i < c; ++i){
        sort(table[i].begin(), table[i].end());
        int pre = 0;
        int sz = table[i].size();
        for(int j = 0; j < sz; ++j){
            int s = table[i][j].first, t = table[i][j].second;
            if(pre == s)    ++sum[s], --sum[t];
            else    ++sum[s-1], --sum[t];
            pre = t;
        }
    }
    for(int i = 0; i <= ub; ++i)    sum[i+1] += sum[i];
    int ans = *max_element(sum.begin(), sum.end());
    cout << ans << endl;
}

Measured memory_bytes: 1920
w, h, n = map(int, input().split())
wz = 0
hz = 0
w_min = 0
h_min = 0
w_max = w
h_max = h
for i in range (n):
    x, y, a = map(int, input().split())
    if a == 1:
        if x >= w_min:
            wz = x
            w_min = x
    if a == 2:
        if x <= w_max:        
            w = x
            w_max = x
    if a == 3:
        if y >= h_min:
            hz = y
            h_min = y
    if a == 4:
        if y <= h_max:
            h = y
            h_max = y
if w_min < w_max and h_min < h_max:
    print((w-wz)*(h-hz))
else:
    print(0)


Measured memory_bytes: 3064
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <iostream>
#include <cstdlib>
#include <typeinfo>

using namespace std;
int main() {
	ios_base::sync_with_stdio(0); 	
	cin.tie(0);
	pair<int, int> p[100010];
	long long int n, k, a = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		a += p[i].second;
		if (a >= k) {
			cout << p[i].first << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
N, A, B = map(int, input().split())

if N == 0:
  print(0)
  exit()

cnt = N // (A + B)
rem = N % (A + B)

ans = 0

if rem >= A:
  ans = A * (cnt + 1)
else:
  ans = A * cnt + rem

print(ans)


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 2000;
const int MaxNK = MaxN - 1;

const int M = 924844033;

inline int add(int a, const int &b)
{
	a += b;
	return a >= M ? a - M : a;
}

int n, nK;

int f[MaxN + 1][MaxN + 1][4];
int g[MaxN + 1];
int h[MaxN + 1];

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

	f[1][0][0] = 1;
	f[1][1][2] = 1;
	for (int i = 2; i <= n; ++i)
		for (int j = 0; j < i; ++j)
			for (int s = 0; s < 4; ++s)
			{
				int v = f[i - 1][j][s];
				if (v == 0)
					continue;

				int p = s >> 1, q = p | 2;
				f[i][j + 0][p] = add(f[i][j + 0][p], v);
				f[i][j + 1][q] = add(f[i][j + 1][q], v);
				if (~s & 1)
					f[i][j + 1][p] = add(f[i][j + 1][p], v);
			}

	g[0] = 1;
	for (int r = 1; r <= nK; ++r)
	{
		int m = n / nK + (n % nK >= r);

		for (int i = 0; i <= n; ++i)
			h[i] = 0;
		for (int i = 0; i <= n; ++i)
			for (int j = 0; j <= m; ++j)
			{
				int k = i + j;
				int d = add(f[m][j][0], f[m][j][1]);

				if (k <= n)
					h[k] = add(h[k], (s64)d * g[i] % M);
			}

		for (int i = 0; i <= n; ++i)
			g[i] = h[i];
	}

	int res = 0;
	int fac = 1, coe = n & 1 ? M - 1 : 1;
	for (int i = 1; i <= n + 1; ++i)
	{
		int v = g[n - i + 1];
		int c = (s64)fac * coe % M;
		res = add(res, (s64)v * c % M);

		coe = M - coe;
		fac = (s64)fac * i % M;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 61056
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long ans = 0;
        for(long i=1;i<a;i++){ans+=(a-1)/i;
                            }       
		System.out.println(ans);
	}
}

Measured memory_bytes: 35884
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    map<char,ll> mp;
    rep(i,0,S.size()) mp[S[i]]++;
    for(auto &e: mp){
        if(e.first == 'N'){
            if(mp['S'] == 0){
                print("No");
                return 0;
            }
        }else if(e.first == 'S'){
            if(mp['N'] == 0){
                print("No");
                return 0;
            }
        }else if(e.first == 'E'){
            if(mp['W'] == 0){
                print("No");
                return 0;
            }

        }else{
            if(mp['E'] == 0){
                print("No");
                return 0;
            }
        }
    }
    print("Yes");

    

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int a = 1000000007;
		/*
		 * nが奇数のとき
		 * 0 2 2 4 4
		 * 2^((n-1)/2)
		 * nが偶数のとき
		 * 1 1 3 3 5 5
		 * 2^(n/2)
		 */
		int tmp, ans = 1;
		int s[] = new int[n];
		for (int i = 0; i < n; i++) {
			s[sc.nextInt()]++;
		}
		if (n % 2 == 0) {
			for (int i = 1; i < n; i = i + 2) {
				if (s[i] != 2) {
					System.out.println(0);
					return;
				}
			}
			for (int i = 0; i < n / 2; i++) {
				ans = (ans * 2) % a;
			}
		} else {
			if (s[0] != 1) {
				System.out.println(0);
				return;
			}
			for (int i = 2; i < n; i = i + 2) {
				if (s[i] != 2) {
					System.out.println(0);
					return;
				}
			}
			for (int i = 0; i < n / 2; i++) {
				ans = (ans * 2) % a;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 53116
k,q = map(int, input().split())
d= list(map(int, input().split()))
for _ in range(q):
    n,x,m = map(int, input().split())
    ans=n-1
    dm=[el%m for el in d]
    loop=(n-1)//k
    rem=(n-1)%k
    eqcnt=0
    lscnt=0
    totsum=0
    remsum=0
    for i in range(k):
        totsum+=dm[i]
        if i<rem:
            remsum+=dm[i]
        if dm[i]==0:
            eqcnt+=1
            if i<rem:
                ans-=1
    ans-=eqcnt*loop
    lscnt+=totsum//m*loop+remsum//m
    lscnt+=(totsum%m*loop+remsum%m+x%m)//m
    ans-=lscnt
    print(ans)

Measured memory_bytes: 68188
N, T = gets.split.map(&:to_i)
ABs = readlines.map{|l| l.split.map(&:to_i)}

dp = Array.new(T + ABs.map(&:first).max + 1, 0)
ABs.sort.each do |a, b|
  (T - 1).downto(0) do |t|
    dp[t + a] = dp[t] + b if dp[t + a] < dp[t] + b
  end
end
puts dp.max

Measured memory_bytes: 2300
pack [] = []
pack (0:xs) = pack xs
pack (x:xs) = x:(pack xs)

sub [] = []
sub (x:xs) = (x-1):(sub xs)

ans' n x =
  if x == take l [1..]
  then n
  else
    if n > 10000
    then -1
    else ans' (n+1) (y++[l])
  where
    l = length x
    y = pack $ sub x
    
ans ([0]:_) = []
ans ([n]:x:xs) =
  (ans' 0 x):(ans xs)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o

Measured memory_bytes: 4896
import numpy as np

n, m = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

def is_ok(x):
    cnt = n**2-np.searchsorted(A, x-A, side='left').sum()
    if cnt >= m:
        return True
    else:
        return False

l = 0
r = 2*10**5+1
while l+1 < r:
    c = (l+r)//2
    if is_ok(c):
        l = c
    else:
        r = c

from itertools import accumulate
B = [0]+list(A)
B = list(accumulate(B))
ans = 0
cnt = 0
for a in A:
    j = np.searchsorted(A, l-a, side='left').sum()
    cnt += n-j
    ans += B[-1]-B[j]+a*(n-j)
ans -= (cnt-m)*l
print(ans)


Measured memory_bytes: 23676
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,ans,r,a;

pair<LL, LL>bc;
vector<pair<LL, LL>>BC;
int main() {

	cin >> N >> M;
	M = M / 2;
	if (N < M) {
		cout << N + (M - N) / 2 << endl;
	}
	else {
		cout << M << endl;
	}
	

	return 0;

}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vpll c(n);
  ll ans=0;
  rep(i,n){
    ll a,b; cin>>a>>b;
    c[i]={a+b,b};
    ans+=a;
  }
  sort(c.rbegin(),c.rend());
  
  rep(i,n){
    if(i%2==0) continue;
    ans-=(c[i].first-c[i].second)+c[i].second;
  }
  
  cout<<ans<<endl;
  
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<vector<PII>> g(n);
    REP(i, n-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }

    vector<ll> ans(n);
    function<void(ll,ll,ll)> dfs = [&](ll v, ll p, ll d) {
        ans[v] = d%2;
        for(auto to: g[v]) if(to.first != p) {
            dfs(to.first, v, d + to.second);
        }
    };
    dfs(0, -1, 0);

    REP(i, n) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	int b = 0, w = 0;
	for (int i = 0; i < (int) s.size(); ++i) {
		if (s[i] == 'B') {
			++b;
		} else {
			++w;
		}
	}

	if (!b || !w) {
		cout << "0\n";
		return 0;
	}

	int sz = s.size();

	char placed;
	if (s[0] == 'B') {
		placed = 'W';
	} else {
		placed = 'B';
	}

	int i = 0; 
	int ops_from_right = 0;
	while (i < sz) {
		while (i < sz && s[i] != placed) {
			++i;
		}

		while (i < sz && s[i] == placed) {
			++i;
		}

		++ops_from_right;

		if (placed == 'B') {
			placed = 'W';
		} else {
			placed = 'B';
		}
	}

	i = sz - 1; 
	int ops_from_left = 0;
	while (i >= 0) {
		while (i >= 0 && s[i] != placed) {
			--i;
		}

		while (i >= 0 && s[i] == placed) {
			--i;
		}

		++ops_from_left;

		if (placed == 'B') {
			placed = 'W';
		} else {
			placed = 'B';
		}
	}

	cout << min(ops_from_left, ops_from_right) << "\n";

	return 0;

}

Measured memory_bytes: 512
#include <cstdio>
#define MAXN 200100
int a[MAXN];
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) 
    	scanf("%d", &a[i]);
	if((n & 1) == 1) {
		for(int i = n; i >= 1; i -= 2) 
			printf("%d ", a[i]);
		for(int i = 2; i <= n-1; i += 2)
			printf("%d ", a[i]);
	}else {
		printf("%d ", a[n]);
		for(int i = n-2; i >= 2; i -= 2)
			printf("%d ", a[i]);
		for(int i = 1; i < n; i += 2)
			printf("%d ", a[i]);
	}
    return 0;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> vec(H,vector<int>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  vector<pair<int,int>> before(0);
  vector<pair<int,int>> after(0);
  pair<int,int> P;
  
  for(int i=0; i<H-1; i++){
    for(int j=0; j<W; j++){
      if(vec.at(i).at(j) %2 != 0){
        P = make_pair(i+1,j+1);
        before.push_back(P);
        vec.at(i).at(j)--;
        P = make_pair(i+2,j+1);
        after.push_back(P);
        vec.at(i+1).at(j)++;
      }
    }
  }
  
  for(int i=0; i<W-1; i++){
    if(vec.at(H-1).at(i) %2 != 0){
      P = make_pair(H,i+1);
      before.push_back(P);
      vec.at(H-1).at(i)--;
      P = make_pair(H,i+2);
      after.push_back(P);
      vec.at(H-1).at(i+1)++;
    }
  }
  
  cout << before.size() << endl;
  for(int i=0; i<before.size(); i++){
    P = before.at(i);
    cout << P.first << " " << P.second << " ";
    P = after.at(i);
    cout << P.first << " " << P.second << endl;
  }
  
  /*for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout << vec.at(i).at(j);
    }
    cout << endl;
  }*/
}

Measured memory_bytes: 5228
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main()
{
    ll N;
    cin >> N ;
    if(N == 1){
        cout << "Hello World" << endl;
    }
    else {
        ll a, b ;
        cin >> a >> b;
        cout << a + b << endl;
    }


    return 0;
}

/*
/^[\w!\x22\#$%&@\'() * +,-.\/;:]+$/
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[4]={0};
int main()
{
	char a;
	int i,n,s=0;
	scanf("%d",&n);
	scanf("%c",&a);
	for(i=0;i<n;i++)
	{
		scanf("%c",&a);
		switch(a)
		{
			case 'P':f[0]=1;break;
			case 'W':f[1]=1;break;
			case 'G':f[2]=1;break;
			case 'Y':f[3]=1;break;
		}
		scanf("%c",&a);
	}
	for(i=0;i<4;i++)
	{
		if(f[i])
		{
			s++;
		}
	}
	switch(s)
	{
		case 1:printf("One");break;
		case 2:printf("Two");break;
		case 3:printf("Three");break;
		case 4:printf("Four");break;
	}
	return 0;
}

Measured memory_bytes: 256
from functools import reduce
N = int(input())
T = [int(input()) for i in range(N)]
def lcm(a, b): # 最小公倍数
    def gcd(a, b): # 最大公約数
        while b:
            a, b = b, a % b
        return a
    return a * b // gcd(a, b)
print(reduce(lcm,T))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;

const double PI = acos(-1.0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin>>N;
    vector<ll> L(N);
    rep(i,N)cin>>L[i];
    sort(all(L));
    ll ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            ll a = L[i];
            ll b = L[j];
            // b - a < c < a + b
            ll r = lower_bound(all(L), a + b) - L.begin();
            ll l = j + 1;
            ans += r - l;
            //cerr<<l<<" "<<r<<endl;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//初めてのBIT(本当
//テストケース28でWAする。(最適解より大きい値が出る)→まさかのオーバーフロー、3*10^5 * 10^5 == 3*10^10 > 2.1*10^9。
#include<iostream>
#include<vector>
#include<stdlib.h>
#define int long long
using namespace std;

struct Bug{
	int a, b;
}bug[300001];
int n;
int a,b;
vector<int> uofB[100002];

signed compare(const void *s1, const void *s2){
	return ((Bug*)s1)->a - ((Bug*)s2)->a;
}

class BIT{
public:
	int bit[600000];	//bit[i] = …
	BIT(){
		for (int i = 0; i <= 500000; i++ ) bit[i] = 0;
	}
	void add(int a, int w){
		for (int x = a; x <= 500000; x += x & -x) bit[x] += w;
	}
	int sum(int a){
		int ret = 0;
		for (int x = a; x > 0; x -= x & -x) ret += bit[x];
		return ret;
	}
	void insert(int a, int w){
		int res = sum(a) - sum(a-1);
		w = w - res;
		add(a, w);
	}
	int solvesum(int l, int r){
		return sum(r) - sum(l-1);
	}
};
BIT segfoo, segins;

signed main(){
	int i;
	cin >> n;
	for( i = 1; i <= n; i++ ){
		cin >> a >> b;
		bug[i].a = a;
		bug[i].b = b;
	}
	qsort( bug+1, n, sizeof(bug[1]), compare );
	//cout << endl;
	//int debug = 0;
	for( i = 1; i <= n; i++ ){
		//debug += bug[i].a;
		//cout << bug[i].a << " " << bug[i].b << " " << debug << endl;
		uofB[bug[i].b + 1].push_back(i);
		segins.insert(i, 1);
		segfoo.insert(i, bug[i].a);
	}
	
	int minB;
	int ans = 0;
	for( minB = 0; minB < 100002; minB++ ){
		for( i = 0; i < uofB[minB].size(); i++ ){
			segfoo.insert(uofB[minB][i], 0);	//微生物uofB[Minb][i]を無効化
			segins.insert(uofB[minB][i], 0);
		}
		/*cout << endl;
		cout << "Union = { ";
		for( i = 1; i <= n; i++ ){
			if( segins.solvesum(i,i) ){
				cout << i << " ";
			}
		}
		cout << "}" << endl;*/
		
		int st = 1, ed = n+1, medi;
		int sumFoo, k;
		while( st <= ed ){
			medi = st + ed;
			medi /= 2;
			sumFoo = segfoo.solvesum(1, medi);
			k = segins.solvesum(1, medi);
			//cout << "sumFoo = " << sumFoo << " minB = " << minB << " k = " << k << " medi = " << medi << endl;
			if( sumFoo > k * minB ) {
				ed = medi - 1;
			}
			else{
				ans = max(ans, k);
				if( segfoo.solvesum(1, medi+1) > segins.solvesum(1, medi+1) * minB )
					break;
				else
					st = medi + 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22476
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left\n";
	}
	else if (a + b == c + d) {
		cout << "Balanced\n";
	}
	else {
		cout << "Right\n";
	}
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v(m);
  for (auto& e : v) cin >> e.first >> e.second;

  for (int d = 0; d < 1000; d++) {
    auto s = to_string(d);
    if (s.size() != n) continue;
    bool b = true;
    for (auto e : v) b = b && (s[e.first - 1] - '0') == e.second;
    if (b) {
      cout << d << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256