akhauriyash/Code-Regression huggingface dataset:
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
	cin>>v[i];
}
#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
cin>>x>>y;
int dis[n+10][n+10];
dis[x][y]=1;
for(int i=1;i<=n;i++)
{
    for(int j=i+1;j<=n;j++)
    {
    if(i<x && j<=x)
    {
        dis[i][j]=j-i;
    } 
    if(i<x && j==y)
    {
        dis[i][y]=dis[i][x]+1;
    }
    if(i<x && j>y)
    {
        dis[i][j]=dis[i][y]+j-y;
    }
    if(i<x && j>x && j<y)
    {
        dis[i][j]=min(j-i,(int)(dis[i][x]+1+y-j));
    }
    if(i==x && j==y)
    {
        dis[i][j]=1;
    }
    if(i==x && j>y)
    {
        dis[i][j]=dis[i][y]+j-y;
    }
    if(i==x && j<y)
    {
        dis[i][j]=min(j-x,1+y-j);
    }
    if(i>=y)
    {
        dis[i][j]=j-i;
    }
    if(i>x && i<y)
    {
        dis[i][j]=min(j-i,(int)(i-x+1+abs(j-y)));
    }
    }
}
int ans[n+10]={0};
for(int i=1;i<=n;i++)
{
    for(int j=i+1;j<=n;j++)
    {
        ans[dis[i][j]]++;
        deb(i);
        deb(j);
        deb(dis[i][j]);   
         }
}
for(int i=1;i<=n-1;i++)
cout<<ans[i]<<'\n';









return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 15872
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

const int MAX_M = 100;
int N, M, X, A[MAX_M];


void solve() {
    int ans1 = 0;
    int ans2 = 0;
    FOR(i, X, N) {
        REP(j, M) if (i == A[j]) ans1++;
    }
    REPR(i, X) {
        REP(j, M) if (i == A[j]) ans2++;
    }
    cout << min(ans1, ans2) << endl;
}

int main() {
    cin >> N >> M >> X;
    REP(i, M) cin >> A[i];
    solve();
    return 0;
}

Measured memory_bytes: 256
S=input()
cnt=0
pre_s=""
if len(S)==1:
  print(0)
  exit(0)
for i in S:
  if pre_s == "":
    pre_s = "1" if i=="1" else "0"
  elif pre_s == i:
    pre_s = "1" if i=="0" else "0"
    cnt +=1
  else:
    pre_s = i
print(cnt)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n,a,b,sum=0;
    cin>>n>>a>>b;
    ll c=n%(a+b),d=n/(a+b);
    sum += a*d;
    if(c>=a) sum += a;
    else if(c<a) sum+=c;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
         
        public class Main { //クラス名はMain
            public static void main(String[] args) {
                //コード
              Scanner sc = new Scanner(System.in);
        	  String n = sc.nextLine();
              String[] strArray = n.split(" ");
              int a = Integer.parseInt(strArray[0]);
              int b = Integer.parseInt(strArray[1]);
              int c = Integer.parseInt(strArray[2]);
              
              int wa = a + b + c;
              
              //判定
              if (wa >= 22) {
                System.out.println("bust");
              }else{
                 System.out.println("win"); 
              }
            }
        }

Measured memory_bytes: 23252
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

int main()
{
	FASTIO;
	int n;
	cin >> n;
	string str;
	cin >> str;
	clock_t start,stop;
	start = clock();
	ll ans = 0;
	for(int i = 0;i < n;i++)
	{
		ans++;
		int j = i;
		while(j < n && (str[j] == str[i])) j++;
		i = j - 1;
	}
	cout << ans << ln;
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
	return 0;
}


