akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 10000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : b;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	cin >> n;
	vector<P> a(n);
	rep(i, n){
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	
	sort(a.begin(), a.end());
	rep(i, n){
		cout << a[i].second << " ";
	}
	cout << endl;
	
	return 0;
}



Measured memory_bytes: 1536
#include<stdio.h>
int main(void)
{
	char N[3];
	for (int i = 0; i < 3; i++) {
		scanf("%c", &N[i]);
	}
	if (N[0] == N[2]) {
		printf("Yes");
	}
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
k, n = list(map(int, input().split()))
houses = list(map(int, input().split()))
distance = 0
for i in range(n):
  if i == n-1:
    tmp = abs(houses[0] - houses[i])
  else:
    tmp = abs(houses[i] - houses[i+1])
  tmp = min(tmp, k - tmp)
  if tmp > distance:
    distance = tmp
print(k - distance)

Measured memory_bytes: 26444
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define rep(i, j) for(int i = 0; i < (j); i++)
using namespace std;

bool visit[51][2501][2501] = {};

int main(){
    int n; cin >> n;
    vector<int> t(n);
    int allsum = 0;
    rep(i, n){
        cin>>t[i];
        allsum += t[i];
    }
    int ans = 1 << 30;
    visit[0][0][0] = true;
    rep(i, n){
        rep(j, allsum){
            rep(k, allsum){
                if(visit[i][j][k] and j + t[i] <= allsum and k + t[i] <= allsum){
                    visit[i+1][j+t[i]][k] = true;
                    visit[i+1][j][k+t[i]] = true;
                    visit[i+1][j][k] = true;
                }
            }
        }
    }
    rep(j, allsum){
        rep(k, allsum){
            if(visit[n][j][k]) ans = min(ans, max({j, k, allsum - j - k}));
        }
    }

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

Measured memory_bytes: 116972
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

ans = 0
l = list(set(s))
for i in range(len(l)):
    ans = max(ans,  max(0, s.count(l[i]) - t.count(l[i])))
print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, d[101], count=0;
	
	cin >> N;
	
	for(int i=0; i<N; i++)
		cin >> d[i];
	
	sort(d, d+N, greater<int>());
	
	for(int i=0; i<N; i++){
		if(d[i] != d[i+1])
			count++;
	}
	
	cout << count;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i,ans=0;
	string s;
	cin >> n >> s;
	for(i=2; i<n; ++i){
		if(s[i-2]=='A' && s[i-1]=='B' && s[i] == 'C'){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n{0};
    cin>>n;
 
    ll arr[n];
    for(ll i=0;i<n;i++)
    	cin>>arr[i];
 
    ll money=1000;
  
    for(ll i=1;i<n;i++){
    	if(arr[i]>arr[i-1]){
        	ll stocks=money/arr[i-1];
            money=(money%arr[i-1])+(stocks*arr[i]);
    	}
    }
 
    cout<<money<<endl;
 
	return 0;
}

Measured memory_bytes: 3636
N = int(input())


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

    # divisors.sort()
    return divisors


C = set(make_divisors(N) + make_divisors(N-1))
C.discard(1)


def f(x, k):
    if x % k == 0:
        return x//k
    else:
        return x % k


ans = 0
for i in C:
    x = N
    c = 0
    while x >= i:
        c += 1
        x = f(x, i)
    if x == 1:
        ans += 1

print(ans)


Measured memory_bytes: 82008
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    A = [NLI() for _ in range(3)]
    N = NI()
    B = [NI() for _ in range(N)]
    hit = [[0]*3 for _ in range(3)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if b == A[i][j]:
                    hit[i][j] = 1

    for h in hit:
        if sum(h) == 3:
            print("Yes")
            exit()
    for j in range(3):
        if hit[0][j] + hit[1][j] + hit[2][j] == 3:
            print("Yes")
            exit()
    if hit[0][2] + hit[1][1] + hit[2][0] == 3:
        print("Yes")
        exit()
    if hit[0][0] + hit[1][1] + hit[2][2] == 3:
        print("Yes")
        exit()
    print("No")



if __name__ == "__main__":
    main()

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

bool isSq(int a){
  bool ok = false;
  for (int i=1; i<=a; i++){
    if (a==i*i) return true;
    if (i*i>a) break;
  }
  return false;
}

int main() {
  int n,d; cin >>n >>d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i=0; i<n; i++){
    for (int j=0; j<d; j++){
      cin >>x.at(i).at(j);
    }
  }
  int ans = 0;
  int dis;
  
  for (int i=0; i<n-1; i++){
    for (int j=i+1; j<n; j++){
      dis = 0;
      for (int k=0; k<d; k++){
        dis += (x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
      }
      if (isSq(dis)) ans++;
    }
  }
  
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static String s = "";

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String ans = "No";

		//Aをとる
		int[][] A = new int[3][3];
		for(int i=0; i<3; i++) {
			for(int j=0; j<3; j++) {
				A[i][j] = sc.nextInt();
			}
		}

		//N
		int N = sc.nextInt();

		//b
		int[] b = new int[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextInt();
		}

		//穴をあける
		for(int i=0; i<3; i++) {
			for(int j=0; j<3; j++) {
				for(int k=0; k<N; k++) {
					if(A[i][j] == b[k])
						A[i][j] = 0;
				}
			}
		}

		//ビンゴか確認
		//横一列
		for(int i=0; i<3; i++) {
			if(A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0)
				ans = "Yes";
		}

		for(int j=0; j<3; j++) {
			if(A[0][j] == 0 && A[1][j] == 0 && A[2][j] == 0)
				ans = "Yes";
		}

		if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0)
			ans = "Yes";
		if(A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0)
			ans = "Yes";

		System.out.println(ans);

	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[9][9],n;
  cin >> n;
  bool f,did=false; 
  while(n--){
    if(did)cout << endl;
    f=true;
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
        cin >> a[i][j];
      }
    }
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
        f=true;
        for(int k=0;k<9;k++){//横
          if(a[i][j]==a[i][k] and j!=k){
            cout << "*" << a[i][j];
            f=false;
            break;
          }
        }
        if(f){
          for(int k=0;k<9;k++){//縦
            if(a[i][j]==a[k][j] and i!=k){
              cout << "*" << a[i][j];
              f=false;
              break;
            }
          }
        }
        if(f){
          for(int ii=0;ii<9;ii++){//箱
            if(ii/3==i/3){
              for(int jj=0;jj<9;jj++){
                if(jj/3==j/3){
                  if(a[i][j]==a[ii][jj] and (i!=ii or j!=jj)){
                    cout << "*" << a[i][j];
                    f=false;
                  }
                }
                if(!f)break;
              }
            }
            if(!f)break;
          }
        }
        if(f){
          cout << " " << a[i][j];
        }
      }
      cout << endl;
    }
    did=true;
  }
  return 0;
}


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

