akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)




int main() {
	ll N, M;
	std::cin >> N >> M;
	map<ll, map<ll, bool>> dic;
	ll A, B;
	rep(i, 0, M) {
		std::cin >> A >> B;
		dic[A][B] = true;
		dic[B][A] = true;
	}

	vll c(N + 1, 999999999);
	vll ans(N + 1, -1);
	ll s = 1;
	c[1] = 0;
	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;
	vector<bool> flg(N+1,false);
	q.push(make_pair(0, 1));

	while (!q.empty()) {
		if (!flg[q.top().second]) {
			flg[q.top().second] = true;
			for (auto itr = dic[q.top().second].begin(); itr != dic[q.top().second].end(); itr++) {
				if (c[q.top().second]+1 < c[itr->first]) {
					c[itr->first] = c[q.top().second] + 1;
					ans[itr->first] = q.top().second;
					q.push(make_pair(c[itr->first], itr->first));
				}
			}
			q.pop();
		}
	}

	repeq(i, 2, N) {
		if (ans[i] < 0) {
			std::cout << "No" << endl;
			return 0;
		}
	}
	std::cout << "Yes" << endl;
	repeq(i, 2, N) {
		std::cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 41152
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N;
int A[100000];
deque<int> deq;

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];

    sort(A,A+N);

    ll ans=0;

    int l=1, r=N-1;
    bool right=true;
    int cnt=0;
    deq.push_back(A[0]);
    repn(i,N-1){
        if(right){
            if(cnt==0){
                deq.push_front(A[r]);
                r--;
                cnt++;
            }else if(cnt==1){
                deq.push_back(A[r]);
                r--;
                cnt=0;
                right=false;
            }
        }else{
            if(cnt==0){
                deq.push_front(A[l]);
                l++;
                cnt++;
            }else if(cnt==1){
                deq.push_back(A[l]);
                l++;
                cnt=0;
                right=true;
            }
        }
    }
    ll res=0;
    int a1,a2=deq.front();
    deq.pop_front();
    rep(i,N-1){
        a1=a2;
        a2=deq.front();
        deq.pop_front();
        res+=abs(a1-a2);
    }
    ans=max(ans,res);



    l=0, r=N-2;
    right=false;
    cnt=0;
    deq.clear();
    deq.push_back(A[N-1]);
    repn(i,N-1){
        if(right){
            if(cnt==0){
                deq.push_front(A[r]);
                r--;
                cnt++;
            }else if(cnt==1){
                deq.push_back(A[r]);
                r--;
                cnt=0;
                right=false;
            }
        }else{
            if(cnt==0){
                deq.push_front(A[l]);
                l++;
                cnt++;
            }else if(cnt==1){
                deq.push_back(A[l]);
                l++;
                cnt=0;
                right=true;
            }
        }
    }
    res=0;
    a1=0,a2=deq.front();
    deq.pop_front();
    rep(i,N-1){
        a1=a2;
        a2=deq.front();
        deq.pop_front();
        res+=abs(a1-a2);
    }
    ans=max(ans,res);

    cout<<ans<<endl;
}

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

int	main()
{
	int	N, K, C;
	string	S;
	cin >> N >> K >> C;
	cin >> S;
	vector<int>	hard_work(N, 0);
	vector<int>	lazy_work(N, 0);
	int	prev = - C - 1;
	int	num = 0;
	for (int i = 0; i < N; ++i) {
		if (S.at(i) != 'x' && i - prev > C) {
			++num;
			hard_work.at(i) = num;
			if (num == K)
				break;
			prev = i;
		}
	}
	int	succ = N + C + 1;
	num = K + 1;
	for (int i = N - 1; i >= 0; --i) {
		if (S.at(i) != 'x' && succ - i > C) {
			--num;
			lazy_work.at(i) = num;
			if (num == 0)
				break;
			succ = i;
		}
	}
	for (int i = 0; i < N; ++i) {
		if (hard_work.at(i) == 0)
			continue;
		if (hard_work.at(i) == lazy_work.at(i))
			cout << i + 1 << endl;
	}
}


