akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint dp[50][(1<<18)];

int main(){
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    modint ans = modint(10).pow(n);

    int mask = (1<<(x+y+z+1))-1;
    int ng = 0;
    ng |= 1<<(x+y+z-1);
    ng |= 1<<(y+z-1);
    ng |= 1<<(z-1);
    dp[0][0] = 1;
    rep(i, n)rep(j, 1<<(x+y+z+1)){
        rep(k, 10){
            LL now = (((j<<1)+1)<<k)&mask;
            if((now&ng) == ng) continue;
            dp[i+1][now] += dp[i][j];
        }
    }
    rep(i, (1<<x+y+z+1)) ans -= dp[n][i];
    cout << ans << endl;

}

Measured memory_bytes: 51456
#include <iostream>
#include <cstdio>
#include <queue>
#define N 1005
using namespace std;

int h, w;
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, -1, 0, 1};
bool v[N][N];
string a;
queue<int> qy, qx, qc;

void push(int p, int q, int r) {
	if (v[p][q]) return;
	v[p][q] = 1;
	qy.push(p);
	qx.push(q);
	qc.push(r);
}

int main()
{
	int i, j, fy, fx, fc;
	cin >> h >> w;
	for (i = 0; i <= h + 1; i++) {
		for (j = 0; j <= w + 1; j++) v[i][j] = 1;
	}
	for (i = 1; i <= h; i++) {
		cin >> a;
		for (j = 0; j < w; j++) {
			if (a[j] == '#') {
				v[i][j + 1] = 1;
				qy.push(i);
				qx.push(j + 1);
				qc.push(0);
			} else {
				v[i][j + 1] = 0;
			}
		}
	}
    while (!qy.empty()) {
        fy = qy.front(), qy.pop();
		fx = qx.front(), qx.pop();
		fc = qc.front(), qc.pop();
		for (i = 0; i < 4; i++) {
			push(fy + dy[i], fx + dx[i], fc + 1);
		}
    }
    cout << fc << endl;
    return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

struct rect{int ht;int pos;};
int tb[1400][1400];
int area_rect(int size,int buf[]){
    stack<rect> st;
    int mx=0;
    buf[size]=0;
    rep(i,size+1){
        rect r;
        r.ht=buf[i];
        r.pos=i;
        if(st.empty()) st.push(r);
        else{
            if(st.top().ht<r.ht) st.push(r);
            else if (st.top().ht>r.ht){
                int ti=i;
                while(!st.empty()&&st.top().ht>=r.ht){
                    rect pre=st.top();st.pop();
                    int area=pre.ht*(i-pre.pos);
                    mx=max(mx,area);
                    ti=pre.pos;
                }
                r.pos = ti;
                st.push(r);
            }
        }
    }
    return mx;
}
int main(){
    int h,w;
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            bool x;
            cin>>x;
            if(i==0||x==1) tb[i][j]=!x;
            else tb[i][j]=tb[i-1][j]+!x;
        }
    }
    int mx=0;
    rep(i,h) mx=max(mx,area_rect(w,tb[i]));
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 10676
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

MOD = 10**9 + 7

X = n()

s = int(math.sqrt(2 * X))

for i in xrange(max(0, s - 200), s + 3000):
    if i**2 + i >= 2 * X:
        print i
        break



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;
//1125~1330
void solve()
{
  ll n;
  cin >> n;
  vector<ll> a(n);

  ll ans = n;
  int num = 0;
  int le = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
    while((num & a[i]) > 0) 
    {
      num ^= a[le];
      le++;
    }
    num ^= a[i];
    ans += (i - le);
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4744
import sys
N=int(input())
A=[int(i) for i in input().split()]
a=max(A)
b=min(A)
if b>=0:
    ans = []
    for i in range(1,N):
        ans.append([i,i+1])
    print(N-1)
    for a ,b in ans:
        print(a,b)
    sys.exit()
if a<=0:
    ans = []
    for i in range(1,N):
        ans.append([N-i+1,N-i])
    print(N-1)
    for a ,b in ans:
        print(a,b)
    sys.exit()  
x=A.index(a)+1
y=A.index(b)+1
if abs(a)>=abs(b):
    ans = []    
    for i in range(N):
        ans.append([x,i+1])
    for i in range(1,N):
        ans.append([i,i+1])
    print(2*N-1)
    for a ,b in ans:
        print(a,b)
    sys.exit()
if abs(b)>abs(a):
    ans = []    
    for i in range(N):
        ans.append([y,i+1])   
    for i in range(1,N):
        ans.append([N-i+1,N-i])
    print(2*N-1)
    for a ,b in ans:
        print(a,b)
    sys.exit()

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#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 ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

i64 a, b;
 
int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	cin >> a >> b;
	cout << a * b / __gcd(a, b) << '\n';
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

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

using namespace std;
#define int long long
signed main() {
    int n;
    cin >> n;
    map < int, int > nums;
    vector < int > vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
        nums[vec[i]]++;
    }
    long long sum = 0;
    for (auto item : nums) {
        long long ans = item.second * (item.second - 1) / 2;
        sum += ans;
    }
    for (int i = 0; i < n; i++) {
        cout << sum - (nums[vec[i]] - 1) << endl;
    }
    return 0;
}

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

