akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;

vector<int> to[100005];
int n, m;
vector<int> root;

int main(){

  cin >> n >> m;
  root = vector<int>(n,-1); 
  rep(i,m){
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> que;
  que.push(0);

  while(!que.empty()){

    int now = que.front(); que.pop();

    for(int u : to[now]){
      if(root[u] == -1){
	que.push(u);
	root[u] = now;
      }
    }
  }

  cout << "Yes" << endl;
  for(int i=1; i < n; ++i) cout << root[i]+1 << endl;

  return 0;
}


Measured memory_bytes: 10240
#include <stdio.h>
#define W 0
#define G 1
#define B 2

int n,M[100][100];
int color[100],d[100],f[100],time;

void visit(int);
void dfs();

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
      
}

void visit(int u){
  int i;
  color[u] = G;
  d[u]  = ++time;
  for(i=0;i<n;i++){
    if(M[u][i]==0) continue;
    if(color[i] == W){
      visit(i);
    }
  }
  color[u] = B;
  f[u] = ++time;
}

void dfs(){
  int i;
  for(i=0;i<n;i++) color[i] = W;
  time=0;

  for(i=0;i<n;i++){
    if(color[i]==W) visit(i);
  }
  
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}



Measured memory_bytes: 2112
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll a, b, ans = 0;
  scanf("%lld%lld", &a, &b);
  for (int i = 0; i <= a; i++)
  {
    for (int j = 0; j <= a; j++)
    {
      ll tmp = b - i - j;
      if (0 <= tmp && tmp <= a)
        ans++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int height = sc.nextInt();
		int width = sc.nextInt();
		boolean ok[][] = new boolean[height][width];
		for(int i = 0; i < height; i ++) {
			String str = sc.next();
			for(int j = 0; j < width; j ++) {
				ok[i][j] = str.charAt(j) != '#';
			}
		}

		int widthNum[][] = new int[height][width];
		int tmp = 0;
		for(int i = 0; i < height; i ++) {
			for(int j = 0; j < width; j ++) {
				if(ok[i][j]) {
					tmp ++;
					widthNum[i][j] = tmp;
				}else {
					tmp = 0;
					widthNum[i][j] = -1;
				}
			}
			tmp = 0;
		}
		for(int i = height - 1; i >= 0; i --) {
			for(int j = width - 2; j >= 0; j --) {
				widthNum[i][j] = widthNum[i][j] == -1 ? -1 : Math.max(widthNum[i][j], widthNum[i][j + 1]);
			}
		}

		int heightNum[][] = new int[height][width];
		tmp = 0;
		for(int i = 0; i < width; i ++) {
			for(int j = 0; j < height; j ++) {
				if(ok[j][i]) {
					tmp ++;
					heightNum[j][i] = tmp;
				}else {
					tmp = 0;
					heightNum[j][i] = -1;
				}
			}
			tmp = 0;
		}

		for(int i = width - 1; i >= 0; i --) {
			for(int j = height - 2; j >= 0; j --) {
				heightNum[j][i] = heightNum[j][i] == -1 ? -1 : Math.max(heightNum[j][i], heightNum[j + 1][i]);
			}
		}

		int num[][] = new int[height][width];
		int max = 0;
		for(int i = 0; i < height; i ++) {
			for(int j = 0; j < width; j ++) {
				num[i][j] = widthNum[i][j] + heightNum[i][j] - 1;
				max = Math.max(max, num[i][j]);
			}
		}
		System.out.println(max);
	}
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S; cin >> S;
  int Q; cin >> Q;
  deque<string> ans;
  REP(i, S.size()) ans.push_back(char_to_string(S[i]));
  bool flag = true;
  for(int i = 0; i < Q; ++i) {
    int a; cin >> a;
    if(a == 1) {
      flag = !flag;
    } else if(a == 2) {
      int b; string c;
      cin >> b >> c;
      if(b == 1) {
        if(flag == true) {
          ans.push_front(c);
        } else {
          ans.push_back(c);
        }
      } else if(b == 2) {
        if(flag == true) {
          ans.push_back(c);
        } else {
          ans.push_front(c);
        }
      }
    }
  }
  if(flag == true) {
    REP(i, ans.size()) {
      cout << ans[i];
    }
    cout << endl;
  } else {
    for(int i = ans.size() - 1; i >= 0; --i) {
      cout << ans[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 13272
#include <cstdio>

int a,b,c;

int main(){
    scanf("%d %d %d",&a,&b,&c);
    if(a==b&&b!=c) printf("%d",c);
    if(a==c&&c!=b) printf("%d",b);
    if(b==c&&b!=a) printf("%d",a);
}


Measured memory_bytes: 128
N,M = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(M):
  num = 0
  for j in range(N):
    if i+1 in A[j][1:]:
      num += 1
  if num == N:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

long long a, b, c, d;

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

void solve() {
  cin >> a >> b >> c >> d;

  if (d < b || a < b) {
    puts("No");
    return;
  }

  long long diff = max(0ll, a - c);
  long long cur = a - (diff / b) * b;
  if (cur > c) {
    if (cur - b < 0) {
      puts("No");
      return;
    }
    cur -= b;
  }
  
  if (c >= b || d == b) {
    puts("Yes");
    return;
  }

  long long from = c + 1, to = b - 1;
  if (from > to) {
    puts("Yes");
    return;
  }
  // cerr << cur << " " << from << " " << to << " " << d - b << endl;

  long long g = gcd(b, d);

  from = ((from - a) % b + b) % b;
  to = ((to - a) % b + b) % b;

  if (from > to) {
    puts("Yes");
    return;
  }

  if (from / g == to / g && from % g > 0) {
    puts("Yes");
  } else {
    puts("No");
  }
}

int main() { 

  int tn;
  scanf("%d\n", &tn);
  while (tn--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

bool isLY(int y)
{
    if (y%400 == 0) {
        return true;
    } else if (y%100 == 0) {
        return false;
    } else if (y%4 == 0) {
        return true;
    } else {
        return false;
    }
}

int main(){
    int a,b;
    bool noLY;
    bool firstSet=true;
    while (true) {
        noLY = true;
        std::cin >> a >> b;
        
        if (a==0 && b==0) {
            break;
        }
        
        if (!firstSet) {
            std::cout << std::endl;
        }

        for (int i=0; i <= (b-a); i++) {
            if (isLY(a+i)) {
                std::cout << a+i << std::endl;
                noLY = false;
            }
        }
        if(noLY){
            std::cout << "NA\n";
        }
        firstSet = false;
    }
    return 0;
}

Measured memory_bytes: 3036
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

int main()
{
    std::size_t n;
    std::cin >> n;

    std::size_t a[n];
    for (std::size_t i = 0; i < n; ++i) {
        std::cin >> a[i];
        std::cout << a[i];
        if (i == (n -1)) {
            std::cout << std::endl;
        } else {
            std::cout << " ";
        }
    }

    for (std::size_t i = 1; i < n; ++i) {
        int key = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > key) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = key;

        for (int k = 0; k < n; ++k) {
            std::cout << a[k];
            if (k == (n - 1)) {
                std::cout << std::endl;
            } else {
                std::cout << " ";
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3104
import numpy as np
n = int(input())
T = []
X = []
Y = []
t1 = 0
x1 = 0
y1 = 0
for i in range(n):
    m = input().split()
    T.append(int(m[0]) - t1)
    t1 = int(m[0])
    X.append(abs(int(m[1]) - x1))
    x1 = int(m[1])
    Y.append(abs(int(m[2]) - y1))
    y1 = int(m[2])
T = np.array(T)
X = np.array(X)
Y = np.array(Y)
for i in range(n):
    if X[i] + Y[i] > T[i] or (X[i] + Y[i] + T[i]) % 2 == 1:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 21636
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(){
	string s;
	bool start = true;
	while(cin >> s){
		int sn = 1;
		int en = s.size();
		char b = s[0];
		char c = s[s.size()-1];
		if(b==',' or b=='.') sn++;
		if(c==',' or c=='.') en--;
		int n = en - sn + 1;
		if(n>=3 and n<=6){
			if(start){ cout << s.substr(sn-1,n); start = false; }
			else cout << " " << s.substr(sn-1,n);
		}
	}
	cout << endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define pb push_back
#define boostup ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
using namespace std;
int main()
{
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=-10000000000000;
    ll x=min(n,b-1);
        ll d;
        d=floor((a*x)/b)-a*floor(x/b);
    cout<<d<<endl;
}

Measured memory_bytes: 3636
a,b,c,d,e,f = map(int,input().split())
xset = set()
yset = set()
for i in range(31):
  for j in range(16):
    if (a*i+b*j)*100 <= f:
      xset.add((a*i+b*j)*100)
xset.remove(0)
for i in range(f//c+1):
  for j in range(f//d+1):
    if c*i+c*j<=f:
      yset.add(c*i+d*j)
ll = []
maxconc = 0
maxsolution = 100*a
maxsolute = 0
for i in xset:
  for j in yset:
    if i+j<= f and i >= (100*j)/e and (100*j)/(i+j)>maxconc:
      maxconc = (100*j)/(i+j)
      maxsolution = i+j
      maxsolute = j
print(str(maxsolution)+' '+str(maxsolute))

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int Alice = 0, Bob = 0;
    int A[110];
    rep(i, N) cin >> A[i];
    sort(A, A + N, greater<int>());
    rep(i, N) {
        if (i % 2 == 0) Alice += A[i];
        else Bob += A[i];
    }
    cout << Alice - Bob << endl;

    return 0;
}


Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

vll idx[26];
void solve(){  
	string s,t;
	cin>>s>>t;
	vll f(26);
	rep(i,0,sz(s)){
		f[s[i]-'a']++;
		idx[s[i]-'a'].pb(i);
	}  
	rep(i,0,sz(t)){
		if(f[t[i]-'a']==0){
			cout<<-1<<endl;
			return;
		}
	}
	int copies=1;
	int idx1=-1;
	rep(i,0,sz(t)){
		auto it = upper_bound(all(idx[t[i]-'a']),idx1);
		if(it==idx[t[i]-'a'].end()){
			++copies;
			idx1=-1;
			it = upper_bound(all(idx[t[i]-'a']),idx1);
		}
		idx1 = *it;
	}
	cout<<(copies-1)*sz(s)+idx1+1<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <boost/math/common_factor_rt.hpp>

#define ll long long
using namespace std;
ll l = 1000000007;

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

	if (c < b / a) {
		cout << c << endl;
	}
	else {
		cout << b / a << endl;
	}
	
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
 
int gcd(int a,int b){
	if(a==0)
	return b;
	if(b==0)
	return a;
	if(a==b)
	return a;
	if(a>b)
	return gcd(a-b,b);
	return gcd(a,b-a);
}
 
int GCD(int a,int b){
	if(a==0)
	return b;
	if(b==0)
	return a;
	if(a==b)
	return a;
	return GCD(b,a%b);
}
 
int main(){
	ll t;
	cin>>t;
	if(t%1000==0)
	cout<<"0"<<endl;
	else{
		ll x=t%1000;
		cout<<1000-x<<endl;
	}
}

Measured memory_bytes: 3616
import java.util.Scanner;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        int maxV = 100000;
        long[] dp = new long[maxV + 1];
        Arrays.fill(dp, W + 1);
        dp[0] = 0;

        for (int i = 0; i < N; i++) {
            for (int j = dp.length - 1; j >= v[i]; j--) {
                dp[j] = Math.min(dp[j], dp[j - v[i]] + w[i]);
            }
        }

        for (int j = dp.length - 1; j >= 0; j--) {
            if (dp[j] <= W) {
                System.out.println(j);
                break;
            }
        }
    }
}

Measured memory_bytes: 24276
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <string>
#include <string.h>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

#define For(i, s, n) for (int i = s; i <= n; ++i)
#define ForD(i, s, n) for (int i = s; i >= n; --i)
#define ForV(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define ms(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define ii pair<int, int>
#define fi first
#define se second

typedef long long ll;

const int N = 1e5 + 5, LIMIT = 1e9 + 7;

map <string, int> mp;
string s;
int n;

void Read()
{
   //freopen("SC.INP", "r", stdin);
   //freopen("SC.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> s;
}

void Process1()
{
    For (i, 0, (1 << n) - 1)
    {
        string r = "", b = "";
        ForV (j, n)
        {
            if (i >> j & 1)
            {
                r = r + s[j];
            }
            else
            {
                b = b + s[j];
            }
        }
        ++mp[r + "." + b];
    }
}

void Process2()
{
    ll ans = 0;
    For (i, 0, (1 << n) - 1)
    {
        string r = "", b = "";
        ForV (j, n)
        {
            if (i >> j & 1)
            {
                r = s[n + j] + r;
            }
            else
            {
                b = s[n + j] + b;
            }
        }
        ans += mp[b + "." + r];
    }
    cout << ans;
}

int main()
{
    Read();
    Process1();
    Process2();
    return 0;
}


Measured memory_bytes: 67968
/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
#define INF 1e18L+1
using namespace std;
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt","w",stderr);
    #endif
}
ll parent[100005];
ll find(ll a)
{
    std::vector<ll> v;
    while(parent[a]>0)
    {
        v.push_back(a);
        a = parent[a];
    }
    for(ll i=0;i<v.size();i++)
        parent[v[i]] = a;
    return a;
}
bool prime[100005];
void SieveOfEratosthenes(int n) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
void union1(ll a, ll b)
{
    a = find(a);
    b = find(b);
    if(a!=b)
    {
        parent[a] = min(parent[a],parent[b]);
        parent[b] = a;
    }
}  
int main()
{
   // fastio();
    ll n;
    cin >> n;
    double dp[n+1];// dp[i] = probabitlity of i heads so far
    memset(dp,0,sizeof(dp));
    dp[0] = 1;
    for(ll coin=0;coin<n;coin++)
    {
        double head;
        cin >> head;
        for(ll i=coin+1;i>=0;i--)
        {
            dp[i] = (i==0?0:dp[i-1]*head) + dp[i]*(1-head);
        }
    }
    // for(ll i=0;i<=n;i++)
    //     cout << dp[i] << " ";
    // cout << endl;
    double ans = 0;
    for(ll i=n/2+1;i<=n+1;i++)
    {
        ans+=dp[i];
    }
    cout << fixed << setprecision(9) << ans << endl;
}

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

int main() {
 int A,B,cnt;
  cin>>A>>B;

  if(B==1) cout<<"0"<<endl;
  else{
  for(int i=1;;i++){
    	cnt=(A-1)*(i-1)+A;
  		if(cnt>=B){
      	cout<<i<<endl;
      	break;
    	}
  	}
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"


const ll MAX = 705;
vll g[MAX];bool vis[MAX];
bool adj[MAX][MAX];
ll bp[MAX];bool pos = true;
ll cc = 0 ; ll cc1;vpll sz;
void dfs(ll x){
	vis[x] = 1;
	if(bp[x]==1)cc++;else cc1++;
	for(auto z:g[x]){
		if(!vis[z]){
			bp[z] = 1-bp[x];dfs(z);
		}
		else {
			if(bp[x]==bp[z])pos = false;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll n;cin>>n;
	ll m;cin>>m;
	ll i,j,k;ll a,b;
	for(i=0;i<m;i++){
		cin>>a>>b;
		adj[b][a] = adj[a][b] = true;
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(i==j)continue;
			if(!adj[i][j])g[i].pb(j);
		}
	}
	for(i=1;i<=n;i++){
		if(!vis[i]){
			cc1 = cc = 0; dfs(i); sz.pb({cc,cc1});
		}
	}
	const ll s = n+1; 
	bitset<705> bs,bs1,bs2,bs3;
	bs.set(0,1);
	for(auto z:sz){
		bs1 = (bs<<(z.F));
		bs2 = (bs<<(z.S));
		bs = bs1|bs2; 
	}
	ll p ;
	for(i=0;i<=n/2;i++){
		if(bs[i]) p = i;
	}
	// trace(p);
	ll ans = p*(p-1) + (n-p)*(n-p-1);ans/=2;
	if(!pos)cout<<"-1";
	else cout<<ans;
}


Measured memory_bytes: 5888
a,b,k=map(int,input().split())
for i in range(k):
    if i%2==0:
        if a%2==1:
            a-=1
        b+=a//2
        a=a//2
    else:
        if b%2==1:
            b-=1
        a+=b//2
        b=b//2
print(a,b)

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

int main() {
    int n, m;
    cin >> n >> m;

    auto edges = vector<vector<int>>(n + 1);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        edges[a].emplace_back(b);
        edges[b].emplace_back(a);
    }

    auto pointer = vector<int>(n + 1);
    auto q = vector<int>(n);
    auto push = 0;
    auto pop = 0;
    q[push++] = 1;
    pointer[1] = 1;
    while (pop < push) {
        auto room = q[pop++];
        for (auto next : edges[room]) {
            if (pointer[next] != 0)
                continue;
            q[push++] = next;
            pointer[next] = room;
        }
    }

    for (int i = 1; i <= n; ++i) {
        if (i == 1)
            cout << "Yes\n";
        else
            cout << pointer[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 10252
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    rep(i, a.size())
    {
        int count = 0;
        if (a[i] == b[i])
            count++;
        if (c[i] == b[i])
            count++;
        if (a[i] == c[i])
            count++;
        if(count==1){
            ans++;
        }
        else if(count==3){}
        else ans+=2;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let (a1, a2, a3) = read_int(&s);
    if a1 + a2 + a3 >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}

fn read_int(s: &String) -> (i32, i32, i32) {
    let mut ws = s.split_whitespace();
    let i1: i32 = ws.next().unwrap().parse().unwrap();
    let i2: i32 = ws.next().unwrap().parse().unwrap();
    let i3: i32 = ws.next().unwrap().parse().unwrap();

    (i1, i2, i3)
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125];

void po(){
  puts("Impossible");
  exit(0);
}
void yo(){
  puts("Possible");
  exit(0);
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  if(n==2){
    if(a[0]==1 && a[1]==1)yo();
    else po();
  }
  int mn = *min_element(a,a+n);
  int mx = *max_element(a,a+n);
  if(mx%2==0){
    if(mn*2 != mx)po();
    if(count(a,a+n,mn)!=1)po();
  }else{
    if(mn*2 != mx+1)po();
    if(count(a,a+n,mn)!=2)po();
  }
  FOR(i,mn+1,mx+1){
    int c = count(a,a+n,i);
    if(c<2)po();
  }

  yo();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
map<pair<int, int>, bool> visited;
vector<string> g;
int h, w;
bool is_valid(int y, int x)
{
    return 0 <= y && y < h && 0 <= x && x < w && visited[{y, x}] == false && g[y][x] != '#';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> h >> w;
    g.resize(h);
    rep(i, h)
    {
        cin >> g[i];
    }
    deque<pair<int, int>> que;
    rep(i, h) rep(j, w)
    {
        if (g[i][j] == '#')
        {
            que.push_back({i, j});
        }
    }
    int ans = 0;
    int dy[4] = {1,
                 -1,
                 0,
                 0};
    int dx[4] = {0,
                 0,
                 1,
                 -1};
    while (!que.empty())
    {
        deque<pair<int, int>> next;
        while (!que.empty())
        {
            auto cur = que.front();
            que.pop_front();

            int y = cur.first;
            int x = cur.second;
            rep(i, 4) if (is_valid(y + dy[i], x + dx[i]))
            {
                next.push_back({y + dy[i], x + dx[i]});
                visited[{y + dy[i], x + dx[i]}] = true;
            }
        }
        ans++;
        que = next;
    }
    cout << max(0, ans - 1) << endl;
    return 0;
}

Measured memory_bytes: 64256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 1e5; // CAMBIAR ESTE

// GJNM

int main(){
	set<string> st;
	int n;
	ri(n);
	FOR(i,0,n){
		string aux;
		cin >> aux;
		st.insert(aux);
	}
	printf("%d\n",(int)st.size() );
	return 0;
}

Measured memory_bytes: 19288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int P[100001], Y[100001];
	rep1(i, M) cin >> P[i] >> Y[i];

	map<int, int> MAP[100001];
	rep1(i, M) {
		MAP[P[i]][Y[i]] = i;
	}

	string S[100001];
	rep1(i, N) {
		int kari = 1;
		for (auto itr : MAP[i]) {
			int kari2 = i;
			int suuji[6];
			rep1(ii, 6) {
				suuji[6 - ii] = kari2 % 10;
				kari2 /= 10;
			}
			rep(ii, 6) S[itr.second] += to_string(suuji[ii]);

			kari2 = kari;
			int suuji2[6];
			rep1(ii, 6) {
				suuji2[6 - ii] = kari2 % 10;
				kari2 /= 10;
			}
			rep(ii, 6) S[itr.second] += to_string(suuji2[ii]);

			kari++;
		}
	}

	rep1(i, M) {
		co(S[i]);
	}

	Would you please return 0;
}

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

int main(){
  ll n,a[5];
  cin >> n ;
  rep(i,5) cin >> a[i];
  
  ll m=1000000000000010;
  rep(i,5){
    m = min(a[i], m);
  }
  
  cout << ((n+m-1)/m + 4) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define LEN 100005

typedef struct pp{
	int t;
	char name[100];
}p;

p Q[LEN];

int head,tail;

void enqueue(p x){
	Q[tail] = x;
	tail=(tail+1)%LEN;
	}
	
p dequeue(){
	p x = Q[head];
	head = (head+1)%LEN;
	return x;
}

int min(int a,int b){
	return a<b? a:b;
}

int main(){
	int n,q,els=0,c;
	p temp;
	scanf("%d %d",&n,&q);
	for(int i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	 head=1,tail=n+1;
	
	while(head!=tail){
	 temp = dequeue();
	 c = min(temp.t,q);
	temp.t-=c;
	els+=c;
	if(temp.t>0){
		enqueue(temp);
	}else{
		printf("%s %d\n",temp.name,els);
	}
	}
	return 0;
}

Measured memory_bytes: 12908
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int dp[50][50];

int main() {
  int h, w;
  cin >> h >> w;
  char c[h][w];
  REP(i, h) REP(j, w) cin >> c[i][j];
  int n[h][w];
  REP(i, h) REP(j, w) n[i][j] = c[i][j] - '0';
  for (int i = 1; i < h; ++i) dp[i][0] += dp[i - 1][0] + n[i][0];
  for (int i = 1; i < w; ++i) dp[0][i] += dp[0][i - 1] + n[0][i];
  for (int i = 1; i < h; ++i) {
    for (int j = 1; j < w; ++j) {
      dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + n[i][j];
    }
  }
  cout << dp[h - 1][w - 1] << endl;
  return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());

    ll ans = L_INF;
    if (N & 1) {
        ll b = A[N / 2];
        ans = 0;
        for (ll i = 0; i < N; i++) {
            ans += abs(A[i] - b);
        }
    }
    else {
        ll b = A[N / 2 - 1];
        ll t = 0;
        for (ll i = 0; i < N; i++) {
            t += abs(A[i] - b);
        }
        b = A[N / 2];
        ll t2 = 0;
        for (ll i = 0; i < N; i++) {
            t2 += abs(A[i] - b);
        }

        ans = min(t, t2);
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include<cstring>
#include <iomanip>
#include <iostream>

using namespace std;


int main(void){
  int m1,m2,d1,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(d2==1){
    cout << 1;
    return 0;
  }
  else {
    cout << 0;
  }
  /*char s[3];
  char *w[7]={SUN,MON,TUE,WED,THU,FRI,SAT}
  cin >> s;
  int checker;

  for(int i=0;i<7;i++){
    checker=strcmp(s,w[i]);
    if(checker==0){
      cout << 7-i;
      return 0;
    }
  }*/

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

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

	string ans;
	vector<string> vs;
	while (N--)
	{
		string s;
		cin >> s;
		vs.push_back(s);
	}

	stable_sort(vs.begin(), vs.end());

	for (int i = 0; i < vs.size(); ++i)
		cout << vs[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int H, W, K;
vector<ll> vary = { 1, 1, 2, 3, 5, 8, 13, 21 };//why?!
ll memo[123][123];

ll dp(int h, int w) {
	if (memo[h][w] != -1) return memo[h][w];
	if (h == 0) {
		if (w == 1) return memo[h][w] = 1;
		else return memo[h][w] = 0;
	}
	ll count = 0;
	if (w != 1) count += dp(h - 1, w - 1) * vary[w - 2] * vary[W - w];
	count %= 1000000007;
	count += dp(h - 1, w) * vary[w - 1] * vary[W - w];
	count %= 1000000007;
	if (w != W) count += dp(h - 1, w + 1) * vary[w - 1] * vary[W - w - 1];

	return memo[h][w] = count % 1000000007;
}

int main() {

	rep(i, 123) rep(j, 123) memo[i][j] = -1;

	scanf("%d%d%d", &H, &W, &K);

	printf("%lld\n", dp(H, K) % 1000000007);

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long 

main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  pair<int, int> ab[n];
  for (int i = 0; i < n; i++) cin >> ab[i].first >> ab[i].second;
  sort(ab, ab + n);
  int p = 0;
  for (int i = 0; i < n; i++) {
    p += ab[i].second;
    if (p >= k) {
      cout << ab[i].first << "\n";
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>



int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> count(n, 0);
	for (auto i = 0; i < m; ++i) {
		int l, r; std::cin >> l >> r;
		count[l - 1]++;
		if (r < n) count[r]--;
	}
	for (auto i = 1; i < n; ++i) {
		count[i] += count[i - 1];
	}
	int result = 0;
	for (const auto c : count) {
		if (c == m) ++result;
	}
	std::cout << result << std::endl;
}

Measured memory_bytes: 640
def read(): return list(map(int, input().split()))


n = int(input())
a = read()

c = [0 for i in range(9)]
for i in a:
    if 1 <= i <= 399:
        c[0] = 1
    elif 400 <= i <= 799:
        c[1] = 1
    elif 800 <= i <= 1199:
        c[2] = 1
    elif 1200 <= i <= 1599:
        c[3] = 1
    elif 1600 <= i <= 1999:
        c[4] = 1
    elif 2000 <= i <= 2399:
        c[5] = 1
    elif 2400 <= i <= 2799:
        c[6] = 1
    elif 2800 <= i <= 3199:
        c[7] = 1
    else:
        c[8] += 1

s = sum(c[:8])
mini = 1 if s < 1 else s
maxi = s + c[8]
print("{} {}".format(mini, maxi))


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
    int A, B;
    cin >> A >> B;

    if (A < 10 && B < 10) {
        cout << A * B << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
s = input()
l = (['', 'keyence'], ['k', 'eyence'], ['ke', 'yence'], ['key', 'ence'],
     ['keye', 'nce'], ['keyen', 'ce'], ['keyenc', 'e'], ['keyence', ''])
for a in l:
    p, q = a[0], a[1]
    if s.startswith(p) and s.endswith(q):
        exit(print('YES'))
print('NO')


Measured memory_bytes: 3060
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b,c,n;
  std::cin >> a >> b >> c >> n;

  for(int i=1; i<=n; i++){
    if(a>b && a>c) a*=2;
    else if(b>c && b>a) b*=2;
    else c*=2;
  }

  std::cout << a+b+c << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

int d[10][10];
int main(void){
	int h, w, i, j, k;
	scanf("%d%d", &h, &w);
	for(i=0; i<=9; i++){
		for(j=0; j<=9; j++){
			scanf("%d", &d[i][j]);
		}
	}
	for(k=0; k<=9; k++)
		for(i=0; i<=9; i++)
			for(j=0; j<=9; j++){
				int D = d[i][k]+d[k][j];
				if(D<d[i][j]) d[i][j]=D;
			}
	int ans=0;
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			scanf("%d", &k);
			ans+=d[k][1];
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M

main=do
    n <- readLn::IO Int
    print =<<  head . sortBy (flip compare) . map snd . M.toList
            . foldl' (\m k -> M.insertWith (+) (k-1) 1 $ M.insertWith (+) (k+1) 1 $ M.insertWith (+) k 1 m) M.empty
            . unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine


Measured memory_bytes: 41340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    bool color[8] = {};
    int free = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a >= 3200) free++;
        else color[a / 400] = true;
    }

    int cnt = 0;
    rep(i, 8) {
        if (color[i]) cnt++;
    }

    int mn = max(cnt, 1);
    int mx = cnt + free;

    cout << mn << " " << mx << endl;
    return 0;
}


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

int main() {
  string S; cin >> S;
  bool T = true;
  for(char c = 'a'; c <= 'z'; ++c) {
    if(S.find(c) == -1) {
      cout << c << endl;
      T = false;
      break;
    }
  }
  if(T != false) cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

string march = "MARCH";
ll cnt[5];
 
int main(int argc, char **argv) {
	ll n;
	CLEAR(cnt);
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		REP(j, 5) if (s[0] == march[j]) ++cnt[j];
	}
	ll res = 0;
	REP(i, 5) FOR(j, i+1, 5) FOR(k, j+1, 5) res += cnt[i] * cnt[j] * cnt[k];
	cout << res << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
const int INF = 1e9;
const double PI = acos(-1.0);

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

	ll ans = 0;
	if (k % 2 == 0) {
		ans += (k / 2)*(k / 2);
	}
	else {
		ans += ((k / 2) + 1)*(k / 2);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll X;
  cin >> X;
  if (X == 3 || X == 5 || X == 7)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


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



int main() {
    int h,w;
    cin>>h>>w;

    vector<vector<char>>s(w,vector<char>(h));

    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            cin>>s.at(i).at(j);
        }
    }

    int count = 0;
    int test = 0;
    int em =0;

    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            count=0;
            em=0;
            if(s.at(i).at(j)=='#'){
                if(i-1>=0){
                    if(s.at(i-1).at(j)=='.'){
                        count++;
                    }
                }else{
                    count++;
                    em++;
                }
                if(i+1<=(w-1)){
                    if(s.at(i+1).at(j)=='.'){
                        count++;
                    }
                }else{
                    count++;
                    em++;
                }
                if(j-1>=0){
                    if(s.at(i).at(j-1)=='.'){
                        count++;
                    }
                }else{
                    count++;
                    em++;
                }
                if(j+1<=(h-1)){
                    if(s.at(i).at(j+1)=='.'){
                        count++;
                    }
                }else{
                    count++;
                    em++;
                }
                if(count==4&&em!=4){
                    cout<<"No"<<endl;
                    test = 1;
                    break;
                }
            }else{
                continue;
            }
        }
        if(test==1){
            break;
        }
    }

    if(test==0){
        cout<<"Yes"<<endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
  int H,W;
  cin >> H >> W;

  vector<string>word(H);

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

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

  for(int i=0;i<H;i++){
    cout << "#" << word[i] << "#" << endl;
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	
	void solve(){
		char aux;
		cin>>aux;
		if('a'<=aux&&aux<='z'){
			cout<<"a";
		}
		else cout<<"A";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
	
}


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

using namespace std;

int main(){

    int x;
    cin >> x;

    int ans = 1;
    for (int b = 2; b <= x; b++){//b^pを全探索したい
        int power = b * b;//b^2で初期化
        while (power <= x){
            ans = max(ans, power);
            power *= b;
        }
            
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
    long n, m;
    cin >> n >> m;

    vector <long int> a(m);
    for(long i = 0; i < m; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    vector <long int> d(m-1);
    for(int i = 1; i < m; i++) {
        d[i-1] = a[i] - a[i-1];
    }

    sort(d.begin(), d.end());

    long long ans = 0;

    for(long i = 0; i < m-n; i++) {
        ans += d[i];
    }

    cout << ans;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

string itos(int x){
    ostringstream s;
    s << x;
    return s.str();
}

int main(){
    ll a, b;
    while(cin>>a>>b){
        cout << SZ(itos(abs(a+b))) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
using namespace std;

struct edge {
  ll to;
  ll cost;
  edge() {}
  edge(ll to_, ll cost_) : to(to_), cost(cost_) {}
};
std::vector<edge> graph[114514];

// O(ElogV)ダイクストラ
ll D[114514];
bool vis[114514];
bool Dijkstra(uint32_t s) {
  using P = std::pair<ll, ll>; // cost pos
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;
  que.emplace(D[s], s);
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    const auto &nowpos = p.second;
    const auto &nowcost = p.first;
    for (const auto &e : graph[nowpos]) {
      auto cost = nowcost + e.cost;

      if (cost != D[e.to] && vis[e.to]) {
        return false;
      }
      if (vis[e.to])
        continue;
      que.emplace(cost, e.to);
      vis[e.to] = 1;
      D[e.to] = cost;
    }
  }

  return true;
}

int main() {
  ll n, m;
  cin >> n >> m;
  REP(i, m) {
    ll l, r, d;
    cin >> l >> r >> d;
    graph[l].pb(edge{r, d});
    graph[r].pb(edge{l, -d});
  }
  REP(i, n) {
    if (vis[i + 1])
      continue;
    if (!Dijkstra(i + 1)) {
      cout << "No" << endl;
      return 0;
    }
  }
  // cout << D[7] << " " << D[8] << " " << D[9] << endl;
  cout << "Yes" << endl;
}


Measured memory_bytes: 16368