Measured memory_bytes: 512
/******************************************
* AUTHOR : Dharmveer Jakhar *
* Handle : dvjakhar *
* INSTITUTION : IIT (BHU) Varanasi *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define lb(arr,n,x) lower_bound(arr,arr+n,x)-arr
#define ub(arr,n,x) upper_bound(arr,arr+n,x)-arr

typedef long long ll;
//Calculation of (x^y)%mm
ll mod_exp(ll x,ll y,ll mm)
{
    if(y==0)
        return(1);
    else if(y%2==0)
        return(mod_exp((x*x)%mm,y/2,mm));
    else
        return((x*mod_exp((x*x)%mm,(y-1)/2,mm))%mm);
}
int binary_search(int array[],int n,int x)
{
	int a = 0, b = n-1;
while (a <= b) {
int k = (a+b)/2;
if (array[k] == x) {
	return k;
// x found at index k
}
if (array[k] > x) b = k-1;
else a = k+1;
}
}

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

int a,b;
cin>>a>>b;
for(int i=1;i<1001;++i)
{
	if(i* 8 / 100 == a && i * 10 / 100 == b){
		cout<<i<<endl;
		return 0;
	}
}
cout<<"-1"<<endl;

return 0;
}

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

using namespace std;

map<char, char> mp;

char next_animal(char a, char b, char c){
    if(b == 'S'){
        if(c == 'o'){
            return a;
        }else{
            return mp[a];
        }
    }else{
        if(c == 'o'){
            return mp[a];
        }else{
            return a;
        }
    }
}

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<string> a(4);
    a[0] = "SS";
    a[1] = "SW";
    a[2] = "WS";
    a[3] = "WW";
    mp['S'] = 'W';
    mp['W'] = 'S';
    bool f = true;
    for(int i = 0; i < 4; i++){
        string ans = a[i];
        for(int j = 1; j < n - 1; j++){
            ans.push_back(next_animal(ans[j - 1], ans[j], s[j]));
        }
        if(next_animal(ans[n - 2], ans[n - 1], s[n - 1]) == ans[0] && next_animal(ans[n - 1], ans[0], s[0]) == ans[1]){
            cout << ans << endl;
            f = false;
            break;
        }
    }
    if(f) cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 776
X = int(input())

N = 10**3

f = False
for i in range(N+1):
    for j in range(N+1):
        if i**5-j**5 == X:
            print(i, j)
            f = True
            break
        if i**5+j**5 == X:
            print(i, -j)
            f = True
            break
    if f:
        break

Measured memory_bytes: 64288
#include <stdio.h>
#include <string.h>

int main(void)
{
	int p_tarou;
	int p_hanako;
	char c_tarou[100];
	char c_hanako[100];
	int n;
	int i;
	
	scanf("%d", &n);
	
	p_tarou = 0;
	p_hanako = 0;
	for (i = 0; i < n; i++){
		scanf("%s %s", c_tarou, c_hanako);
		if (strcmp(c_tarou, c_hanako) == 0){
			p_tarou++;
			p_hanako++;
		}
		else if (strcmp(c_tarou, c_hanako) < 0){
			p_hanako += 3;
		}
		else {
			p_tarou += 3;
		}
	}
	printf("%d %d\n", p_tarou, p_hanako);
	
	return (0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n;cin >> n;
  vector<int> posi;
  for (int i = 0; i < (1 << n); i++){
    // cout << i << endl;
    // cout << bitset<8>(i) << endl;
    for (int v = 0; v < n; v++){
      if(i & (1 << v)){
        posi.push_back(v);
      }
    }
    cout << i << ":";
    if (!posi.empty()){
      for (auto itr = posi.begin(); itr != posi.end(); itr++){
        cout << " " << *itr;
      }
    }
    cout << endl;
    posi.clear();
  }
}


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

int main(){
  ll t1,t2,a1,a2,b1,b2;
  cin>>t1>>t2>>a1>>a2>>b1>>b2;
  if(a1*t1+a2*t2==b1*t1+b2*t2){
    cout << "infinity" << endl;
    return 0;
  }
  ll ok = 0,ng = 1e16;
  ll a = a1*t1+a2*t2;
  ll b = b1*t1+b2*t2;
  ll last = 0;
  while(ng-ok>1){
    ll mid = (ng+ok)/2;
    ll ax0 = a*(mid-1);
    ll bx0 = b*(mid-1);
    ll ax1 = a*(mid-1)+a1*t1;
    ll ax2 = a*mid;
    ll bx1 = b*(mid-1)+b1*t1;
    ll bx2 = b*mid;
    bool cr1 = (ax0<bx0&&ax1>=bx1)|| (ax0>bx0&&ax1<=bx1);
    bool cr2 = (ax1<bx1&&ax2>=bx2)|| (ax1>bx1&&ax2<=bx2);
    if(cr1 || cr2){
      ok = mid;
      last = cr1+ cr2;
    }else{
      ng = mid;
    }
  }
  ll ans=0;
  if(ok==1){
    ans = last;
  }else if(ok){
    ans = ok*2-1;
    if(last==1)ans--;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define bl bool
#define INF 1e+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int main(){
	ll n,d;
	read(n),read(d);
	ll ans=d*2+1;
	if(n%ans==0){
		cout<<n/ans<<endl;
		return 0;
	}
	ans=n/ans+1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <stdlib.h>

int jagh(int n){
  int i=1;
  while(i>0){
    if(pow(i,2)>n){
      return pow(i-1,2);
    }
    i++;
  }
}

int main(){
  int n,c=0;
  scanf("%d",&n);
  printf("%d",jagh(n));
}
  

Measured memory_bytes: 128
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)

mon = 1000

(n-1).times do |i|
	next if arr[i] >= arr[i+1]
	mon = (mon - mon / arr[i] * arr[i]) + (mon / arr[i]) * arr[i+1]
end
puts mon	

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

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

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

  string x;
  string y;
  rep(i, b) x+=to_string(a);
  rep(i, a) y+=to_string(b);

  if(x<y) cout << x;
  else cout << y; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n, hbef = 0, haft, ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        scanf("%d", &haft);
        if(haft >= hbef) ans += haft - hbef;
        hbef = haft;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 200005

const int INF = 1e9+7;

int n,m;
vector<int> g[ARRAY_MAX];
bool used[ARRAY_MAX];

void dfs(int now){

    used[now] = true;

    for(int i = 0;i < g[now].size();i++){
        if(used[g[now][i]] == true){
            continue;
        }
        dfs(g[now][i]);
    }
    return;
}

int main(){

    cin >> n >> m;

    for(int i = 0;i < n;i++){
        int k;
        cin >> k;
        for(int j = 0;j < k;j++){
            int a;
            cin >> a;
            a--;
            g[i].push_back(a+n);//人iが話せる言語
            g[a+n].push_back(i);//言語a-1を話せる人の番号
        }
    }
    
    dfs(0);
    //１回のdfsで終わらないなら連結でない

    for(int i = 0;i < n;i++){
        if(used[i] == false){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 8704
n = gets.to_i
as = gets.split.map(&:to_i)

sum = as.inject(:+)
x = as.shift
ans = (2 * x - sum).abs

as[0..-2].each do |a|
  x += a
  diff = (2 * x - sum).abs
  ans = diff if diff <= ans
end

puts ans


Measured memory_bytes: 27284
def main():
    length = int(input())
    string = list(input())
    index = int(input())
    not_replace = string[index - 1]
    for i in range(length):
        if string[i] != not_replace:
            string[i] = "*"
    print("".join(string))


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
		int a,b,c;
		char op;
		while(1){
			scanf("%d %c %d",&a,&op,&b);
			if(op=='+'){
				c=a+b;
				printf("%d\n",c);
			}
			if(op=='-'){
				c=a-b;
				printf("%d\n",c);
			}
			if(op=='*'){
				c=a*b;
				printf("%d\n",c);
			}
			if(op=='/'){
				c=a/b;
				printf("%d\n",c);
			}
			if(op=='?'){
				break;
			}
		}
		return 0;
}	


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

int ans[100005];
string s;
vector<int> di,num;

int main()
{
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;++i) {
		if(s[i]=='R'&&s[i+1]=='L') {
			num.push_back(i+1);
		}
		else if(s[i]=='L'&&s[i+1]=='R') {
			di.push_back(i+1);
		}
	}
	di.push_back(n);
	int las=1;
	for(int i=0;i<di.size();++i) {
		int t=di[i];
		if((t-las+1)%2==0) {
			for(int j=las;j<=t;++j) {
				if(j==num[i]||j==num[i]+1) ans[j]=(t-las+1)/2;
				else ans[j]=0;
			}
		}
		else {
			int l=num[i]-las+1;
			if(l%2==1) ans[num[i]]=(t-las+2)/2,ans[num[i]+1]=(t-las)/2;
			else ans[num[i]]=(t-las)/2,ans[num[i]+1]=(t-las+2)/2;
			for(int j=las;j<=t;++j) {
				if(j==num[i]||j==num[i]+1) continue;
				ans[j]=0;
			}
		}
		las=t+1;
	}
	for(int i=1;i<=n;++i) printf("%d ",ans[i]);
}

Measured memory_bytes: 1532
//
// Created by yuu on 2019-07-07.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int N,A,B;

    cin>>N>>A>>B;

    cout<<min(N*A, B)<<endl;



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(){
	int n, a = 0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n - 2; i++)
		if (s[i] == 'A'&&s[i + 1] == 'B'&&s[i + 2] == 'C')
			a++;
	cout << a;
}

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

int main() {
	//cout<<"GfG!";
	string s;
	cin>>s;
	if(s=="SUN")
	    cout<<7<<endl;
	else if(s=="SAT")
	    cout<<1<<endl;
	else if(s=="FRI")
	    cout<<2<<endl;
	else if(s=="THU")
	    cout<<3<<endl;
	else if(s=="WED")
	    cout<<4<<endl;
	else if(s=="TUE")
	    cout<<5<<endl;
	else
	    cout<<6<<endl;
	return 0;
}

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

using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B) {
    cout << C;
  } else if (B == C) {
    cout << A;
  } else {
    cout << B;
  }
  return 0;
}


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

int main(int argc, char const *argv[])
{
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++)
  {
    if(i % 3 == 0)
      cout << " " << i << flush;
    else
    {
      int m = i;
      while(m != 0)
      {
        if(m % 10 == 3)
        {
          cout << " " << i << flush;
          break;
        }
        m /= 10;
      }
    }
  }
  cout << endl;
  return 0;
}

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

int main(){
    double l;
    cin >> l;
    double s = l/3;
    cout << fixed  << setprecision(8) << pow(s,3) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int p[n];
  for (int i=0;i<n;i++){
    cin >> p[i];
  }
  int x=0;
  int y=0;
  int z=0;
  int ans;
  for (int i=0;i<n;i++){
    if(p[i]<=a){
      x++;
    }
    else if(p[i]>a && p[i]<=b){
      y++;
    }
    else{
      z++;
    }
  }
  ans=min({x,y,z});
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <cmath>
#define F first
#define S second
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int n,w;
int V[120],W[120];
int dp[11000]={};

int main()
{
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		cin>>V[i]>>W[i];
	}


	for(int i=0;i<n;i++)
	{
		for(int l=w;l>=0;l--)
		{
			if(l-W[i]<0)break;
			dp[l]=max(dp[l],dp[l-W[i]]+V[i]);
		}
	}
	cout<<dp[w]<<endl;
	return 0;

}

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

int main(){
  int n;
  cin >> n;
  bool radius[101];
  for(int i = 1; i <=100; i++){
    radius[i] = false;
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    int d;
    cin >> d;
    if(radius[d]==false){
      radius[d] = true;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int n, m, q;
ll ans = 0;
vint a, b, c, d;
ll calc(vint A) {
    ll res = 0;
    rep(i, q) {
        if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    }
    return res;
}

void dfs(vint A, int mn, int idx) {
    A[idx] = mn;
    if (idx==n-1) {
        ans = max(ans, calc(A));
        return;
    }
    for (int i = mn; i <= m; ++i) {
        dfs(A, i, idx+1);
    }
}

int main() {
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];
        --b[i];
    }

    vint A(n, -1);
    dfs(A, 1, 0);

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

Measured memory_bytes: 3628
def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

N = int(input())
factor = [0]*101

for i in range(1,N+1):
    f = prime_factorize(i)
    for p,n in f:
        factor[p] += n

ov2 = 0
ov4 = 0
ov14 = 0
ov24 = 0
ov74 = 0
for f in factor:
    if 2 <= f:
        ov2 += 1
    if 4 <= f:
        ov4 += 1
    if 14 <= f:
        ov14 += 1
    if 24 <= f:
        ov24 += 1
    if 74 <= f:
        ov74 += 1

ans = 0
##(2,4,4)
ans += (ov2-ov4)*(ov4)*(ov4-1)//2 + ov4*(ov4-1)*(ov4-2)//2

##(2,24)
ans += (ov2-ov24)*(ov24) + (ov24-1)*(ov24)

##(14,4)
ans += (ov4-ov14)*(ov14) + (ov14-1)*(ov14)

##(74)
ans += ov74

print(ans)

Measured memory_bytes: 3064
a, b = map(int, input().split())

x = -1

xa = 0
xb = 0

a_arr = []
b_arr = []

for temp_a in range(10001):
    xa = temp_a * 0.08
    if xa // 1 == a:
        a_arr.append(temp_a)

for temp_b in range(10001):
    xb = temp_b * 0.1
    if xb // 1 == b:
        b_arr.append(temp_b)




for aa in a_arr:
    if aa in b_arr:
        print(aa)
        exit(0)

print('-1')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;

int main(){
	int n,r;
	cin >> n >> r; 
	if(n >= 10) cout << r << endl;
	else cout << r + 100*(10-n) << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    if (n % 2 == 0) {
        cout << n / 2 - 1;
    }
    else {
        cout << n / 2;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  string s;
  cin >> s;

  stack<char> S;
  for (const char c : s) {
    if (S.size() and S.top() != c) {
      S.pop();
    } else {
      S.push(c);
    }
  }

  cout << s.size() - S.size() << endl;

  return 0;
}


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

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> d(200001,0);
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		d[a]++;
	}
	vector<pair<int,int>> v;
	for(int i=0;i<200001;i++){
		if(d[i]) {
			v.emplace_back(make_pair(d[i],i));
		}
	}
	sort(v.begin(),v.end());
	int ans = 0;
	for(int i=0;i<(signed)v.size() - k;i++){
		ans += v[i].first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc093/tasks/abc093_b

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    set<int> st;
    for (int i = A; i < A+K; i++) {
        if (i < A || i > B) continue;
        st.insert(i);
    }
    for (int i = B; i > B-K; i--) {
        if (i < A || i > B) continue;
        st.insert(i);
    }

    for (int i : st) {
        cout << i << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
typedef long long ll;
#define mod 1000000007

ll mod_pow(ll x, ll n){
  ll res = 1;
  while (n != 0){
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n = n >> 1;
  }
  return res;
}

ll mod_fact(ll x){
  ll res = 1;
  for (ll i = x; i > 0; i--)
    res *= i, res %= mod;
  return res;
}

ll nCr(ll n, ll r){
  ll nume = mod_fact(n);
  ll deno = mod_fact(r) * mod_fact(n - r) % mod;
  return nume * mod_pow(deno, mod - 2) % mod;
}

int main() {
  int N, M;
  cin >> N >> M;
  ll ans = 0;
  if(abs(N - M) == 0) {
    ans = 2 * mod_fact(N);
    ans = ans * mod_fact(M) % mod;
  } else if(abs(N - M) == 1) {
    ans = mod_fact(N);
    ans = ans * mod_fact(M) % mod;
  }
  cout << ans << endl;
  return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

int v, e;
vector<int> g[10000];
bool visited[10000];
vector<int> ans;

void dfs(int now)
{
    if (visited[now]) return;
    visited[now] = true;
    for (auto &nxt: g[now]) {
        dfs(nxt);
    }
    ans.emplace_back(now);
}

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

    cin >> v >> e;
    for (int i = 0; i < e; i++) {
        int s, t; cin >> s >> t;
        g[s].emplace_back(t);
    }
    for (int i = 0; i < v; i++) dfs(i);
    reverse(ans.begin(), ans.end());
    for (auto &x: ans) cout << x << '\n';
    return 0;
}



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


parent = [i for i in range(N)]
rank = [0] * N


def find(i):
    if parent[i] == i:
        return i
    else:
        parent[i] = find(parent[i])
        return parent[i]


def same(x, y):
    return find(x) == find(y)


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return

    if rank[x] > rank[y]:
        parent[y] = x
    else:
        parent[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1


for i in range(M):
    X, Y, Z = map(int, input().split())
    X, Y = X - 1, Y - 1
    if not same(X, Y):
        unite(X, Y)

num = 0
for i in range(N):
    if i == find(i):
        num += 1

print(num)

Measured memory_bytes: 85536
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>
#include <stack>
#include <string>
#include <set>
#include <queue>
#include <functional>
#include <deque>

using namespace std;

#define forn(i,n) for(int i = 0; i < n; i++)
#define forr(i,n) for(int i = n-1; i >= 0; i++)
#define ALL(x) x.begin(),x.end()
#define mp(x,y) make_pair(x,y);
#define lson x*2, l, m
#define rson x*2+1, m+1, r

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;
typedef vector<int> vint;
typedef vector<int64> vint64;
template <typename T> istream& operator >> (istream& in, vector<T>& t) { for (int i = 0;i < t.size();i++) in >> t[i]; return in; }
template <typename T> ostream& operator << (ostream& out, vector<T>& t) { for (int i = 0;i < t.size();i++) out << t[i] << " "; return out; }

int main()
{
#ifdef _SANYA
	freopen("abc.txt", "r", stdin);
#else
#define T "permutation"
	//freopen(T ".in", "r", stdin);
	//freopen(T ".out", "w", stdout);
#endif
	string str;cin >> str;
	cout << "ABC" + str << endl;
	exit(0);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define mod 1000000007
using namespace std;


long int modpow(int a, long int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		long int r = p / 2;
		long int ans = modpow(a, r);
		return ans * ans % mod;
		/*指数が偶数の時はそのまま繰り返し二乗を再帰で求める*/
	}
	else {
		/*指数が奇数の時はa^p=a×a^(p-1)て考えるといい*/
		return a * modpow(a, p - 1) % mod;
	}
}

