akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define llrep(i, a, b) for(ll i = (a); i < (b); ++i )
#define llrrep(i, a, b) for(ll i = (a); i > (b); --i )
#define llREP(i, a, b) for(ll i = (a); i <= (b); ++i )
#define llRREP(i, a, b) for(ll i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )

int A[100010];
int n;

double halfN;
int NGi;
int OKi = 0;
bool check(int i) {
    return A[i] < halfN;
}

void nibutan() {
    while (abs(OKi-NGi)>1) {
        int m = (OKi + NGi) / 2;
        if (check(m)) {
            OKi = m;
        } else {
            NGi = m;
        }
    }
}


int main() {
    cin >> n;
    rep(i, 0, n) {
        cin >> A[i];
    }
    sort(A, A+n);
    int maxN = A[n-1];
    NGi = n;
    halfN = maxN / 2.;
    nibutan();
    if(abs(halfN - A[OKi]) > abs(halfN-A[OKi+1])) {
        cout << maxN << " " << A[OKi + 1] << endl;
    }else{
        cout << maxN << " " << A[OKi] << endl;
    }
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		double d=sc.nextDouble();
		int c=0;
		for(int i=0;i<n;i++) {
			long x=sc.nextLong();
			long y=sc.nextLong();
			double a=Math.sqrt((x*x)+(y*y));
			if(d>=a)
				c++;
		}
		System.out.println(c);





	}

}

