akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int f[N];
int Find(int x) { return x == f[x] ? x : f[x] = Find(f[x]); }
int n;
int ans;
int cnt[N];

inline void solve()
{
    int m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
        f[i] = i;
    for (int i = 1; i <= m; ++i)
    {
        int x, y;
        cin >> x >> y;
        int fx = Find(x), fy = Find(y);
        if (fx != fy)
            f[fy] = fx;
    }
    for (int i = 1; i <= n; ++i)
        cnt[Find(i)]++, ans = max(ans, cnt[Find(i)]);
    cout << ans << endl;
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 5164
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 1030000;

    void solve() {
      string s;
      cin >> s;
      if(s.length() == 3) reverse(all(s));
      cout << s << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

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

int main () {
    ll h,w;
    cin >> h >> w;
    ll ans = 1e18;
    ll h1,h2,h3;
    ll w1,w2,w3;
    ll s1,s2,s3;
    ll maxs,mins;
    auto calc_square = [&](){
        s1 = h1*w1; 
        s2 = h2*w2;
        s3 = h3*w3;
    };
    auto calc_tmp = [&](){
        maxs = max({s1,s2,s3});
        mins = min({s1,s2,s3});
        ans = min(ans,maxs-mins);
    };
    //まず横線を引く
    for(int i = 1;i<=h-1;i++) {
        //横線を引く
        h1 = i;
        h2 = (h-h1)/2;
        h3 = (h-h1)-h2;
        w1 = w;
        w2 = w;
        w3 = w;
        calc_square();
        calc_tmp();
        //縦線を引く
        h2 = h-h1;
        h3 = h-h1;
        w2 = w/2;
        w3 = w-w2;
        calc_square();
        calc_tmp();
    }
    //最初に縦線を引く場合
    for(int i = 1;i<=w-1;i++) {
        //横線を引く
        h1 = h;
        h2 = h/2;
        h3 = h-h2;
        w1 = i;
        w2 = w-w1;
        w3 = w-w1;
        calc_square();
        calc_tmp();
        //縦線を引く
        h1 = h;
        h2 = h;
        h3 = h;
        w1 = i;
        w2 = (w-w1)/2;
        w3 = (w-w1)-w2;
        calc_square();
        calc_tmp();
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define intt int64_t
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define INF 2000000000

int solve(string t, string r) {
	int ret=0;
	set<char> tt, rr;
	for(auto x:t) tt.insert(x);
	for(auto x:r) rr.insert(x);
	for(auto x:tt) {
		for(auto y:rr) {
			if (x == y) ret++;
		}
	}
	return ret;
}

int main() {
	int n;
	scanf("%d", &n);
	string s;
	cin >> s;
	int ans=0;
	for(int i=1;i<n;i++) {
		ans=max(ans, solve(s.substr(0,i), s.substr(i)));
	}
	printf("%d\n", ans);
}


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

int main(){
    int a, b;
    while(cin >> a >> b){
        int v = a + b;
        int ans = 0;
        while(v){
            v /= 10;
            ++ans;
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3008
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

unsigned euclidean_gcd(unsigned a,unsigned b){ //a:large one,b:small one
  unsigned t;
  while(1){
    if(a<b) t=a,a=b,b=t;
    if(!b) break;
    a%=b;
  }
  return a;
}

int main(){
  int a,b;
  cin >> a >> b;
  int r = euclidean_gcd(a,b);
  cout << r << endl;
}

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

int main() {
    string S;
    int64_t K;
    cin >> S;
    cin >> K;
    
    int64_t ini = 300;
    int64_t ini_num = -1;
    for ( int64_t i = 0; i < S.size(); ++i){
        if ( S[i] != '1' ){
            ini = i;
            ini_num = S[i] - '0';
            break;
        }
    }
    
    if ( K >= ini + 1 ){
        cout << ini_num << endl;
    } else {
        cout << S[K-1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint x;
    cin >> x;
    lint res = (x / 500) * 1000;
    x %= 500;
    res += (x / 5) * 5;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define watch cerr << 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

int32_t main(){

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int arr[] = {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 k;
	cin >> k;
	cout << arr[k-1] << endl; 

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    ll n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            ll b=i*m+j*n-2*i*j;
            if(b==k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

const int MAXV = 1e5;

int main()
{
    int n;
    cin >> n;
    vector<ll> cnt(MAXV);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        cnt[a]++;
    }

    ll sum = 0;
    for (int i = 0; i <= MAXV; i++)
    {
        sum += i * cnt[i];
    }

    int q;
    cin >> q;
    while (q--)
    {
        int b, c;
        cin >> b >> c;
        sum -= b * cnt[b];
        sum -= c * cnt[c];

        cnt[c] += cnt[b];
        cnt[b] = 0;

        sum += c * cnt[c];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3972
s[50],j,p,q;
main(i){for(;j=i=atoi(gets(s));printf("%d\n",i)){
for(;i;s[j-i--]=strlen(gets(s+j)));
for(;q>0||(j?p=i++,j=q=6:0);)for(q=6842496>>--j*4&15;q>1;)q-=s[p++];
}}

Measured memory_bytes: 532
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner sc =new Scanner(System.in);
int n =sc.nextInt();
int[] arr=new int[n];
for(int i =0;i<n;i++){
	arr[i]=sc.nextInt();
}
Arrays.sort(arr);
boolean b=true;
for (int i=0;i<n-1;i++){
	if(arr[i]==arr[i+1]){
		b=false;
		break;
	}
}
	if(b==true){
		System.out.println("YES");
	}
	else{
		System.out.println("NO");
	}
}
}


Measured memory_bytes: 66272
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int M,D;
    cin >> M >> D;
    ll ans = 0;
    for (int i = 1; i <= M;i++)
    {
        for (int j = 1; j <= D;j++)
        {
            if(j > 9){
                int pre2 = j / 10;
                int pre1 = j - pre2 * 10;
                if (pre2 > 1 && pre1 > 1)
                {
                    if(i == pre2*pre1){
                        ans++;

                    }
                }
                else{

                }
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  int ma = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    sum += l;
    ma = max(ma, l);
  }
  cout << (ma < sum-ma ? "Yes" : "No") << endl;
}


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

int calcDigitSum(int n) {
  int digitSum = 0;
  for (int j = n; j > 0; j /= 10) {
    digitSum += j % 10;
  }
  return digitSum;
}

int main() {
  int N;
  cin >> N;
  
  int a, b, tmp, upper = N / 2 + 1;
  int min = 108;
  for (a = 1; a <= upper; a++) {
    b = N - a;
    tmp = calcDigitSum(a) + calcDigitSum(b);
    if (tmp < min) {
      min = tmp;
    }
  }
  
  cout << min << endl;
}


Measured memory_bytes: 3632
///Rabbi Zidni Ilma

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll n,r,ans;
	scl(n);
	r=n%1000;
	if(r!=0)
	ans=1000-r;
	else
	ans=r;
	printf("%lld\n",ans);
}

Measured memory_bytes: 3816
#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;
const int N = 1e6 + 100;

int n, m;
vector<int> a[N];
vector<int> g[N];

bool used[N];

void dfs(int v) {
    if (used[v]) {
        return ;
    }
    used[v] = true;
    for (int i : g[v]) {
        dfs(i);
    }
}

int main() {
#ifdef XCODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int len; scanf("%d", &len);
        for (int j = 0; j < len; j++) {
            int x; scanf("%d", &x), x--;
            a[x].pb(i);
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < len(a[i]) - 1; j++) {
            g[a[i][j]].pb(a[i][j + 1]);
            g[a[i][j + 1]].pb(a[i][j]);
        }
    }
    dfs(0);
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 53880
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;

int main() {
	int n;
	int A[100];
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> A[i];
	}
	bool flag = true;
	int count = 0;
	while (flag) {
		flag = false;
		for (int j = n - 1;j >= 1;j--) {
			if (A[j] < A[j - 1]) {
				int a = A[j];
				A[j] = A[j - 1];
				A[j - 1] = a;
				count++;
				flag = true;
			}
		}
	}
	for (int i = 0;i < n-1;i++) {
		cout << A[i] << " ";
	}
	cout << A[n - 1]<<endl;
	cout << count << endl;
}

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

int main() {

  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  if(s[k-1] == 'A') s[k-1] = 'a';
  else if(s[k-1] == 'B') s[k-1] = 'b';
  else if(s[k-1] == 'C') s[k-1] = 'c';
  cout << s;


  return 0;
}


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

int main()
{
    string S;
    cin >> S;
    vector<char> ACGT = {'A', 'C', 'G', 'T'};

    int counts = 0;
    int max_counts = 0;
    int flag = 0;
    for (int i = 0; i < S.size(); i++)
    {
        for (char a : ACGT)
        {
            if (a == S.at(i))
            {
                flag = 1;
            }
        }
        if (flag == 1)
        {
            counts++;
        }
        else
        {
            if (counts > max_counts)
            {
                max_counts = counts;
            }
            counts = 0;
        }
        flag = 0;
    }

    if (counts > max_counts)
    {
        max_counts = counts;
    }

    cout << max_counts << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    priority_queue<int> q;
    string s;
    int n;
    for(;;){
        cin >> s;
        if (s == "insert"){
            cin >> n;
            q.push(n);
        } else if (s == "extract"){
            cout << q.top() << endl;
            q.pop();
        } else if (s == "end"){
            break;
        }
    }
}


Measured memory_bytes: 6952
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
typedef long long ll;

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

	int N;
	double temp;
	vector<double> A;

	cin >> N;

	REP(i, N)
	{
		cin >> temp;
		A.pb(temp);
	}

	temp = 0.0;
	REP(i, N)
	{
		temp += 1.0 / A[i];
	}
	
	cout <<  1.0 / temp << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
//const double EPS = 1e-9;
const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  long double a, b, c;
  cin >> a >> b >> c;
  if (sqrt(a) + sqrt(b) + EPS < sqrt(c)) yn;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

def check(l):
    D = []
    for i in range(N - 2 * l + 1):
        D.append(S[i : i + l])
        if S[i + l : i + 2 * l] in D:
            return True

ok = 0
ng = N // 2 + 1

while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m):
        ok = m
    else:
        ng = m

print(ok)

Measured memory_bytes: 6260
import sys
import collections
#import cython

    
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
    
def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    a = int(read())
    cnt = collections.Counter(prime_factorize(a))
    tot = 0
    for val in cnt.values():
        cnt = 0
        while val > 0:
            cnt += 1
            val -= cnt
            if val < 0:
                cnt -= 1
                break
            if val == 0: break
        tot += cnt
    print(tot)
 
if __name__ == "__main__":
    main()


Measured memory_bytes: 9480
using System;
class Program{
	static void Main(){
		string s=Console.ReadLine();
		string q=Console.ReadLine();
		string a="No";

		for(int i=0;i<s.Length;i++){
			if(s==q){a="Yes";break;}
			s=s[s.Length-1]+s;
			s=s.Remove(s.Length-1,1);
		}
		Console.WriteLine(a);
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int main() {
	string s;
	cin >> s;
	// 01234
	//   ___
	int ans = INF;
	for (int i = 0; i < s.length() - 2; i++){
		string t = s.substr(i, 3);
		int tt = stoi(t);
		int ttt = abs(tt - 753);
		if (ans > ttt) {
			ans = ttt;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int ans[15];
	for(int i = 0; i < 6; i++) scanf("%d", &ans[i]);
	int ok = 1;
	for(int i = 0; i < 4; i++)
		for(int j = i+1; j < 5; j++)
		{
			if(abs(ans[i] - ans[j]) > ans[5])  
				{ cout << ":(" << endl; return 0; }
		}
	if(ok) cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll n,k,m;
vector< pair< ll , ll > > e,pos;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;

    m = (n-1)*(n-2)/2;

    if( k > m ){
        cout << -1;
        return 0;
    }

    for(ll i=2; i<=n; i++) e.pb( {1,i} );
    for(ll i=2; i<=n; i++) for(ll j=i+1; j<=n; j++) pos.pb( {i,j} );

    while( m>k && pos.size()>0 ){
            e.pb( pos.back() ); pos.pop_back(); m--;
    }

    if( m!=k ){
        cout << -1;
        return 0;
    }

    cout << e.size() << "\n";
    for( auto val:e ) cout << val.fi << " " << val.se << "\n";

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
vector<string>v;
int bfs(int x) {
	int len = v[x].length(); int res = 0;
	if (v[x][len - 1] == '+') {
		x++;
		while (x < (int)v.size() && len+1 <= (int)v[x].length()) {
			if (v[x].length() == len+1) {
				res += bfs(x);
			}
			x++;
		}
	}
	else if (v[x][len - 1] == '*') {
		res = 1; x++;
		while (x < (int)v.size() && len + 1 <= (int)v[x].length()) {
			if (v[x].length() == len + 1) {
				res *= bfs(x);
			}
			x++;
		}
	}
	else {
		res = v[x][len - 1]-'0';
	}
	return res;
}
int main() {
	int n;
	while (cin >> n, n) {
		v.clear();
		string t;
		rep(i, n) {
			cin >> t;
			v.push_back(t);
		}
	    cout << bfs(0) << endl;
	}
	return 0;
}


Measured memory_bytes: 3172
d, g = [int(i) for i in input().split()]
A, B = zip(*[[int(i) for i in input().split()] for j in range(d)])

D = [0] * 10
ans = 10 ** 3

for bit in range(1, 2**10+1):
    score = 0
    cnt = 0
    for i in range(d):
        if bit >> i & 1:
            score += A[i] * (i+1) * 100 + B[i]
            cnt += A[i]

    if not score >= g:
        for i in range(d-1, -1, -1):
            if not bit >> i & 1:
                for j in range(A[i]):
                    score += (i+1) * 100
                    cnt += 1
                    if score >= g:
                        break
                else:
                    continue
                break

    if score >= g:
        ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();

			int n = cin.Int();
			int d = cin.Int();
			int a = cin.Int();
			var xh = new Tuple<long, long>[n];
			for (int i = 0; i < n; i++) {
				long x = cin.Long();
				long h = cin.Long();
				xh[i] = new Tuple<long, long>(x, h);
			}

			var xh2 = xh.OrderBy(x => x.Item1).ToArray();
			long[] damages = new long[n];
			long ans = 0;
			for (int i = 0; i < n; i++) {
				if (i != 0) {
					damages[i] += damages[i - 1];
				}

				long hh = xh2[i].Item2 - damages[i];
				if (hh > 0) {
					long c = hh / a;
					if (hh % a != 0) {
						++c;
					}

					ans += c;
					long nx = xh2[i].Item1 + d + d;
					long nd = a * c;

					int left = -1;
					int right = damages.Count();
					while (right - left > 1) {
						int mid = (right + left) / 2;
						if (xh2[mid].Item1 > nx) {
							right = mid;
						} else {
							left = mid;
						}
					}

					damages[i] += nd;
					if (right < n) {
						damages[right] -= nd;
					}
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

typedef long long STATES;

int main( void )
{
	STATES free_days[31], dp[51], goal_state, next;
	int i, j;
	int n, answer, free_day, k;

	while ( scanf( "%d", &n ) == 1 && n )
	{
		memset( free_days, 0, sizeof(free_days) );
		memset( dp, 0, sizeof(dp) );

		goal_state = 0;
		for ( i = 0; i < n; i++ ) goal_state |= 1LL << i;

		for ( i = 0; i < n; i++ )
		{
			scanf( "%d", &k );
			for ( j = 0; j < k; j++ )
			{
				scanf( "%d", &free_day );
				free_days[free_day] |= 1LL << i;
			}
		}

		answer = -1;
		for ( i = 0; i < n; i++ ) dp[i] = 1LL << i;
		for ( i = 1; i <= 30; i++ )
		{
			next = 0;
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) next |= dp[j];
			if ( next == goal_state )
			{
				answer = i;
				break;
			}
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) dp[j] |= next;
		}

		printf( "%d\n", answer );
	}

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



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



Measured memory_bytes: 3780
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M)%M;
}

int main(){
  ll mod=1000003;
  ll q;
  cin>>q;
  ll x[q],d[q],n[q],s[q],t[q];
  rep(i,q){
    cin>>x[i]>>d[i]>>n[i];
  }
  ll fac[mod],inv[mod];
  fac[0]=1,fac[1]=1;
  rep1(i,mod-1){
    fac[i+1]=fac[i]*(i+1)%mod;
  }
  inv[1]=1;
  for (int i=2;i<mod;i++){
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  }
  rep(i,q){
    if(d[i]==0){
      cout<<RepeatSquaring(x[i],n[i],mod)<<"\n";
    }else{
      s[i]=(inv[d[i]]*x[i])%mod;
      if(s[i]==0 || s[i]+n[i]-1>=mod){
        cout<<0<<"\n";
      }else{
        t[i]=(inv[fac[s[i]-1]]*fac[s[i]+n[i]-1])%mod;
        cout<<(t[i]*RepeatSquaring(d[i],n[i],mod))%mod<<"\n";
      }
    }
  }
}


Measured memory_bytes: 20352
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>())

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
using ll = long long;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


void Main() {
  int a,b,q;
  cin >> a >> b >> q;
  vector<ll> A(a+2);
  vector<ll> B(b+2);
  REP(i,a) IN(A[i]);
  REP(i,b) IN(B[i]);
  A[a] = B[b] = 1e12;
  A[a+1] = B[b+1] = -1e12;
  SORT(A);
  SORT(B);
  
  REP(i,q){
    ll Q;
    IN(Q);
    auto up_a = lower_bound(ALL(A), Q);
    auto up_b = lower_bound(ALL(B), Q);
    int aa= up_a - A.begin();
    int bb= up_b - B.begin();
    ll ans=1e12;
    FOR(k,0,2){
      FOR(j,0,2){
        ll tmp = abs(Q - A[aa-k]) + abs(A[aa-k]- B[bb-j]);
        ll tmp2 = abs(Q - B[bb-j]) + abs(A[aa-k]- B[bb-j]);
        tmp = MIN(tmp, tmp2);
        if(tmp < ans) ans = tmp;
      }
    }
    OUT(ans);
  }
  
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();

  return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

template <class T> struct Dinic {
    
    struct Edge {
        int to,rev; T cap;
        Edge (int t, int r, T c) : to(t), rev(r), cap(c) {}
    };
    
    vector < vector< Edge > > G;
    vector < int > level, iter;
    const T INF = numeric_limits < T > ::max();
    Dinic (int n) : G(n), level(n, 0), iter(n, 0) {}
    
    void add_edge(int from, int to, T cap) {
        G[from].push_back(Edge(to, (int)(G[to].size()), cap));
        G[to].push_back(Edge(from, (int)(G[from].size()) - 1, 0));
    }
    
    void bfs(int s) {
        fill(level.begin(), level.end(), -1);
        queue < int > que({s});
        level[s] = 0;
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            for (int i = 0; i < G[v].size(); i++) {
                Edge& e = G[v][i];
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }
    
    T dfs(int cur, int t, T f) {
        if (cur == t) return f;
        for (int &i = iter[cur]; i < G[cur].size(); i++) {
            Edge& e = G[cur][i];
            if (e.cap > 0 && level[e.to] > level[cur]) {
                T d = dfs(e.to, t, min(f, e.cap));
                if (d == 0) continue;
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
        return 0;
    }
    
    T max_flow(int s, int t) {
        T flow = 0, d;
        while (true) {
            bfs(s);
            if(level[t] < 0) break;
            fill(iter.begin(), iter.end(), 0);
            while ((d = dfs(s, t, INF)) > 0) {
                flow += d;
            }
        }
        return flow;
    }
    
};

int main ()
{
    int N; cin >> N;
    vector < int > a(N),b(N),c(N),d(N);
    REP(i,N) cin >> a[i] >> b[i];
    REP(i,N) cin >> c[i] >> d[i];

    Dinic < int > inst(400);

    REP(i,N) {
        REP(j,N) {
            if (a[i] < c[j] && b[i] < d[j]) {
                inst.add_edge(i, j + 150, 1);
            }
        }
    }

    REP(i,N) {
        inst.add_edge(i + 150, 300, 1);
        inst.add_edge(299, i, 1);
    }

    cout << inst.max_flow(299, 300) << endl;

    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
int N, T, A, X;
int main()
{
    scanf("%d%d%d ", &N, &T, &A);
    int res = 0;
    int cc = 1 << 30;
    for (int i = 1; i <= N; i++)
    {
        scanf("%d ", &X);
        int d = (T * 1000 - X * 6) - A * 1000;
        if (d < 0)
            d = -d;
        if (cc > d)
            cc = d, res = i;
    }
    printf("%d \n ", res);
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   
    string s;
    cin>>s;

    deque<char>dq;

    for(auto it:s)
    dq.push_back(it);

    int flag=0;

    int q;
    cin>>q;
    while(q--)
    {
        int type;
        cin>>type;

        if(type==1)
        flag^=1;

        else
        {
            int f;
            cin>>f;

            char c;
            cin>>c;

            if(flag==1)
            {
                if(f==1)
                dq.push_back(c);
                else
                {
                    dq.push_front(c);
                }
                
            }
            else
            {
                if(f==1)
                dq.push_front(c);
                else
                {
                    dq.push_back(c);
                }
                
            }
            
        }
        
    }

    string ans = "";
    while(!dq.empty())
    {
        ans+=dq.front();
        dq.pop_front();
    }

    if(flag)
    reverse(ans.begin(),ans.end());

    cout<<ans;



   
}

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

int main()
{
  int N, a, b, c, d, ans = 0;
  cin >> N;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> A, B;
  for (int i = 0; i < N; i++)
  {
    cin >> a >> b;
    A.push(make_pair(a, b));
  }
  for (int i = 0; i < N; i++)
  {
    cin >> c >> d;
    B.push(make_pair(c, d));
  }
  priority_queue<pair<int, int>> ayx;
  for (int x = 0; x < 2 * N; x++)
  {
    if (B.top().first != x)
      continue;
    int bx, by;
    tie(bx, by) = B.top();
    B.pop();
    while (!A.empty() && A.top().first < x)
    {
      ayx.emplace(make_pair(A.top().second, A.top().first));
      A.pop();
    }
    queue<pair<int, int>> tmp;
    while (!ayx.empty())
    {
      if (ayx.top().second < bx && ayx.top().first < by)
      {
        ayx.pop();
        ans++;
        break;
      }
      else
      {
        tmp.push(ayx.top());
        ayx.pop();
      }
    }
    while (!tmp.empty())
    {
      ayx.push(tmp.front());
      tmp.pop();
    }
  }
  cout << ans << endl;
}

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

int main()
{
    int i, j;
	int N, M;
	cin>>N>>M;
	int numN,numM;
	if (N<2){numN=0;}
	else{numN=N*(N-1)/2;}
	if (M<2){numM=0;}
	else{numM=M*(M-1)/2;}
	cout<<numN+numM;
   return 0;
}

Measured memory_bytes: 256
INF = 10**18

class BITmin():
    def __init__(self, max):
        self.max = max
        self.data = [self.max-1]*(self.max+1)
    
    # 上に登ってく
    def query_min(self, i):
        s = INF
        while i <= self.max:
            if s > self.data[i]:
                s = self.data[i]
            i += i & -i
        return s

    # iまで全ての要素をxで更新
    def update(self, i, x):
        while i > 0:
            if x < self.data[i]:
                self.data[i] = x
            # i += i & -i
            i -= i & -i

import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())
Query = [list(map(int, input().split())) for _ in range(Q)]

BitX = BITmin(N)
BitY = BITmin(N)

ans = (N-2)*(N-2)
for a, b in Query:
    b -= 1
    if a == 1:
        loc = BitX.query_min(b)
        ans -= loc-1
        BitY.update(loc, b)
    else:
        loc = BitY.query_min(b)
        ans -= loc-1
        BitX.update(loc, b)
    
print(ans)

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

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

    int n;
    cin >> n;

    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define INF (1<<21)
#define MAXSIZE 100
int n,A[N][N];
int dis[N];
int Q[MAXSIZE];
int head = 0;
int tail = 1;

void enqueue(int x)
{
  Q[tail++] = x;
}

int deq() {
  int s;
  s = Q[head++];
  return s;

}
int empty()
{
  return (head == tail);
}
void bfs(int t)
{
  int i,j;
  enqueue(t);
  for(i=0;i<n;i++)dis[i]=INF;
  dis[t]=0;
  int a;
  while(!empty())
    {
      a=deq();
      for(j=0;j<n;j++)
        {
          if(A[a][j]==0)continue;
          if(dis[j]!=INF)continue;
          dis[j]=dis[a]+1;
          enqueue(j);
        }
    }
  for(i=0;i<n;i++)
    {
      printf("%d %d\n",i+1,((dis[i]==INF)?(-1):dis[i]));
    }
}
int main()
{
  int i,j,p,k,pnum;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
        {
          A[i][j]=0;
        }
    }
  for(i=0;i<n;i++)
    {
      scanf("%d %d",&p,&k);
      p--;
      for(j=0;j<k;j++)
        {
          scanf("%d",&pnum);
          pnum--;
          A[p][pnum]=1;
        }
    }
  bfs(0);
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k; cout<<n-k+1<<"\n";
	return 0;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MX = 2010;
const ll MOD = 1e9 + 7;

int a, b;
int cnk[MX * 2][MX * 2];
int dp1[MX][MX];
int cc[MX][MX];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	for (int i = 0; i < MX * 2; ++i)
		for (int j = 0; j < MX * 2; ++j) {
			if (i == j || j == 0)
				cnk[i][j] = 1;
			else if (j > i)
				cnk[i][j] = 0;
			else
				cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % MOD;
		}
	for (int i = 0; i < MX; ++i) {
		cc[i][0] = 1;
		for (int j = 1; j <= i; ++j) {
			cc[i][j] = (cc[i][j - 1] + cnk[i][j]) % MOD;
		}
	}
	cin >> a >> b;
	for (int i = 0; i <= a; ++i)
		for (int j = 0; j <= b; ++j) {
			if (i == 0 && j == 0)
				dp1[i][j] = 1;
			if (i)
				dp1[i][j] = dp1[i - 1][j];
			if (j) {
				dp1[i][j] = (dp1[i][j] + cc[j - 1][min(j - 1, i)]) % MOD;
			}
		}
	ll ans = 0;
	for (int i = 0; i <= a; ++i) {
		for (int j = 0; j <= b - 1; ++j) {
			if (a - i >= (b - 1 - j))
				ans = (ans + ll(cnk[b - 1][j]) * dp1[a - i - (b - 1 - j)][b - 1 - j]) % MOD;
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 94080
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int a,b;

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

        cin >> a >> b;

        int m = 0;
        m = a + a-1;
        m = max(m, a + b);
        m = max(m, b + b-1);

        cout << m << endl;


        return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N,check=1;
    string S;
    cin >> S;
    N= S.size();
    for(int i=0;i<N/2;i++){
        if(S[i] != S[N-i-1]){
            check = 0;
        }
    }
    if(check==1){
        for(int i=0;i<N/2/2;i++){
            if(S[i] != S[N/2-1-i]){
                check = 0;
                break;
            }
        }
        if(check==1){
            for(int i=0;i<N/2/2;i++){
                if(S[N/2+1+i] != S[N-1-i]){
                    check = 0;
                    break;
                }
            }
        }
    }
    if(check == 1){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> b;
    b.emplace_back(inf);
    for(int i=0; i<n-1; i++){
        int val; cin>>val;
        b.emplace_back(val);
    }
    b.emplace_back(inf);

    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += min(b[i], b[i+1]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	
    int n,d,x;
    cin >> n >> d >> x;
    int array[n];
    rep(i,n){
      cin >> array[i];
      array[i] = (d + (array[i] - 1))/array[i];
    }
    cout << accumulate(array,array+SIZE_OF_ARRAY(array),0) + x << endl;
    return 0;

  }    

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;
  int X, Y, Z;
  int a[110], b[110], c[110];
  cin >> X;
  for (int i = 0; i < X; i++) {
    cin >> a[i];
  }
  cin >> Y;
  for (int i = 0; i < Y; i++) {
    cin >> b[i];
  }
  cin >> Z;
  for (int i = 0; i < Z; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < Z; i++) {
    bool flag = true;
    for (int j = 0; j < X; j++) {
      if (a[j] == c[i]) flag = false;
    }
    if (flag) {
      ans++;
      continue;
    }
    for (int j = 0; j < Y; j++) {
      if (b[j] == c[i]) flag = true;
    }
    if (flag) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main(void) {
    long long int N, K;
    cin >> N >> K;
    long long cnt = 0;
    if (K > 0) {   
        for (int i = K + 1; i <= N; i++) {
            cnt += (N / i) * (i - K) + (N % i >= K ? N % i - K + 1 : 0);
        }
    } else {
        cnt = N * N;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256