akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

int main(int argc, char* argv[])
{
  string s;
  cin >> s;
  ll k;
  cin >> k;
  int n = s.size();
  for(int i = 0; i < n; i++){
    if(s[i] == 'a') continue;
    if('z' - s[i] + 1 <= k){
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }

/*
  rep(i, n) {
    if (s[i] == 'a') continue;
    int num = count(s[i]);
    if (num <= k) {
      s[i] = 'a';
      k -= num;
    }
    if (k == 0) break;
  }
*/
  // 最後に残った K を処分
  if (k > 0) {
    k %= 26;
    s[n - 1] += k;

    if (s[n - 1] > 'z') s[n - 1] -= 26;
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
  
int main(){
    ll n, x; cin >> n >> x;
    vector<ll> y(n);
    rep(i, n)cin >> y[i];
    vector<ll> z(n - 1);
    rep(i, n - 1){
        z[i] = abs(y[i + 1] - y[i]);
    }
    ll GCD = abs(y[0] - x);
    rep(i, n - 1){
        GCD = gcd(z[i], GCD);
    }
    cout << GCD << endl;
}


Measured memory_bytes: 1792
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()
left = A[0]
right = A[N - 1]
ans = right - left
for i in range((N - 2) // 2):
    if i % 2 == 0:
        ans += right - A[1 + i]
        ans += A[N - 2 - i] - left
        right = A[1 + i]
        left = A[N - 2 - i]
    else:
        ans += left - A[1 + i]
        ans += A[N - 2 - i] - right
        left = A[1 + i]
        right = A[N - 2 - i]

if N % 2 == 1:
    ans += max(abs(right - A[N // 2]), abs(left - A[N // 2]))

print(ans)


Measured memory_bytes: 13384
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // 整数の入力
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    //　条件分岐と出力
    if (a==b && a==c) {
      System.out.println(1);
    } else if (a==b) {
      System.out.println(2);
    } else if (b==c) {
      System.out.println(2);
    } else if (a==c) {
      System.out.println(2);
    } else {
      System.out.println(3);
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int m;
  cin>>n;
  cin>>m;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    x=min(x,n-x+1);
    y=min(y,n-y+1);
    cout<<min(x-1,y-1)%3+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b;
	int d,r;
	double f; // double precision real number
	
	cin >> a >> b;
	
	d = a/b; // ?????????integer
	r = a%b;
	f = double(a)/double(b) ; // double() ??????????????°??§??¨???
	
	printf("%d %d %.5f", d, r, f);  // %d:10?????°??§??¨??? %.5f:?°???°???5????????§
}

Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
int main() {
    int a,b,c,d; cin>>a>>b>>c>>d;
    int ans = min(a,b) + min(c,d);
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int A, B;
  cin >> A >> B;
  
  if(A == 1)
    A += 13;
  if(B == 1)
    B += 13;

  if(A == B)
    cout << "Draw" << endl;
  else if(B > A)
    cout << "Bob" << endl;
  else if(A > B)
    cout << "Alice" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

signed main() {
	int n,m; cin >> n >> m;
	vector<int> S[m];
	int P[m];
	REP (i,m) {
		int k; cin >> k;
		REP (j,k) {
			int x; cin >> x; x--;
			S[i].push_back(x);
		}
	}
	REP (i,m) cin >> P[i];
	int ans = 0;
	REP (i,pow(2,n)) {
		int p = i;
		bool on[n]; REP (j,n) on[j] = false;
		int cnt = 0;
		while (p != 0) {
			if (p % 2 == 1) {
				on[cnt] = true;
			}
			p /= 2;
			cnt++;
		}
		bool ok = true;
		REP (j,m) {
			int tmp = 0;
			REP (k,S[j].size()) {
				if (on[S[j][k]]) tmp++;
			}
			if (tmp%2 != P[j]) ok = false;
		}
		if (ok) ans++;
	}
	cout << ans << endl;
}


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

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

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

vector<vector<int>> cycles(const vector<int>& f){
	int n=f.size();
	vector<vector<int>> res;
	vector<int> color(n,-1);
	rep(u,n) if(color[u]==-1) {
		int v=u;
		do{ color[v]=u; v=f[v]; }while(color[v]==-1);
		if(color[v]==u){
			vector<int> C;
			int w=v;
			do{ C.emplace_back(v); v=f[v]; }while(v!=w);
			res.emplace_back(C);
		}
	}
	return res;
}

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> p(n),w(n);
	rep(u,n) scanf("%d",&p[u]), p[u]--;
	rep(u,n) scanf("%d",&w[u]);

	auto C=cycles(p);
	vector<int> id(n);
	rep(i,C.size()) for(int u:C[i]) id[u]=i;

	vector<lint> wsum(C.size());
	rep(i,C.size()) for(int u:C[i]) wsum[i]+=w[u];

	lint ans=-INF;
	rep(u0,n){
		int k_tmp=k;

		lint res=0;
		int len=C[id[u0]].size();
		int m=max(k/len-1,0);
		k-=m*len;
		if(wsum[id[u0]]>0){
			res=m*wsum[id[u0]];
			ans=max(ans,res);
		}
		for(int u=u0;k>0;k--){
			u=p[u];
			res+=w[u];
			ans=max(ans,res);
		}

		k=k_tmp;
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3860
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int rec(vector<int>& dishes, vector<bool>& orders, int counter)
{
    if (counter == dishes.size() - 1)
    {
        for (int i = 0; i < dishes.size(); ++i)
            if (!orders[i]) return dishes[i];
    }

    int ret = 130*5;

    for (int i = 0; i < dishes.size(); ++i)
    {
        if (!orders[i])
        {
            orders[i] = true;

            int timing = dishes[i] % 10 == 0 ? dishes[i] : (dishes[i] + 10) / 10 * 10;
            ret = std::min(ret, timing + rec(dishes, orders, counter + 1));

            orders[i] = false;
        }
    }

    return ret;
}


int solve()
{
    vector<int> dishes = fetch_vec<int>(5);
    vector<bool> orders(5, false);

    return rec(dishes, orders, 0);
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define rep(i,a,n) for(int i=(a);i<(n);i++)
using namespace std;

int main() {
	int H, W,Q;
	cin >> H >> W>>Q;
	vector<vector<char>> a(H, vector<char>(W, '.'));
	rep(i, 0, Q) {
		int x, y, z;
		cin >> x >> y >> z;
		if (z == 2) {
			rep(i, x, H)rep(j, 0, W)a[i][j] = '#';
		}\
		if (z == 1) {
			rep(i, 0, x )rep(j, 0, W)a[i][j] = '#';
		}
		if (z == 3) {
			rep(i, 0, H)rep(j, 0, y)a[i][j] = '#';
		}
		if (z == 4) {
			rep(i, 0, H)rep(j, y , W)a[i][j] = '#';
		}
	}
	int ans = 0;
	rep(i, 0, H) {
		rep(j, 0, W) {
			if (a[i][j] == '.')ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int l; cin >> l;
	double x = l;

	cout << fixed << setprecision(12);
	cout << x * x * x / 27 << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	X = inputInt()

	tmp = X % 100
	kai = X // 100

	tmptmp = -(-tmp // 5)

	if tmptmp <= kai:
		print(1)
	else:
		print(0)

	#print(tmptmp)
	#print(kai)



if __name__ == "__main__":
	main()


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

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

    int n;
    cin >> n;
    vector<int> A(n);
    REP(i, n) cin >> A[i];

    vector<int> B(8, 0);
    int r = 0;
    REP(i, n){
        if(A[i] < 3200) B[A[i] / 400]++;
        else r++;
    }
    
    int cnt = 0;
    REP(i, 8) if(B[i]) cnt++;

    int mi, ma;
    mi = max(1, cnt);
    ma = cnt + r;

    cout << mi << " " << ma << endl;

    return 0;
}

Measured memory_bytes: 256
import math


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

aaa = (math.floor(a * (b - 1) / b)) - (a * math.floor((b - 1) / b))

if n < (b - 1):
    aaa = (math.floor(a * n / b)) - (a * math.floor(n / b))

print(aaa)


Measured memory_bytes: 9184
#include <stdio.h>

int main()
{
    int r, g, b, n;
    int tmp, ans=0;
    scanf("%d%d%d%d", &r, &g, &b, &n);
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            tmp = n - r*i - g*j;
            if(tmp < 0) break;
            if(tmp % b == 0) {
                ans++;
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>

using namespace std;

int data[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
  int k;
  cin>>k;
  
  cout<<data[k-1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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 ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(){
    string s;
    cin >> s;
    int n = s.size();

    bool flag = true;
    set<char> st;
    for(int i=1; i<n-1; i++){
        if(s[i-1] != s[i+1]) flag = false;
    }
    rep(i, n) st.insert(s[i]);

    if(st.size() == 2 && flag){
        cout << "Second" << endl;
        return 0;
    }

    if(s[0] == s[n-1]){
        if((n-2)%2 == 0) cout << "First" << endl;
        else cout << "Second" << endl;
    }
    else if((n-2)%2 == 0) cout << "Second" << endl;
    else cout << "First" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <array>

using namespace std;

int main(void)
{
    long long int x;
    cin >> x;


    int year = 0;
    long long int cash = 100;
    while(cash < x)
    {
        year++;
        cash += static_cast<long long int>(cash * 0.01);
    }

    cout << year << endl;
}

Measured memory_bytes: 3580
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
signed main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
            cin >>
        v.at(i);
    sort(v.begin(), v.end());
    int maxi = v.at(n - 1);
    vector<bool> flag(maxi + 1, true);
    int ans = 0;
    int skip = -1;
    rep(i, n)
    {
        if(skip==v.at(i))
            continue;
        if (flag.at(v.at(i)) == true)
        {
            if (i != n - 1 && v.at(i + 1) == v.at(i))
            {
                skip = v.at(i);
            }
            else
            {
                ans++;
            }
            for (int p = 2 * v.at(i); p < maxi + 1; p += v.at(i))
                flag.at(p) = false;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ll long long
using namespace std;

const int N = 2001;


void solve() {
    int n, k, c;
    string s;
    cin >> n >> k >> c;
    vector<int> pref(n + 2), suf(n + 2);
    cin >> s;
    s = '#' + s;
    int day = 1;
    for (int i = 1; i <= n; ++i) {
        if (s[i] == 'x')
            continue;
        pref[i] = day++;
        i += c;
        if (day > k)
            break;
    }
    day = k;
    for (int i = n; i >= 1; --i) {
        if (s[i] == 'x')
            continue;
        suf[i] = day--;
        i -= c;
        if (day < 1)
            break;
    }
    for (int i = 1; i <= n; ++i) {
        if (pref[i] == suf[i] and pref[i] != 0) {
            cout << i << endl;
        }
    }
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;

int main(void){
  long int N;
  long int A[100010];
  int cnt[100010], temp = 0;
  int num = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A, A + N);
  for(int i = 0; i < N; i++){
    if(A[i] == A[i + 1]) temp++;
    else{
      cnt[i] = temp + 1;
      temp = 0;
    }
  }
  for(int i = 0; i < N; i++){
    if(cnt[i] % 2 == 1) num++;
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main(){
	int b1, b2 , b3;

	cin >> b1 >> b2 >> b3;

	if (b1 == 0 && b2 == 0 && b3 == 1){
		cout << "Open" << endl;
	}
	else if (b1 + b2 + b3 == 2){
		cout << "Open" << endl;
	}
	else {
		cout << "Close" << endl;
	}
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  string s; cin >> s;
  if(SZ(s)<4) no();
  if(s.substr(0,4) == "YAKI")yes();
  else no();
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parent=[i for i in range(n)]
        self.rank=[1]*n#木の高さ
        self.size=[1]*n#size[i]はiを根とするグループのサイズ

    def find(self,x):#ｘの根（親）を返す
        if self.parent[x]==x:
            return x
        else:
            self.parent[x]=self.find(self.parent[x])#経路圧縮
            return self.parent[x]

    def unite(self,x,y):#ｘ、ｙの集合の統合
        x=self.find(x)
        y=self.find(y)
        if x!=y:
            if self.rank[x]<self.rank[y]:#ランクの比較
                self.parent[x]=y
                self.size[y]+=self.size[x]
            else:
                self.parent[y]=x
                self.size[x]+=self.size[y]
                if self.rank[x]==self.rank[y]:
                    self.rank[x]+=1

    def is_same(self,x,y):#ｘ、ｙが同じ集合に属するかを判定する
        return self.find(x)==self.find(y)

    def group_size(self,x):#ｘが属する集合の大きさ
        return self.size[self.find(x)]

    def group_members(self,x):#ｘが属する集合の要素をかえす
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]

    def roots(self):#すべての根をリストで返す
        return [i for i, x in enumerate(self.parent) if i==x]

    def group_count(self):#木の数を返す
        return len(self.roots())

    def all_group_members(self):#すべての木の要素を辞書で返す
        return {r: self.group_members(r) for r in self.roots()}

n,m=map(int,input().split())
un=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    un.unite(a-1,b-1)
ans=un.group_count()-1
print(ans)

Measured memory_bytes: 76664
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int N,M,a,b;
ll A[100010];
vector<vector<int>> v(100010);
vector<vector<ll>> u(100010);
int c = 0,visited[100010] = {0};

void dfs(int n){
	visited[n] = 1;
	u[c].push_back(A[n]);
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i]]==0) dfs(v[n][i]);
	}
}

int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<M;i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	if(M==N-1){
		cout << 0 << endl;
		return 0;
	}
	if(N<2*(N-M-1)){
		cout << "Impossible" << endl;
		return 0;
	}
	for(int i=0;i<N;i++){
		if(visited[i]==0){
			dfs(i);
			c++;
		}
	}
	ll ans = 0;
	priority_queue<ll> Q;
	for(int i=0;i<c;i++){
		sort(u[i].begin(),u[i].end());
		for(int j=0;j<u[i].size();j++){
			if(j==0) ans += u[i][j];
			else Q.push(-u[i][j]);
		}
	}
	while(c<2*(N-M-1)){
		ll t = Q.top();
		ans += -t;
		Q.pop();
		c++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11640
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a= sc.nextInt();
		int b = sc.nextInt();
		int c =sc.nextInt();
	    int[] d=new int[n];
		int ans=3000;
		for(int i = 0; i<n; i++){
			int l=sc.nextInt();
			d[i]=l;
		}
		for(int i = 0; i<Math.pow(2,n); i++){
			for(int j = 0; j<Math.pow(2,n); j++){
				int t=i;
				int y=j;
				int cost=0;
				int a1=0;
				int b1=0;
				int c1=0;
				for(int k=0; k<n; k++){
					if((t & 1)==1 && (y & 1)==1){
						if(a1!=0){
							cost+=10;
						}
						a1+=d[k]; 
					}else if((t & 1)==0 && (y & 1)==1){
						if(b1!=0){
							cost+=10;
						}
						b1+=d[k];
					}else if((t & 1)==1 && (y & 1)==0){
						if(c1!=0){
							cost+=10;
						}
						c1+=d[k];
					}
					t>>=1;
					y>>=1;
				}
				if(a1!=0 && b1!=0 && c1!=0){
					a1=Math.abs(a-a1);
					b1=Math.abs(b-b1);
					c1=Math.abs(c-c1);
					ans=Math.min(ans,cost+a1+b1+c1);
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        long a=sc.nextInt(),b=sc.nextInt();
        int[] x=new int[n];
        for (int i = 0; i < n; i++) {
            x[i]=sc.nextInt();
        }
        long ans=0;
        for (int i = 0; i < n-1; i++) {
            long d=x[i+1]-x[i];
            ans+=min(d*a,b);
        }
        out.println(ans);
    }
}

Measured memory_bytes: 50264
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;
 
//            < = = = = =    GCD     = = = = = >
 
ll gcd(ll a,ll b)
{
	if(a<b)	gcd(b,a);
	if(b==0)	return a;
	return gcd(b,a%b);
}
 
//            < = = = = =    LCM     = = = = = >
 
ll lcm(ll a,ll b) 
{ 
	ll x=(a/gcd(a,b))*b; 
	return x;
}
 
//            < = = = = =    power  x^n     = = = = = >
 
ll power(ll x , ll n , ll m=inf){
	if(x==0){
		return 0;
	}
	if(n==0){
		return 1;
	}
	ll ans;
	if(n%2==0){
		ll smallAns = power(x,n/2,m);
		ans = (smallAns*smallAns)%m;		
	} else {
		ll smallAns = power(x,n-1,m);
		ans = x;
		ans = (ans*smallAns)%m;
	}
	// for negative values also
	return (ans+m)%m;
	
}
 
//            < = = = = =    CHECK FOR PRIME     = = = = = >
 
bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
 
//            < = = = = =    SOLVE    = = = = = >
 
// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }
 
// void rec(int n){
//     if(){
//         return;
//     }
    
//     return;
// }
 
int solve() {fastio
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes";
    else cout<<"No";
    return 0;
}

//            < = = = = =    MAIN     = = = = = >
 
int main() {fastio
    
 	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3460
#include "bits/stdc++.h"
using namespace std;

// #include "debug.h"
#define debug(...) 42


using ll = long long;

bool check(string s, vector <char> v) {
   int ptr = 0;
   for(int i = 0; i < s.length(); i++) {
      if(s[i] == v[ptr]) {
         ptr++;
         if(ptr == v.size()) return true;
      }
   }
   return false;
}


void solve() {
   int n;
   cin >> n;
   string s;
   cin >> s;

   int ans = 0;
   for(char i = '0'; i <= '9'; i++) {
      for(char j = '0'; j <= '9'; j++) {
         for(char k = '0'; k <= '9'; k++) {
            vector <char> v = {i, j, k};
            ans += check(s, v);
         }
      }
   }
   cout << ans << endl;
} 

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct P
{

    int x,y;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
vector<int> v[1010];

int a,b,c,o[1051]={1,2,3,4,6,7,8,9},i,k,d,n,m,e,dy[15]={0,0,-1,1,-1,1,-1,1},dx[15]={-1,1,0,0,1,1,-1,-1};
int l[1<<25];

long long x,y,z[52],v1,v2;
//P u[100600];
//int j[6000000];
queue<int> q,q1;
////stack<int> s;
//queue<P> q;

//deque<int> d;
//'1'==49;
//'A'==65;
//'a'==97;
map<int, int > p1,p2;
string r,r1;
//char r[1010][1010];

bool as(int a,int b)
{
    if(p1[a]!=p1[b]) return p1[a]>p1[b];
    return p2[a]<p2[b];
}


int f(int b)
{
    if(b<10) return b;
    return f(b/10)+b%10;
}
//2147483647
int main()
{
    scanf("%d %d",&a,&b);
    printf("%d",(1900*b+100*(a-b))<<b);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>	
#include <cstring>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

const int MAX_S = -1;
const int MIN_S = 1001;
int score[1001];

int main()
{
	int n, m;
	while (scanf ("%d", &n ) && n ){
		memset (score, 0, sizeof (score ) );
		int max_s = MAX_S;
		int min_s = MIN_S;
		rep (i, n ){
			int in;
			scanf (" %d", &in );
			score[in]++;
			max_s = max (max_s, in );
			min_s = min (min_s, in );
		} // end rep
		score[max_s]--;
		score[min_s]--;
		int sum = 0;
		int sum_n = 0;
		for (int i = 0; i <= 1000; i++ ){
			sum += i*score[i];
			sum_n += score[i];
		} // end for
		int res = sum/sum_n;
		printf ("%d\n", res );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) 				for(int i=0; i<(n); ++i)
#define all(c) 				(c).begin(),(c).end()
#define sortall(x)                 sort(all(x))
#define tr(c,i) 				for( typeof( (c).begin() ) i = (c).begin();  i != (c).end(); ++i)
#define pb 					push_back
#define sz(a) 					int((a).size())
#define mp                         make_pair
#define ll                         long long
#define F                          first
#define S                          second
#define PI                         3.1415926535897932384626
// Input macros
#define s(n)                       scanf("%d",&n)
#define sc(n)                      scanf("%c",&n)
#define sl(n)                      scanf("%lld",&n)
#define sf(n)                      scanf("%lf",&n)
#define ss(n)                      scanf("%s",n)

// Others
#define test(t) 				int t; cin>>t; while(t--)
#define endl 					"\n"

using namespace std;

typedef pair<int, int> 			pii;
typedef pair<ll, ll> 	          pll;
typedef vector<int> 			vi;
typedef vector<ll>                 vl;

const int mod = 1000000007;
const int INF = 1e9+5;

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

     int n;
     s(n);
     
     // dp[i] = the max value of the fun when did the ith activity today
     
     vector<int> dp(3,0);
     
     for(int i=0 ; i<n ; i++){
		int fun[3];
		scanf("%d %d %d",&fun[0],&fun[1],&fun[2]);
		
		vector<int> dp_new(3);
		
		for(int j=0 ; j<3; j++){
			for(int k=0 ; k<3 ; k++) {
				if(j!=k){
					dp_new[j] = max(dp_new[j], dp[k]+fun[j]);
				}
			}
		}
		
		dp = dp_new;
		
	 }
	 
	 int ans = max(dp[0], max(dp[1], dp[2]));
	 printf("%d\n",ans);
     
     
     

     return 0;

}


Measured memory_bytes: 3780
#include <stdio.h>
int main(){
	int bell[3];
	for(int i=0;i<3;i++)
		scanf("%d",&bell[i]);	
	for(int i=0;i<2;i++){
		if(bell[i] > bell[i+1]){
			bell[i] ^= bell[i+1];
			bell[i+1] ^= bell[i];
			bell[i] ^= bell[i+1];
		}
	}
	printf("%d\n",bell[0]+bell[1]);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>

using namespace std;

int a[2][100], dp[2][100];

int update(int i, int j){
	if(i == 0 && j == 0) return a[i][j];
	if(i == 0) return dp[i][j - 1] + a[i][j];
	if(j == 0) return dp[i - 1][j] + a[i][j];
	return max(dp[i][j - 1], dp[i - 1][j]) + a[i][j];
}

int main(){
	int n; scanf("%d", &n);
	for(int i = 0; i < 2; i++) for(int j = 0; j < n; j++) scanf("%d", &a[i][j]);
	for(int i = 0; i < 2; i++) for(int j = 0; j < n; j++){
		dp[i][j] = update(i, j);
	}
	printf("%d\n", dp[1][n - 1]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int N,K;
string S;
VI p;

int main() {
	//input
	cin >> N >> K >> S;
	S+='2';
	if(S[0]=='0')p.push_back(0);
	int cnt=1;
	for(int i=1; i<=N; i++){
		if(S[i]==S[i-1])cnt++;
		else {
			p.push_back(cnt); cnt=1;
		}
	}
	if(S[N-1]=='0')p.push_back(0);

	//do
	int ans = 0, tmp = 0;
	for(int i=0; i<min(2*K+1,(int)p.size()); i++) ans+=p[i];
	tmp = ans;
	for(int i=2*K+1; i+1 < p.size(); i+=2){
		tmp = tmp - p[i-K*2-1] - p[i-K*2] + p[i] + p[i+1];
		ans = max(ans,tmp);
	}

	//output
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

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

	ll sum = 0;
	rep(i, N)
	{
		cin >> A[i];
	}

	ll now = 0;
	rep(i, N)
	{
		sum += abs(A[i] - now);
		now = A[i];
	}
	sum += abs(now - 0);
	rep(i, N)
	{
		ll p_sum = sum;
		if (i == 0)
		{
			p_sum -= abs(A[i] - 0) + abs(A[1] - A[0]);
			p_sum += abs(A[1] - 0);
		}
		else if(i == N - 1){
			p_sum -= abs(A[i] - 0) + abs(A[i] - A[i - 1]);
			p_sum += abs(A[i - 1] - 0);
		}
		else {
			p_sum -= abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]);
			p_sum += abs(A[i - 1] - A[i + 1]);
		}
		cout << p_sum << endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
	static ll C[51][51];
	for (int i = 0; i <= 50; i++) {
		C[i][0] = C[i][i] = 1;
		for (int j = 1; j < i; j++) {
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
		}
	}
	int n, p;
	cin >> n >> p;
	int b[2] = {};
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		b[a % 2]++;
	}
	ll m = 0;
	for (int i = 0; i <= b[0]; i++) {
		for (int j = p; j <= b[1]; j += 2) {
			m += C[b[0]][i] * C[b[1]][j];
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-18
//priority_queue<int,vector<int>, greater<int> > q2;



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

	double A, B;
	cin >> A >> B;

	
	B += eps;
	int C = A * B;
	cout << C << endl;

	return 0;
}



Measured memory_bytes: 3748
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  vector< int > an;
  cin >> n;

  for( int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    an.push_back(tmp);
  }
  sort(an.begin(), an.end());
  if( n==2 ){
    printf("%d %d\n", an[1], an[0]);
    return 0;
  }
  int c=an.back();
  double cc=c;
  double b=cc/2;
  double pre_d=fabs(b-an[0]);
  for( int i=1; i<n-1; i++){
    double d = fabs(b-an[i]);
    if( (an[i]!=an[i-1]) && (d > pre_d) ){
      printf("%d %d\n", c, an[i-1]);
      break;
    }
    if( i == (n-2) ){
      printf("%d %d\n", c, an[i]);
      break;
    }
    pre_d = d;
  }
  return 0;
  
}


Measured memory_bytes: 892
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int sum = 0;
	if(k>=a){
		sum+=a;
		k-=a;
	}else{
		sum += k;
		cout << sum << endl;
		return 0;
	}
	if(k>=b){
		k-=b;
	}else{
		cout << sum << endl;
		return 0;
	}
	if(k>=c){
		sum-=c;
		k-=b;
	}else{
		sum -= k;
		cout << sum << endl;
		return 0;
	}
	cout << sum << endl;
}	


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int K, T;
	cin >> K >> T;
	vector<int> a(T);
	for (int i = 0; i < T; ++i)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << max(a[T - 1] - 1 - (K - a[T - 1]), 0) << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define int long long
int x[100000],vx[100000];
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	f(i,a)cin>>x[i];
	sort(x,x+a);
	f(i,a){
		if(i)vx[i]+=vx[i-1];
		vx[i]+=x[i];
	}
	int l=-1,r=1000000000;
	while(r-l>1){
		int z=(l+r)/2;
		bool bo=true;
		if(x[a-d]-z>b)bo=false;
		z+=b;
		int a2=lower_bound(x,x+a,z-b)-x;
		if(b*c>a2*b+min(d-1,a-a2)*b+z*max(a-d+1-a2,(int)0)-vx[max(a-d+1,a2)-1]+vx[a2-1])bo=false;
		if(bo)r=z-b;
		else l=z-b;
	}
	cout<<a-(lower_bound(x,x+a,r)-x)<<endl;
	return 0;
}


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

void judge()
{
  int num;
  cin >> num;

  if(num%10 == 2 || num%10 == 4 || num %10 == 5 || num%10 == 7 || num%10 == 9)
  {
    cout << "hon" << endl;
  }
  //else if(num%10 == 0 || num%10 == 1 || num%10 == 6 || num%10 == 8)
  else if(num%10 == 3)
  {
    cout << "bon" << endl;
  }
  else
  {
    cout << "pon" << endl;
  }
}
int main()
{
  judge();
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std ;
#define LL long long
int a[200010] ;
int n ;
LL calc( int k ){
   LL ans = 0 ;
   for( int i = 1 ; i <= n ; i++ )
       ans += abs( a[i] - k - i ) ;
   return ans ;
}
int main(){
    cin >> n ;
    for( int i = 1 ; i <= n ; i++ )
        scanf( "%d" , &a[i] ) ;
    int l = -n ; int r = 1e9 + n ;
    while( l + 1 < r ){
          int mid1 = l + ( r - l ) / 3 ;
          int mid2 = l + ( r - l ) * 2 / 3 ;
          if ( calc( mid1 ) < calc( mid2 ) ) r = mid2 - 1 ;
          else l = mid1 + 1 ;
    }
    LL ans = min( calc( l ) , calc( r ) ) ;
    cout << ans << endl ;
    return 0 ;
}

Measured memory_bytes: 1024
#<C>
N = int(input())
H = list(map(int,input().split()))
H.append(10 ** 9 + 1)
ans = 0
i = 0
for n in range(N):
    if H[n] >= H[n + 1]:
        i += 1
    else:
        ans = max(ans, i)
        i = 0

print(ans)
    

Measured memory_bytes: 20496
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000

int main() {
  int a, b;
  scanf("%d %d", &a, &b);

  int n = b-a;
  printf("%d\n", n*(n+1)/2-b);



  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int max(int a,int b){
  if(a>b)return a;
  else return b;
}
int main(){
  int n,w;
  scanf("%d %d",&n,&w);
  int dp[110][10010]={0};
  int i,j;
  for(i=1;i<1+n;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    for(j=0;j<1+w;j++){
      if(j-b>=0)dp[i][j]=max(dp[i-1][j],dp[i][j-b]+a);
      else dp[i][j]=dp[i-1][j];
    }
  }
  printf("%d\n",dp[n][w]);

  return 0;
}

Measured memory_bytes: 5336
n = int(input())
al = []
for i in range(n):
    a = int(input())
    al.append(a)
 
al.insert(0, 0)
ans = -1
push = 1
for i in range(1, n+2):
    light = al[push]
    push = light
    if light == 2:
        ans = i
        break
print(ans)

Measured memory_bytes: 12928
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
n,m = map(int,input().split())
mod = 10**9+7
if n == m:
    ans = P(n,n) * P(m,m) * 2
    print(ans%mod)
elif abs(n-m) > 1:
    print(0)
else:
    ans = P(n,n)*P(m,m)
    print(ans%mod)

Measured memory_bytes: 55152
from math import ceil
n=int(input())
c=[0]*n
s=[0]*n
f=[0]*n
for i in range(n-1):
  c[i],s[i],f[i]=map(int,input().split())
for i in range(n):
  t=s[i]+c[i]
  if i<n-1:
    for j in range(i+1,n-1):
      if s[j]>=t:
        t=s[j]+c[j]
      else:
        t=ceil(t/f[j])*f[j]+c[j]
  print(t)

Measured memory_bytes: 74592
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n,k,q = map(int,input().split())
    p = [0 for i in range(n)]
    for i in range(q):
        a = int(input())
        p[a-1] += 1
    for i in range(n):
        if k-q+p[i]>0:
            print("Yes")
        else:
            print("No")
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5532
N = int(input())
table = [[-1]*(N) for i in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        table[i][x-1] = y
# print(table)
# table[i][x] 人iが人xを正直者;1,真偽不明:0,未言及:-1

ans = 0
for i in range(2**N):

    hito = [0]*N
    for j in range(N):
        if i >> j & 1:
            hito[j] = 1

    flag = True
    cnt = 0
    for j in range(N):
        if i >> j & 1:
            cnt += 1
            for k in range(N):
                if table[j][k] != -1:
                    if table[j][k] != hito[k]:
                        flag = False
    if flag:
        if cnt > ans:
            ans = cnt
print(ans)
#print(3 >> 0) # 3????



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

int main(){

  int n;

  while(cin >> n, n){
    int k = -n+1;

    for(int i=2;i*i<n;i++){
      if( !(n%i) ) k += n/i + i;
    }

    if(!k && n != 1) cout << "perfect number";
    else if(k < 0 || n == 1) cout << "deficient number";
    else cout << "abundant number";
    cout << endl;
  }

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,d,res=0;
	cin>>n>>d;
	int a[13][13];
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<n;i++){//第几行主 
		for(int j=i+1;j<n;j++){//和哪行比
			int sum=0;
			for (int k=0;k<d;k++){ //元素 
				sum=(a[i][k]-a[j][k])*(a[i][k]-a[j][k])+sum;
			} 
			double x=sqrt(sum);
			if (x-int(x)==0){
				res++;
			}
		}
	}
	cout<<res;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
// #define INF 1LL<<60

const int INF = 1e9;

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    REP(i, N) cin >> v[i];

    vector<int> dp(N+1, INF);
    int ans = 0;

    REP(i, N) {
        auto itr = lower_bound(dp.begin(), dp.end(), v[i]);
        *itr = min(*itr, v[i]);
        ans = max(ans, int(itr - dp.begin()));
    }

    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 3552
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
int n;
int main(){
  scan(n);
  int i=1;
  while(i*i<=n) i++;
  prin((i-1)*(i-1));
  
  return 0;
}


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

long long ans = 0;
int A[200005], n;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        A[i] -= (i+1);
    }
    sort(A,A+n);
    for(int i = 0; i < n; i++) ans += abs(A[n/2] - A[i]);
    cout << ans << '\n';
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
bool has3(int x) {
    while(x) {
     if (x % 10 == 3) {
        return true;
        }
        x /= 10;
    }
    return false;
     
}
void call(int n) {
     for (int x = 1; x <= n; x++) {
        if((x % 3) ==0  || has3(x)) {
            cout << " " << x;
        }
        
        
    }
   
   cout << endl;
}
int main(){
    int n;
    cin >> n;
    call(n);
   
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    sort(v.rbegin(), v.rend());
    int a = 0, b = 0;
    for(int i = 0; i < n; i++){
        if(i % 2)
            b += v[i];
        else
            a += v[i];
    }
    cout << a - b << endl;
}


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

int main(){
  int a[4],b[4],i,j,hit=0,blow=0;


  while(scanf("%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3]) != EOF){ 
    hit=0;
    blow=0;
  for(i=0;i<4;i++){
    for(j=0;j<4;j++){
      if(a[i] == b[j] && i != j)blow++;
      if(a[i] == b[j] && i == j)hit++;
    }
  }

  cout << hit << " " << blow << endl;
  }


}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int l,r,d;

int main(){
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;i++) if(i%d==0) cnt++;
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 3612
// https://atcoder.jp/contests/abc162/tasks/abc162_a

#include <iostream>
#include <string>
using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes";
  else cout << "No";
  return 0;
}

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

ans = 0
for i in range(n):
  if a[i] < b[i]:
    b[i] -= a[i]
    ans += a[i]
    if a[i+1] < b[i]:
      ans += a[i+1]
      a[i+1] = 0
    else:
      ans += b[i]
      a[i+1] -= b[i]
  else:
    ans += b[i]
    
print(ans)

Measured memory_bytes: 18624
#define ll long long
#include<iostream>

using namespace std;

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

int main()
{
  ll a=0,b=0,cd=0;
  cin>>a>>b;
  cd = gcd(a,b);
  cout<<(a*b)/cd;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
path = []
ans = 0
for i in range(N):
    A = int(input())
    path.append([])
    for j in range(A):
        x, y = map(int,input().split())
        x -= 1
        path[-1].append((x, y))
for i in range(1<<N):
    i |= (1<<N)
    judge = True
    for j in range(N):
        if not judge:
            break
        if (1<<j) & i:
            for k in range(len(path[j])):
                if path[j][k][1] != int(bin(i)[-path[j][k][0] - 1]):
                    judge = False
                    break
    if judge:
        if ans < bin(i).count("1") - 1:
            ans = bin(i).count("1") - 1
print(ans)

Measured memory_bytes: 3064