Measured memory_bytes: 62888
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int N=100010;
int tp,tt;
bool vis[N];
vector <int> q[N];
int v[N],head[N],to[N*2],nxt[N*2],in[N],a[N],b[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline int dfs(int x,int fa) {
    if(vis[x]) return 0;
    vis[x]=1,v[++tp]=q[x].size();
    for(int i=head[x];i;i=nxt[i])
	if(to[i]!=fa) return dfs(to[i],x);
    return x;
}
int main() {
    int n;
    cin>>n;
    for(int i=1;i<n;i++)
	++in[a[i]=gi()],++in[b[i]=gi()];
    for(int i=1;i<n;i++) {
	int x=a[i],y=b[i];
	if(in[x]>1&&in[y]>1) {
	    to[++tt]=y,nxt[tt]=head[x],head[x]=tt;
	    to[++tt]=x,nxt[tt]=head[y],head[y]=tt;
	}
	if(in[x]==1) q[y].push_back(x);
	if(in[y]==1) q[x].push_back(y);
    }
    if(n==2) return puts("1\n2"),0;
    for(int i=1;i<=n;i++)
	if(in[i]>1) {
	    int x=dfs(i,0);
	    if(!x) return puts("-1"),0;
	    memset(vis,0,sizeof(vis));
	    tp=0,x=dfs(x,0);
	    for(int j=1;j<=n;j++)
		if(in[j]>1&&!vis[j]) x=0;
	    if(!x) return puts("-1"),0;
	    break;
	}
    int l=1,r=tp,t=0;
    while(l<=r) {
	if(v[l]<v[r]) break;
	if(v[l]>v[r]) {t=1;break;}
	++l,--r;
    }
    if(t) reverse(v+1,v+1+tp);
    --v[1],--v[tp];
    ++tp,t=2;
    cout<<1<<' ';
    for(int i=1;i<=tp;i++) {
	int x=v[i];
	for(int j=1;j<=x;j++) printf("%d ",t+j);
	printf("%d ",t),t+=x+1;
    }
    return 0;
}

Measured memory_bytes: 7168
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 55, MOD = 1000000007;

int cnt[MAX_N << 1], N, tot;

int f[MAX_N][MAX_N << 1][MAX_N << 1];

int main() {
  scanf("%d", &N);
  for (int i = 1, A; i < N << 1; ++i) {
    scanf("%d", &A);
    cnt[A]++;
  }
  for (int i = 1; i < N << 1; ++i) {
    while (!cnt[i] && i < N << 1) i++;
    if (cnt[i]) cnt[++tot] = cnt[i];
  }
  
  for (int i = 1; i <= tot; ++i) cnt[i] += cnt[i - 1];
  
  int l = tot, r = 1, now;
  
  while (cnt[l - 1] >= N) l--;
  while (cnt[r] < N) r++;
  now = r - l + 1;

  f[N][1][1] = 1;
  for (int i = N - 1; i >= 1; --i) {
    int nl = 0, nr = 0;
    if (cnt[l - 1] >= i) l--, nl = 1;
    if (cnt[r] < 2 * N - i) r++, nr = 1;
    
    for (int j = 1; j <= tot; ++j)
      for (int k = 1; k <= j; ++k)
	if (f[i + 1][j][k]) {
	  int nk = k + nl, nj = j + nl + nr;
	  for (int x = 1; x <= nj; ++x)
	    (f[i][nj - (x - nk == 0 ? 0 : abs(x - nk) - 1)][x <= nk ? x : nk + 1] += f[i + 1][j][k]) %= MOD;
	}
  }

  int res = 0;
  for (int i = 1; i <= tot; ++i)
    for (int j = 1; j <= i; ++j)
      res = (res + f[1][i][j]) % MOD;
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	P p[100010];
	rep(i, m) {
		int a, b; cin >> a >> b;
		p[i].first = b;
		p[i].second = a;
	}
	sort(p, p + m);
	int l = 0;
	int ans = 0;
	rep(i, m) {
		if (p[i].first != p[i + 1].first && !(p[i].first > l&&p[i].second <= l)) {
			ans++;
			l = p[i].first - 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String line = br.readLine();
			while ((line = br.readLine()) != null) {
				String[] s = line.split(" ");
				BigDecimal[] ia = new BigDecimal[s.length];
				for (int i = 0; i < s.length; i++) {
					ia[i] = new BigDecimal(s[i]);
				}
				boolean isParallel = parallel(ia);
				System.out.println(isParallel ? "YES" : "NO");
			}
		}
	}
	public static boolean parallel(BigDecimal[] b) {
		// dx1 / dy1 = dx2 / dy2
		// dx1 * dy2 = dy1 * dx2
		BigDecimal dx1 = b[2].subtract(b[0]);
		BigDecimal dx2 = b[3].subtract(b[1]);
		BigDecimal dy1 = b[6].subtract(b[4]);
		BigDecimal dy2 = b[7].subtract(b[5]);
		return dx1.multiply(dy2).compareTo(dx2.multiply(dy1)) == 0;
	}
}

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

using namespace std;

#define ll long long

bool s[110][100010];

ll r[110][100010], v[110], w[110], n;

ll res(ll id,ll rw)
{
    if(id>=n) return 0;
    if(rw==0) return 0;
    if(rw-w[id]<0) return res(id+1, rw);

    if(s[id][rw]!=1)
    {
        r[id][rw]=max(v[id]+res(id+1,rw-w[id]), res(id+1, rw));
        s[id][rw]=1;
    }
    return r[id][rw];
}

main()
{
    ll i, j, k;

    cin>>n>>k;


    for(i=0; i<n; i++) scanf("%lld %lld", &w[i], &v[i]);

    j=res(0, k);

    cout<<j<<endl;
}


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

using namespace std;

const int inf = (int)1e9+7;

struct Task {
	int n;
	vector<string> s;

	Task(int n): n(n), s(n) {
		for (auto& item : s) {
			cin >> item;
		}
	}

	void run() {
		vector<int> good(n);
		int all = 0;
		for (int j = 0; j < n; ++j) {
			good[j] = 1;
			for (int i = 0; i < n; ++i) {
				good[j] &= s[i][j] == '#';
				if (!good[j]) break;
			}
			all += good[j];
		}
		int result = inf;
		for (int a = 0; a < n; ++a) {
			for (int b = 0; b < n; ++b) {
				int cur = n - all;
				if (s[a][b] == '.') {
					bool found = false;
					for (int c = 0; c < n; ++c) {
						if (s[c][a] == '#') {
							++cur;
							found = true;
							break;
						}
					}
					if (!found) continue;
				}
				for (int j = 0; j < n; ++j) {
					cur += s[b][j] == '.';
				}
				result = min(result, cur);
			}
		}
		if (result == inf) {
			result = -1;
		}
		cout << result << endl;
	}
};

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

	int n;
	cin >> n;

	Task a(n);
	a.run();

	return 0;
}

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