#define X first
#define Y second
typedef long long ll;
typedef pair<ll,ll> pll;

ll n;

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);
    
    cin >> n;
    ll ans = n * (n - 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
N,x = map(int,input().split())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)

arrA.sort()
ans = 0
flg = True
for i in range(N):
    if arrA[i]<=x:
        x -= arrA[i]
        ans += 1
    else:
        flg = False

# print(flg,x)
if flg and x>0:
    print(ans-1)
elif flg and x == 0:
    print(ans)
elif not flg and x==0:
    print(ans)
else:
    print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
cnt = 0

while True:
  for i in range(N):
    if A[i] % 2 == 0 and i != N-1:
      A[i] //= 2
    elif A[i] % 2 == 0 and i == N-1:
      A[i] //= 2
      cnt += 1
    else:
      print(cnt)
      exit()

Measured memory_bytes: 3064
import heapq
from collections import defaultdict

INF = float('inf')


V, E = map(int, input().split())
Adj_list = defaultdict(set)

for i in range(E):
    s, t, w = map(int, input().split())
    Adj_list[s].add((t, w))
    Adj_list[t].add((s, w))
    
def prim(x):
    d = [INF] * x
    d[0] = 0
    isVisited = [False] * x
    hq = [(0,0)] 
    
    while hq:
        u = heapq.heappop(hq)[1]
        isVisited[u] = True
        
        for v, c in Adj_list[u]:
            if not isVisited[v] and d[v] > c:
                d[v] = c
                heapq.heappush(hq, (c, v))
    return sum(d)