class Program
{
    static void Main()
    {
        checked
        {
            var _ = Console.ReadLine().Split();
            var n = long.Parse(_[0]);
            var k = long.Parse(_[1]);

            var inss = new List<Tuple<long, long>>();

            for (var i = 0; i < n; i++)
            {
                var __ = Console.ReadLine().Split();
                var a = long.Parse(__[0]);
                var b = long.Parse(__[1]);

                inss.Add(Tuple.Create(a, b));
            }

            inss.Sort((x, y) => x.Item1.CompareTo(y.Item1));

            long cnt = 0;

            foreach (var ins in inss)
            {
                cnt += ins.Item2;

                if (cnt >= k)
                {
                    Console.WriteLine(ins.Item1);
                    return;
                }
            }

            throw new Exception();
        }
    }
}

Measured memory_bytes: 23752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	if (n == 0) {
		cout << 0 << endl;
		return;
	}
	string s = "";
	while (n != 0) {
		if (n > 0) {
			s += ('0' + (n % 2));
			n = n / 2 * (-1);
		} else {
			if (abs(n) % 2 == 0) {
				n = abs(n) / 2;
				s += '0';
			} else {
				n = abs(n) / 2 + 1;
				s += '1';
			}
		}
	}
	reverse(ALL(s));
	cout << s << endl;
}

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

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bitset>
#include <cstring>

using namespace std;

#define maxr 15
#define maxc 10005

int r,c,ans;
bitset<maxc> a[maxr];

void dfs(int f) {
	if(f==r) {
		int result=0;
		for(int j=0;j<c;j++) {
			int upNum=0;
			for(int i=0;i<r;i++) {
				if(a[i][j]) upNum++;
			}
			result+=max(upNum,r-upNum);
		}
		ans=max(ans,result);
		return;
	}
	dfs(f+1);
	a[f].flip();
	dfs(f+1);
	
}

void solve() {
	ans=0;
	dfs(1);
	printf("%d\n",ans);
}

