akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main(){

  int n,i,j,min,flag=1,sum=0;
  char c1[36];
  int  c2[36];
  char babble1[36];
  int  babble2[36];
  char esc1;
  int  esc2;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf(" %c%d",&c1[i],&c2[i]);

  for(i=0;i<n;i++){
    babble1[i]=c1[i];
    babble2[i]=c2[i];
  }

  if(n==1){
    printf("%c%d\nStable\n",c1[0],c2[0]);
    printf("%c%d\nStable\n",c1[0],c2[0]);
  }

  if(n!=1){
    //start babble

    while(flag){
      flag=0;

      for(j=n-1;j>=1;j--){
	if(babble2[j] < babble2[j-1]){
	  esc1=babble1[j-1];
	  esc2=babble2[j-1];
	  babble1[j-1]=babble1[j];
	  babble2[j-1]=babble2[j];
	  babble1[j]=esc1;
	  babble2[j]=esc2;

	  flag=1;
	}
      }
    }	
    for(i=0;i<n;i++){
      printf("%c%d",babble1[i],babble2[i]);
      if(i==n-1) break;
      printf(" ");
    }

    printf("\nStable\n");  //end babble

    //start select

    for(i=0;i<n-1;i++){
      min=i;
      for(j=i+1;j<n;j++){
	if(c2[j]<c2[min]){
	  min=j;
	}
      }
      if(i==min) continue;
      esc1=c1[i];
      esc2=c2[i];
      c1[i]=c1[min];
      c2[i]=c2[min];
      c1[min]=esc1;
      c2[min]=esc2;
    }
    for(i=0;i<n;i++){
      printf("%c%d",c1[i],c2[i]);
      if( !((c1[i]==babble1[i]) && (c2[i]==babble2[i]))) sum++;
      if(i==n-1) break;
      printf(" ");
    }

    if(sum==0) printf("\nStable\n");
    else       printf("\nNot stable\n");

    //end select
  }
  return 0;
}

Measured memory_bytes: 612
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int H = nextInt(), W = nextInt();
        grid = new char[H][W];
        numOfWays = new int[H][W];
        seen = new boolean[H][W];
        for (int i = 0; i < H; i++) grid[i] = next().toCharArray();

        System.out.println(calcWays(0, 0));
    }

    private static char[][] grid;
    private static int[][] numOfWays;
    private static boolean[][] seen;

    private static int calcWays(int r, int c) {
        if (seen[r][c]) return numOfWays[r][c];
        seen[r][c] = true;
        if (grid[r][c] == '#') return 0;
        if (r == grid.length - 1 && c == grid[0].length - 1) {
            numOfWays[r][c] = 1;
            return 1;
        }
        int ways = 0;
        if (r + 1 < grid.length) ways += calcWays(r + 1, c);
        if (c + 1 < grid[0].length) ways += calcWays(r, c + 1);

        numOfWays[r][c] = ways % 1000000007;
        return numOfWays[r][c];
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 35972
#include<iostream>

using namespace std;

int main()

{
    int n,a[100];

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--){
        cout<<a[i];
        if(i>0) cout<<' ';
        else
        {
            cout<<'\n';
        }
        
    }
}


Measured memory_bytes: 3092
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n, m, x;
bool a[101];

int main() {
    fastio();

    cin >> n >> m >> x;
    forn(i, m) {
        int b;
        cin >> b;
        a[b] = true;
    }

    int ans1 = 0;
    for (int i = x + 1; i <= n; i++) {
        if (a[i]) ans1++;
    }

    int ans2 = 0;
    for (int i = x - 1; i >= 0; i--) {
        if (a[i]) ans2++;
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int m = 61;
int n;
vector<bitset<m>> gaussian_elimination(vector<bitset<m>> b) {
  vector<bitset<m>> c(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) c[i][j] = b[i][m - 1 - j];
  }
  int x = 0;
  for (int i = 0; i < n && x < m; i++, x++) {
    int pivot = -1;
    for (int j = i; j < n; j++) {
      if (c[j][x]) {
        pivot = j;
        break;
      }
    }
    if (pivot == -1) {
      i--;
      continue;
    }
    swap(c[pivot], c[i]);
    for (int j = i + 1; j < n; j++) {
      if (c[j][x]) c[j] ^= c[i];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) b[i][j] = c[i][m - 1 - j];
  }
  return b;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  vector<long long> a(n);
  vector<bitset<m>> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = bitset<m>(a[i]);
  }
  long long x = 0;
  for (int j = 0; j < m; j++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      cnt += b[i][j];
    }
    if (cnt % 2 == 0) continue;
    x += 1LL << j;
    for (int i = 0; i < n; i++) {
      b[i][j] = 0;
    }
  }
  b = gaussian_elimination(b);
  bitset<m> y;
  for (int j = m - 1; j >= 0; j--) {
    for (int i = 0; i < n; i++) {
      if (b[i][j] && y.to_ullong() < (y ^ b[i]).to_ullong()) {
        y ^= b[i];
        break;
      }
    }
  }
  cout << x + ((y.to_ullong()) << 1) << endl;
  return 0;
}