long int modcombi(int a, int c) {
	int i;
	long int ans;
	long int bunsi = 1;
	long int bunbo = 1;
	for (i = 0; i < c; i++) {
		bunsi = bunsi * (a - i) % mod;
		bunbo = bunbo * (i + 1) % mod;
		/*ans=(a-i)×(i+1)^(mod-2)%modってやりたいけど
		毎回modpowを呼ぶことになるので計算時間が伸びるので
		先に分母,分子の積を求めてansに放り込むと
		modpowの呼び出しが一回ですむ*/
	}
	ans = bunsi * modpow(bunbo, mod - 2) % mod;
	return ans;

}


int main(void) {
	int n, m;
	scanf("%d%d", &n, &m);
	int copym = m;
	int long ans = 1;
	int i;
	for (i = 2; i*i <= copym; i++) {
		/*なんでi×iかは解説放送みて*/
		if (copym%i == 0) {
			int count = 0;
			while (copym % i == 0) {
				count++;
				copym = copym / i;
				/*各素因数の指数を求める*/

			}
			/*各素因数の指数が求まるごとにansに入れるといちいち指数
			全部をメモさせておく必要がないから楽*/
			ans = ans * modcombi(count + n - 1, n - 1);
			ans = ans % mod;
		}
	}
	/*素因数分解していったときの最後が素数だった時の処理
	　例;3 12の入力があったときmの変化は12>6>3となるけどsqrt3<3だからforのループからは
	 　ぬけるけど,3の指数について計算されてないので処理する必要がある*/
	if (copym != 1) {
		ans = ans * modcombi(n + 1 - 1, n - 1);
		ans = ans % mod;
		copym = copym / copym;
	}


	printf("%ld", ans);
	return 0;
}


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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
   double n,k;
   cin >>n;
   vl vec(n);
   ll mul=1;
    for (ll cur, i = 0; i < n; ++i) {
        cin >>cur;
        vec[i]=cur;
        mul*=cur;
    }
    double sum =0;
    for (int i = 0; i <n ; ++i) {
        sum +=1/(double)vec[i];
    }
    printf("%.10lf",1/sum);
    return 0;
}



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

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>b(0);
    for(int i=n-1;i>=0;i-=2){
        b.push_back(a[i]);
    }
    if(a.size()%2==0){
        for(int i=0;i<n;i+=2){
            b.push_back(a[i]);
        }
    }
    else{
        for(int i=1;i<n;i+=2){
            b.push_back(a[i]);
        }
    }
    rep(i,n){
        if(i<n-1)cout<<b[i]<<" ";
        else cout<<b[n-1]<<endl;
    }
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K; cin >> N >> K;
  for(int i = 0; i < N; i++) {
    char c; cin >> c; cout << ((i == K - 1) ? (char)(c + ('a' - 'A')) : c);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int N,M,P,r=1<<29;
	scanf("%d%d%d",&N,&M,&P);
	vector<int>v(M+1);
	for(int i=0;i<M;i++)scanf("%d",&v[i]);
	v[M]=P;
	M++;
	sort(v.begin(),v.end());
	int idx=distance(v.begin(),lower_bound(v.begin(),v.end(),P));
	for(int i=0;i<M;i++){
		//unused section=v[i]..v[i+1]
		r=min(r,min(
			(v[i]-v[idx]+N)%N+(v[i]-v[(i+1)%M]+N)%N,
			(v[idx]-v[(i+1)%M]+N)%N+(v[i]-v[(i+1)%M]+N)%N
		));
	}
	printf("%d\n",r*100);
}

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