int main() {
	while(scanf("%d %d",&r,&c)) {
		if(r==0 && c==0) break;
		for(int i=0;i<r;i++) {
			for(int j=0;j<c;j++) {
				int tmp=0;
				scanf("%d",&tmp);
				a[i][j]=tmp;
			}
		}
		solve();
	}
	
	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;
 
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin>>N;

	if(N%2==1)cout<<0<<endl;
	else
	{
		int ans=0;
		while(N!=0)
		{
			ans+=(N/5)/2;
			N/=5;
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long int64;

class DCaracalVsMonster {
 public:

  int64 func(int64 x) {
    if (x == 1) return 1;
    return (2LL * func(x / 2)) + 1LL;
  }

  void solveOne(std::istream &in, std::ostream &out) {
    int64 h;
    in >> h;

    out << func(h) << endl;
  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  DCaracalVsMonster solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG



//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)



int main(){
	int x;
	scanf("%d", &x);
	if(x == 0) printf("1\n");
	else printf("0\n");

	//printf("%d\n", max);
	
	return 0;
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;


int n,m,x[N];

vvi 
    a = {
        {1,0,1}, 
        {1,1,1}, 
        {1,2,2}
    },
    b = {
        {1,0,0},
        {1,1,0},
        {1,2,1}
    },
    one {
        {1,0,0},
        {0,1,0},
        {0,0,1}
    };

void add(int &x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

vvi operator*(const vvi &a, const vvi &b) {
    vvi c(3,vi(3));
    forn(i,3) forn(k,3) forn(j,3) {
        add(c[i][j], (ll) a[i][k] * b[k][j] % MOD);
    }
    return c;
}

vvi expomod(vvi a, int e) {
    vvi res(one);
    while (e) {
        if (e&1) res = res*a;
        e /= 2;
        a = a*a;
    }
    return res;
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    forn(i,m) cin >> x[i];

    vvi ans(one);
    int cur = 0;
    forn(i,m) {
        if (x[i] > cur) ans = expomod(a,x[i]-cur-1) * ans;
        ans = b * ans;
        cur = x[i];
    }
    ans = expomod(a,n-cur-1) * ans;

    int sum = 0;
    forn(i,3) add(sum, ans[2][i]);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
use proconio::*;

#[fastout]
fn main() {
    input! {
        mut a: i32,
        mut b: i32,
        mut c: i32,
        mut k: i32,
    }

    let mut ans = 0;
    let ca = std::cmp::min(a, k);
    a -= ca;
    k -= ca;
    ans += ca;
    let cb = std::cmp::min(b, k);
    b -= cb;
    k -= cb;

    println!("{}", ans - k);
}


Measured memory_bytes: 2200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> ll = new ArrayDeque<Integer>(2000000);
		int n = Integer.parseInt(br.readLine());
		
		for (int i = 0; i < n; i++) {
			String op = br.readLine();
			
			if (op.startsWith("insert")) {
				int num = Integer.parseInt(op.substring(7));
				ll.offerFirst(num);
			}
			else if (op.startsWith("deleteLast")) {
				ll.pollLast();
			}
			else if (op.startsWith("deleteFirst")){
				ll.pollFirst();
			}
			else {
				int num = Integer.parseInt(op.substring(7));
				ll.remove((Integer)num);
			}
		}

		StringBuilder sb = new StringBuilder();
		sb.append(ll.poll());
		for (Integer num : ll) {
			sb.append(" ").append(num);
		}
		System.out.println(sb.toString());
		
		br.close();
	}

}

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

typedef long long int ll;
#define mamba() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
	mamba()
	ll a,b;cin>>a>>b;
  for(int i=1;i<1100;i++)
  {
  	ll A=floor(i*0.08);
    ll B=floor(i*0.1);
    if(a==A&&b==B)
    {cout<<i;return 0;}
  }
  cout<<"-1";
}


Measured memory_bytes: 256
import fractions

a,b,c = map(int, input().split())

gab = fractions.gcd(a, b)
gbc = fractions.gcd(gab,c)

if gab ==1:
    print("YES")
    exit()
if c ==0:
    print("YES")
    exit()

if gbc == gab:
    print("YES")
    exit()
print("NO")

Measured memory_bytes: 5048
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int a, b, k;

	cin >> a >> b >> k;

	for (int i = a; i <= b; i++) {
		if (i <= a + k - 1 || i >= b - k + 1)
			cout << i << endl;
	}

	return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

template <typename T>
struct BIT_RAQ {
    int n;          // 配列の要素数(数列の要素数+1)
    vector<T> bit[2];  // データの格納先(1-indexed)。初期値は0
    BIT_RAQ(vector<T> v){
        n = v.size() + 1;
        int i;
        for(i = 0;i < 2;++i){
            bit[i].assign(n, 0);
        }
        for(i = 0;i < v.size();++i){
            add(i, i+1, v.at(i));
        }
    }
    
    //内部は1-indexedで作動
    void add_sub(int p, int i, T x){
        int ind;
        for(ind = i;ind < n;ind += (ind & -ind)){
            bit[p][ind] += x;
        }
    }
    
    //0-indexedで受け取り, [l, r)に加算, 1-indexedで渡す
    void add(int l, int r, T x){
        ++l;    ++r;    //1-indexedに修正
        add_sub(0, l, -x*(l-1));
        add_sub(0, r, x*(r-1));
        add_sub(1, l, x);
        add_sub(1, r, -x);
    }
    
    T sum_sub(int p, int i){
        T s = 0;
        int ind;
        for(ind = i;ind > 0;ind -= (ind & -ind)){
            s += bit[p][ind];
        }
        return s;
    }
    
    //0-indexedで受け取り, [l, r)に加算, 1-indexedで渡す
    T sum(int l, int r){
        ++l;    ++r;
        ll sum1 = sum_sub(0, r-1) + sum_sub(1, r-1)*(r-1);
        ll sum2 = sum_sub(0, l-1) + sum_sub(1, l-1)*(l-1);
        return sum1 - sum2;
    }
    
};


int main()
{
    ll i,j;
    ll n,q;
    cin >> n >> q;
    vector<ll> c(n);
    rep(i,n){
        cin >> c.at(i);
    }

    vector<pair<pair<ll,ll>,ll>> kueri(q);
    vector<ll> ans(q);
    rep(i,q){
        ll l,r;
        cin >> l >> r;
        --l;    --r;
        kueri.at(i).first.second = l;
        kueri.at(i).first.first = r;
        kueri.at(i).second = i;
    }

    sort(all(kueri));

    vector<ll> prev(n+1, -1);
    vector<ll> v(n, 0);
    BIT_RAQ<ll> seg(v);
    ll r = 0;
    rep(i,q){
        ll left = kueri.at(i).first.second;
        ll right = kueri.at(i).first.first;
        ll ind = kueri.at(i).second;
        for(;r <= right;++r){
            ll f = prev.at(c.at(r)) + 1;
            seg.add(f, r + 1, 1);
            prev.at(c.at(r)) = r;
        }
        ll tmp = seg.sum(left, left+1);
        ans.at(ind) = tmp;
    }
    for(auto x:ans) cout << x << endl;

    return 0;
}

Measured memory_bytes: 42268
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
LL a[100000];
int main() {
	int N, L;
	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int idx = -1;
	for (int i = 0; i + 1 < N; i++) {
		if (a[i] + a[i + 1] >= L) {
			idx = i;
			break;
		}
	}
	if (idx == -1) {
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	for (int i = 0; i < idx; i++) {
		cout << i + 1 << endl;
	}
	for (int i = N - 2; i >= idx + 1; i--) {
		cout << i + 1 << endl;
	}
	cout << idx + 1 << endl;
}

Measured memory_bytes: 1664
//A
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;

int main() {
	bool x;
	cin >> x;
	cout << !x << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
int A,B,m,minA=2e5,minB=2e5;
int a[100004],b[100004],ans;
int main(){
	cin>>A>>B>>m;
	for (int i=1;i<=A;i++) cin>>a[i],minA=min(minA,a[i]);
	for (int i=1;i<=B;i++) cin>>b[i],minB=min(minB,b[i]);
	ans=minA+minB;
	for (int i=1;i<=m;i++){
		int x,y,c;cin>>x>>y>>c;
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans;
}

Measured memory_bytes: 1024
// #include<bits/stdc++.h>
// using namespace std;
 
// typedef vector <int> vi;
// typedef pair< int ,int > pii;
// #define all(v) v.begin(),v.end()
// #define PB push_back
// #define T(val) while(val--)
// #define FIN for(i=0;i<n;i++)
// #define FIS for(i=0;i<s.length();i++)
// #define AIN for(i=0;i<n;i++){cin>>a[i];}
// #define F(i,k,n) for(i=k;i<n;i++)
// #define FG(i,k,n,x) for(i=k;i<n;i+=x)
// #define YES cout<<"YES\n"; 
// #define NO cout<<"NO\n"; 
// #define ll long long
// #define MOD 1000000007
// #define deb(x) cout << #x << "=" << x << endl;
// #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
// #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// //sort(arr, arr+n, greater<int>()); For sorting in reverse order

// int solve(){
//   int i,n,m;
//   cin>>n>>m;
//   vector < int > DG[n],UG[n];
//   int x,y,z;
//   F(i,0,m){
//     cin>>x>>y>>z;
//     if(x==0){
//       UG[x].PB(y);
//       UG[y].PB(x);
//     }
//     if(x==1){
//       DG[x].PB(y);
//     }
//   }
//   iscyclic()
//   return 0;
// }
// int main(){
// fast
//   int t;
//   cin>>t;
//   T(t){
//     solve();
//   }
//   return 0;
// }
// cin>>t;



#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define all(v) v.begin(),v.end()
#define PB push_back
#define T(val) while(val--)
#define FIN for(i=0;i<n;i++)
#define FIS for(i=0;i<s.length();i++)
#define AIN for(i=0;i<n;i++){cin>>a[i];}
#define F(i,k,n) for(i=k;i<n;i++)
#define FG(i,k,n,x) for(i=k;i<n;i+=x)
#define YES cout<<"YES\n"; 
#define NO cout<<"NO\n"; 
#define ll long long
#define MOD 1000000007
#define deb(x) cout << #x << "=" << x << endl;
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//sort(arr, arr+n, greater<int>()); For sorting in reverse order 
 
int solve(){
  int n,k;
  cin>>n>>k;
  int i;
  int h[n];
  FIN{
    cin>>h[i];
  }
  ll dp[n]={0};
  // dp[0]=0;
  for(i=1;i<min(n,k);i++){
    dp[i]=abs(h[i]-h[0]);
  }
  ll ans=1e9;
  for(i=k;i<n;i++){
    ans = 1e9;
    for(int j=1;j<=k;j++){
      ans=min(ans,abs(h[i]-h[i-j])+dp[i-j]);
    }
    // deb(ans);
    dp[i]=ans;//min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
  }
  cout<<dp[n-1]<<"\n";
  return 0;
}
int main(){
fast
  int t=1;
  // cin>>t; 
  T(t){
    solve();
  }
  return 0;
}

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

#define LL long long
#define DB double
#define MAXN 1000000
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return (1LL*a*b)%MOD;}
int fst_pow(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=mul(res,a);
		a=mul(a,a),b>>=1;
	}
	return res;
}

struct Matrix{
	int ma[3][3];
	Matrix(){mem(ma,0);}
	int* operator [](int i) { return ma[i]; }
};
Matrix operator*(Matrix A,Matrix B){
	Matrix C;
	for(int k=0;k<3;k++)
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
			C[i][j]=add(C[i][j],mul(A[i][k],B[k][j]));
	return C;
}
Matrix fst_pow(Matrix A,int b){
	Matrix res;
	for(int i=0;i<3;i++)res[i][i]=1;
	while(b){
		if(b&1)res=res*A;
		A=A*A,b>>=1;
	}
	return res;
}
int n,m,lst;
Matrix A,B;

int main(){
	n=read(),m=read();

	A[0][0]=2,A[0][1]=1,A[0][2]=1;
	A[1][0]=2,A[1][1]=1,A[1][2]=0;
	A[2][0]=1,A[2][1]=1,A[2][2]=1;

	B[0][0]=1,B[0][1]=0,B[0][2]=0;
	B[1][0]=2,B[1][1]=1,B[1][2]=0;
	B[2][0]=1,B[2][1]=1,B[2][2]=1;

	Matrix res;
	res[0][0]=1;
	for(int i=1;i<=m;i++){
		int x=read();
		res=fst_pow(A,x-lst-1)*res;
		res=B*res;
		lst=x;
	}
	res=fst_pow(A,n-lst)*res;
	printf("%d\n",res[2][0]);
}

Measured memory_bytes: 3772
n, k = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
a.sort()
dp = {} #determines whether dp[k] is a winning position or not
for i in range(k+1):
    dp[i] = False

for e in a:
    dp[e] = True

for i in range(a[0],k+1):
    for j in a:
        if i-j in dp:
            dp[i] = dp[i] or not(dp[i-j]) #if previous is true this is false
                                          #taken or to get best case of all optimality

if dp[k] is False:
    print('Second')
else:
    print('First')


Measured memory_bytes: 49644
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
 
 
 
int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif
 
    int x,y;
    cin >> x >> y;

    int ans = x + (y/2);
    cout << ans << endl;
	
 
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
long long a[51],b[51],k,ans;
int n;
int main()
{
	a[0]=1;b[0]=1;for(int i=1;i<=50;++i) a[i]=a[i-1]*2+3,b[i]=b[i-1]*2+1;
	scanf("%d%lld",&n,&k);
	for(int i=n;i>=0;--i)
	if(a[i]+n-i<=k) {ans+=b[i];k-=a[i]+n-i;n=i;if(k) {++ans;k--;}}
	else if(k-n+i>=a[i]-i) {ans+=b[i];break;}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll N;
    cin >> N;
    cout << (N-2)*180 << endl;
}

Measured memory_bytes: 256
e1,e2,e3,e4=map(int,input().split())
if e1==e2 and e3==e4:
    print("yes")
elif e1==e3 and e2==e4:
    print("yes")
elif e1==e4 and e3==e2:
    print("yes")
else:
    print("no")


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

int main() {
	int n, a,ans=0;
	map<int, int> m;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (m[a] == 1) {
			m[a]--;
			ans--;
		}
		else {
			m[a]++;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
from itertools import accumulate

MOD = 10 ** 9 + 7
table_len = 2 * 10 ** 5 + 10

fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)
    
finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len-1, -1, -1):
    finv[i-1] = finv[i] * i % MOD


N = int(input())

adj = [[] for _ in range(N+1)]

for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)


dfs_order = []
parent = [0] * (N+1)
root = 1
stack = [root]
while stack:
    node = stack.pop()
    dfs_order.append(node)
    for child in adj[node]:
        if child != parent[node]:
            parent[child] = node
            stack.append(child)

def func(t1, t2):
    size1, value1 = t1
    size2, value2 = t2
    size = size1 + size2
    comb = fac[size] * finv[size1] * finv[size2] % MOD
    value = comb * value1 * value2 % MOD
    return (size, value)
       
dp1 = [(0, 1)] * (N+1)
for node in reversed(dfs_order):
    for child in adj[node]:
        if child != parent[node]:
            dp1[node] = func(dp1[node], dp1[child])
    dp1[node] = (dp1[node][0] + 1, dp1[node][1])

dp2 = [(0, 1)] * (N+1)
for node in dfs_order:
    around = [dp1[next_node] if next_node != parent[node] else dp2[node] for next_node in adj[node]]
    from_left = [(0, 1)] + list(accumulate(around, func))[:-1]
    from_right = list(accumulate(reversed(around), func))[-2::-1] + [(0, 1)]
    without = [func(l, r) for l, r in zip(from_left, from_right)]
    for next_node, t in zip(adj[node], without):
        if next_node != parent[node]:
            dp2[next_node] = (t[0] + 1, t[1])

for t1, t2 in zip(dp1[1:], dp2[1:]):
    print(func((t1[0] - 1, t1[1]), t2)[1])

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

int main(){
  
  int D;
  int N;
  int p;
  int q;
  cin>>N>>D;
  
  q = N/(2*D+1);
  
  p = N%(2*D+1);
    if (p==0){
      cout<<q<<endl;
    }
  else{
    cout<<q + 1<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
S = gets.split.map(&:to_i)
q = gets.to_i
T = gets.split.map(&:to_i)
count = 0
for t in T
  start = -1
  last = n-1
  while !(last-start==1)
    mid = (start+last)/2
    if t > S[mid]
      start = mid
    else
      last = mid
    end
    if S[last] == t
      count += 1
      break
    end
  end
end
puts count

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

int f(int n, int v, int w){
    int p=1;
    if(n==1){
        p=min(v,w);
    }else{
        int q=v;
        p=w;
        while(p!=q){
            if(p>q){
                p=(p+n-2)/n;
            }else{
                q=(q+n-2)/n;
            }
        }
        
    }
    return p;
}


int main(void){
    int n,q;
    cin>>n>>q;
    for(int i=0;i<q;i++){
        int v,w;
        cin>>v>>w;
        cout<<f(n, v, w)<<endl;
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
    //int nax = max_element(p.begin(),p.end())-p.begin();
    //int nin = max_element(p.begin(),p.end())-p.begin();
     //sort(l.begin(),l.end(),greater<int>());
     //stringは",charは'
     //ちょっとあやしかったら立ち止まって考える
     //例外処理はreturn忘れずに

 int main(){
     string s;
     cin >> s;
     bool can = false;
     if(s=="hi") can = true;
     if(s=="hihi") can = true;
     if(s=="hihihi") can = true;
     if(s=="hihihihi") can = true;
     if(s=="hihihihi") can = true;
     if(s=="hihihihihi") can = true;
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
     return 0;
 }

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
	int rem;
	if(x>y)rem=min(a,c*2);
	else rem=min(b,c*2);
	cout<<min(a+b,c*2)*min(x,y)+abs(x-y)*rem<<"\n"s;
}

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

int main()
{
	int N;
	std::string S;
	std::cin >> N >> S;

	std::vector<int> v( N );
	bool color = false;	//	白から始まるとしておく
	int pos = 0;

	for ( int i = 0; i < S.length(); i++ )
	{
		if ( S[i] == '#' )
		{
			if ( color == false )	//	白なら色を変える
			{
				// 色を黒にしてインデックスを進める
				color = true;
				++pos;
			}
			v[pos]++;
		}
		else
		{
			if ( color == true )	//	黒なら色を変える
			{
				// 色を白にしてインデックスを進める
				color = false;
				++pos;
			}
			v[pos]++;
		}
	}

	int TransNum = 0;
	int TransWhite = 0;

	for ( int i = 2; i <= pos; i += 2 )	//	v[2n]は必ず白の個数（n>=0）であり、v[0]は変換不要なので無視して良い
	{
		if ( ( v[i] < v[i - 1] ) && ( v[i] < v[i - 1] - TransWhite * 2 ) )
		{
			// 白の左側の黒の個数が自身より多いなら、自分を変換するべき
			// 今までに変換した白を加味しても多いならOK（ダメなら、そもそも最初に変換したのは間違った色だった）
			TransNum += v[i];
			v[i + 1] += ( v[i] + v[i - 1] );	//	自分を黒にしたので、次の白にとっての左側の黒の個数が変わる
			TransWhite += v[i];	//	白の変換量を保存する
		}
		else
		{
			// そうでないなら、左側の黒の方を変換するべき
			TransNum += v[i - 1];

			// 変換対象が黒なら、前回変換した範囲を対象に含んでいる可能性がある
			TransNum -= TransWhite * 2;	//	余分に加算したので、引く
			TransWhite = 0;	//	左側は全部白になったはずなので、リセット
		}
	}

	std::cout << TransNum << std::endl;

	return ( 0 );
}


Measured memory_bytes: 2036
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define N 5010
using namespace std;

ll l,last,ans;
string a;

ll num(ll l,ll r)
{
	ll i,res=0;
	for(i=l;i<=r;i++)
	{
		res=res*10+a[i]-48;
	}
//	cout<<res<<" ";
	return res;
}

int main()
{
	int i,j;
	cin>>a;
	l=a.size()-1;
	for(i=0;i<(1 << l);i++)
	{
		last=0;
		for(j=0;j<l;j++)
		{
			if((1 << (j))&i)
			{
				ans+=num(last,j);
				last=j+1;
			}
		}
		ans+=num(last,l);
//		puts("");
	}
	cout<<ans;
}

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

int N;
long long int T;
long long int t[200000];

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

    long long int sum = 0;
    for(int i = 0; i < N; i++) cin >> t[i];

    for(int i = 0; i < N-1; i++){
        if(t[i] + T < t[i+1]) sum += T;
        else sum += (t[i+1]-t[i]);
    }

    cout << (sum+T);
    return 0;
}

Measured memory_bytes: 1792
def main(): 
    from collections import defaultdict
    n = int(input())
    di = [list(map(int, input().split(' '))) for _ in range(n)]
    #result = {0:0}
    md = defaultdict(int)
    md[0] = 0
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            else:
                p = di[i][0] - di[j][0]
                q = di[i][1] - di[j][1]
                #result[(p,q)] = result.get((p,q), 0)+1
                md[(p,q)] += 1
    #print(result)
    #print(n - max(result.values()))
    #print(md)
    print(n - max(md.values()))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define faio(arr) for(int i=0;i<n;i++)cout<<arr[i]<<" ";
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

bool DFS(int start,vector<int>*adj,bool*visited)
{

    visited[start]=true;
    for(auto x:adj[start])
    {
        if(!visited[x])
        {
          DFS(x,adj,visited);
        }
    }
}



int main() {
  // FILE;
  SPEED;
  
  int n,m;

  cin>>n>>m;

  vector<int> adj[n+1];

  for(int i=0;i<m;i++)
  {
     int x,y,z;
     cin>>x>>y>>z;

     adj[x].push_back(y);
     adj[y].push_back(x);
  } 

  bool visited[n+1];

  rep(i,0,n+1)visited[i]=false;
  int cc=0;
  rep(i,1,n+1)
  {
     if(!visited[i])
     {
         DFS(i,adj,visited);
         cc++;
     }
  }

  cout<<cc<<endl;

}

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

typedef long long ll;

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

    vector<pair<ll, ll>> job;
    for(int i=0; i<N; i++){
        ll a, b;
        cin >> a >> b;
        
        job.push_back({b, a});
    }

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

    ll now = 0;
    for(int i=0; i<N; i++){
        now += job[i].second;

        if(now > job[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<< "Yes"  <<endl;
    return 0;
}

Measured memory_bytes: 7444
fn main() {
    let n = read();
    let mut nums = vec![0; n];
    for i in 0..n - 1 {
        let v: usize = read();
        nums[v - 1] += 1;
    }
    for i in 0..n {
        println!("{}", nums[i]);
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2760
N = int(input())
a = 0
flag = True
for i in range(500):
    a += i+1
    if N == a:
        flag = False
        l = [[] for j in range(i+2)]
        b = i+1
        c = 0
        d = i+1
        for j in range(N):
            l[c].append(j+1)
            l[c + d - b + 1].append(j+1)
            if b > 1:
                b -= 1
            else:
                b = d - 1
                c = c + 1
                d = d - 1

        print("Yes")
        print(i+2)
        for j in range(i+2):
            print(i+1,' '.join(map(str, l[j])))
        break

if flag:
    print("No")

Measured memory_bytes: 12308
#include<stdio.h>

int _max(int a,int b){return a>b?a:b;}

int main(){
	
	long long ans=0;
	int n,k,i,a;
	scanf("%d%d",&n,&k);
	for(i=k+1;i<=n;i++){
		ans+=(long long)(n/i)*(i-k);
		ans+=(long long)_max(0,n%i-k+1);
	}
	if(k==0)ans=(long long)n*n;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

ans = 0
for i in range(N-M+1):
    for h in range(N-M+1):
        cnt = 0
        for k in range(M):
            for j in range(M):
                if A[i+k][h+j] != B[k][j]:
                    cnt += 1
        if cnt == 0:
            ans += 1
if ans != 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 40560
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
  `(let ((it ,expr))
     (if it ,then ,else)))

(defmacro awhen (expr &rest then)
  `(aif ,expr (progn ,@then) nil))

(defun comulative (function list &key base)
  (if base
      (comulative function (cons base list))
      (do ((lst (cdr list) (cdr lst))
           (acc (list (car list))))
          ((null lst) (reverse acc))
        (push (funcall function (car acc) (car lst)) acc))))

(defun binary-search (function left right
                      &optional
                        (eps 1)
                        (average-function (lambda (x y) (ash (+ x y) -1))))
  (if (<= (abs (- left right)) eps)
      right
      (let ((mid (funcall average-function left right)))
        (if (funcall function mid)
            (binary-search function left mid eps average-function)
            (binary-search function mid right eps average-function)))))

(defun arithmetic-mean (&rest body)
  (/ (apply #'+ body) (length body)))

(defvar +MOD+ (+ (expt 10 9) 7))

(defun mapa-b (fn a b &optional (step 1))
  (do ((i a (+ i step))
       (result nil))
      ((> i b) (nreverse result))
    (push (funcall fn i) result)))

(defun map0-n (fn n)
  (mapa-b fn 0 n))

(defun map1-n (fn n)
  (mapa-b fn 1 n))

(defun read-string (&optional (stream *standard-input*))
  (labels ((is-empty (x)
             (or (char= x #\space) (char= x #\newline))))
    (loop for char = (read-char stream)
          with result
          when (is-empty char)
            do (return (concatenate 'string (nreverse result)))
          do (push char result))))

(defun make-cons (a b)
  (if (> a b) (cons b a)
      (cons a b)))

(defun main (lst)
  (- (length lst)
     (length
      (remove-duplicates
       (loop for i from 1
             for j in lst
             collect (make-cons i j))
       :test #'equal))))

(princ (main (read-times (read))))


Measured memory_bytes: 62524
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 0;i < n;i++){
    ans+=a[i]-1;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
# coding:utf-8

import sys
from collections import Counter


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


N, H, W = inpl()

ans = 0
for _ in range(N):
    a, b = inpl()
    if a >= H and b >= W:
        ans += 1

print(ans)


Measured memory_bytes: 39920
#include<stdio.h>
#include<math.h>
#include<string>
#include<cmath>
int main(){
    int n,m;
    int s[5];
    int c[5];
    scanf("%d %d",&n,&m);
    for(int a=0;a<m;a++){
        scanf("%d %d",&s[a],&c[a]);
    }
    int ans,max;
    if(n==1) ans=0,max=10;
    if(n==2) ans=10,max=100;
    if(n==3) ans=100,max=1000;
    if(m==0){printf("%d",ans);return 0;}
    for(int x=ans;x<max;x++){
        std::string str;
        str=std::to_string(x);
        for(int a=0;a<m;a++){
            std::string strs;
            strs=std::to_string(c[a]);
            if(str[s[a]-1]!=strs[0]){
                break;
            }
            if(a==m-1){
                printf("%d",x);
                return 0;
            }

        }
    }
    printf("-1");
    return 0;
}

Measured memory_bytes: 256