Measured memory_bytes: 3456
import java.util.Scanner;

/**
 *
 * @author k16069kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int count = 0;
        
        for (int i = a; i <= b; i++) {
            if(c%i == 0) count++;
        }
        System.out.println(count);
    }
    
}



Measured memory_bytes: 26268
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<int> v1[100005];
vector<int> path[100005];
bool used[100005];
LL num[100005];
int pa[100005];
LL s=0;
LL n,m;

void create_path(int a){
	if(used[a])return;
	used[a]=true;
	int b;
	for(int i=0;i<v1[a].size();i++){
		b=v1[a][i];
		if(used[b])continue;
		path[a].push_back(b);
		pa[b]=a;
		create_path(b);
	}
}
int check(int a){
	if(m-num[pa[a]]<=0)return -1;
	s*=m-num[pa[a]];
	//cout<<a<<" "<<num[pa[a]]<<endl;
	if(s>=MAX)s%=MAX;
	num[pa[a]]++,num[a]++;
	for(int i=0;i<path[a].size();i++){
		num[path[a][i]]++;
		if(check(path[a][i])==-1)return -1;
	}
	return 0;
}

int main(){
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<n-1;i++){
		cin>>a>>b;
		a--,b--;
		v1[a].push_back(b);
		v1[b].push_back(a);
	}
	create_path(0);
	s=m,num[0]++;
	for(i=0;i<path[0].size();i++){
		num[path[0][i]]++;
		if(check(path[0][i])){
			s=0;break;
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 17152
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,M;
    cin >> N >> M;
    auto H = InputVec(N);
    auto G = InputGraph(N,M);
    ll count = 0;
    for (int i = 0; i < N; ++i) {
        bool judge = true;
        for (int j = 0; j < G[i].size(); ++j) {
            if(H[i] > H[G[i][j]]){
                continue;
            }
            judge = false;
        }
        if(judge){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 9864
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/abc145/tasks/abc145_e
# E - All-you-can-eat
"""
DP1[i][j] =the maximum sum of deliciousness of dishes, which are chosen from 1st- to i-th dishes,
such that he can finish them in j minutes

still WA!!!

"""
t1 = gi()
t2 = gi()
a1 = gi()
a2 = gi()
b1 = gi()
b2 = gi()

if a1 < b1:
    a1, b1 = b1, a1
    a2, b2 = b2, a2

#print(a1, a2, b1, b2)

d1 = (a1 - b1) * t1
d2 = (a2 - b2) * t2

net = d1 + d2


def run():
    if d1 == 0 or net == 0:
        print('infinity')
        return
    elif net > 0:
        print(0)
        return

    d = abs(net)

    ans = 0
    p2 = (d1 // d)
    if (d1 % d == 0):
        ans = 2 * p2
    else:
        ans = 2 * p2 + 1

    print(ans)


run()


Measured memory_bytes: 13292
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <math.h>
#define ll long long;

using namespace std;
int n;
int x[100];
int y[100];
int z[100];
int man;
double eu;
double th;
int che;

int manh(int z[]) {
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += z[i];
	}
	return sum;
}

double euk(int z[]) {
	int ss = 0;
	for (int i = 0; i < n; i++) {
		ss += z[i] * z[i];
	}
	return (double)sqrt(ss);
}

double thr(int z[]) {
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += z[i] * z[i] * z[i];
	}
	return pow(sum, 1.0 / 3.0);
}

int cheb(int  z[]) {
	int max;
	max = z[0];
	for (int i = 0; i < n; i++) {
		if (max < z[i]) max = z[i];
	}
	return max;
}


int main() {
	

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	for (int i = 0; i < n; i++) {
		cin >> y[i];
		z[i] = abs(x[i] - y[i]);
	}

	man = manh(z);
	eu = euk(z);
	che = cheb(z);
	th = thr(z);

	printf("%d\n", man);
	printf("%.8f\n", eu);
	printf("%.8f\n", th);
	printf("%d\n", che);
}

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

int main(){
  string s;
  cin>>s;
  map<char,int> st;
  for(auto i:s)st[i]++;
  auto it = st.begin();
  if(st.size()==2 && it->second==2){
    cout<<"Yes"<<endl;
  }else{
     cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using ull = unsigned long long;

ll n;

// 扩展欧几里得算法
template<class T>
T ExGcd(T a, T b, T &x, T &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    T d = ExGcd(b, a % b, y, x);
    y -= a / b * x;
    return d;  // gcd
}

ll a[5], m[5];

ll mul(ll x, ll y, ll P) {
    return (x * y - (ll) (x / (long double) P * y + 1e-3) * P + P) % P;
}

template<class T>
bool CRT(T &a0, T &m0, T a[], T m[], int k) {
    T x, y;
    a0 = a[0], m0 = m[0];
    for (int i = 1; i < k; i++) {
        T C = a[i] - a0;
        T g = ExGcd(m0, m[i], x, y);
        if (abs(C) % g != 0) return 0;
        T Mod = m[i] / g;
        x = (mul(x, (C / g), Mod) + Mod) % Mod;
        //这里上面的x*(C/g)在某些特殊情况可能需要改成mul(x,C/g,Mod)
        a0 += m0 * x;  // 余数累加
        m0 *= Mod;     // m0 = m1*m2*...*mk
        if (a0 <= 0)
            a0 += m0;
        else
            a0 %= m0;
    }
    return 1;
}

bool test2(ll ans) {
    return mul(ans % n, (ans + 1) % n, n) % n == 0;
}

ll test(ll x, ll y) {
    m[0] = x, m[1] = y;
    a[0] = 0, a[1] = -1;
    ll ans, M;
    if (CRT(ans, M, a, m, 2)) {
        //printf("%lld %lld %lld\n", x, y, ans);
        return ans;
    }
    return numeric_limits<long long>::max();
}


int main() {
    //cin.sync_with_stdio(0);
#ifdef trote
    freopen("../1.txt", "r", stdin);
    //freopen("../2.txt", "w", stdout);
    auto bg = clock();
#endif
    scanf("%lld", &n);
    n *= 2;
    vector<ll> v;
    for (int i = 1; (ll) i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            v.push_back(n / i);
        }
    }
    sort(all(v));
    v.erase(unique(all(v)), end(v));
    ll ans = numeric_limits<long long>::max();
    for (auto &x:v) {
        auto y = n / x;
        ans = min(ans, test(x, y));
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3856
import java.util.Scanner;
public class Main {

			public static void main(String[]args) {
			
				Scanner sc = new Scanner(System.in);
				int n = sc.nextInt();
				int a = sc.nextInt();
				int b = sc.nextInt();
				
				int max = 0;
				int min = 0;
				
				if(a>b) max = b; else max = a;
				if(n>(a+b)) min = 0; else min = (a+b)-n;
				
				System.out.println(max+  " "+ min);
				
				
			}
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;
const lli INF = 1ll << 63;

lli a,b,k;
lli x;
vll ans;

int main(){
  cin >> a >> b >> k;
  for(x = 0;x <= a && x <= b;){
    x++;
    while(x <= a && x <= b && (a%x != 0 || b%x != 0)) x++;
    if(x > a || x > b) break;
    ans.push_back(x);
  }
  cout << ans[ans.size()-k] << endl;

}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 1000000000000000000
#define N 1000000007
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

//try thinking from a different angle after spending some time
//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
	speed
	//global var
	int ans=1;
	for (int i = 1; i < 6; ++i)
	{
		int tmp;cin>>tmp;
		if(tmp==0){ans=i;}
	}
	cout<<ans<<"\n";
}

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

int main()
{
  int bingo[3][3];
  rep(i, 3) cin >> bingo[i][0];
  rep(i, 3) cin >> bingo[i][1];
  rep(i, 3) cin >> bingo[i][2];
  bool open[3][3];
  rep(i, 3)
  {
    rep(j, 3) open[i][j] = false;
  }
  int n;
  cin >> n;
  rep(i, n)
  {
    int b;
    cin >> b;
    rep(j, 3)
    {
      rep(k, 3) if (bingo[j][k] == b) open[j][k] = true;
    }
  }
  rep(i, 3)
  {
    if (open[i][0] && open[i][1] && open[i][2])
    {
      cout << "Yes" << endl;
      return 0;
    }
    if (open[0][i] && open[1][i] && open[2][i])
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (open[0][0] && open[1][1] && open[2][2])
  {
    cout << "Yes" << endl;
    return 0;
  }
  if (open[2][0] && open[1][1] && open[0][2])
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

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

  for (int i = 0 ; i < b + 2 ; i++){
    cout << "#";
  }
  cout << endl;

  for (int V = 0 ; V < a ; V++){
  vector<char> VL(b);
   cout << "#";
    for ( int VB = 0 ; VB < b ; VB++){
      cin >> VL.at(VB);
      cout << VL.at(VB);
    }
   cout << "#" << endl;
  }
  for (int i = 0 ; i < b + 2 ; i++){
    cout << "#";
  }
  cout << endl;   
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)

N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    edge[x-1].append(y-1)
dp = [-1]*N

def calc(x):
    if dp[x]!=-1:
        return dp[x]
    if not len(edge[x]):
        dp[x] = 0
        return 0
    dp[x] = max([calc(i) for i in edge[x]])+1
    return dp[x]

ans = 0
for i in range(N):
    ans = max(ans, calc(i))
print(ans)

Measured memory_bytes: 115612
N,M=map(int,input().split())
L=[list(map(int,input().split()))[1:] for _ in range(M)]
P=list(map(int,input().split()))
ans=0
for i in range(2**N):
  lit=[0]*M
  for j,switch in enumerate(L):
    cnt=0
    for s in switch:
      if i>>(s-1)&1:
        cnt+=1
    if cnt%2==P[j]:
      lit[j]=True
    else:
      lit[j]=False
  if all(lit): ans+=1 
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<int> v (100001, 0);
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		v[t]++;
	}

	int res = 0;
	if (n % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}

	int count = 0;
	for (int i = 1; i <= 100000; i++) {
		count += v[i];

		if (count == n / 2) {
			i++;
			while (v[i] == 0 && i <= 100000) {
				res++;
				i++;
			}
			res++;
			cout << res << endl;
			return 0;
		}
	}
	cout << 0 << endl;

}














Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int i,j,k,n,c=0;
    vector<int> v;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        int q; cin>>q; v.push_back(q);
    }
    sort(v.begin(),v.end());
    for(i=0;i<k;i++)
    {
        c=c+v[i];
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  int n;
  int i,j,k;
  int count[5][4][11]={{{}}};
  cin >> n;
  int b,f,r,v;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    count[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	cout << " ";
	cout << count[i][j][k];
      }
      cout << endl;
    }
    if(i<3)cout << "####################" << endl;
  }
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, k, ans=0;

	cin>> n >> k;

	ans=n-k;

	cout<< (ans+k-2)/(k-1)+1 << endl;
 
	return 0;
}

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


int main(){

string st;
string ss;
int n[5]={},np[5]={};
int x=0,y=0;

while(1){
cin>>st>>ss;
if(st=="0"&&ss=="0")break;
for(int i=0;i<4;i++)
{
n[i]=st[i]-'0';np[i]=ss[i]-'0';
}

for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
{if(n[i]==np[j]&&i==j)x++;
else if(n[i]==np[j]&&i!=j)y++;
}

cout<<x<<" "<<y<<endl;
x=0;y=0;
}
return 0;
}

Measured memory_bytes: 1184
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);

    let mut islands1 = vec![false;n];
    let mut islands2 = vec![false;n];

    for _ in 0..m{
        let line = read_as_vec::<usize>();
        let (s, e) = (line[0]-1, line[1]-1);
        if s == 0{
            islands1[e] = true;
        }else if e == 0{
            islands1[s] = true;
        }else if s == n-1{
            islands2[e] = true;
        }else if e == n-1{
            islands2[s] = true;
        }
    }

    for i in 0..n{
        if islands1[i] && islands2[i]{
            println!("POSSIBLE");
            return;
        }
    }

    println!("IMPOSSIBLE");

}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
/*
forテ」ツδォテ」ツδシテ」ツδ療」ツつжhileテ」ツδォテ」ツδシテ」ツδ療」ツつ津、ツスツソテ」ツつ湘」ツ?ェテ」ツ??
ifテ」ツ?ィテ・ツ崢崚・ツ可?ヲツシツ氾ァツョツ療」ツ?ョテ」ツ?ソテ」ツ?ョテヲツ鳴ケテヲツウツ?
*/