int main()
{
	int h, n, k;
	long long sum = 0;
	priority_queue<int, vector<int>, greater<int>> q;
	cin >> n >> k;
	for(int i = 0; i < n; ++i){
		cin >> h;
		sum += h;
		q.push(h);
		if(q.size() > k)
			q.pop();
	}
	while(!q.empty()){
		sum -= q.top();
		q.pop();
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    rep(i, n){
        ans += s[i] == '.';
    }
    ll tmp = ans;
    rep(i, n){
        if(s[i] == '#'){
            tmp++;
        }else{
            tmp--;
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	ll N,A,B;
	cin>>N>>A>>B;
	if(A>B || (N==1 && A!=B)){
		cout<<0<<endl;
		return 0;
	}

	cout<<A+(N-1)*B-(N-1)*A-B+1<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = [0]*(N+1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if N < n:
                continue
            ans[n] += 1


for a in ans[1:]:
    print(a)


Measured memory_bytes: 9292
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10, MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int in;
	for(int i = 1; i <= 5; i++){
		cin >> in;
		if(in == 0){
			cout << i << '\n';
		}
	}
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

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

ll n, k;
ll a[100010];
bool can = true;

bool solve() {
	ll res = a[0];
	for (int i = 0; i < n; i++) {
		res = gcd(res, a[i]);
	}
	//1が作れるなら引き続けることでなんでも作れる(maxv : a[i]の最大値　以下の値にかぎることに注意)
	if (res == 1 || k % res == 0) return true;

	return false;
}

int main(void){
	cin>>n>>k;
	ll maxv = -1;
	for (int i = 0; i < n; i++) {
		cin>>a[i];
		if (a[i] == k) {
			cout<< "POSSIBLE" <<endl;
			return 0;
		}
		maxv = max(maxv, a[i]);
	}

	//a[i]の最大値maxvがkより小さければ引くことでkはつくれない
	if (maxv < k) can = false;

	if (solve() && can) cout<< "POSSIBLE" <<endl;
	else cout<< "IMPOSSIBLE" <<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 998244353; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
//main内でCOMinit(N+1)を忘れずに！
vl fac, finv, inv;
void COMinit(ll N) {
	fac.resize(N);
	finv.resize(N);
	inv.resize(N);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < N; 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;
	}
}
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll Npow(ll x, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) return Npow(x * x % MOD, n / 2);
	else return x * Npow(x, n - 1) % MOD;
}

int main() {
	cin >> N >> M >> K;
	COMinit(N + 1);
	for (i = 0; i <= K; i++) {
		ll num = N - i;
		ll base = (M*(Npow(M - 1, num - 1))%MOD)%MOD;
		//debug(base);
		base = (base * COM(N-1,i)) % MOD;
			//debug(base);
		ans = (ans + base) % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 7860
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n = ni()
t = [0] + list(li())
v = [0] + list(li()) + [0]

t_acc = list(accumulate(t))
t_max = t_acc[-1]
t_cur = [10**10]*(2*t_max+1)

interval = dict({(0,0): 0, (t_max,t_max): 0})
for i in range(n):
    interval.update({(t_acc[i], t_acc[i+1]): v[i+1]})
    
for t_idx in range(2*t_max+1):
    for i, ((tl,tr), v) in enumerate(interval.items()):
        
        if t_idx*0.5 < tl:
            t_cur[t_idx] = min(t_cur[t_idx], abs(v+(tl-t_idx*0.5)))
            
        elif tl <= t_idx*0.5 <= tr:
            t_cur[t_idx] = min(t_cur[t_idx], v)
            
        elif tr < t_idx*0.5:
            t_cur[t_idx] = min(t_cur[t_idx], abs(v+(t_idx*0.5-tr)))

ans = 0
for i in range(len(t_cur)-1):
    ans += (1/4)*(t_cur[i] + t_cur[i+1])

print(ans)

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

int main() {
  int n, count = 1;
  string str;
  cin >> n;
  cin >> str;

  for (int i = 1; i < n; i++) {
    if (str[i] != str[i-1]) {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <complex>

using namespace std;

typedef complex<double> P;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

// OÏ (cross product) : a~b = |a||b|sinÆ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
// 2¼üÌ½s»è : a//b <=> cross(a, b) = 0
int is_parallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}
int main(){

	int n;
	cin>>n;
	for(int j = 0; j < n; j++){
		P v[4];
		for(int i = 0; i < 4; i++){
			double x,y;
			cin>>x>>y;
			v[i] = P(x,y);
		}
		if(is_parallel(v[0],v[1],v[2],v[3])){
			cout<<"YES"<<endl;
		}
		else
			cout<<"NO"<<endl;
	}

	return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

int main(){

  int h, w;
  cin >> h >> w;

  char **s = new char*[h];
  char **ans = new char*[h];
  REP(i,h){
    s[i] = new char[w];
    ans[i] = new char[w];
  }
  vector<string> temp;
  REP(i,h){
    REP(j,w){
      cin >> s[i][j];
    }
  }

  REP(i,h){
    REP(j,w){
      if(s[i][j] == '#'){
        ans[i][j] = s[i][j];
      } else {
        int count=0;
        if(i != 0){
          if(j != 0){
            if(s[i-1][j-1] == '#') count++;
          }
          if(s[i-1][j] == '#') count++;
          if(j != w-1){
            if(s[i-1][j+1] == '#') count++;
          }
        }
        if(j != 0){
          if(s[i][j-1] == '#') count++;
        }
        if(j != w-1){
          if(s[i][j+1] == '#') count++;
        }
        if(i != h-1){
          if(j != 0){
            if(s[i+1][j-1] == '#') count++;
          }
          if(s[i+1][j] == '#') count++;
          if(j != w-1){
            if(s[i+1][j+1] == '#') count++;
          }
        }
        ans[i][j] = count+48;
      }
    }
  }

  REP(i,h){
    REP(j,w){
      cout << ans[i][j];
    }
    cout << endl;
  }


  REP(i,h){
    delete[] s[i];
    delete[] ans[i];
  }
  delete[] s;
  delete[] ans;

  return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int D, T ,S;

int main() {
  INCANT;
  cin >> D >> T >> S;
  string ans = S*T>=D?"Yes":"No";
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
struct edge {
    ll to, maisu, cost;
};
vector<edge> g[50];
vl v_maisu, v_hun;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> a;
    rep(i, m) {
        cin >> x >> y >> z >> w;
        x--;
        y--;
        g[x].push_back({y, z, w});
        g[y].push_back({x, z, w});
    }

    rep(i, n) {
        cin >> x >> y;
        v_maisu.push_back(x);
        v_hun.push_back(y);
    }

    ll dp[50][20000];
    rep(i, 50) {
        rep(j, 20000) { dp[i][j] = INF; }
    }

    t = n - 1;
    priority_queue<pair<ll, PP>, vector<pair<ll, PP>>, greater<pair<ll, PP>>> VP;

    rep(i, min(a, 9999LL) + 1) { dp[0][i] = 0; }
    VP.push(make_pair(0LL, make_pair(min(a, 9999LL), 0)));
    // cout << dp[0][2] << endl;

    e = 200000;
    while(e--) {
        auto C = VP.top();
        x = C.first;         //今の分
        y = C.second.first;  //今の枚数
        z = C.second.second; //今の頂点
        VP.pop();
        if(10000 > y + v_maisu[z] && dp[z][y + v_maisu[z]] > x + v_hun[z]) {
            VP.push(make_pair(x + v_hun[z], make_pair(y + v_maisu[z], z)));
            k = y + v_maisu[z];
            while(dp[z][k] > x + v_hun[z]) {
                dp[z][k] = x + v_hun[z];
                k--;
            }
        }
        for(edge i : g[z]) {
            p = i.cost;
            q = i.to;
            r = i.maisu;
            if(y >= r && dp[q][y - r] > x + p) {
                k = y - r;
                while(dp[q][k] > x + p) {
                    dp[q][k] = x + p;
                    if(k == 0) {
                        // cout << x + p << " " << y - r << " " << q << endl;
                        t--;
                        break;
                    }
                    k--;
                }
                VP.push(make_pair(x + p, make_pair(y - r, q)));
            }
        }
    }

    rep(i, n - 1) { cout << dp[i + 1][0] << endl; }
}

Measured memory_bytes: 11580
#include<iostream>
#include<iomanip>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<unordered_set>
using namespace std;
const int INF = 2147483647;
const int MAX = 100000;
#include<stdio.h>

int main(void)
{
	char ch;
	int cnt = 0;
	for (int i = 0; i < 6; i++) {
		cin >> ch;
		if (ch == '1')cnt++;
	}

	cout << cnt << endl;

	return 0;
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> ball;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        ball[A[i]]++;
    }

    ll sum = 0;
    for (auto num : ball) {
        if (num.second >= 2) {
            sum += num.second * (num.second - 1) / 2;
        }
    }

    for (int i = 0; i < N; i++) {
        ll out = sum;
        if (ball[A[i]] > 2) {
            out -= ball[A[i]] - 1;
        } else if (ball[A[i]] == 2) {
            out -= 1;
        }
        cout << out << endl;
    }

    return 0;
}


Measured memory_bytes: 12720
#include<stdio.h>
int main()
{
  long long n,a,x,mn,mx,s;
  s=0;
  mn=1000000;
  mx=-1000000;
  scanf("%lld",&n);
  for(x=0;x<n;x++){
    scanf("%lld",&a);
    s=s+a;
    if(mn>a){mn=a;}
    if(mx<a){mx=a;}
  }
  printf("%lld %lld %lld\n",mn,mx,s);
  return 0;
}



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

string s[114514];

int main(){
  ll N; cin >> N;
  for(int i=0;i<N;i++) {
    cin >> s[i];
  	sort(s[i].begin(), s[i].end());
  }
  sort(&s[0], &s[N]);
  ll ans = 0;
  ll cnt = 0;
  for(int i=0;i<N;i++){
    if (i > 0 && s[i-1] != s[i]){
      ans += cnt * (cnt - 1) / 2;
      cnt = 1; 
    }else cnt++;    
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
  return 0;
}


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

int main(){
  
  string a; cin >> a;  string b; cin >> b;  string c; cin >> c;
  
  char t = 'a';
  int ia = 0;
  int ib = 0;
  int ic = 0;
  while(1){
  	if(t == 'a'){
      
      if(ia == a.size()){
        cout << 'A' << endl;
      	return 0;
      }
      t = a[ia];
      ia++;
      
    }else if(t == 'b'){
      if(ib == b.size()){
        cout << 'B' << endl;
      	return 0;
      }
      t = b[ib];
      ib++;
      
    }else{
      if(ic == c.size()){
        cout << 'C' << endl;
      	return 0;
      }
      t = c[ic];
      ic++;
      
    }
  }
}


Measured memory_bytes: 256
from sys import stdin
from math import factorial

def permutations_count(n, r):
  return factorial(n) // factorial(r) // factorial(n - r)

N,K = map(int,stdin.readline().split())
mod = pow(10,9)+7

frame = N-K+1
for i in range(1,K+1):
  if i > frame:
    print("0")
  else:
    select=permutations_count(frame, i) % mod
    pattern=permutations_count(K-1, i-1) % mod
    print((select * pattern) % mod )

Measured memory_bytes: 68952
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

class Node {
	int id;
	int left;
	int right;

	public Node(int id) {
		this.id = id;
	}

}

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		Node[] tree = new Node[n];

		for (int i = 0; i < n; i++) {
			tree[i] = new Node(i);
		}

		boolean[] isChild = new boolean[n];
		for (int i = 0; i < n; i++) {
			int nowNum = sc.nextInt();

			Node now = tree[nowNum];
			now.left = sc.nextInt();
			now.right = sc.nextInt();

			if (now.left != -1) isChild[now.left] = true;
			if (now.right != -1) isChild[now.right] = true;
		}

		int root = -1;
		for (int i = 0; i < n; i++) {
			if(!isChild[i]) {
				root = i;
				break;
			}
		}

		sc.close();

		pByPreorder(root, tree);
		pByInorder(root, tree);
		pByPostorder(root, tree);

	}

	private static void pByPostorder(int root, Node[] tree) {
		System.out.println("Postorder");
		porder(root, tree);
		System.out.println();
	}

	private static void porder(int id, Node[] tree) {
		Node now = tree[id];
		if(now.left != -1) porder(now.left, tree);
		if(now.right != -1) porder(now.right, tree);
		System.out.print(" " + id);
	}

	private static void pByInorder(int root, Node[] tree) {
		System.out.println("Inorder");
		inorder(root, tree);
		System.out.println();
	}

	private static void inorder(int id, Node[] tree) {
		Node now = tree[id];
		if(now.left != -1) inorder(now.left, tree);
		System.out.print(" " + id);
		if(now.right != -1) inorder(now.right, tree);
	}

	private static void pByPreorder(int root, Node[] tree) {

		System.out.println("Preorder");

		Deque<Integer> deq = new LinkedList<>();
		deq.push(root);

		while(!deq.isEmpty()) {

			int nowId = deq.pop();
			System.out.print(" " + nowId);

			Node now = tree[nowId];
			if (now.right != -1) deq.push(now.right);
			if (now.left != -1) deq.push(now.left);

		}
		System.out.println();
	}
}

Measured memory_bytes: 26208
import math
N, K = map(int, input().split())
def comb(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    else:
        return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
for i in range(1, K + 1):
    print((comb(K-1,i-1) * comb(N-K+1,i))%(10**9+7))


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

using namespace std;


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

  uint64_t ret = 0;
  for(uint64_t i = 1;
      i <= sqrt(n) + 1;
      ++i)
    {
      if(n % i == 0)
        {
          if(i < (n/i - 1))
            {
              ret += (n/i - 1);
            }
        }
    }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

using namespace std;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

template <class T>
constexpr bool in(T min, T max, T t)
{
    return t >= min && t <= max;
}

template <class T>
constexpr bool nin(T min, T max, T t)
{
    return !in(min, max, t);
}

template <class T>
void ninDebug(T min, T max, T t)
{
    using namespace std;
    if (nin(min, max, t))
    {
        cout << "ERROR" << endl;
    }
}


int main()
{
    ll n, m;
    cin >> n >> m;

    vec<ll> h(n);

    for (auto& e : h)
    {
        cin >> e;
    }
        

    vvec<ll> edges(n);

    for (int i = 0; i < m; ++i)
    {
        ll a, b;
        cin >> a >> b;

        --a, --b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    ll ans{};

    for (int i = 0; i < n; ++i)
    {
        ll ma = accumulate(edges[i].cbegin(), edges[i].cend(), 0, 
            [&h](ll init, ll e) 
        {return max(init, h[e]); });
        
        if (h[i] > ma)
            ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9796
#include <iostream>
int main(void)
{
  int inputNum1, inputNum2;
  std::cin >> inputNum1 >> inputNum2;
  int total = inputNum1 * inputNum2;
  if(total % 2 == 1) {
    std::cout << "Odd" << std::endl;
  }
  else {
    std::cout << "Even" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
// Calvin Gagliano 
// @calgagi
// Oregon State University
// Competitive Programming Template
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ii = pair<int, int>;

int main() {
    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);
    srand(chrono::steady_clock::now().time_since_epoch().count()); 
    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
    
    string t;
    cin >> t;
    for (auto& c : t) {
        cout << 'x';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int A[N], B[N], C[N-1];
  FOR(i,0,N) {cin >> A[i]; --A[i];}
  FOR(i,0,N) cin >> B[i];
  FOR(i,0,N-1) cin >> C[i];
  int total=B[A[0]];
  int before = A[0];
  //cout << total << '\n';
  FOR(i,1,N)
  {
    total += B[A[i]];
    if(A[i] == before+1) total += C[before];
    before = A[i];
    //cout << total << '\n';
  }
  cout << total << '\n';
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m;
int a[50], b[50];
bool graph[50][50],reached[50];

void dfs(int v) {
    reached[v] = true;
    for (int w = 0; w < n; ++w) {
        if (graph[v][w] == false) continue;
        if (reached[w] == true) continue;
        dfs(w);
	}
}

int main() {
  cin>>n>>m;
  for(int i = 0; i < m; ++i) {
	cin >> a[i] >> b[i];
	a[i]--, b[i]--;
	graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  int ans=0;
  for(int i=0;i<m;i++){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    for(int j=0;j<n;j++) reached[j]=false;
    dfs(0);
    bool bridge=false;
    for(int j=0;j<n;j++) if(reached[j]==false) bridge=true;
    if(bridge) ans+=1;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    
  }
  cout<<ans<<endl;
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5+5;
vector<int> g[N];
ll dp[N][2];
int mod = 1e9+7;
bool hasCh[N];



ll f(int u, int p, int col){
    ll &ans = dp[u][col];
    if(ans != -1)return ans;
    ans = 1;
    for(int v: g[u]){
        if(v == p)continue;
        ll aux = 0;
        if(!col)aux = f(v, u, col);
        aux = (aux+f(v, u, !col))%mod;
        ans = (ans*aux)%mod;
    }
    return ans;
}

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

  int n, u, v;
  cin >> n;
  forn(i, 0, n-1){
      cin >> u >> v;
      u--,v--;
      g[u].pb(v);
      g[v].pb(u);
  }
  memset(dp, -1, sizeof dp);
  ll ans = f(0, -1, 0);
  ans = (ans + f(0, -1, 1))%mod;
  cout << ans << endl;


}





Measured memory_bytes: 18948
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int a,b,c;
  cin >> a >> b >> c;

  if(b-a == c-b){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

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

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

	int ret = C - (A - B);
	if (ret < 0) ret = 0;

	cout << ret << endl;
}

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

if n >= 100:
  na = n % 100
  na = na % 10
elif n >= 10:
  na = n % 10
else:
  na = n
pon = [0,1,6,8]

if na == 3:
  print("bon")
elif na in pon:
  print("pon")
else:
  print("hon")



Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>

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

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

int main()
{
  int X, A;
  cin >> X >> A;

  if (X < A)
    cout << 0 << endl;
  else
    cout << 10 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

bool prime_num(long x){
    if(x == 1) return false;
    for(long i=2; i<=int(sqrt(x)); i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    long X;
    cin >> X;
    for(long i = X; ; i++){
        if(prime_num(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long b = sc.nextLong();
        long r = sc.nextLong();
        
        long tmp1 = n / (b+r);
        long tmp2 = n % (b+r);
        
        long ans = tmp1*b+Math.min(b, tmp2);
        
        
        System.out.println(ans);
    }
}


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

typedef long long int ll;
using Graph = vector<vector<int>>;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
  ll N;
  cin >> N;
  int ans = 0;
  for(int i = pow(N,0.5);i >= 1;i--){
    if(N % i == 0){
      int a = i,b = N / a;
      int t = max(a,b);
      for(int i = 0;i < N;i++){
        if(t == 0){
          break;
        }
        ans++;
        t /= 10;
      }
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (int)1e5+5
#if !testing
#define cerr if(0)cout
#endif
int A[MAXN];
const int sqn = 400;
int cnt[sqn+5][sqn+5], nxt[sqn+5][sqn+5], id[sqn+5][sqn+5]; //ith element in the jth bucket 
//"inspiration" from holes
int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	int n; cin>>n;
	FOR(i,0,n-1)cin>>A[i];
	int L;cin>>L;
	cnt[(n-1)%sqn][(n-1)/sqn]=1;
	nxt[(n-1)%sqn][(n-1)/sqn]=id[(n-1)%sqn][(n-1)/sqn]=n+1;
	DEC(i,n-2,0) {
		int tgt = prev(upper_bound(A,A+n,A[i]+L))-A;
		if(i/sqn==tgt/sqn) {
			cnt[i%sqn][i/sqn]=cnt[tgt%sqn][tgt/sqn]+1;
			nxt[i%sqn][i/sqn]=tgt;
			id[i%sqn][i/sqn]=id[tgt%sqn][tgt/sqn];
		} else {
			cnt[i%sqn][i/sqn]=1;
			nxt[i%sqn][i/sqn]=id[i%sqn][i/sqn]=tgt;
		}
	}
	FOR(i,0,n-1) {
		//printf("cnt: %i nxt: %i id: %i\n",cnt[i%sqn][i/sqn],nxt[i%sqn][i/sqn],id[i%sqn][i/sqn]);
	}
	int Q;cin>>Q;
	while(Q--) {
		int a,b;cin>>a>>b;
		--a,--b;
		if(a>b)swap(a,b);
		int day = 0;
		int idx = a;
		FOR(i,a/sqn,b/sqn) {
			if(idx>=b)break;
			db2(idx,day);
			if(i==b/sqn) {
				while(idx<b) {
					++day;
					idx=nxt[idx%sqn][idx/sqn];
				}
			} else {
				day+=cnt[idx%sqn][idx/sqn];
				idx=id[idx%sqn][idx/sqn];
				if(idx>=b)break;
			}
		}
		cout<<day<<'\n';
	}
}


Measured memory_bytes: 5504
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
	char x;
	cin>>x;
	cout << char(x-'a' + 1+'a');
	
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2,s3="";
	cin>>s1>>s2;
	s3=s2.substr(0,s1.size());
	if(s1==s3)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
ll mod = (ll)1e9+7;

int main(void){
    string s,t;
    bool flg = 1;
    cin >> s >> t;
    map<char,char> mp,mp2;
    for(int i = 0;i < s.size();i++){
        if(mp.count(s[i]) && mp[s[i]] != t[i]) flg = false;
        if(mp2.count(t[i]) && mp2[t[i]] != s[i]) flg = false;
        mp[s[i]] = t[i];
        mp2[t[i]] = s[i];
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 776
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int x, y, xs, ys;

	cin>>x>>y;

	int a[7]={1, 3, 5, 7, 8, 10, 12}, b[4]={4, 6, 9, 11}, c=2;

	rep(i, 7){
		if(x==a[i]) xs=1;
		if(y==a[i]) ys=1;
	}
	rep(i, 4){
		if(x==b[i]) xs=2;
		if(y==b[i]) ys=2;
	}
	if(x==c) xs=3;
	if(y==c) ys=3;

	cout<<yn(xs==ys)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int N, X;
	cin >> N >> X;
	int ans = 0;
	int d = 0;
	for (int i = 0; i < N; i++) {
		if (d <= X) ans++;
		int L;
		cin >> L;
		d += L;
	}
	if (d <= X) ans++;
	cout << ans << endl;
}


Measured memory_bytes: 3644
n, m=gets.split.map &:to_i
a=(1..n).map{gets.split.map &:to_i}
b=(1..m).map{gets.split.map &:to_i}
a.each do |x, y|
	i=0
	p b.map{|s,t| [(x-s).abs+(y-t).abs,i+=1]}.min[1]
end

Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(x) cout << (x) << endl;
const int INF = 1e+8+7;
ll n,m;
string s,t;
int d[100],dp1[500][500],dp2[500][500];
vi vec;

int main(){
  n = 1;
  cin >> s >> t;
  rep(i,0,3){
    if(s[i] != t[2-i])n = 0;
  }
  if(n)puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int N = IntRead();
        int[,] c = new int[N, 3];
        for (int i = 0; i < N; i++)
        {
            int[] inp = IntLine();
            c[i, 0] = inp[0];
            c[i, 1] = inp[1];
            c[i, 2] = inp[2];
        }
        long[,] dp = new long[100010, 3];
        for (int i = 0; i <= N; i++) dp[i, 0] = dp[i, 1] = dp[i, 2] = 0;
        for (int i = 0; i < N; i++)
        {
            dp[i + 1, 0] = Math.Max(dp[i, 1] + c[i, 0], dp[i, 2] + c[i, 0]);
            dp[i + 1, 1] = Math.Max(dp[i, 2] + c[i, 1], dp[i, 0] + c[i, 1]);
            dp[i + 1, 2] = Math.Max(dp[i, 0] + c[i, 2], dp[i, 1] + c[i, 2]);
        }
        long ans = Math.Max(dp[N, 0], dp[N, 1]);
        Console.WriteLine(Math.Max(dp[N,2],ans));
    }
}



public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int GCD(int a, int b)
    {
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(int a, int b)
    {
        return (long)a * b / GCD(a, b);
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static long Combination(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r + 1), r).ToList().Aggregate((now, next) => now * next) /
            Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next);
    }
    public static long Permutation(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r), r).ToList().Aggregate((now, next) => now * next);
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 18740