int main(){
    char number[1001];

    while(1){
        scanf("%s",number);
        if(number[0]=='0')break;
        
        int sum = 0;
        int num;
        for(int i=0; i<strlen(number);i++){
            num = number[i] - '0';
            sum += num;
        }
     
     printf("%d\n",sum);

    }

    return 0;
}


Measured memory_bytes: 2728
def check():
    if X[0][0] == X[1][1] == X[2][2] == 'x':
        return 1
    if X[0][2] == X[1][1] == X[2][0] == 'x':
        return 1
    for e in X:
        if len(set(e)) == 1 and e[0] == 'x':
            return 1
    for e in list(zip(*X)):
        if len(set(e)) == 1 and e[0] == 'x':
            return 1
    return 0

A = [list(map(int, input().split())) for _ in range(3)]
X = [['o' for _ in range(3)] for _ in range(3)]
N = int(input())
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                X[i][j] = 'x'
print(["No", "Yes"][check()])


Measured memory_bytes: 3064
S = str(input())
ans = []
N = len(S)  # 最後の文字の判定を行う


def rec(tmp_s, n):
    if n == N-1:  # 最後の文字なら計算を開始する
        ans.append(eval(tmp_s))
        return
    rec(tmp_s+"+"+S[n+1], n+1)
    rec(tmp_s+S[n+1], n+1)


