akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 

vector<ll> sub(const string &s, ll c) {
    ll n = s.size();
    ll cur = 0, last = -c-1;
    vector<ll> res(n+1, 0);
    for (ll i = 0; i < n; ++i) {
        if (i - last > c && s[i] == 'o') {
            ++cur, last = i;
        }
        res[i+1] = cur;
    }
    return res;
}

int main() {
    ll n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    const auto & left = sub(s, c);
    string t = s;
    reverse(t.begin(), t.end());
    const auto & right  = sub(t, c);

    for (ll i = 0; i < n; ++i) {
        if (s[i] == 'x') continue;
        if (left[i] + right[n-i-1] < k) cout << i+1 << endl;
    }
}


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

vector<vector<int>> g;
vector<int> visit;

int reachable(int s, int t)
{
    if (s == t) {
        return 1;
    }
    int found = 0;
    visit[s] = 1;
    for (auto k : g[s]) {
        if (!visit[k] && reachable(k, t)) {
            found = 1;
            break;
        }
    }
    visit[s] = 0;
    return found;
}

int count_bridge(int i)
{
    visit[i] = 1;
    // cout << i + 1 << endl;
    int cnt = 0;
    for (auto j : g[i]) {
        int found = 0;
        for (auto k : g[i]) {
            if (k != j) { // 目的地とは異なる頂点を経由して
                // cout << "    " << i + 1 << " to " << j + 1 << " via " << k + 1 << " " << reachable(k, j) << endl;
                if (reachable(k, j)) {
                    found = 1;
                    break;
                }
            }
        }
        if (!found) {
            cnt++;
        }
    }
    visit[i] = 0;
    return cnt;
}

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

    g.assign(n, vector<int>());
    visit.assign(n, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += count_bridge(i);
    }
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int solve( int n );

int main( void )
{
	int N;

	std::cin >> N;

	int ans = solve( N );
	std::cout << ans << std::endl;

	return 0;
}

int solve( int n )
{
	int ans = 0;

	ans = n * n * n;

	return ans;
}


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