print(prim(V))
    

Measured memory_bytes: 46232
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i, n){
		cin>>v[i];
		v[i]--;
	}
	int cnt = 0;
	rep(i, n){
		if(v[i]==i){
			cnt++;
			if(i<n-1) swap(v[i], v[i+1]);
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 640
/*********বিসমিল্লাহির রাহমানির রাহিম**********/

#include <bits/stdc++.h>
#define ll long long
#define PI 2 * acos(0)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 200000
#define MOD 1e7
#define all(x) (x).begin(), (x).end()
using namespace std;
/*................OMI.................*/

vector<ll> prime;
bool isPrime(ll n)
{
   if (n <= 1)
      return false;
   if (n <= 3)
      return true;

   if (n % 2 == 0 || n % 3 == 0)
      return false;

   for (ll i = 5; i * i <= n; i = i + 2)
      if (n % i == 0)
         return false;

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

ll lcm(ll a, ll b)
{
   ll g = gcd(a, b);
   ll ans = (a * b) / g;
   return ans;
}
void primes(ll m)
{
   bool isprime[m];

   for (int i = 0; i <= m; i++)
      isprime[i] = true;

   for (int i = 3; i * i <= m; i++)
   {
      if (isprime[i])
      {

         for (int j = i * i; j <= m; j += i)
            isprime[j] = false;
      }
   }
   prime.push_back(2);
   for (int i = 3; i <= m; i += 2)
      if (isprime[i])
         prime.push_back(i);
}

/************MAIN_FUNCTION***********/

int main(int argc, char *argv[])
{

   FAST;
   double r;

   cin>>r;

   cout<<setprecision(23);
   cout<<2*PI*r<<endl;

   return 0;
}

Measured memory_bytes: 3828
S=int(input())
leng=len(str(S))

bin(2**leng-1)
ans=0
if leng==1:
    print(S)
    exit()
for i in range(2**(leng-1)):
    bid=bin(2**(leng-1)+i)
    start=0
    for j in range(3,len(str(bid))):
        if bid[j]=='1':
            ans+=int(str(S)[start:j-2])
            start=j-2
        if j==len(str(bid))-1:
            ans+=int(str(S)[start:j-1])
print(ans)

Measured memory_bytes: 9212
s = str(input())
S = [int(s[i]) for i in range(len(s))]
K = int(input())
ans = 1
count = 0
for i in range(min(len(S),K)):
    if S[i] != 1 and count == 0:
        ans = S[i]
        count += 1
        break
print(ans)

Measured memory_bytes: 38256
#include <stdio.h>
int main() {
    long int n, i, max, min, sum = 0;
    int data[10000];
    scanf ("%ld", &n);
    for(i = 0; i < n; i++) scanf("%d", &data[i]);
    max = data[0];
    min = data[0];
    for(i = 0; i < n; i++) {
        sum += data[i];
        if(max < data[i]) max = data[i];
        if(min > data[i]) min = data[i];
    }
    printf("%ld %ld %ld", min, max, sum);
    printf("\n");
    return 0;
}

Measured memory_bytes: 1892
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 200005
#define mod 1000000007
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
ll n,m;
int main(){
	n=read(); m=read();
	if ((m/2)<n) return printf("%lld",m/2)&0;
	printf("%lld",n+(m-2*n)/4);
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    int diff1 = b-a,diff2 = c-b;
    bool f = false;
    if(abs(c-a)<=d)f = true;
    if(abs(b-a)<=d && abs(c-b<=d))f = true;
    cout<<(f?"Yes":"No");
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ff first
#define ss second
const ll mod = 1e9 + 7 ;
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
///////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////
void solve( ){
    ll h ;
    cin >> h ;
    ll ans = 1 ;
    ll p = 1 ;
    while(h!=1){
        ans += powl(2,p);
        p++;
        h/=2;
    }
    cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test_case=1 ;
    //cin >> test_case ;
    for( int i = 1 ; i <= test_case ; i++){
        solve( );
    }
}


Measured memory_bytes: 512
import java.io.*;
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if((a < b) && (b < c)){
                System.out.println("Yes");
            } else{
                System.out.println("No");
            }
    } 
}


Measured memory_bytes: 26160
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

ll x[maxn], y[maxn];
ll a[maxn], b[maxn];

ll sum(ll n) {
    return n * (n + 1) / 2 % Mod;
}

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%lld", &x[i]);
    for (int i = 1; i <= m; i++) scanf("%lld", &y[i]);
    for (int i = 1; i < n; i++) a[i] = (x[i + 1] - x[i] + Mod) % Mod;
    for (int i = 1; i < m; i++) b[i] = (y[i + 1] - y[i] + Mod) % Mod;
    n--, m--;
    ll X = 0, Y = 0;
    for (int i = 1; i <= n; i++) {
        ll cnt = sum(n) - sum(i - 1) - sum(n - i);
        cnt %= Mod;
        cnt = (cnt + Mod) % Mod;
        ll delta = cnt * a[i] % Mod;
        X = (X + delta) % Mod;
    }
    for (int i = 1; i <= m; i++) {
        ll cnt = sum(m) - sum(i - 1) - sum(m - i);
        cnt %= Mod;
        cnt = (cnt + Mod) % Mod;
        ll delta = cnt * b[i] % Mod;
        Y = (Y + delta) % Mod;
    }
    ll ans = X * Y % Mod;
    printf("%lld\n", ans);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    int N;
    cin >> N;
    set<string> st;

    for(int now=0; now < (1<<N)/2; ++now) {
        string s = "a";
        REP(k,N-1) {
            if((1 << k) & now) s.push_back('b');
            else s.push_back('a');
        }
        st.insert(s);
    }
    for (const auto &it: st) {
        cout << it << endl;
    }
}

void solve2() {
    int N;
    cin >> N;
    queue<string> q;
    set<string> ans;
    q.push("a");
    while (!q.empty()) {
        string s = q.front(); q.pop();
        if (s.size() == N) ans.insert(s);
        else {
            auto c = *max_element(ALL(s));
            FOR(i,(int)'a',min((int)c+2,(int)'z'+1)) {
                string cs = {(char)i};
                // cerr << s+cs << endl;
                q.push(s+cs);
            }
        }
    }
    for(const auto &it: ans) cout << it << endl;
}

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


Measured memory_bytes: 14208
def main():
		import sys
		read = sys.stdin.buffer.read
		readline = sys.stdin.buffer.readline
		from fractions import gcd
		
		class SegmentTree:
		    def __init__(self, N, func, I):
		        self.sz = N
		        self.func = func
		        self.I = I
		        self.seg = [I for i in range(self.sz * 2)]
		 
		    def assign(self, k, x):
		        self.seg[k + self.sz] = x
		 
		    def build(self):
		        for i in range(self.sz - 1, 0, -1):
		            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
		 
		    def update(self, k, x):
		        k += self.sz
		        self.seg[k] = x
		        while k > 1:
		            k //= 2
		            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
		 
		    def query(self, a, b):
		        R = self.I
		        a += self.sz
		        b += self.sz
		        while a < b:
		            if a % 2 == 1:
		                R = self.func(R, self.seg[a])
		                a += 1
		            if b % 2 == 1:
		                b -= 1
		                R = self.func(self.seg[b], R)
		            a //= 2
		            b //= 2
		        return R
		      
		N = int(readline())
		m = map(int,read().split())
		seg = SegmentTree(N , gcd , 0)
		for i in range(N):
		    seg.assign(i , next(m))
		seg.build()
		ans = 1
		for i in range(N):
		    ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
		print(ans)

main()

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

int main(){
    int N;
    cin >> N;

    bool four = false;
    for(int i = 0; i < N; ++i){
        char S;
        cin >> S;
        if(S == 'Y') four = true;
    }
    cout << (four ? "Four" : "Three") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

#define vowel(n) cout << ((n) ? "vowel" : "consonant"  ) << endl
bool chk(str s)
{
    if(s=="a"||s=="e"||s=="i"||s=="o"||s=="u"){
        return true;
    }else{
        return false;
    }
}

int main()
{
    char s[100],t[100],u[100];
    in(s);in(t);in(u);
    cout << "A" << t[0] << "C" << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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


int main(){
    double x1,x2,x3,y1,y2,y3,xp,yp;
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
        double d1 = (x2-x1)*(yp-y1) - (xp-x1)*(y2-y1);
        double d2 = (x3-x2)*(yp-y2) - (xp-x2)*(y3-y2);
        double d3 = (x1-x3)*(yp-y3) - (xp-x3)*(y1-y3);
        if (( d1<0 && d2<0 && d3<0 ) || ( d1>0 && d2>0 && d3>0 )) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 3180
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
const ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

vvll g;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m;
  cin >> n >> m;
  g.resize(n);
  vll u(m), v(m);
  rep(i, m){
    cin >> u[i] >> v[i];
    u[i]--, v[i]--;
    g[u[i]].emplace_back(v[i]);
    g[v[i]].emplace_back(u[i]);
  }
  vi visited(n, 0);
  auto dfs = [&](auto& Self, int node, int color) -> void{
    visited[node] = color;
    for(auto&& e: g[node]){
      if(visited[e] == color){
        print(n*(n-1)/2-m);
        exit(0);
      }
      if(!visited[e]){
        Self(Self, e, 3-color);
      }
    }
  };
  dfs(dfs, 0, 1);
  ll c[2] = {0};
  rep(i, n){
    c[visited[i]-1]++;
  }
  print(c[0]*c[1]-m);
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-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;
}
const ll mod = 1e9 + 7;

ll modpow(ll p,ll q){
    if(q == 0) return 1;
    if(q%2 == 0){
        ll x = modpow(p,q/2);
        return x*x%mod;
    }else{
        return modpow(p,q-1)*p%mod;
    }
}


int main(void){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    vector<ll> kai(n+1);
    kai[0] = 1;
    rep(i,n){
        kai[i+1] = kai[i]*(i+1)%mod;
    }
    rep(i,min(n,k+1)){
        ll mul1 = kai[n]*kai[n-1]%mod;
        ll mul2 = (kai[n-i]*kai[n-i-1]%mod)*(kai[i]*kai[i]%mod)%mod;
        ans += mul1*modpow(mul2,mod-2)%mod;
        ans %= mod;
    }

    cout << ans << endl;

    
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	
	if(A<B) cout<<"<"<<endl;
	if(A>B) cout<<">"<<endl;
	if(A==B) cout<<"="<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int x; cin >> x;
    cout << 10-x/200 << '\n';
    
    
    return 0;
}


Measured memory_bytes: 3636
import math
def koch(d, p1, p2):
    if d == 0:
        return
    
    v = [p2[0] - p1[0], p2[1] - p1[1]]
    s = [p1[0] + v[0] / 3, p1[1] + v[1] / 3]
    t = [p1[0] + 2 * v[0] / 3, p1[1] + 2 * v[1] / 3]
    u = [p1[0] + v[0] / 2 - v[1] * math.sqrt(3) / 6, p1[1] + v[1] / 2 + v[0] * math.sqrt(3) / 6]

    koch(d - 1, p1, s)
    print(" ".join(map(str, s)))
    koch(d - 1, s, u)
    print(" ".join(map(str, u)))
    koch(d - 1, u, t)
    print(" ".join(map(str, t)))
    koch(d - 1, t, p2)

n = int(input())
print("0 0")
koch(n, [0, 0], [100, 0])
print("100 0")


Measured memory_bytes: 5716
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x) std::sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

itn main() {
	std::ios::sync_with_stdio(false);

	string n;

	cin >> n;

	if (n[0] == n[2]) {
		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 < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc172/abc172_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S, T;
  cin >> S >> T;

  int N = S.size();
  ll ans = 0;
  rep(i, N) {
    if (S[i] != T[i]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3868
#include<iostream>
#include<string>

int main(){
    int N;
    std::cin >> N;

    char A[N+1], B[N+1], C[N+1];
    std::cin >> A;
    std::cin >> B;
    std::cin >> C;

    int c = 0;

    for (int i=0; i<N; i++) {
        if (A[i] == B[i] && B[i] == C[i]) {
            continue;
        }
        if (A[i] == B[i] ||  B[i] == C[i] || C[i] == A[i]) {
            c++;
            continue;
        }
        c += 2;
    }

    std::cout << c << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner (System.in);
    int B[]=new int[9];
    for(int i=0;i<9;i++){
        B[i]=sc.nextInt();}
    int N =sc.nextInt();
    int M[]=new int[N];
    Integer[] P=new Integer[10];
    for(int k=0;k<N;k++){
      M[k]=sc.nextInt();
      loop:for(int l=0;l<9;l++){
          if(M[k]==B[l]){P[k]=l+1;break loop;}}
    if(Arrays.asList(P).contains(1)){
        if(Arrays.asList(P).contains(2)&&Arrays.asList(P).contains(3)){System.out.println("Yes");System.exit(0);}
        else if(Arrays.asList(P).contains(4)&&Arrays.asList(P).contains(7)){System.out.println("Yes");System.exit(0);}
        else if(Arrays.asList(P).contains(5)&&Arrays.asList(P).contains(9)){System.out.println("Yes");System.exit(0);}}
      if(Arrays.asList(P).contains(5)){
        if(Arrays.asList(P).contains(2)&&Arrays.asList(P).contains(8)){System.out.println("Yes");System.exit(0);}
        if(Arrays.asList(P).contains(3)&&Arrays.asList(P).contains(7)){System.out.println("Yes");System.exit(0);}
        if(Arrays.asList(P).contains(4)&&Arrays.asList(P).contains(6)){System.out.println("Yes");System.exit(0);}}
      if(Arrays.asList(P).contains(9)){
        if(Arrays.asList(P).contains(3)&&Arrays.asList(P).contains(6)){System.out.println("Yes");System.exit(0);}
        if(Arrays.asList(P).contains(7)&&Arrays.asList(P).contains(8)){System.out.println("Yes");System.exit(0);}}}
    System.out.println("No");}
}

Measured memory_bytes: 23764
#include<cstdio>
using namespace std;
int a,b,c,x,ans;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
			{
				int t=i*500+j*100+k*50;
				(t==x)&&(ans++);
				if(t>x)break;
			}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  namespace mp = boost::multiprecision;
  using Real = mp::number< mp::cpp_dec_float< 1024 > >;
  cin.tie(0);
  ios::sync_with_stdio(false);
  Real W, H, x, y;
  cin >> W >> H >> x >> y;
  Real area = 1.0 * W / 2.0 * H;
  cout << area << " " << ((x * 2 == W && y * 2 == H) ? 1 : 0) << "\n";
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int N, Q;
	string S;
	cin >> N>>Q>>S;
	vector<int> A(N+1, 0);
	for (int i = 2; i <= N; ++i) {
		if (S[i - 1-1] == 'A' && S[i-1] == 'C') {
			A[i]++;
		}
		A[i] += A[i - 1];
	}
	for (int i = 0; i < Q; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		int res = A[R+1] - A[L];
		if (S[L] == 'C' && L>0) {
			if (S[L - 1] == 'A') {
				res--;
			}
		}
		cout << res << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const ll INF = 1e18;
const int mod = 1e9+7;
const int MAX = 1e6;

struct edge {int to, cost;}; // 辺
vector<edge> graph[MAX]; // 隣接リスト
bool visited[MAX]; // 訪問の有無

void dfs(int cur, int &cnt) {
    cnt++;
    visited[cur] = true;
    for (edge e : graph[cur]) {
        if (not visited[e.to]) {
            dfs(e.to, cnt);
        }
    }
}

void solve1() {
    int n, m;
    cin >> n;
    cin >> m;
    rep(i, m) {
        int a, b;
        cin >> a;
        cin >> b;
        graph[a].push_back({b, 0});
        graph[b].push_back({a, 0});
    }
    int ans = 0;
    rep(i, n) {
        int cnt = 0;
        if (not visited[i]) {
            dfs(i, cnt);
            ans = max(cnt, ans);
        }
    }
    cout << ans << endl;
}

int main() {
    solve1();
}

Measured memory_bytes: 42876
def gcd(x,y):
  a = max(x,y)
  b = min(x,y)
  if a%b==0:
    return b
  else:
    while a%b!=0:
      c = a%b
      a = b
      b = c
    else:
      return c

def lcm(x, y):
  return int(x*y/gcd(x,y))

k,l = list(map(int, input().split()))
print(lcm(k,l))

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

inline int gcd(int a,int b){
    while(b){
        a=a%b;
        swap(a,b);
    }
    return a;
}

int n,a[1000005],u[1000005];

int main(){

    scanf("%d",&n);
    int g=0;
    for(int i=1;i<=n;i++){
        scanf("%d",a+i);
        g=gcd(g,a[i]);
        for(int j=2;j*j<=a[i];j++){
            if(a[i]%j==0){
                u[j]++;
                while(a[i]%j==0)a[i]/=j;
            }
        }
        u[a[i]]++;
    }
    if(g>1){
        cout<<"not coprime\n";
        return 0;
    }
    for(int i=2;i<=(int)1e6;i++){
        if(u[i]>1){
            cout<<"setwise coprime\n";
            return 0;
        }
    }
    cout<<"pairwise coprime\n";


    return 0;
}

Measured memory_bytes: 11340
A,B = map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
if A != 1 and B != 1:
    AB = set(prime_factorize(A)) & set(prime_factorize(B))
    print(len(AB)+1)
else:
    print(1)


Measured memory_bytes: 3064
n = int(input())
mi0,ma0 = 10**9,-(10**9)
mi1,ma1 = 10**9,-(10**9)
for i in range(n):
    a,b = map(int, input().split())
    c,d = a-b,a+b
    if c < mi0:
        mi0 = c
    if c > ma0:
        ma0 = c
    if d < mi1:
        mi1 = d
    if d > ma1:
        ma1 = d
print(max(ma0-mi0,ma1-mi1))


Measured memory_bytes: 9168
#include <cstdio>

int main()
{
  static char s[100100];
  scanf("%s",s);
  int F=0;
  for(int a=0;a<26;a++){
    char c='a'+a;
    int A=0,L=0;
    for(int i=0;s[i];i++){
      if(s[i]==c){
	L++;
	if(L>0&&i-A>0){
	  printf("%d %d\n",A+1,i+1);
	  F=1;
	  break;
	}
      }
      else{
	if(L==0){
	  A=i+1;
	}
	else{
	  L--;
	}
      }
    }
    if(F){
      break;
    }
  }
  if(!F){
    printf("%d %d\n",-1,-1);
  }
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    char a, b;
    cin >> a >> b;
    if (a == 'H') {
        cout << b << endl;
    } else if (b == 'H') {
        cout << 'D' << endl;
    } else {
        cout << 'H' << endl;
    }
    return 0;
}


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

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

int main()
{
    int N;
    cin>>N;
    vector<int> A(N);
    for (int &a: A)
        cin>>a;

    vector<int> F(1000001);
    for (int a: A)
    {
        for (int f=2; f*f<=a; f++)
        {
            int c = 0;
            while (a%f==0)
            {
                a /= f;
                c++;
            }
            F[f] = max(F[f], c);
        }
        if (a>1)
            F[a] = max(F[a], 1);
    }

    long long M = 1000000007;
    long long m = 1;
    for (int i=0; i<=1000000; i++)
        for (int j=0; j<F[i]; j++)
            m = m*i%M;

    long long ans = 0;
    for (int i=0; i<N; i++)
    {
        ans += m*powmod(A[i], M-2, M);
        ans %= M;
    }
    cout<<ans<<endl;
}


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

int main(){
    int n, m; cin >> n >> m;
    string s;
    int p;
    int pn[n+1];
    int ac[n+1];
    for(int i = 0; i < n+1; i++) pn[i] = ac[i] = 0;
    for(int i = 0; i < m; i++){
        cin >> p >> s;
        if(ac[p] == 0 && s == "WA") pn[p]++;
        else if(s == "AC") ac[p] = 1;
    }
    ll sum_ac = 0, sum_pn = 0;
    for(int i = 1; i <= n; i++){
        sum_ac += ac[i];
        sum_pn += (ac[i] == 1) ? pn[i] : 0;
    }
    cout << sum_ac << " " << sum_pn << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(){
    ll n,m;
    cin>>n>>m;
    if(n>m) swap(n,m);
    if(m==1) return 1;
    if(n==1) return m-2;
    return (m-2)*(n-2);
}

int main(void){
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Longest Path
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();

            List<List<Integer>> g = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                g.add(new ArrayList<>());
            }

            for (int i = 0; i < M; i++) {
                int x = sc.nextInt() - 1;
                int y = sc.nextInt() - 1;

                g.get(y).add(x);
            }

            int[] dp = new int[N];

            for (int i = 0; i < N; i++) {
                solve(i, dp, g);
            }

            int max = Arrays.stream(dp).max().getAsInt();

            System.out.println(max);
        }
    }

    static int solve(int x, int[] dp, List<List<Integer>> g) {
        if (dp[x] != 0) {
            return dp[x];
        }

        for (Integer e : g.get(x)) {
            dp[x] = Math.max(dp[x], solve(e, dp, g) + 1);
        }

        return dp[x];
    }

}


Measured memory_bytes: 113872
#include <iostream>
#include <stdio.h>
using namespace std;
 
long long int zet(long long int x){
    if(x>0 || x==0){
        return x;
    }else{
        return -x;
    }
}

int main(){
    int N;
    scanf("%d",&N);
    long long int a[N];
    for(int i=0;i<N;i++){
        scanf("%lld",&a[i]);
    }    
    long long x=a[0];
    long long y=0;
    int i;
    for(i=1;i<N;i++){
        y=y+a[i];
    }
    long long int min=zet(x-y);
    long long int temp=0;
    for(i=1;i<N-1;i++){
        x=x+a[i];
        y=y-a[i];
        temp=zet(x-y);
        if(temp<min){
            min=temp;
        }
    }
    printf("%lld\n",min);

    return 0;
    
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
cnt_4 = 0
cnt_2 = 0
for a in A:
    if a % 4 == 0:
        cnt_4 += 1
    elif a % 2 == 0:
        cnt_2 += 1
cnt = N - 2*cnt_4 - cnt_2
if cnt_4 > 0 and N % 2 == 1:
    cnt -= 1
if cnt <= 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 85160