rec(S[0], 0)
print(sum(ans))


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);

  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  
  long long ans=0;
  int right=0,sum=0;
  for(int left=0;left<n;left++){
    while(right<n && (sum+a[right])==(sum^a[right])){
      sum+=a[right];
      right++;
    }
    ans+=right-left;
    if(left==right) right++;
    else sum-=a[left];
  }
  cout << ans << endl;  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 100005

// it's swapnil07 ;)
vector<int> adj[MAXN];

int vis[MAXN]={false};

void dfs(int i){
    vis[i]=true;
    for(auto j: adj[i]){
        if(!vis[j])
            dfs(j);
    }
}

signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int ct = 0;
    int n, m; cin>>n>>m;
    For(i, 0, m){
        int x, y, z;
        cin>>x>>y>>z;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    For(i, 1, n+1){
        if(!vis[i]){
            ct++;
            dfs(i);
        }
    }
    cout<<ct;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;

	vector<pii> edges(m);

	for(int i = 0; i < m; i++)
		cin >> edges[i].fi >> edges[i].se;

	sort(all(edges));

	vector<vector<int>> adj(200001, vi());

	for(int i = 0; i < m; i++)
		adj[edges[i].fi].pb(edges[i].se);

	for(int node: adj[1])
	{
		if(binary_search( all(adj[node]), n))
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 10112
N, M = gets.chomp.split(' ').map(&:to_i)

target_switches = []
M.times do
  l = gets.chomp.split(' ').map(&:to_i)
  l.shift
  target_switches.push(l)
end

require_mods = gets.chomp.split(' ').map(&:to_i)

puts ([0, 1].repeated_permutation(N).map do |switches|
  M.times.map do |i|
    on_count = target_switches[i].reduce(0) { |sum, si| sum += switches[si - 1]  }
    on_count % 2 == require_mods[i] ? 1 : 0
  end.reduce(1, &:*)
end).reduce(0, &:+)


Measured memory_bytes: 1916
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.d = [-1] * n

    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            if self.d[x] > self.d[y]:
                x, y = y, x
            self.d[x] += self.d[y]
            self.d[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)


    def size(self, x):
        return -self.d[self.find(x)]

n, m = map(int, input().split())
a = [0] * m
b = [0] * m
for i in range(m):
    val1, val2 = map(int, input().split())
    val1 -= 1
    val2 -= 1
    a[i], b[i] = val1, val2
ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if j == i:
            continue
        else:
            uf.unite(a[j], b[j])
    cnt = uf.find(0)
    #print(uf.d)
    for j in range(n):
        if uf.find(j) != cnt:
            ans += 1
            break

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
ll c,d,e,f,p,t,x,y,ans=0;


string s;

void input(void){
    cin>>s;
}

ll solve(void){
    if(s=="Sunny")cout<<"Cloudy"<<endl;
  if(s=="Cloudy")cout<<"Rainy"<<endl;
  if(s=="Rainy")cout<<"Sunny"<<endl;

    return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

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

int g[101][101];
int main(){
    int n,u,k,v;
    cin>>n;
    rep(i,n){
        cin>>u>>k;
        --u;
        rep(j,k){
            cin>>v;
            --v;
            g[u][v]=1;
        }
    }
    rep(i,n){
        rep(j,n) cout<<g[i][j]<<(j==n-1?"":" ");
        cout<<endl;
    }
    return 0;
}


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

using namespace std;

const int N = 1e5 + 3;
char a[N];
int n, q;
struct node {
	int cnt;
	char first, last;
	node(char f = 0, char l = 0, int c = 0) {
		cnt = c;
		first = f;
		last = l;
	}
} st[N * 4];
node operator+(const node& L, const node& R) {
	node res(L.first, R.last, L.cnt + R.cnt);
	if (L.last == 'A' && R.first == 'C') res.cnt++;
	return res;
}

void build(int id, int l, int r) {
	if (l == r) {
		st[id] = node(a[l], a[r], 0);
		return;
	}
	int mid = (l + r) / 2;
	build(id * 2, l, mid);
	build(id * 2 + 1, mid + 1, r);
	st[id] = st[id * 2] + st[id * 2 + 1];
}

node get(int id, int l, int r, int u, int v) {
	if (r < u || v < l) return 0;
	if (u <= l && r <= v) return st[id];
	int mid = (l + r) / 2;
	node L = get(id * 2, l, mid, u, v);
	node R = get(id * 2 + 1, mid + 1, r, u, v);
	return L + R;
}

int main() {
	scanf("%d%d", &n, &q);
	scanf("%s", a + 1);
	build(1, 1, n);
	while (q--) {
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", get(1, 1, n, l, r).cnt);
	}
	return 0;
}


Measured memory_bytes: 4096
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			Plant[] plants = new Plant[n];
			for(int i = 0; i < n; i++){
				String name = sc.next();
				
				int[] params = new int[9];
				for(int j = 0; j < 9; j++){
					params[j] = sc.nextInt();
				}
				plants[i] = new Plant(name, params);
			}
			
			Arrays.sort(plants);
			
			for(int i = 0; i < n; i++){
				System.out.println(plants[i].name);
			}
			System.out.println("#");
		}
	}

}