int main() {
  int n, ans = 0;
  cin >> n;

  int l[n];
  for (int i=0; i<n; ++i) cin >> l[i];

  if (n < 3) {
    cout << ans << endl;
    return 0;
  }

  for (int i=0; i<n-2; ++i) {
    for (int j=i+1; j<n-1; ++j) {
      for (int k=j+1; k<n; ++k) {
        if (l[i] < (l[j] + l[k]) && l[j] != l[k]) {
          if (l[j] < (l[k] + l[i]) && l[k] != l[i]) {
            if (l[k] < (l[i] + l[j]) && l[i] != l[j]) {
              ans++;
            }
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

long long keta_wa(long long n){
	long long res=0;
	while(n>0){
		res+=n%10;
		n/=10;
	}
	return res;
}//nの各桁の和を求める関数

double sunuke(long long n){
	return double(n)/keta_wa(n);
}//nのsunuke数を求める関数

int main(){
	vector<long long>res;
	long long base=1;

	for(int i=0;i<15;++i){
		for(int j=1;j<150;++j){
			res.push_back(base*(j+1)-1);
		}
		base*=10;
	}
	sort(res.begin(),res.end());
	res.erase(unique(res.begin(),res.end()),res.end());

	for(long long int i=0;i<res.size();++i){
		for(long long int j=i+1;j<res.size();++j){
			if(sunuke(res[i])>sunuke(res[j])){
				res.erase(res.begin() + i--);
				break;
			}
		}
	}
	long long int k;
	cin>>k;
	for(int i=0;i<k;++i){
		cout<<res[i]<<endl;
	}
}

Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  string s;
  cin >> s;
  int ans = 0;
  for(auto t:s){
    if(t=='+')ans++;
    else ans--;
  }
  cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PB push_back
#define REP(i, x, n) for(int i=x; i<n; i++)

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

        ll a, b;
        cin >> a >> b;
        cout << a * b << endl;

        return 0;
}

Measured memory_bytes: 3508
def readinput():
    s=input()
    t=input()
    return s,t

def main(s,t):
    found=False
    it=0
    for i in range(len(s)-len(t),-1,-1):
        for j in range(len(t)):
            #print(s[i+j],t[j])
            if s[i+j]=='?':
                continue
            if s[i+j]!=t[j]:
                break
        else:
            found=True
            it=i
            break
    if found==False:
        return 'UNRESTORABLE'

    ans=s[:it]+t+s[it+len(t):]
    ans=ans.replace('?','a')

    return ans

if __name__=='__main__':
    s,t=readinput()
    ans=main(s,t)
    print(ans)


Measured memory_bytes: 9084
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
set<int> st;
int n;
void solve(int idx, int rem, int num) {
	if (!rem) st.insert(num);
	if (idx == n + 1) return;
	solve(idx + 1, rem, num);
	solve(idx + 1, rem - 1, num + idx);
}
int mod = 1e9 + 7;
int main() {
//	file();
	fast();
	/*n = 13;
	int last = 0;
	for (int i = 1; i <= n + 1; i++) {
		st.clear();
		solve(0, i, 0);
		cout << i << ' ' << sz(st) << ' ' << sz(st) - last << endl;
		last = sz(st);
	}*/
	
	int n, k; cin >> n >> k;
	ll ans = 0;
	ll add = n + 1;
	ll last = 0;
	for (int i = 1; i <= n + 1; i++) {
		ll num = (last + add + mod) % mod;
		if (i >= k) ans += num;
		if (i == 1) add -= 1;
		add -= 2;
		add += mod;
		add %= mod;
		last = num;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define debug(x) (cout << "#x = " << (x) << '\n')

using namespace std;
typedef long long ll;

inline char gc() {
	static char buf[100000], *p1 = buf, *p2 = buf;
	return (p1 == p2) && (p2 = (p1 = buf) +
		fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
}

#define dd ch = getchar()
template <class T>
inline void read(T &x) {
	x = 0;
	int f = 0; char dd;
	for (; !isdigit(ch); dd) f ^= (ch == '-');
	for (; isdigit(ch); dd)  x = (x << 1) + (x << 3) + (ch ^ 48);
	x = f? -x: x;
}
#undef dd

template <class T>
inline void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 | 48);
}

template <class T>
inline void wrn(T x) {
	write(x), putchar(' ');
}

template <class T>
inline void wln(T x) {
	write(x), putchar('\n');
}

template <class T>
inline void wlnn(T x, T y) {
	wrn(x), wln(y);
}

ll n, r, cnt = 0;

int main()
{
	read(n), read(r);
	for (; n; n /= r) ++cnt;
	return wln(cnt), 0;
}

/*

*/




Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))
z_list = list(map(int, input().split()))

x_list = sorted(x_list, reverse=True)
y_list = sorted(y_list, reverse=True)
z_list = sorted(z_list, reverse=True)

# 次にとるindexの管理
next_dict = {}

def sumxyz(tup):
  return x_list[tup[0]] + y_list[tup[1]] + z_list[tup[2]]

def argmax(l):
  mxi = -1
  mx = -1
  for i, v in enumerate(l):
    if v >= mx:
      mx = v
      mxi = i
  return mxi

def add_next(tup):
  def add_not_exist(ntup):
    sm = sumxyz(ntup)
    if ntup not in next_dict:
	    next_dict[ntup] = sm
    
  if tup[0] < len(x_list)-1:
    ntup = (tup[0]+1, tup[1], tup[2])
    add_not_exist(ntup)
  if tup[1] < len(y_list)-1:
    ntup = (tup[0], tup[1]+1, tup[2])
    add_not_exist(ntup)
  if tup[2] < len(z_list)-1:
    ntup = (tup[0], tup[1], tup[2]+1)
    add_not_exist(ntup)

for i in range(K):
  if i == 0:
    print(sumxyz((0,0,0)))
    add_next((0,0,0))
  else:
    v = next_dict.values()
    k = list(next_dict.keys())
    max_idx = argmax(v)
    print(next_dict[k[max_idx]])
    next_dict[k[max_idx]] = -1
    
    add_next(k[max_idx])


Measured memory_bytes: 4528
//ABC052B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	string s;
	cin >> n >> s;
	int num = 0;
	int ans = 0;
	for(int i=0;i<n;i++){
		if(s.at(i) == 'I'){
			num++;
		}else{
			num--;
		}
		ans = max(ans,num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n; cin >> n;
    ll seven = 7 % n;
    int ans = 1;
    while(ans < 1000000) {
        if(seven == 0) {
            cout << ans;
            return 0;
        } else {
            seven = (seven * 10 + 7) % n;
            ++ans;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define MAXN 25
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
#define KONJ 42-42
using namespace std;

int n, a[MAXN], b[MAXN], c[MAXN], sol;

void print(int arr[MAXN][MAXN], int r, int s) {
	cout << "\nTEST:\n";
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < s; j++) {
			cout << arr[i][j] << " ";
		}
		cout << "\n";
	}
	cout << "\n";
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (int i = 1; i < n; i++) {
		cin >> c[i];
	}
	sol += b[a[1]];
	for (int i = 2; i <= n; ++i) {
		sol += b[a[i]];
		if (a[i] == a[i - 1] + 1) {
			sol += c[a[i - 1]];
		}
	}
	cout << sol;
	return 0;
}


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

int main() {
  string N;
  cin >> N;
  ll sum = 0;
  for (int i = 0; i < N.size(); i++) sum += (N[i]-'0');
  if (sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3748
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll X, A;
  cin >> X >> A;
  if (X < A)
    cout << 0 << endl;
  else
    cout << 10 << endl;
  return 0;
}


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

int main()
{
    int n, s = 0, r, l;

    scanf("%d", &n);
    while (n--) {
        scanf("%d%d", &l, &r);
        s += r - l + 1;
    }
    printf("%d\n", s);
}


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

int main(void){
    int N;
    cin >> N;
    int f[10010] = { 0 };
    
    int x,y,z;
    
    for(int i = 1 ; i <= N ; i++){
        for(x = 1 ; x*x < i ; x++){
            for(y = 1 ; x*x + y*y + x*y < i ; y++){
                for(z = 1 ; x*x + y*y + z*z + x*y + y*z + z*x <= i ; z++){
                    if(x*x + y*y + z*z + x*y + y*z + z*x == i) f[i]++;
                }
            }
        }
    }
  
    for(int i = 1 ; i <= N ; i++){
        cout << f[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#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 ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int n;
	cin >> n;
	auto oddNo = (n+1) / 2;
	cout << (double)oddNo / n << endl;
	return 0;
	
}



Measured memory_bytes: 256
//import kotlin.math.absoluteValue
//import kotlin.math.min

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val xs = readLine()!!.split(" ").map { it.toInt() }

    // n - k + 1
    val list = arrayListOf<List<Int>>()
    var i = 0
    repeat(n - k + 1, {
        list.add(xs.subList(i, i + k))
        i++
    })

//    list.forEach { println(it) }

    val min1 = list.map {
        if (it[0] < 0) -it[0] + (it[k - 1] - it[0])
        else it[0] + (it[k - 1] - it[0])
    }.min()
    val min2 = list.map {
        if (it[k - 1] < 0) -it[k - 1] + (it[k - 1] - it[0])
        else it[k - 1] + (it[k - 1] - it[0])
    }.min()

//    println("min1: $min1")
//    println("min2: $min2")

    println(if (min1!! < min2!!) min1 else min2)
}


Measured memory_bytes: 58212
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	r := nextInt()
	fmt.Println(r * r)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long i,j,n,a,b,c;
 cin>>n>>b>>c;
 i=min(b,c);
 j=(b+c)-n;
 if(j>0) cout<<i<<" "<<j<<endl;
 else  cout<<i<<" "<<"0"<<endl;
return 0;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
struct Vector{int x;int y;};

int cross(Vector a,Vector b)
{
	return a.x*b.y-a.y*b.x;
}
int scaler(Vector a,Vector b)
{
	return a.x*b.x+a.y*b.y;
}

int main()
{
	int n;cin>>n;
	REP(i,n)
	{
		Vector a,b;
		int x0,y0,x1,y1,x2,y2,x3,y3;
		cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
		a.x=x1-x0;
		a.y=y1-y0;
		b.x=x3-x2;
		b.y=y3-y2;
		if(cross(a,b)==0)cout<<2<<endl;
		else if(scaler(a,b)==0)cout<<1<<endl;
		else cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


inline size_t
find(const size_t i, vector<int> & par)
{
    return par[i] < 0 ? i : par[i] = find(par[i], par);
}

inline void
join(size_t i, size_t j, vector<int> & par)
{
    if((i = find(i, par)) != (j = find(j, par)))
    {
        if(par[j] < par[i]) swap(i, j);
        par[i] += par[j];
        par[j] = i;
    }
}


int64_t
arc076_b()
{
  size_t n;
  cin >> n;

  vector<pair<int64_t, int64_t>> xs(n);
  cin >> xs;

  typedef pair<size_t, size_t> edge_t;
  vector<edge_t> edge;
  {
    vector<size_t> idx(n);
    iota(begin(idx), end(idx), 0);
    sort(begin(idx), end(idx), [&xs](const size_t i, const size_t j) {
         return xs[i] < xs[j];
         });
    for(size_t i = 0; i + 1 < n; ++i)
      edge.emplace_back(idx[i], idx[i + 1]);
  }
  {
    vector<size_t> idx(n);
    iota(begin(idx), end(idx), 0);
    sort(begin(idx), end(idx), [&xs](const size_t i, const size_t j) {
         return xs[i].second < xs[j].second;
         });
    for(size_t i = 0; i + 1 < n; ++i)
      edge.emplace_back(idx[i], idx[i + 1]);
  }

  sort(begin(edge), end(edge), [&xs](const edge_t & a, const edge_t & b){
       const auto d = min(abs(xs[a.first].first  - xs[a.second].first),
                          abs(xs[a.first].second - xs[a.second].second));

       const auto e = min(abs(xs[b.first].first  - xs[b.second].first),
                          abs(xs[b.first].second - xs[b.second].second));

       return d < e;
       });


  vector<int> par(n, -1); /* each node its own parent */

  size_t k = 0;
  int64_t out = 0;

  for(const auto & e: edge)
    if(find(e.first, par) != find(e.second, par))
    {
      join(e.first, e.second, par);
      ++ k;

      out += min(abs(xs[e.first].first  - xs[e.second].first),
                 abs(xs[e.first].second - xs[e.second].second));

      if(k + 1 == n)
        break;
    }

  return out;
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << arc076_b();

  return EXIT_SUCCESS;
}


Measured memory_bytes: 8672
// Believe in yourself...
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)

#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=110;

#pragma GCC Optimize("Ofast")

int g[maxn][maxn];// bishtare 1 mishe
// 1 black
// -1 white
// 0 black

const ll lm=48;
const ll SZ=100;

int main(){
	ll w,b;cin>>w>>b;
	w--;b--;
	REP(i,lm){
		REP(j,lm){
			if((i%2)==0&&(j%2)==0){
				if(b>0){
					g[i][j]=1;
					b--;
				}
				else
					g[i][j]=-1;
			}
			else
				g[i][j]=-1;
		}
	}
	
	REP(i,lm){
		REP(j,lm){
			if((i%2)==0&&(j%2)==0){
				if(w>0){
					g[SZ-1-i][SZ-1-j]=-1;
					w--;
				}
				else
					g[SZ-1-i][SZ-1-j]=1;
			}
			else
				g[SZ-1-i][SZ-1-j]=1;
		}
	}
	cout<<SZ<<" "<<SZ<<endl;
	REP(i,SZ){
		REP(j,SZ){
			if(g[i][j]==-1)
				cout<<'.';
			else
				cout<<'#';
		}
		cout<<endl;
	}		
}

Measured memory_bytes: 256
from sys import stdin, stdout


def main():
    line = stdin.readline()
    parts = line.split()
    n = int(parts[0])
    countfive = 0
    countseven = 0
    for i in parts:
        if int(i)==5:
            countfive= countfive+1
        if int(i)==7:
            countseven= countseven+1


    stdout.write( "YES" if countfive==2 and countseven == 1 else "NO")


main()


Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<ll,ll> pll;
ll n,x,d;
map<ll,vector<pll> >M;
inline ll sm(ll x){return x*(x-1)/2;}
inline ll bg(ll x){return x*(2*n-x-1)/2;}
signed main(){
	cin>>n>>x>>d;
	if(!d){
		if(!x)puts("1");
		else cout<<(n+2)/2+(n+1)/2<<endl;
		return 0; 
	}
	if(d<0){
		x+=(n-1)*d;
		d=-d;
	}
	for(ll i=0,j;i<=n;++i){
		j=n-i;
		ll f=(ll)(i-j)*x,mn=sm(i)-bg(j),mx=bg(i)-sm(j);
		ll val=f+mn*d,ind=val%(2ll*d);
		if(ind<0)ind+=2ll*d;
		ll a=(val-ind)/(2ll*d),b=a+(mx-mn)/2ll;
		M[ind].push_back(pll(a,b));
	}
	ll res=0;
	for(auto it:M){
		vector<pll>v=it.second;
		sort(v.begin(),v.end());
		res+=v[0].second-v[0].first+1;
		ll lst=v[0].second;
		for(ll i=1;i<v.size();++i){
			if(v[i].second<=lst);
			else if(v[i].first<=lst){
				res+=v[i].second-lst;
				lst=v[i].second;
			}else{
				res+=v[i].second-v[i].first+1;
				lst=v[i].second;
			}
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010,mod=998244353;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,m,p[11],q[11],cnt;
vector<int> vec[11];
int main(){
	n=read();m=read();
	FOR(i,0,m-1){
		int k=read();
		FOR(j,1,k) vec[read()-1].push_back(i);
	}
	FOR(i,0,m-1) p[i]=read();
	FOR(i,0,(1<<n)-1){
		FOR(j,0,m-1) q[j]=0;
		FOR(j,0,n-1) if((i>>j)&1){
			FOR(k,0,(int)vec[j].size()-1) q[vec[j][k]]^=1;
		}
		bool flag=true;
		FOR(j,0,m-1) if(p[j]!=q[j]) flag=false;
		if(flag) cnt++;
	}
	printf("%d\n",cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int ma = f/(a*100)+1;
  int mb = f/(b*100)+1;
  int mc = f*e/(100+e)/c+1;
  int md = f*e/(100+e)/d+1;
  
  int swans=0,sans=0;
  double co=-1;
  rep(i,ma)rep(j,mb)rep(k,mc)rep(l,md){
    int wsum=i*a*100+j*b*100;
    int ssum=k*c+l*d;
    if(wsum+ssum>f){ continue; }
    if(wsum/100*e<ssum){ continue; }
    double tmp=(double)ssum/(ssum+wsum);
    if(tmp>co){
      co=tmp;
      swans=ssum+wsum;
      sans=ssum;
    }
  }
  cout << swans << " " << sans << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i

class Node
  attr_accessor :id, :parent, :left, :right, :sibling, :degree, :depth, :height, :node_type
  def initialize(i)
    @id = i
    @parent = -1
    @left = -1
    @right = -1
    @depth = 0
    @height = 0
    @sibling = -1
    @degree = -1
  end
end

nodes = {}
# 大きさが分かるので初期化しておく
n.times do |i|
  nodes[i] = Node.new(i)
end
# 階層
levels = []

def heightrec(par, nodes)
  l, r = 0, 0
  if nodes[par].left >= 0
    tmp_left = nodes[par].left
    l = heightrec(tmp_left, nodes) + 1
  end
  if nodes[par].right >= 0
    tmp_right = nodes[par].right
    r = heightrec(tmp_right, nodes) + 1
  end
  nodes[par].height = [r, l].max
end

def depthrec(par, nodes)
  left_child = nodes[par].left
  if left_child >= 0
    nodes[left_child].depth = nodes[par].depth + 1
    depthrec(left_child, nodes)
  end
  right_child = nodes[par].right
  if right_child >= 0
    nodes[right_child].depth = nodes[par].depth + 1
    depthrec(right_child, nodes)
  end
end

n.times do |i|
  data = gets.chomp.split.map(&:to_i)
  my_id = data[0]
  child_l = data[1]
  child_r = data[2]
  # 子データをセット
  nodes[my_id].left = child_l
  nodes[my_id].right = child_r
  # 子に親と兄弟データをセット
  if child_l >= 0
    nodes[child_l].parent = my_id
    if child_r >= 0
      nodes[child_l].sibling = child_r
    end
  end
  if child_r >= 0
    nodes[child_r].parent = my_id
    if child_l >= 0
      nodes[child_r].sibling = child_l
    end
  end
  # 子の数をセット
  nodes[my_id].degree = [child_l, child_r].select{|c|c!=-1}.size
  # 深さ更新
  depthrec(my_id, nodes)
end

# 高さ計算とタイプ
# root、internal node、leaf 
nodes.each do |k, node|
  heightrec(k, nodes)
  if node.parent == -1
    node.node_type = "root"
  elsif node.degree.zero? 
    node.node_type = "leaf"
  else
    node.node_type = "internal node"
  end
end

# 出力
# node id: parent = p , sibling = s , degree = deg, depth = dep, height = h, type
nodes.each do |k, node|
  puts "node #{node.id}: parent = #{node.parent}, sibling = #{node.sibling}, degree = #{node.degree}, depth = #{node.depth}, height = #{node.height}, #{node.node_type}"
end


Measured memory_bytes: 6876
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	HashMap<String, Integer> map;
	int m;
	V[] vs;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); m = sc.nextInt();
		map = new HashMap<String, Integer>();
		id = 0;
		vs = new V[2*m+10];
		for(int i=0;i<2*m+10;i++) vs[i] = new V();
		for(int i=0;i<n;i++) {
			s = sc.next(); p = 0;
			E e = exp();
//			debug(e.v1, e.v2, e.op);
			if( e.op == 1) {
				vs[id2num(-e.v1)].l.add(id2num(e.v2));
				vs[id2num(e.v2)].rl.add(id2num(-e.v1));
				vs[id2num(-e.v2)].l.add(id2num(e.v1));
				vs[id2num(e.v1)].rl.add(id2num(-e.v2));
			} else {
				vs[id2num(-e.v1)].l.add(id2num(e.v1));
				vs[id2num(e.v1)].rl.add(id2num(-e.v1));
				vs[id2num(-e.v2)].l.add(id2num(e.v2));
				vs[id2num(e.v2)].rl.add(id2num(-e.v2));
			}
		}
//		for(V v: vs) debug(v.l, v.rl);
//		debug(map);
		scc();
//		debug(comp);
		boolean ans = true;
		for(int i=1;i<=m;i++) ans &= comp[i*2-1] != comp[i*2];
		System.out.println((ans? "accept": "reject"));
	}
	LinkedList<Integer> list;
	boolean visited[];
	int[] comp;
	int scc() {
		list = new LinkedList<Integer>();
		visited = new boolean[2*m+10];
		comp = new int[2*m+10];
		for(int i=1;i<2*m;i++) if(!visited[i]){
			dfs(i);
		}
//		debug(list);
		fill(visited, false);
		int k = 0;
		for(int p: list) if(!visited[p]){
			rdfs(p, ++k);
		}
		return k;
	}
	
	void dfs(int p) {
		visited[p] = true;
		for(int i: vs[p].l) if(!visited[i])dfs(i);
		list.addFirst(p);
	}
	
	void rdfs(int p, int k) {
		visited[p] = true;
		comp[p] = k;
		for(int i: vs[p].rl) if(!visited[i])rdfs(i, k);
	}
	
	class V {
		ArrayList<Integer> l;
		ArrayList<Integer> rl;
		V() {
			l = new ArrayList<Integer>();
			rl = new ArrayList<Integer>();
		}
	}
	
	int id2num(int id) {
		if(id<=0) return -id*2;
		return id*2-1;
	}
	
	String s; int p;
	char next() {
		return s.charAt(p++);
	}
	
	E exp() {
		E e1 = term();
//		debug(e1.v1, e1.v2, e1.op);
		char c = next(); int op = -1;
		if( c == ';' || c == ')') return e1;
		if( c == '|' ) op = 1;
		if( c == '&' ) op = 0;
		E e2 = term();
		return new E(e1.v1, e2.v1, op);
	}
	
	E term() {
		char c = next();
		if( c == '~' ) {
			E e = term();
//			debug("", e.v1, e.v2, e.op);
			if( e.op == 2 ) {
				return new E(-e.v1, -e.v2, e.op);
			}
			return new E(-e.v1, -e.v2, 1-e.op);
		}
		if( c == '(' ) {
			E e = exp();
//			debug("", e.v1, e.v2, e.op, p);
			return e;
		}
		return new E(val(), 0, 2);
	}
	
	int id;
	int val() {
		p--;
		String name = "";
		for(char c=next();(c>='a' && c<='z') || (c>='A' && c<='Z');c=next() )
			name += c;
		p--;
		if( map.containsKey(name) ) return map.get(name);
		map.put(name, ++id);
		return id;
	}
	
	//op and: 0, or: 1, non: 2
	class E {
		int v1, v2, op;
		E(int v1, int v2, int op ) {
			this.v1 = v1;
			this.v2 = v2;
			this.op = op;
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 26640
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
typedef vector<ll> vll;
#define rall(s) s.rbegin(),s.rend()
typedef map<ll,ll> mll;
#define fr(n,x) for(ll n=0;n<x;n++)
#define pb push_back
#define EL cout<<'\n'
const ll MOD=1e9+7;
#define all(s) s.begin(),s.end()


int main(){
    map<string,ll>st;
    string s;
    ll n,x,a,b,res=0;;
    cin>>x;
    fr(n,x){
        cin>>s>>a;
        res+=a;
        st[s]=res;
    }
    cin>>s;
    cout<<res-st[s];
}







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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

bool array_equal(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return false;
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return false;
    }
  }
  return true;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
  std::cout << std::setprecision(9);
  string s, t;
  cin >> s >> t;

  vector<char> s_c(s.begin(), s.end());
  vector<char> t_c(t.begin(), t.end());
  int ans = 0;
  for(int i=0; i<s_c.size(); i++) {
    if(s_c.at(i) != t_c.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4128
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    int aux = n, sum = 0;
    while (aux) {
        sum += aux%10;
        aux /= 10;
    }
    if (n%sum == 0) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
def maybe_prime(d,s,n):
    for a in (2,3,5,7):
        p = False
        x = pow(a,d,n)
        if x==1 or x==n-1:
            continue
        for i in range(1,s):
            x = x*x%n
            if x==1: return False
            elif x == n-1:
                p = True
                break
        if not p: return False
    return True

def is_prime(n):
    if n in (2,3,5,7): return True
    elif n%2==0: return False
    else:
        d,s = n-1, 0
        while not d%2:
            d,s = d>>1,s+1
        return maybe_prime(d,s,n)
cnt = 0
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n): cnt+=1

print(cnt)

Measured memory_bytes: 7764
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void unite(int, int);
bool same(int, int);
int root(int);
int p[10000], s[10000];

int main(){
  int n, q, com, x, y, comc=0, ans[100000];
  cin >> n >> q;
  for(int i=0;i<n;i++){
    p[i]=i;
    s[i]=1;
  }
  for(int i=0;i<q;i++){
    cin >> com >> x >> y;
    if(com == 0){
      unite(x, y);
    }else if(com==1){

      cout<<same(x,y)<<endl;

    }
  }

  return 0;
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(s[x]<s[y]){
    swap(x, y);
  }
  if(x!=y){
    p[y]=x;
    s[x]+=s[y];
  }
}

int root(int x){
  vector< int > v;
  while(p[x]!=x){
    v.push_back(x);
    x=p[x];
  }
  for(int i=0;i<v.size();i++){
    p[v[i]]=x;
  }
  return x;
}

bool same(int x, int y){
  x=root(x);
  y=root(y);
  if(x==y){
    return true;
  }
  return false;
}

Measured memory_bytes: 3220
#include <iostream>
 
using namespace std;
 
int main(){
  int s;
 
  cin >> s;
  int h = s / 3600; s %= 3600;
  int m = s / 60; s %= 60; 
  cout << h << ":" << m << ":" << s << endl;
 
  return 0;
}

Measured memory_bytes: 3004
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 13:54:24 2020

@author: naoki
"""
import sys
#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
a = list(map(lambda x:int(x)-1,list(input())))
   
all_odd = 0
kai = [0] * N

if (0 not in a) and (1 not in a):
    print(0)
    sys.exit()
if (1 not in a) and (2 not in a):
    print(0)
    sys.exit()
if (0 not in a) and (2 not in a):
    print(0)
    sys.exit()
    
for k in range(1,N):
    count = 0
    p = k
    for _ in range(N):
        if p % 2 == 1:
            kai[k] = kai[k-1] + count
            break
        p = p/2
        count += 1

all_num = 0
for k in range(N):
    if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
        all_num += 1

if all_num % 2 == 1:
    print(1)
elif 1 in a:
    print(0)
else:
    for i in range(N):
        a[i] = a[i]/2
    for k in range(N):
        if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
            all_num += 1
    if all_num % 2 == 1:
        print(2)
    else:
        print(0)

Measured memory_bytes: 148220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

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

  rep(i, n-k){
    cout << (a[i] < a[i+k] ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 4048
s = input()
t = input()

dp = [ [0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]

for i in range(1, len(s)+1):
    for j in range(1, len(t)+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1]+ 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
#print(dp)

str = ''
while(i > 0 and j > 0):
    if (dp[i][j] == dp[i-1][j]):
        i -= 1
    elif (dp[i][j] == dp[i][j-1]):
        j -= 1
    else:
        str = s[i-1] + str
        i -= 1
        j -= 1

print(str)


Measured memory_bytes: 121180
import numpy as np

lst = list(map(int,input().split()))

lst = sorted(lst, reverse=True)
lst_odd = list(map(lambda x: x%2, lst))
ans = 0

# 二つに1を足す操作は多くとも一回しか使わないことに注意
# まず全ての数を lst[0]-1 <= x <= lst[0] の範囲に入れる

n_plus2_1 = (lst[0] - lst[1]) // 2
lst[1] += 2 * n_plus2_1
ans += n_plus2_1
n_plus2_2 = (lst[0] - lst[2]) // 2
lst[2] += 2 * n_plus2_2
ans += n_plus2_2

# 全ての数を一致させる
if lst.count(lst[0]) == 1:
  ans += 1
elif lst.count(lst[0]) == 2:
  ans += 2

print(int(ans))

Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 1e9 + 7;
typedef long long ll;

int main(){
	int N;
	double T, A;
	double D = 0.006;
	cin >> N >> T >> A;
	vector<pair<double, int>> H(N);
	rep(i, N){
		H[i].second = i + 1;
		cin >> H[i].first;
		H[i].first = abs(A - (T - H[i].first * D));
	}
	SORT(H);
	cout << H[0].second;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    char C1,C2;
    string s;

    cin >> a >> b;

    cout << max(a+b,max(a-b,a*b)) << "\n";

    return 0;
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let sum = a.iter().sum::<usize>();
    let mut count = 0;
    for a in a.into_iter() {
        if a * 4 * m >= sum {
            count += 1;
        }
    }

    if count >= m {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
n=int(input())
a=list(map(int,input().split()))

sum=0
num=[0]*(10**5+1)
for i in range(n):
    sum+=a[i]
    num[a[i]]+=1

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    sum+=(c-b)*num[b]
    print(sum)
    num[c]+=num[b]
    num[b]=0

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
//template<typename... Args>
//void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int x;
    cin>>x;
    ll ans=0;
    ans+=x/500*1000;
    x%=500;
    ans+=x/5*5;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <numeric>

class UnionFind {
private:
	int size_;
	std::vector<int> parent;
	std::vector<int> rank;
public:
	UnionFind() : size_(0), parent(std::vector<int>()), rank(std::vector<int>()) {};
	UnionFind(int size__) : size_(size__) {
		parent = std::vector<int>(size_);
		rank = std::vector<int>(size_, 0);
		std::iota(parent.begin(), parent.end(), 0);
	}
	int size() { return size_; }
	int root(int x) {
		if (parent[x] == x) return x;
		std::vector<int> path;
		while (x != parent[x]) {
			path.push_back(x);
			x = parent[x];
		}
		for (int i : path) parent[i] = x;
		return x;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) parent[x] = y;
		else if (rank[x] > rank[y]) parent[y] = x;
		else parent[y] = x, rank[x]++;
	}
};

#include <cstdio>
int n, q, tp, x, y;
int main() {
	scanf("%d%d", &n, &q);
	UnionFind uf(n);
	while(q--) {
		scanf("%d%d%d", &tp, &x, &y);
		if(tp == 0) uf.unite(x, y);
		else printf("%d\n", uf.same(x, y));
	}
	return 0;
}

Measured memory_bytes: 2832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;


int main() {

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

	ll sum = 0;
	ll ans1 = 0, ans2 = 0;
	ll b1 = 0, b2 = 0;

	rep(i, n) {

		sum += a[i];
		ll k = sum + b1;
		ll l = sum + b2;

		if (i % 2 == 0 && k <= 0) { ans1 += -k + 1;b1 += -k + 1; }
		if (i % 2 == 1 && k >= 0) { ans1 += k + 1;b1 -= k + 1; }

		if (i % 2 == 1 && l <= 0) { ans2 += -l + 1;b2 += -l + 1; }
		if (i % 2 == 0 && l >= 0) { ans2 += l + 1;b2 -= l + 1; }
	}

	cout << min(ans1,ans2) << endl;

}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int N,c[22],v[22];
int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> v[i];
    for(int i = 0; i < N; i++) cin >> c[i];
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(v[i]-c[i] >= 0) ans += (v[i]-c[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256