Measured memory_bytes: 3332
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
bool check_prime(int a)
{
    if(a == 1)
    {
        return false;
    }
    for(int i = 2;i <= sqrt(a);i++)
    {
        if(a % i == 0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    const int size = 100010;
    int num[size] = {};
    for(int i = 1;i < size;i++)
    {
        if(check_prime(i) && check_prime((i + 1) / 2))
        {
            num[i]++;
        }
        num[i] += num[i - 1];
    }
    int q;
    cin >> q;
    int ans[q];
    for(int i = 0;i < q;i++)
    {
        int l,r;
        cin >> l >> r;
        ans[i] = num[r] - num[l - 1];
    }
    for(int i = 0;i < q;i++)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}

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

const int MOD = 1e9 + 7;
const int LAST16 = (1 << 16) - 1;
const int LAST17 = (1 << 17) - 1;

int bin_pow(int a, int n) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = (res * 1ll * a) % MOD;
        a = (a * 1ll * a) % MOD;
        n >>= 1;
    }
    return res;
}

int get_bits(int x) {
    int ret = 1;
    for (int i = 0; i < x - 1; ++i) ret <<= 1;
    return ret;
}

int sum(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}

int sub(int a, int b) {
    a -= b;
    if (a < 0) a += MOD;
    return a;
}

int x, y, z;

bool ok(int bits) {
    int t = 0, sum = 0;
    int cur = 0;
    while (bits > 0) {
        if ((bits & 1) == 0) ++cur;
        else {
            ++cur;
            sum += cur;
            cur = 0;
            if (t == 0) {
                if (sum == z) sum = 0, t = 1;
            } else if (t == 1) {
                if (sum == y) sum = 0, t = 2;
            } else if (t == 2) {
                if (sum == x) {
                    sum = 0, t = 3;
                    break;
                }
            }
        }
        bits >>= 1;
    }
    return t != 3;
}