class Plant implements Comparable<Plant>{
	String name;
	int[] param;
	double efficiency;
	
	Plant(String name, int[] param){
		this.name = name;
		this.param = param;
		
		calcEfficency();
	}
	
	//効率を計算
	private void calcEfficency(){
		int timeDE = param[4] + param[5];
		
		int totalTime = param[1] + param[2] + param[3] + 
				timeDE*param[8];
		
		int totalProfit = param[6]*param[7]*param[8] - param[0];
		
		this.efficiency = (double)totalProfit/totalTime;
	}

	//効率について降順に
	//効率が等しい場合は名前について辞書順
	@Override
	public int compareTo(Plant p) {
		if(this.efficiency > p.efficiency){
			return -1;
		}
		else if(this.efficiency == p.efficiency){
			return this.name.compareTo(p.name);
		}
		else {
			return 1;
		}
	}
}


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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int k;
    int a,b;
    cin>>k>>a>>b;
    int lo=(a/k)+(a%k==0?0:1);
    int hi=(b/k);
    if(lo<=hi) cout<<"OK\n";
    else cout<<"NG\n";
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n, a, b;
  cin >>  n >> a >> b;
  if(n == 1)cout << "Hello World" << endl;
  else if(n == 2) cout << a + b << endl;
  return 0;
}


Measured memory_bytes: 256