int main(void){

	int L, A, B, C, D;
	// char ;

	scanf("%d %d %d %d %d", &L, &A, &B, &C, &D);

	int hoge = (A / C);
	int huga = (B / D);
	if (hoge * C != A) hoge++;
	if (huga * D != B) huga++;
	int day = hoge;
	if (hoge < huga) day = huga;

	printf("%d\n", L - day);

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
//typedef pair<ll, ll> p_ll;
//typedef vector<pair<ll, ll>> vec_p;

/*const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;*/


int main()
{
    ll A,h,m,s;

    cin >> A;
    h = A / 3600;
    s = A % 60;
    m = (A - 3600 * h - s) / 60;

    cout << h << ":" << m << ":"<< s << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int main() {
	long long n, p;

	cin >> n >> p;

	long long a = pow(p, (1.0/n)) + 1;
	
	for (; a >= 1; a--) {
		if (p % (long long)pow(a, n) == 0) break;
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
//mp.reserve(1024);
//mp.max_load_factor(0.25);
bool sortinrev(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return (a.first > b.first);
}

int main()
{
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
    ll H,W,k;
    cin>>H>>W>>k;
    string s[H];
    ll cnt=0;
    for(ll i =0;i<H;i++){
		cin>>s[i];
		for(ll j=0;j<W;j++){
			if(s[i][j]=='#')
				cnt++;
		}
	}
	ll ans = 0;
	for(ll i =0;i<(1ll<<H) ;i++){
		for(ll j=0;j<(1ll<<W);j++){
			ll curr=0;
			for(ll z=0;z<H;z++){
				for(ll y=0;y<W;y++){
					if(((i>>z)&1)==0 &&((j>>y)&1)==0&&s[z][y]=='#')
						curr++;
				}
			}
			if(curr == k)
				ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (max(a, b) < 2 * min(a, b) ? "Yay!" : ":(") << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, H, max = 0, ans = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &H);
		if (H >= max) {
			ans++;
			max = H;
		}
	}
	printf("%d\n", ans);	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n,m,ret;
int edge[64];

void bt(int pos,int cur,int cnt){
	if(cnt >= ret) return;
	if(cur == (1ll<< n)-1 ){
		ret = cnt;
		return;
	}
	if(pos == n)return;
	bt(pos+1,cur|edge[pos],cnt+1);
	bt(pos+1,cur,cnt);
}
int main(){
	while(cin >> n >> m ,n){
		rep(i,n)edge[i] = (1<<i);
		rep(i,m){
			int a, b;
			cin >> a >> b;
			edge[a] |= (1<<b);
			edge[b] |= (1<<a);
		}
		ret = 99;
		bt(0,0,0);
		cout << ret << endl;
	}
}

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

int cnt[10];
bool check(int x) {
  while(x) {
    if(cnt[x%10]) return false;
    x /= 10;
  }
  return true;
}

int main() {
  int N, K;
  cin >> N >> K;
  while(K--) {
    int a;
    cin >> a;
    cnt[a] = 1;
  }

  for(int i = N; i <= 99999; i++)
    if(check(i)) {
      cout << i;
      return 0;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<int> treeone(N);
        for (int i = 0; i < N; ++i) {
            cin >> treeone[i];
        }
        int highestTreeone = *max_element(all(treeone));

        int ans = 0;
        for (int i = 0; i < highestTreeone; ++i) {
            ll tmp = treeone[0] > 0;
            int state = treeone[0];
            for (int j = 1; j < N; ++j) {
                if (state == 0) {
                    if (treeone[j] > 0) {
                        state = treeone[j];
                        tmp++;
                    } else {

                    }
                } else {
                    if (treeone[j] > 0) {

                    } else {
                        state = 0;
                    }
                }
            }
            ans += tmp;
            for (int j = 0; j < N; ++j) {
                if (treeone[j] > 0) treeone[j]--;
            }
        }
        cout << ans << endl;


    }
};


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

    Solve().solve();


    return 0;
}


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

namespace CSharpSample01
{


    class Program
    {

        

        static void Main(string[] args)
        {

            int[] data = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = data[0];
            int M = data[1];
            int X = data[2];

            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            if (X == N && X == 0) Console.WriteLine(0);

            var dic = new Dictionary<int, int>();
            for(int i = 0; i < M; i++)
            {
                dic[A[i]] = 1;
            }

            int cost1 = 0;
            int cost2 = 0;

            for (int i = X; i <= N; i++)
            {
                if (dic.ContainsKey(i)) cost1++;
            }

            for(int i = X; i >= 0; i--)
            {
                if (dic.ContainsKey(i)) cost2++;
            }

            Console.WriteLine(Math.Min(cost1, cost2));


        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> G(H);
  for(int i=0; i<H; i++){
    cin >> G[i];
  }
  queue<P> que;
  que.push(make_pair(0,0));
  vector<vector<int>> dist(H, vector<int> (W,-1));
  dist[0][0] = 1;
  while(que.size()){
    P v = que.front();
    que.pop();
    for(int i=0; i<4; i++){
      int ny = v.first + dy[i];
      int nx = v.second + dx[i];
      if(ny<0 || ny>=H || nx<0 || nx>=W) continue;
      if(dist[ny][nx] != -1) continue;
      if(G[ny][nx] == '#')continue;
      dist[ny][nx] = dist[v.first][v.second] + 1;
      que.push(make_pair(ny,nx));
    }
  }
  int cnt = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(G[i][j] != '#') cnt++;
    }
  }
  if(dist[H-1][W-1] == -1){
    cout << -1 << endl;
  }else{
    cout << cnt - dist[H-1][W-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	//static final int size = 1000000003;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
//		long[] bis = new long[size];
//		for(int i = 0; i<size; i++)bis[i]=0;
		long now=1;
		long next=0;
		long future=0;
		long exchange = B-A;
//		bis[0]=1;
		//int yen = 0;
		for(int i = 0; i<K; i++) {
//			bis[i+1]=Math.max(bis[i+1],bis[i]+1);
//			if(bis[i]>=A)bis[i+2]=Math.max(bis[i+2],bis[i]+exchange);

			next = Math.max(next,now+1);
			if(now>=A)future = Math.max(future, now+exchange);

			now = next;
			next = future;
			future = 0;

		}
		System.out.println(now);
	}

}


Measured memory_bytes: 23892
n, k = map(int, input().split())
ans = 0

for i in range(k - 1, n + 1):
    ans += ((i + 1)*(n + n - i)//2)
for i in range(k - 1, n + 1):
    ans -= (i + 1)*i//2
ans += n + 2 - k
print(ans%(10**9 + 7))

Measured memory_bytes: 9136
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

fn main() {
    input! {
        n: usize, k: usize,
        mut a: [usize; n],
    }

    a.sort_by_key(|&v| Reverse(v));

    let mut ng = 0;
    let mut ok = a[0];
    'out: while ok - ng > 1 {
        let mid = (ok + ng) / 2;
        let mut count = 0;
        for &v in &a {
            count += (v + mid - 1) / mid - 1;
            if count > k {
                ng = mid;
                continue 'out;
            }
        }
        ok = mid;
    }
    println!("{}", ok);
}


Measured memory_bytes: 6132
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]
ans = 0
for r in range(1<<H):
    for c in range(1<<W):
        k = 0
        for h in range(H):
            if (r>>h)&1: continue
            for w in range(W):
                if (c>>w)&1: continue
                if C[h][w]=='#': k+=1
        if k==K: ans+=1
        
print(ans)


Measured memory_bytes: 9184
import re
n=int(input())
A=[]
for i in range(n):
    B=["."]*n
    for x,y in [list(map(int,input().split())) for k in range(int(input()))]:
        B[x-1]=str(y)
    A.append("".join(B))

ans=0
for i in range(2**n):
    num=format(i,"b").zfill(n)
    cnt,flag=0,1
    for k,j in enumerate(num):
        result=re.search(r"".join(A[k]),num)
        if result!=None and j=="1":
            cnt +=1
        elif (result!=None and j=="0") or (result==None and j=="1"):
            flag=0
            break
    if flag:ans=max(ans,cnt)
print(ans)

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

int main()
{
  int a,i;
  int64_t L[87]={0};
  L[0]=2;
  L[1]=1;
  
  cin >> a;
  for(i=2;i<=a;i++)
  {
    L[i]=L[i-1]+L[i-2];
  }
  cout << L[a];
  
  return 0;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    ll n;
    cin >> n;

    if(n==0) {
        cout << 0 << endl;
        return 0;
    }

    ll div = -2;
    ll tmp_quo, tmp_mod;
    stack<ll> S;
    while(n!=0) {
        tmp_quo = n / div;
        tmp_mod = abs(n%div)/abs(div/-2);
        S.push(tmp_mod);
        n -= tmp_mod*(div/-2);
        div *= -2;
    }

    ll ans;
    while(!S.empty()) {
        ans = S.top(); S.pop();
        cout << ans;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var s = sc.next();
		sc.close();

		if (s.endsWith("s")) {
			s += "es";
		} else {
			s += "s";
		}
		System.out.println(s);
	}
}


Measured memory_bytes: 38512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int D, G;
int Min = 9999999;
int count = 0;

// q 問題のペア
// check その問題を使ったか
// k 何問目を使ってるか
// puls その問題を足すか
// rest 残りの点数
// count 何問解いたか

//どういう順番で足すかだから高々10!=3628800<O(10^6)
void calc(vector<pair<int, int>> q, vector<bool> check, int k, int rest,
          int count) {
  if (k != -1) {
    check[k] = true;
    if(q[k].first*(k+1)*100+q[k].second < rest){
      count += q[k].first;
      rest -= q[k].first*(k+1)*100+q[k].second;
    }
    else{
      for (int i = 0; i < q[k].first; i++) {  //高々100回
        rest -= (k + 1) * 100;
        count++;
        if (i == q[k].first - 1) {
          rest -= q[k].second;
        }
        if (rest <= 0) {
          if (Min > count) {
            Min = count;
          }
          return;
        }
      }
    }
  }
  for (int i = 0; i < D; i++) {
    if (!check[i]) {
      calc(q, check, i, rest, count);
    }
  }
}

// All green
int main() {
  cin >> D >> G;
  vector<pair<int, int>> q;
  for (int i = 0; i < D; i++) {
    int a, b;
    cin >> a >> b;
    pair<int, int> p = make_pair(a, b);
    q.push_back(p);
  }
  vector<bool> check(D, false);
  calc(q, check, -1, G, 0);
  cout << Min << endl;
}

Measured memory_bytes: 256
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll x;
    cin>>n>>x;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    if(v[0]>x){
        sum=v[0]-x;
        v[0]=x;
    }
    for(ll i=1;i<n;i++){
        if(v[i]+v[i-1]>x){
        sum+=v[i-1]+v[i]-x;
        v[i]=x-v[i-1];
        }
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

void dfs(const vector<vector<ll>> & graph, vector<bool>& visited, const ll start, ll node, const pair<ll,ll> pair)
{
    visited[node] = true;
    for(size_t i=0;i<graph[node].size(); i++)
    {
        if(visited[graph[node][i]]) continue;
        if((pair.first == node && pair.second == graph[node][i])
        || (pair.second == node && pair.first == graph[node][i])) continue;
        dfs(graph, visited, start, graph[node][i], pair);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N,M;
    cin >> N >> M;
    vector<vector<ll>> graph(N);
    long a, b;
    vector<pair<ll,ll>> edge(M);
    for(size_t i=0;i<M; i++)
    {
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
        edge[i] = make_pair(a-1, b-1);
    }
    ll count=0;
    for(size_t i=0;i<M; i++)
    {
        vector<bool> visited(N, false);
        dfs(graph, visited, 0, 0, edge[i]);
        for(auto i : visited) if(!i){count++;break;}
    }
    cout << count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

template<typename T>
struct PotentializedUnionFind{
private:
private:
    std::vector<int> par;
    std::vector<int> size;
    std::vector<T> diff;
public:
    PotentializedUnionFind(int n){
        par.resize(n);
        std::iota(par.begin(),par.end(),0);
        size.resize(n);
        std::iota(size.begin(),size.end(),0);
        diff.assign(n,0);
    }

    int root(int x){
        if(par[x]==x){
            return x;
        }
        else{
            int r=root(par[x]);
            diff[x]+=diff[par[x]];
            return par[x]=r;
        }
    }

    T potential(int x){
        root(x);
        return diff[x];
    }

    T potential_diff(int x,int y){
        return potential(y)-potential(x);
    }

    bool same(int x,int y){//0-indexed
        return root(x)==root(y);
    }

    bool unite(int x,int y,T w){//0-indexed,potential(y)-potential(x)=w
        w+=potential(x);
        w-=potential(y);

        if(root(x)==root(y)){
            return potential_diff(x,root(x))==potential_diff(y,root(y));
        }
        x=root(x);
        y=root(y);
        if(size[x]<size[y]){
            par[x]=y;
            size[y]+=size[x];
            diff[x]=-w;
        }
        else{
            par[y]=x;
            size[x]+=size[y];
            diff[y]=w;
        }
        return true;
    }
};

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> G(n,vector<int>(n,-1));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            char c;
            cin>>c;
            G[i][j]=c-'0';
        }
    }
    int ans=-1;
    for (int st = 0; st < n; ++st) {
        queue<pair<int,int>> q;
        q.push(make_pair(st,1));
        vector<int> gr(n,-1);
        gr[st]=1;
        while(!q.empty()){
            auto t=q.front();
            q.pop();
            for (int i = 0; i < n; ++i) {
                if(G[t.first][i]==1){
                    if(gr[i]==-1){
                        q.push(make_pair(i,t.second+1));
                        gr[i]=t.second+1;
                    }
                    else{
                        if(gr[i]+1==t.second||gr[i]-1==t.second)continue;
                        else goto next;
                    }
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                ans=max(ans,gr[i]-gr[j]+1);
            }
        }
        next:;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, k; cin >> n >> k;
	int ans = k * pow(k - 1, n - 1);
	cout << ans << endl;
}

Measured memory_bytes: 764
#include<stdio.h>
int main(void)
{
	int x[12],i,j,flg,y;
	for(i=0;i<12;i++)  scanf("%d",&x[i]);
	for(i=0;i<12;i++){
		for(j=i+1;j<12;j++){
			if(x[i]>x[j]){
				y=x[i];
				x[i]=x[j];
				x[j]=y;
			}
		}
	}
	flg=0;
	for(i=0;i<12;i+=4){
		for(j=i+1;j<i+4;j++){
			if(x[i]!=x[j]){
				flg=1;
			}
		}
	}
	if(flg==1){
		printf("no\n");
	}
	else{
		printf("yes\n");
	}
	return 0;
}
		


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

using namespace std;

typedef long long ll;

const int MAX_M=20000;

ll N, M;
ll cost[1011][1011];

int main(){
        cin>>N>>M;
        for(int i=1;i<=N;i++){
                for(int j=1;j<=N;j++){
                        if(i==j){
                                cost[i][j]=0;
                        }
                        else{
                                cost[i][j]=-1000000000000000;
                        }
                }
        }
        for(int i=0;i<M;i++){
                ll from, to, cst;
                cin>>from>>to>>cst;
                cost[from][to]=cst;
        }

        for(ll k=1;k<=N;k++){
                for(ll i=1;i<=N;i++){
                        for(ll j=1;j<=N;j++){
                                cost[i][j]=max(cost[i][j], cost[i][k]+cost[k][j]);
                        }
                }
        }
        if(cost[1][1]>0){
                cout<<"inf"<<endl;
        }
        else{
                cout<<cost[1][N]<<endl;
        }
        return 0;
}


Measured memory_bytes: 8192
import * as fs from 'fs';

const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).split('\n');

const [a, b, c] = input[0].split(' ').map((x: string): number => +x);

if(a===b && b===c){
    console.log('No');
}else if(a!==b && a!==c && b!==c){
    console.log('No');
}else{
    console.log('Yes');
}

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

set <int> S;
vector <vector <int>> adj(51);
int n;
vector <int> a, b;
bool mark[51];

void DFS(int v){
	mark[v] = true;
	for (auto u: adj[v]){
		if (!(mark[u])){
			DFS(u);
		}
	}
}

bool check_set(){
	for (int i = 0; i <= 50; i++){
		adj[i].clear();
		for (auto s: S){
			adj[i].push_back(i % s);
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= 50; j++)
			mark[j] = false;
		DFS(a[i]);
		if (!(mark[b[i]]))
			return false;
	}
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 0; i < n; i++){
		cin >> b[i];
	}
	for (int i = 1; i <= 50; i++){
		S.insert(i);
	}
	// cout << 1 << endl;
	if (!check_set()){
		cout << -1;
		return 0;
	}
	// cout << 2 << endl;
	long long ans = 0;
	for (int i = 50; i >= 1; i--){
		S.erase(i);
		if (!check_set()){
			S.insert(i);
			ans += powl(2, i);
		}
		// cout << i << endl;
	}
	cout << ans;
}

Measured memory_bytes: 512