int main() {
    int n;
    scanf("%d%d%d%d", &n, &x, &y, &z);

    vector<vector<int>> dp(n + 1, vector<int>(1 << 16));
    dp[0][0] = 1;
    for (int len = 1; len <= n; ++len) {
        for (int prev = 0; prev < (1 << 16); ++prev) {
            for (int cur = 1; cur <= 10; ++cur) {
                int bits = get_bits(cur);
                int cur_bits = (prev << cur) | bits;
                cur_bits &= LAST17;
                if (ok(cur_bits)) {
                    cur_bits &= LAST16;
                    dp[len][cur_bits] = sum(dp[len][cur_bits], dp[len - 1][prev]);
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << 16); ++i) {
        ans = sum(ans, dp[n][i]);
    }

    ans = sub(bin_pow(10, n), ans);
    printf("%d\n", ans);
}


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty rnd(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

vector<int> edges[MAXN];
int ans[MAXN];
int level[MAXN];

inline void bfs() {
	queue<int> q;
	q.emplace(1);
	ans[1] = -1;

	while(q.size()) {
		int u = q.front();
		q.pop();

		for (int v : edges[u]) {
			if (!ans[v]) {
				q.emplace(v);
				ans[v] = u;
			}
		}
	}

}

int main() {
	int n, m; rd(n, m);
	for (int i = 0; i < m; i++) {
		int u, v; rd(u, v);
		edges[u].eb(v);
		edges[v].eb(u);
	}

	bfs();
	for (int i = 1; i <= n; i++) {
		if (!ans[i]) {
			puts("No");
			return 0;
		}
	}

	printf("Yes\n");
	for (int i = 2; i <= n; i++) {
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 13000
using System;
using System.Collections.Generic;
public class ABC130C {
    public static void Main() {
        double W, H, S, x, y;
        int ans = 0;
        string[] str = System.Console.ReadLine().Split(' ');
        W = int.Parse(str[0]);
        H = int.Parse(str[1]);
        x = int.Parse(str[2]);
        y = int.Parse(str[3]);

        S = W * H / 2;

        if (x == W / 2 && y == H / 2) ans = 1;
        else ans = 0;

        Console.WriteLine("{0} {1}", S, ans);
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 1000100
int n,f[N],o,i,ans;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&o);
		f[o]=f[o-1]+1;
		ans=max(ans,f[o]);
	}
	cout<<n-ans;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll vis[1000001];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   

    ll n; cin >> n;
 
   //  cout << n << endl;
    queue<pair<ll,ll>> q;
    ll temp = 7%n;
    q.push({1,temp});
    pair<ll,ll> cur;
   
        while(!q.empty() && vis[0]==0)
        {
            cur=q.front();
            q.pop();
            ll rem=cur.second;
            ll num=cur.first;
            vis[rem]=num;
            rem=((rem*10)%n+7)%n;
            if(vis[rem]==0)
            {
                q.push({num+1,rem});
            }
        }

        if(vis[0]==0) cout << "-1" << "\n";
        else
        {
           cout << vis[0] << endl;
        }
        
 
    
}






Measured memory_bytes: 11452
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        List<Integer>[] islands = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            islands[i] = new ArrayList<>();
        }

        for (int i = 0; i < m; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            islands[a].add(b);
            islands[b].add(a);
        }
        
        for (List<Integer> island : islands) {
            if (island.contains(0) && island.contains(n - 1)) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}


Measured memory_bytes: 135876
n = int(input())
if n == 1:
    print(1)
    exit()
if n == 2:
    print(3)
    exit()
n *= 2
ans = n*2

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        return float("INF")
    else:
        return x % m
def calc(b1,m1,b2,m2):
    p = modinv(m1,m2)
    if p == float("INF"):
        return float("INF")
    tmp = (b2-b1)*p%m2
    m = m1*m2
    tmp = (b2-b1)*p%m2
    r = (b1+m1*tmp)%m
    return r

for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        ans = min(ans,calc(0,i,n//i-1,n//i))
        if i != 1:
            ans = min(ans,calc(0,n//i,i-1,i))
print(ans)

Measured memory_bytes: 69832
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__

	ll N, K;
	cin >> N >> K;
	VI A(N);
	REP(i, N)cin >> A[i];

	ll ans = 0;

	REP(i, N)REP(j, N) {
		if (i < j && A[i] > A[j]) {
			ans = (ans % MOD + K) % MOD;
		}
		if (A[i] > A[j]) {
			ans = (ans % MOD + ((K * (K - 1)) / 2) % MOD) % MOD;
		}
		ans %= MOD;
	}

	cout << ans % MOD << endl;







	return 0;
}


Measured memory_bytes: 3532
#include<cstdio>
#include<ctime>

#define gec     getchar
#define FILE(F) freopen(F".in","r",stdin),freopen(F".out","w",stdout)
#define RunTime fprintf(stderr,"Running Time:%.5lfs\n",1.*clock()/1e6)

typedef long long ll;
typedef long double lb;
template<typename T>void umin(T &x,T y){if(x>y)x=y;}
template<typename T> T min(T x,T y){return x<y?x:y;}
template<typename T>void umax(T &x,T y){if(x<y)x=y;}
template<typename T> T max(T x,T y){return x>y?x:y;}
template<typename T>
inline void read(T &x)
{
	x=0;bool f=0; char c=gec();
	for(;c<'0'||c>'9';c=gec())f=(c=='-');
	for(;c>='0'&&c<='9';c=gec())x=x*10+c-'0';
	x=f?-x:x;
}

namespace DEBUG{
inline void fpr(char *c){fprintf(stderr,"%s\n",c);}
inline void fpr(int    x,char *c){fprintf(stderr,"[ %s ] : = %d   \n",c,x);}
inline void fpr(ll     x,char *c){fprintf(stderr,"[ %s ] : = %lld \n",c,x);}
inline void fpr(double x,char *c){fprintf(stderr,"[ %s ] : = %.5lf\n",c,x);}
inline void fpr(lb     x,char *c){fprintf(stderr,"[ %s ] : = %.5Lf\n",c,x);} 
}using namespace DEBUG;

const int MAXN(200010);
int n;
ll S[MAXN];
ll ABS(ll x){return x<0?-x:x;}
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
	{
		read(S[i]);
		S[i]+=S[i-1];
	}
	ll Ans=0x7fffffffffffffff;
	for(int i=1;i<n;i++)
		umin(Ans,ABS(S[n]-S[i]-S[i]));
	printf("%lld\n",Ans);
	return 0;
}	

Measured memory_bytes: 1664
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

long long int ps(long long int x , long long int n){
    if(n==0) return 1;
    if(n==1) return x ;
    if(n%2) return ((x* ps(x,n-1)));
    else {
        long long int z=ps(x,n/2);
        return (z*z) ;
    }
}

bool ssort(const pair<int,int> &a,
              const pair<int,int>  &b)
{
    return (a.first < b.first);
}
bool ssort3(const pair<int,int> &a,
              const pair<int,int>  &b)
{
    if(a.first == b.first) return (a.second < b.second);
    return (a.first < b.first);
}

long long int a,b,c,d,n;
string s,t;
#define mo 998244353

#define pair<int , int > pi

int main()
{
    IOS;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy";
    else if(s=="Cloudy") cout << "Rainy";
    else if(s=="Rainy") cout << "Sunny";



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int x,y,z; cin>>x>>y>>z;
    x-=z;
    cout<<x/(y+z)<<endl;
}

Measured memory_bytes: 3628
public class Main {

  private static void solve() {
    int n = ni();

    n = n % 10;

    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
      System.out.println("hon");
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
      System.out.println("pon");
    } else {
      System.out.println("bon");
    }

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

int main() {
  char S;
  cin >> S;

  // ここにプログラムを追記
  if (S == 'a') {
    cout << "vowel" << endl;
  }
  else if (S == 'i') {
    cout << "vowel" << endl;
  }
  else if (S == 'u') {
    cout << "vowel" << endl;
  }
  else if (S == 'e') {
    cout << "vowel" << endl;
  }
  else if (S == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    s=[]
    for i in range(m):
        ss=[int(_) for _ in input().split()]
        s.append(ss[1:])
    P=[int(_) for _ in input().split()]
    ans=0
    for j in range(2**n):
        i=0#i桁目が1ならi番目を使う
        nn=j#nn=1010110
        Q=[0]*m #onになってる数
        while nn>0:
            if ((nn&1)==1):
                for x,ss in enumerate(s):
                    if i+1 in ss:
                        Q[x]+=1
            nn>>=1
            i+=1
        for x,q in enumerate(Q):
            if q%2!=P[x]:
                break
        else:
            ans+=1
    print(ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 41328
import collections

class UnionFind():
    """
        unionfindtree のクラス
            グループを管理するデータ構造.
            全てのメソッドの計算量が O(log(n)) よりも小さい
        init: 管理対象の個数 n を用いて初期化
        find: ある要素 x の親がどの要素か返す
        union: ある要素 x と y が属しているグループを結合して1つのグループとする
        msize: ある要素 x が属するグループの大きさを返す
    """
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        self.rank = [0]*n
        self.size = [1]*n

    def find(self, x):
        """
            ある要素 x の親の要素を見つけるメソッド
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        """
            ある要素 x, y の属するグループを結合するメソッド
            x と y のランク(子の数)の小さい方が結合先の親となる
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def msize(self, x):
        """
            ある要素 x の属するグループの大きさを返すメソッド
        """
        return self.size[self.find(x)]

def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1; B -= 1
        uf.union(A, B)
    ans = collections.Counter(uf.parents)[-1] - 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 13628
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<algorithm>
#include<bitset>
#include<utility>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	vector<ll>a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll cur=0;
	for (int i=0;i<n;i++)
		cur=a[i]-cur;
	vector<ll>ans(n);
	ans[0]=cur/2;
	for(int i=1;i<n;i++)
		ans[i]=a[i-1]-ans[i-1];
	for(int i=0;i<n;i++)
		cout<<2LL*ans[i]<<" \n"[i==n-1];
	return 0;
}


Measured memory_bytes: 2816
while True:
    a, l = map(int, input().split())
    if a == l == 0:
        break
    calced = {}
    zfill = ("{0:0%dd}" % l).format
    cnt = 0
    while True:
        if calced.get(a) == None:
            calced[a] = cnt
        else:
            # print(calced, a, cnt)
            print(calced[a], a, cnt - calced[a])
            break
        sorted_decimal = sorted(zfill(a))
        # print(int("".join(sorted_decimal)))
        # print(int("".join(sorted_decimal[::-1])))
        a = int("".join(sorted_decimal[::-1])) - int("".join(sorted_decimal))
        cnt += 1

Measured memory_bytes: 7580
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,k; cin>>n>>k;
    ll sum = 0;
    vector<ll> a(n);
    rep(i,n) cin>>a[i], sum+=a[i];

    set<ll> div;
    for (int i = 1; i*i <= sum; ++i) {
        if (sum%i == 0) {
            div.insert(i); div.insert(sum/i);
        }
    }

    auto check = [&] () {
        ll ans = 0;
        for (auto &&e: div) {
            vector<ll> tmp,tnp;
            rep(i,n) {
                if (a[i]%e) {
                    tmp.push_back(a[i]%e);
                    tnp.push_back(e-(a[i]%e));
                }
            }

            sort(tmp.begin(), tmp.end());
            sort(tnp.begin(), tnp.end(), greater<>());
            vector<ll> smp(tmp.size()+1), snp(tnp.size()+1);
            rep(i,tmp.size()) smp[i+1] += smp[i]+tmp[i];
            for (int i = tnp.size(); i > 0; --i) snp[i-1] += snp[i]+tnp[i-1];

            rep(i,smp.size()) if (smp[i]==snp[i]) {
                if (smp[i] <= k) {
                    chmax(ans,e);
                    break;
                }
            }
        }
        return ans;
    };

    cout << check() << '\n';

    return 0;
}

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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

int a, b;

int gcd(int a, int b)
{
   int t; // 補助変数
   while (b != 0)
   { // 他方が0になるまで
      t = a % b;
      a = b;
      b = t; // 一方を剰余に置き換える
   }
   return a; // 他方が0になったときの一方がGCD
}

int coprime(int a, int b)
{
   return (gcd(a, b) == 1);
}

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

   int n, cnt = 0, ans = 0;
   cin >> n;
   vector<int> x, y;

   rep(i, n)
   {
      cin >> a;
      x.push_back(a);
   }

   sort(all(x));

   for (int i = 1; i < n; ++i)
   {
      if (x[i] == x[i - 1])
      {
         cout << "NO" << '\n';
         return 0;
      }
   }
   cout << "YES" << '\n';
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int k,x;
	cin >> k >> x;

	for(int i = x-k+1 ; i <= x+k-1; i++){
		cout << i;
		cout << (i == x+k-1 ? '\n' : ' ');
	}

	return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

vi merge(const vi& a,const vi& us,const vi& vs)
{
	vi res;
	for(int i=0,j=0;i<us.size()||j<vs.size();){
		if(i<us.size()&&j<vs.size())
			res.push_back(a[us[i]]>=a[vs[j]]?us[i++]:vs[j++]);
		else if(i<us.size())
			res.push_back(us[i++]);
		else
			res.push_back(vs[j++]);
	}
	return res;
}

vi dfs(const vvi& g,const vi& a,int u,vi& vis)
{
	vis[u]=1;
	vi res;
	for(int v:g[u]) if(!vis[v])
		res=merge(a,res,dfs(g,a,v,vis));
	res.insert(begin(res),u);
	return res;
}

int main()
{
	for(int n;cin>>n&&n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		sort(all(a));
		vvi g(n);
		rep(i,n) repi(j,i+1,n) if(__gcd(a[i],a[j])!=1){
			g[i].push_back(j);
			g[j].push_back(i);
		}
		vi vis(n),res;
		rep(i,n) if(!vis[i])
			res=merge(a,res,dfs(g,a,i,vis));
		rep(i,n) cout<<a[res[i]]<<" \n"[i==n-1];
	}
}


Measured memory_bytes: 17920
sa = input().rstrip()
sb = input().rstrip()
sc = input().rstrip()

sa = sa.replace('a','0').replace('b','1').replace('c','2')
sb = sb.replace('a','0').replace('b','1').replace('c','2')
sc = sc.replace('a','0').replace('b','1').replace('c','2')

dD = {0:[sa,-1],1:[sb,-1],2:[sc,-1]}
dR ={0:"A",1:"B",2:"C"}
def travace(i):
    iNext = int(dD[i][0][dD[i][1]])
    if len(dD[i][0]) - 1 == dD[i][1]:
        return i
    else:
        dD[i][1] += 1
        return travace(iNext)
print(dR[travace(0)])


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

// SegmentTree
template<typename T>
class SegTree{
public:
    int n;
    T defaultValue;
    vector<T> dat;

    SegTree(int m, T value){
        n = 1;
        while(n < m){
            n *= 2;
        }
        dat.assign(2 * n - 1, value);
        defaultValue = value;
    }

    void update(int i, T value){
        i += n - 1;
        dat[i] += value;
        while(i > 0){
            i = (i - 1) / 2;
            dat[i] = ope(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }

    T query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0){
            r = n;
        }

        if(r <= a || b <= l){
            return defaultValue;
        }
        if(a <= l && r <= b){
            return dat[k];
        }
        else{
            T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return ope(vl, vr);
        }
    }

private:
    T ope(T a, T b){
        return a + b;
    }
};

int main(){

    int n, q;
    cin >> n >> q;

    SegTree<int> segTree(n, 0);

    for(int i = 0; i < q; i++){
        int com, x, y;
        cin >> com >> x >> y;
        if(com == 0){
            segTree.update(x - 1, y);
        }
        else{
            cout << segTree.query(x - 1, y) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int ans=0;
    rep(i,n-1){
        if(s[i]!=s[i+1])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
import collections
import sys
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    H_list = list(map(int,input().split()))
    ab_list = [list(map(int,input().split())) for _ in range(M)]

    ab_dict = {i: [] for i in range(N)}
    for a,b in ab_list:
        a,b = a-1,b-1
        ab_dict[a].append(b)
        ab_dict[b].append(a)

    c = collections.Counter(H_list)

    # print(H_list)
    # print(ab_dict)
    ans = 0
    for k,v_list in ab_dict.items():
        for v in v_list:
            if H_list[v] >= H_list[k]:
                break
        else:ans += 1
    print(ans)

main()


Measured memory_bytes: 65452
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


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


def llmi(n):
    return [lmi() for _ in range(n)]

N  =int(input())
print(len(collections.Counter([input() for _ in range(N)])))

Measured memory_bytes: 38844
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var d = S.Select(c => (int)(c - '0')).ToArray();
		
		int cnt = 0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					
					int cc = 0;
					int[] a = new int[]{i,j,k};
					for(int t=0;t<N;t++){
						if(d[t] == a[cc]){
							cc++;
							if(cc == 3) break;
						}
					}
					if(cc == 3) cnt++;
					
				}
			}
		}
		
		Console.WriteLine(cnt);
		
		
		
	}
	int N;
	String S;
	public Sol(){
		N = ri();
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using ll = long long;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

int N;

string W[102];

int main() {
  cin.tie(0);cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>N;
  
  rep(i, N)cin>>W[i];
  
  for_(i, 1, N) {
  	rep(j, i) {
  		if(W[i] == W[j]) {
  			cout<<"No"<<endl;
  			return 0;
  		}
  	}
  	if(W[i-1].back() != W[i].front()) {
  		cout<<"No"<<endl;
  		return 0;
  	}
  }
  
  cout<<"Yes"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define ll long long

struct Egn{
	ll X, Y;
	double angle;
	Egn(ll inputtedX, ll inputtedY){
		X=inputtedX, Y=inputtedY;
		if(X==0 && Y==0) angle=0.0;
		else angle=atan2(Y, X);
	}
	bool operator<(const Egn &a){
		return angle < a.angle;
	}
};

int main() {
	int N;
	std::cin >> N;
	std::vector<Egn> p;
	for(int i=0; i<N; ++i){
		ll x, y;
		std::cin >> x >> y;
		p.push_back(Egn(x, y));
	}
	std::sort(p.begin(), p.end());
	double mx=0.0;
	for(int i=0; i<N; ++i){
		ll nx=0, ny=0;
		for(int j=0; j<N; ++j){
			nx += p[(i+j)%N].X;
			ny += p[(i+j)%N].Y;
			mx=std::max(mx, pow(nx*nx+ny*ny, 0.5));
		}
	}
	std::cout << std::setprecision(20) << mx << std::endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

bool f(string& s, int src, int dst){
    vector<bool> reaches(s.size());
    reaches[src]=true;
    for(int i=src+1; i<=dst; ++i){
        if(s[i]=='#') reaches[i]=false;
        else reaches[i]=((i-1 >= src) && reaches[i-1]) || ((i-2 >= src) && reaches[i-2]);
    }
    return reaches[dst];
}

int main(){
    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    --a; --b; --c; --d;
    string s; cin >> s;
    bool has_space=false;
    int space_len=0;
    for(int i=b; i<=d; ++i){
        if(s[i]=='.') ++space_len;
        else{
            if(space_len>=3) break;
            else space_len=0;
        }

    }
    if(space_len>=3)
        has_space=true;
    if(s[d-1]=='.' && d+1<n && s[d+1]=='.') has_space=true;
    if(1 <= b && s[b-1]=='.' && s[b+1]=='.') has_space=true;

    bool ans;
    if(d<c)
        ans=has_space && f(s, a, c) && f(s, b, d);
    else
        ans=f(s, a, c) && f(s, b, d);
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,dp[100009],a[100009],mx=1e9+8;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
    {
        dp[i]=mx;
    }
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
        dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
    }
    cout<<dp[n-1];
}


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

vector<ll>visited;
int main(){
  ll N ,K;
  cin >> N >> K ;
  ll A[N];
  rep(i,N) cin >> A[i];

  vector<ll> place;
  vector<ll> visited(N+1,-1);
  int c = 1, l = 0;
  {
    int v = 1;
    while(visited[v] == -1){
      visited[v] = place.size();
      place.push_back(v);
      v = A[v-1];
    }
    c = place.size() - visited[v];
    l = visited[v];
  }

  if(K < l) cout << place[K] << endl;
  else {
    K -= l;
    K %= c;
    cout << place[K+l];
  }
  return 0;
}


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


int main() {

    int a, b;
    cin >> a >> b;
    if (a >= 13) cout << b << endl;
    else if (6 <= a && a <= 12) cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int scc(const VV<>& g, V<>& comp) {
  int n = g.size();
  VV<> rg(n);
  for (int v = 0; v < n; v++) for (int w : g[v]) {
    rg[w].push_back(v);
  }
  V<> vs;
  V<bool> vis(n);
  comp.resize(n);
  auto dfs = [&](const auto& dfs, int v) -> void {
    vis[v] = true;
    for (int w : g[v]) if (!vis[w]) {
      dfs(dfs, w);
    }
    vs.push_back(v);
  };
  auto rdfs = [&](const auto& rdfs, int v, int k) -> void {
    vis[v] = true;
    comp[v] = k;
    for (int w : rg[v]) if (!vis[w]) {
      rdfs(rdfs, w, k);
    }
  };
  for (int v = 0; v < n; v++) if (!vis[v]) {
    dfs(dfs, v);
  }
  vis.assign(n, false);
  int k = 0;
  reverse(begin(vs), end(vs));
  for (int v : vs) if (!vis[v]) {
    rdfs(rdfs, v, k++);
  }
  return k;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  int t = 0;
  VV<> id(n, V<>(n));
  for (int i = 0; i < n; ++i) for (int j = 0; j < i; ++j) {
    id[i][j] = id[j][i] = t++;
  }
  assert(t == n * (n - 1) / 2);
  VV<> g(t);
  for (int i = 0; i < n; ++i) {
    V<> a(n - 1); for (auto&& e : a) cin >> e, --e;
    for (int j = 0; j < n - 2; ++j) {
      g[id[i][a[j]]].push_back(id[i][a[j + 1]]);
    }
  }
  V<> comp;
  int k = scc(g, comp);
  if (k < t) return cout << -1 << '\n', 0;
  V<> idx(t);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) { return comp[i] < comp[j]; });
  V<> dp(t);
  for (int i : idx) {
    for (int j : g[i]) {
      dp[j] = max(dp[j], dp[i] + 1);
    }
  }
  cout << *max_element(begin(dp), end(dp)) + 1 << '\n';
}

Measured memory_bytes: 63092
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
vector<ll> Nkai(200005);


ll Nk(ll n) {
	if (n == 1) {
		Nkai.at(1) = 1;
		return 1;
	}

	if (n == 0) { Nkai.at(0) = 0; return 0; }
	
	else {
		ll nw = 0;
		ll k = n;
		while(k > 0) {
			nw += k % 2;
			k /= 2;
		}
		Nkai.at(n) = Nk(n%nw) + 1;
		return Nkai.at(n);
	}
}




int main() {
	for (long long i = 0; i < (long long)(200005); i++) {
		Nkai.at(i) = -1;
	}
	ll N;
	string X;
	cin >> N >> X;
	vector<ll> x(N);
	vector<ll> a(N);
	ll wa = 0;



	
	rep(i, N) {
		x.at(i) = int(X.at(i) - '0');
		wa += x.at(i);
	}
	if (wa == 0) {
		rep(i, N) { cout << 1 << endl; }
		return 0;
	}

	ll wap = wa + 1;
	ll wam = wa - 1;
	vector<ll> WAP(N);
	vector<ll> WAM(N);
	ll waps = 0;
	ll wams = 0;
	WAP.at(0) = 1;
	if (wam > 0) {
		WAM.at(0) = 1 % wam;
	}
	
	rep(i, N-1) {
		WAP.at(i+1) = (2*WAP.at(i))%wap;
		if (wam > 0) {
			WAM.at(i + 1) = (2 * WAM.at(i)) % wam;
		}
		
	}
	rep(i, N) {
		if (x.at(i) == 1) {
			waps += WAP.at(N - 1 - i);
			if (wam > 0) {
				wams += WAM.at(N - 1 - i);
			}
		}
	}
	rep(i, N) {
		if (x.at(i) == 1) {
			if (wam > 0) {
				a.at(i) = (wams - WAM.at(N - 1 - i)) % wam;
			}
			else {
				a.at(i) = -1;
			}

		}
		else {
			a.at(i) = (waps + WAP.at(N - 1 - i)) % wap;
			
		}
	}
	
	rep(i, N) {
		if (a.at(i) == -1) {
			cout << 0 << endl;
		}
		else {
			cout << Nk(a.at(i)) + 1 << endl;
		}
	}
	



	
}



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

using namespace std;

int main()
{
  int a, b, c, x, y, ans = 1000000001;

  scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

  int ab = c * 2;

  for (int i = 0; i <= 100000; i++)
  {
    ans = min(ans, ab * i + a * max(0, x - i) + b * max(0, y - i));
  }

  printf("%d", ans);
}

Measured memory_bytes: 256
n = gets.to_s.to_i
s = gets.to_s.chomp.chars

ans = s.count('R') * s.count('G') * s.count('B')
n.times do |i|
  t = 1
  while i + 2 * t < n
    j = i + t
    k = j + t
    ans -= 1 if s[i] != s[j] && s[j] != s[k] && s[i] != s[k]
    t += 1
  end
end

puts ans

Measured memory_bytes: 14340
/**
  * @file pd.cpp
  * @brief atcoder

  *

  * @author yao
  * @date 2018-10-27
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#define N 512
#define ft first
#define sd second
#define INF ((int)1e9)
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#endif //DBG

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int count(int n)
{
    int res = 1;
    while( res*(res-1)/2 < n ) ++res;
    return res*(res-1)/2 == n ? res : -1;
}

int ans[N][N], nans[N];

int main()
{
    int n;
    scanf("%d",&n);
    int k = count(n);
    if( k == -1 ) return puts("No"), 0;
    puts("Yes");
    printf("%d\n",k);
    int cnt = 1;
    for(int i=0;i<k;++i)
    {
        for(int j=i+1;j<k;++j)
        {
            ans[i][nans[i]++] = cnt;
            ans[j][nans[j]++] = cnt;
            ++cnt;
        }
    }
    for(int i=0;i<k;++i)
    {
        printf("%d", nans[i]);
        for(int j=0;j<nans[i];++j)
            printf(" %d", ans[i][j]);
        printf("\n");
    }
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    double ans = v[0];
    for(int i=1;i<n;i++){
        ans = (ans+v[i])/2;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define for(a,n) for(int i = int(a); i<int(n); i++)
#define ll long long

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes";
    else
        cout<<"No";












    return 0;
}


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


int main() {
  long x,n;
  cin>>x>>n;
  vector<long>a(n);
  vector<bool>b(111);
  rep(i,n){
    cin>>a.at(i);
    b[a.at(i)]=true;
  }
  int ans=0;
  int sa=110-x;
  for (int i = 110; i >=0; i--){
    if(!b[i]){
      if(sa>=abs(x-i)){
        ans=i;
        sa=abs(x-i);
      }
    }
  }
  
  
  cout<<ans<<endl;
}



Measured memory_bytes: 3628
s = int(input())
a = []

a.append(s)
i = 1

while True:
    prev = a[i-1]
    if prev % 2 == 0:
        a.append(prev / 2)
    else:
        a.append(3 * prev + 1)

    if a.count(a[i]) > 1:
        print(i+1)
        break
    else:
        i += 1


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
string s,a;
int main() {
	ios::sync_with_stdio(false);
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == '0')
			a += '0';
		if(s[i] == '1')
			a += '1';
		if(s[i] == 'B' && a.size())
			a.erase(a.size() - 1,1);
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= 5) cout << 0 << endl;
	else if (a < 13) cout << b / 2 << endl;
	else cout << b << endl;
}


Measured memory_bytes: 892
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        boolean test = true;
        
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<N-1; i++){
            if(a[i] == a[i+1]){
                test = false;
            }
        }
        if(test){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 61348