akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __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 deb(...)
#endif

	
//////////////////////////////code//////////////////////////////

void solve()
{
  //  cout << "-------------------" << "\n";
     
   int m;
   cin>>m;
   
   if(m>=30)
   db("Yes")
   else
   db("No")
   
  
 

  //  cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
    //cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll N, K;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> K;
  if (K == 0) {
    cout << N * N << endl;
    return 0;
  }
  ll ans = N * (N - K);
  for (ll i = K + 1; i <= N; i++) {
    ans -= (N / i) * K + min(K - 1, N % i);
  }
  cout << ans << endl;

  return 0;
}

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

#define O 0
#define I 1
#define H 100

int n,l,j,u,k,t;
int list[H][H];
int lengthlist[H];

void search(int y, int len){
  int i;
  len++;
  lengthlist[y]=len;
  for(i=O;i<n;i++){
    if(list[y][i]==I){
      if(lengthlist[i] <= len && lengthlist[i] >=O){
        continue;
      }
      search(i,len);
    }
  }
}

int main(){
  scanf("%d",&n);
  for(l=O;l<n;l++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=O;j<k;j++){
      scanf("%d",&t);
      list[u-I][t-I]=I;
    }
  }
  for(l=O;l<n;l++){
    lengthlist[l]=-I;
  }
  search(O,-I);
  for(j =O;j<n;j++){
    printf("%d %d\n",j+I,lengthlist[j]);
  }
  return O;
}



Measured memory_bytes: 2028
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        String S = sc.next();
	        char[] c = S.toCharArray();
	        
	        int max=0;
	        int ans=3000000;
	        int bcnt=0;
	        int wcnt=0;
	        for(int i=0;i<N;i++) {
	        	if(c[i]=='#') {
		        		bcnt++;	        		
	        	} else {
		        		wcnt++;
	        	}
	        }
	        int ibcnt=0;
	        int iwcnt=0;
	        for(int i=0;i<N;i++) {
	        	ans=Math.min(ans, ibcnt+wcnt-iwcnt);
	        	if(c[i]=='#') {
	        		ibcnt++;
	        	} else {
	        		iwcnt++;
	        	}
	        }
        	ans=Math.min(ans, ibcnt+wcnt-iwcnt);
	        System.out.println(ans);
	 }
	 

}


Measured memory_bytes: 29072
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int INF = 100100100;

int main(){
    int n;  cin >> n;
    vector<int>x(n);
    rep(i, n)   cin >> x[i];
    int ans = INF;
    rep(i, 150){
        int tmp = 0;
        rep(j, n){
            tmp += (x[j]-i)*(x[j]-i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		if (s.charAt(0) == s.charAt(1) && s.charAt(0) == s.charAt(2))
			System.out.println("No");
		else
			System.out.println("Yes");
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
//#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 1000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;

int main(){
    int n;
    std::cin >> n;
    VEC(ll,a,n);
    std::vector<ll> p(n);
    ll ans=0;
    rep(i,n){
        ans+=(i+1);
    }
    rep(i,n){
        p[a[i]-1]=i;
    }
    
    std::set<ll> se,ise;
    se.insert(-1);
    se.insert(n);
    ise.insert(1);
    ise.insert(-n);
    rep(i,n){
        ll r=*se.lb(p[i])-p[i]-1;
        ll l=p[i]+(*ise.lb(-p[i]))-1;
        //ppri(l,r);
       // std::cout << (l*r)+(l+r) << std::endl;
        ans+=((l*r)+(l+r))*(i+1);
        se.insert(p[i]);
        ise.insert(-p[i]);
    }    
    std::cout << ans << std::endl;
}

Measured memory_bytes: 22144
n = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(n):
    minj = i
    for j in range(i,n,1):
        if a[minj] > a[j]:
            minj = j
    if minj != i:
        a[minj], a[i] = a[i], a[minj]
        count += 1
print(*a)
print(count)



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it.fi<<" "<<it.se<<endl;}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
//#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())

int32_t main()
{
 io
  int n;
  cin>>n;
  vector<pair<int,int>>v(n);int x,y;vector<pair<int,int>>a,b;
  for(int i=0;i<n;i++)
  {
    cin>>x>>y;
    v[i]={x,y};
    
  }
  so(v);
  for(int i=0;i<n;i++)
  {
    a.pb({v[i].fi,v[i].fi+v[i].se});
    b.pb({v[i].fi,v[i].fi-v[i].se});
  }

int ans=0;
so(a);
so(b);
int mx=INT_MAX;

for(int i=0;i<a.size();i++)
{
    if(i==0)
    {
      mx=min(mx,a[i].se);
    }
    else
    {
      ans=max(ans,a[i].se-mx);
      mx=min(mx,a[i].se);
    }
}
mx=INT_MAX;
for(int i=0;i<b.size();i++)
{
   if(i==0)
   {
    mx=min(mx,b[i].se);
   }
   else
   {
     ans=max(ans,b[i].se-mx);
     mx=min(mx,b[i].se);
   }
}
cout<<ans<<endl;


}


Measured memory_bytes: 12868
/*
 * @Author: hesorchen
 * @Date: 2020-07-03 17:05:01
 * @LastEditTime: 2020-09-04 19:45:56
 * @Description: https://hesorchen.github.io/
 */
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define endl '\n'
#define PI acos(-1)
#define PB push_back
#define ll long long
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pll pair<ll, ll>
#define lowbit(abcd) (abcd & (-abcd))
#define max(a, b) ((a > b) ? (a) : (b))
#define min(a, b) ((a < b) ? (a) : (b))

#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define FRE                              \
    {                                    \
        freopen("in.txt", "r", stdin);   \
        freopen("out.txt", "w", stdout); \
    }

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}
//head==============================================================================

long long a[100010];
int main()
{
    long long n;
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    int s = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] < 0)
            s++;
        if (a[i] == 0)
        {
            s = 0;
            break;
        }
    }
    long long ans = 0;
    if (s % 2 == 0)
    {
        for (int i = 1; i <= n; i++)
            ans += abs(a[i]);
    }
    else
    {
        // int minn = INF;
        // for (int i = 1; i <= n; i++)
        // {
        //     if (a[i] < 0 && abs(a[i]) < minn)
        //         minn = abs(a[i]);
        // }
        // for (int i = 1; i <= n; i++)
        // {
        //     ans += abs(a[i]);
        // }
        // ans -= 2 * minn;
        for (int i = 1; i <= n; i++)
            a[i] = abs(a[i]);
        sort(a + 1, a + 1 + n);
        for (int i = 2; i <= n; i++)
            ans += a[i];
        ans -= a[1];
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    if ((s[0] == s[1] && s[1] == s[2] && s[0] == s[2]) || (s[1] == s[2] && s[2] == s[3] && s[3] == s[1]))
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

int dp[100005];
void solve(){	
	int n, k;
	cin>>n>>k;
	memset(dp, inf, sizeof(dp));
	int arr[n];
	FOR(i, 0, n) cin>>arr[i];
	dp[0] =0;
	for(int i=1;i<n;i++){
		for(int j=1;j<=min(i,k);j++){
			dp[i] = min(abs(arr[i]-arr[i-j])+dp[i-j], dp[i]);
		}
		//cout<<dp[i]<<" ";
	}	
	cout<<dp[n-1]<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
n,k = [int(x) for x in input().split()]

d = {}
for x in input().split():
    x = int(x)
    if x not in d:
        d[x] = 0
    d[x] += 1

cnt = 0
ret = 0
for kk,v in sorted(d.items(), key=lambda x:-x[1]):
    cnt += 1
    if cnt>k:
        ret += v
print(ret)


Measured memory_bytes: 41120
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[6],k;
	for(int i=1;i<=5;i++) cin>>a[i];
	cin>>k;
	for(int i=1;i<5;i++){
		for(int j=i+1;j<=5;j++){
			if(abs(a[j]-a[i])>k){
				cout<<":(";
				return 0;
			}
		}
	}
	cout<<"Yay!";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int A;
	int B;
	cin >> A >> B;
	if (A <= 9 && B <= 9)
	{
		cout << A*B << endl;
	}
	else
	{
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#coding:utf-8
import math
n, k = map(int, input().split())

if n < k:
    print(min(n, abs(n-k)))
elif k == 1 or n == 0 or n%k == 0:
    print(0)
elif n%k != 0:
    print(min(abs(n%k-k), n%k))


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

const int M = 1000000007;

void add_self(int &a,int b){
	a+=b;
	if(a>=M){
		a-=M;
	}
}

int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin>>h>>w;
    vector<vector<int>>dp(h,vector<int>(w,0));
    dp[0][0]=1;
    string s[h+1];
    for(int i=0;i<h;i++){
    	cin>>s[i];
    }
    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		for(int k=i;k<=i+1;k++){
    			int col=j;
    			if(k==i){
    				col=j+1;
    			}
    			if(k<h && col<w && s[k][col]=='.'){
    				add_self(dp[k][col],dp[i][j]);
    			}
    		}
    	}
    }
    cout<<dp[h-1][w-1];
    return 0;
}

Measured memory_bytes: 12560
from collections import deque

N, X, Y = [int(x) for x in input().split()]
X -= 1
Y -= 1

result = {x: 0 for x in range(N)}


def push(v, d, queue, dist):
    if v in dist:
        return
    dist[v] = d
    queue.appendleft(v)


def check(i):
    queue = deque()
    dist = {}
    push(i, 0, queue, dist)

    while queue:
        pos = queue.pop()
        d = dist[pos]

        if pos - 1 >= 0:
            push(pos - 1, d + 1, queue, dist)
        if pos + 1 < N:
            push(pos + 1, d + 1, queue, dist)
        if pos == X:
            push(Y, d + 1, queue, dist)
        if pos == Y:
            push(X, d + 1, queue, dist)

    for i in range(N):
        result[dist[i]] += 1


for i in range(N):
    check(i)

for i in range(1, N):
    print(result[i] // 2)


Measured memory_bytes: 81224
#include<stdio.h>
#include<string.h>
int main(){
  char a[100],b[100];
  int n,m,i;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)a[i]=m+'0';
  for(i=0;i<m;i++)b[i]=n+'0';
  a[n]=b[m]=0;
  printf("%s\n",strcmp(a,b)<0?a:b);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))

S = [0]
s = 0
for i in range(N):
    s+=A[i]
    S.append(s)

def bisect(l,r,Su,il):
    while r-l>1:
        if S[(l+r)//2]-S[il] > Su//2:
            r = (l+r)//2
        else:
            l = (l+r)//2
    return l

min_score = 10**27

for i in range(2,N-1):
    l1 = bisect(0,i,S[i],0)
    l2 = bisect(i,N,S[N]-S[i],i)
    P = S[l1]
    Q = S[i]-P
    R = S[l2]-S[i]
    S1 = S[N]-S[l2]
    val1 = max(P,Q,R,S1)-min(P,Q,R,S1)
    P = S[l1+1]
    Q = S[i]-P
    R = S[l2]-S[i]
    S1 = S[N]-S[l2]
    val2 = max(P,Q,R,S1)-min(P,Q,R,S1)
    P = S[l1]
    Q = S[i]-P
    R = S[l2+1]-S[i]
    S1 = S[N]-S[l2+1]
    val3 = max(P,Q,R,S1)-min(P,Q,R,S1)
    P = S[l1+1]
    Q = S[i]-P
    R = S[l2+1]-S[i]
    S1 = S[N]-S[l2+1]
    val4 = max(P,Q,R,S1)-min(P,Q,R,S1)
    min_score = min(val1,val2,val3,val4,min_score)

print(min_score)



Measured memory_bytes: 100052
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

vector<int> makeTable(const string& s) {
    int n = s.size();
    vector<int> ret(n+1);
    ret[0] = -1;
    int j = -1;
    for (int i = 0; i < n; i++) {
        while (j >= 0 && s[i] != s[j]) j = ret[j];
        ret[i+1] = ++j;
    }
    return ret;
}

vector<int> kmp(const string& str, const string& word) {
    vector<int> table = makeTable(word), ret(str.size());
    int m = 0, i = 0, n = str.size();
    while (m+i < n) {
        if (word[i] == str[m+i]) {
            if (++i == (int)(word.size())) {
                ret[m]++;
                m = m+i-table[i];
                i = table[i];
            }
        } else {
            m = m+i-table[i];
            if (i > 0) i = table[i];
        }
    }
    return ret;
}


int main() {
    string s, t, u;
    cin >> s >> t;
    u = s;
    int cnt = 0;
    while(s.size() < t.size()*15 || cnt < 15){
        s += u;
        cnt++;
    }
    auto A = kmp(s, t);
    s += s;
    auto B = kmp(s, t);
    int m = t.size();
    for (int i = m; i < A.size(); ++i) {
        if(A[i]) A[i] = max(A[i], A[i-m]+1);
    }
    for (int i = m; i < B.size(); ++i) {
        if(B[i]) B[i] = max(B[i], B[i-m]+1);
    }
    int ans = *max_element(A.begin(),A.end()), ans2 = *max_element(B.begin(),B.end());
    if(ans != ans2){
        puts("-1");
    }else {
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 113224
use petgraph::algo::{condensation, toposort};
use petgraph::Graph;
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        e: [(usize, usize); m],
    }
    let mut g = Graph::new();
    let nodes: Vec<_> = (0..n).map(|nod| g.add_node(nod)).collect();
    for (a, b) in e {
        g.add_edge(nodes[a], nodes[b], ());
    }
    let scc_equiv = condensation(g, true);
    let sorted = toposort(&scc_equiv, None).unwrap();
    println!("{}", sorted.len());
    for &node in &sorted {
        let s = scc_equiv[node]
            .iter()
            .map(|i| i.to_string())
            .collect::<Vec<_>>()
            .join(" ");
        println!("{} {}", scc_equiv[node].len(), s);
    }
}


Measured memory_bytes: 71288
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] C = new int[4];
            string[] s = new string[4]
            {
                "AC x "
                ,"WA x "
                ,"TLE x "
                ,"RE x "
            };
            for (int i = 0; i < N; i++)
            {
                string tmp = Console.ReadLine();
                if (tmp == "AC")
                {
                    C[0]++;
                }
                else if (tmp == "WA")
                {
                    C[1]++;
                }
                else if (tmp == "TLE")
                {
                    C[2]++;
                }
                else if (tmp == "RE")
                {
                    C[3]++;
                }
            }
            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine(s[i] + C[i]);
            }
                //List<string> S = new List<string>();
                //int AC = 0;
                //int WA = 0;
                //int TLE = 0;
                //int RE = 0;
                //for(int i = 0;i < N; i++)
                //{
                //    S.Add(Console.ReadLine());
                //}
                //for (int i = 0; i < N; i++)
                //{
                //    if (S[i] == "AC")
                //    {
                //        AC++;
                //    }
                //    else if (S[i] == "WA")
                //    {
                //        WA++;
                //    }
                //    else if (S[i] == "TLE")
                //    {
                //        TLE++;
                //    }
                //    else if (S[i] == "RE")
                //    {
                //        RE++;
                //    }
                //}
                //Console.WriteLine("AC x "  + AC);
                //Console.WriteLine("WA x "  + WA);
                //Console.WriteLine("TLE x " + TLE);
                //Console.WriteLine("RE x "  + RE);
            }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 30708
#include<stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d", &a, &b);
	c = a + b;
	switch (c) {
	case 3:
		printf("3");
		break;
	case 4:
		printf("2");
		break;
	case 5:
		printf("1");
		break;
	default:
		break;
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,cnt=0;
  string S;
  cin>>N>>S;
  for(int i=0; i<=N; i++)
  {
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
    {
      cnt++;
    }
  }
  	cout<<cnt<<endl;
}
      

Measured memory_bytes: 3620
import sys
s=sys.stdin
f=lambda:s.readline()
while 1:
 n=int(f())
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=f().strip().split()
  d[k]=v
 a=''
 for _ in[0]*int(f()):
  e=f().strip()
  a+=d[e]if e in d else e
 print(a)


Measured memory_bytes: 6472
N = gets.to_i
a = gets.split.map(&:to_i)

d = Hash.new(0)

a.each do |aa|
  d[aa] += 1
end

h = []
d.sort_by { |k, _v| k }.reverse.each do |dd|
  if dd[1] >= 4
    h << dd[0]
    h << dd[0]
  elsif dd[1] >= 2
    h << dd[0]
  end

  if h.size >= 2
    break
  end
end

if h.size >= 2
  puts h[0] * h[1]
else
  puts 0
end

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


int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++)cin >> a[i];

	int kougen = 0, bonti = 0, sanhuku = 0, mine = 0, kuboti = 0;
	for (int i = 1; i < N - 1; i++) {
		if (a[i - 1]<a[i] && a[i]>a[i + 1])mine++;
		if (a[i - 1] > a[i] && a[i] < a[i + 1])kuboti++;
	}
	for (int i = 1; i < N - 1; i++) {
		if (a[i - 1] != a[i] && a[i] == a[i + 1]) {
			int j = i + 1;
			while (j < N - 1 && a[j] == a[j + 1]) {
				j++;
			}
			if (j == N - 1)break;
			if (a[i - 1] < a[i]) {
				(a[j] < a[j + 1] ? sanhuku : kougen)++;
			}
			else {
				(a[j] > a[j + 1] ? sanhuku : bonti)++;
			}
			i = j;
		}
	}
	cout << kougen << " " << bonti << " " << sanhuku << " " << mine << " " << kuboti << endl;
}


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

int main(){
  int a;
  cin >> a;
  int s1,s2,s3;
  s1=a/100;
  s2=(a-s1*100)/10;
  s3=a-s1*100-s2*10;
  int x;
  x=s1+s2+s3;
  cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        final int A = scan.nextInt();
        final int B = scan.nextInt();
        int result = 0;
        result = (B - A) / (A - 1) + 1;
        if((B - A) % (A - 1) >= 1){
            result++;
        }
        System.out.println(result);
        scan.close();
    }
    
}

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
    int k;
    cin>> n>> k;

    cout<< min(n%k, k - n%k)<< endl;

}

int32_t main(){
	fastio;
	solve();
	return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
double tor(double x) { return x * M_PI / 180.0; }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a, b, x;
    cin >> a >> b >> x;
    double t = atan(b / a) * 180.0 / M_PI;
    double ok = 0, ng = 90;
    double v = a * a * b;
    int c = 100;
    while (c--) {
        double mid = (ok + ng) / 2.0;
        bool f = false;
        if (mid <= t) {
            if (a * a * a * tan(tor(mid)) / 2.0 <= v - x) {
                f = true;
            }
        } else {
            if ((b / tan(tor(mid))) * a * b / 2.0 >= x) {
                f = true;
            }
        }
        if (f) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << fixed << setprecision(12) << ok << endl;
}

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

int main() {

	int N;
	string S;
	cin >> N;
	cin >> S;

	int sum = 1;

	for (int j = 1; j < N; j++) {
		if (S[j] == S[j - 1]) {
			continue;
		}
		else
		{
			sum++;
		}
	}
	cout << sum << endl;
}

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

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[] n = new int[in.nextInt()];
        for (int i = 0; i < n.length; i++) {
            n[i] = in.nextInt();
        }
        Arrays.sort(n);
        final int left = n[n.length / 2 - 1];
        final int right = n[n.length / 2];
        if (left == right) {
            System.out.println(0);
            return;
        }
        System.out.println(right - left);
    }
}


Measured memory_bytes: 51824
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pi pair<int,int>
#define pl pair<ll, ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const ll N = 2e5 + 5, mod = 1e9 + 7;
const ll inf = 1e18;

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b){
    if(a.F == b.F) return a.S < b.S;
    return a.F > b.F;
}
ll power(ll x, ll p){
    ll r = 1ll;
    x = x % mod;
    while(p > 0){
        if(p & 1) r = (r * x) % mod;
        p = p >> 1;
        x = (x * x) % mod;
    }
    return r;
}

void solve(){
    ll n, d;
    cin >> n >> d;
    d *= d;
    ll x, y, ans = 0;
    for(ll i = 0; i < n; i++){
        cin >> x >> y;
        x *= x;
        y *= y;
        if(x + y <= d) ans++;
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);//cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("Input.txt", "r", stdin);
    #endif*/
    //freopen("running_on_fumes_chapter_1_input (1).txt", "r", stdin);
    //freopen("Output.txt", "w", stdout);
    int t = 1, p;
    //cin >> t;
    for(p = 1; p <= t; p++){
        //cout << "Case #" << p << ": ";
        solve();
    }
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <iomanip>

int main(){
    int A,B,H,M;
    std::cin >> A >> B >> H >> M;
    static const double pi = 3.141592653589793;
    double m_angle,h_angle,ans;
    // m_angle = 2*pi*M*6;//times 360
    // h_angle = 2*pi*H*30 + pi*M;//times 360
    // ans = std::sqrt(A*A + B*B - 2*A*B* std::cos((m_angle - h_angle)/360));
    m_angle = 2*pi*M/60;
    h_angle = 2*pi*H/12 + pi*M/360;
    ans = std::sqrt(A*A + B*B - 2*A*B*(std::cos(m_angle)*std::cos(h_angle) + std::sin(m_angle)*std::sin(h_angle)));
    std::cout << std::fixed << std::setprecision(10)<< ans << std::endl;
}





Measured memory_bytes: 4148
#include<stdio.h>
#include<string.h>
int main() {
	char s[4];
	int v;
	scanf ("%s",&s);
	if (strlen(s) == 2) {
		printf ("%s",&s);
	} else if (strlen(s) == 3) {
		v = s[2];
		s[2] = s[0];
		s[0] = v;
		printf ("%s",&s);
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	int s=abs(a[0]);
	for (int i = 0; i < n-1; ++i)
	{
		s+=abs(a[i]-a[i+1]);
	}
	s+=abs(a[n-1]);
	for (int i = 0; i < n; ++i)
	{
		if (i==0)
		{
			cout<<s-abs(a[0])-abs(a[0]-a[1])+abs(a[1])<<endl;
		}
		else if (i==n-1)
		{
			cout<<s-abs(a[n-2]-a[n-1])-abs(a[n-1])+abs(a[n-2])<<endl;
		}
		else
		{
			cout<<s-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
		}
	}
	return 0;
}


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

char symbol(int t){
  if(t){
    return '+';
  }else{
    return '-';
  }
}

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

  for(int i = 0;i < 8;i++){
    int tmp = s[0] - '0';
    for(int j = 1;j < 4;j++){
      if(i & (1 << (j-1))){
        tmp += s[j] - '0';
      }else{
        tmp -= s[j] - '0';
      }
    }

    if(tmp == 7){
      for(int j = 0;j < 4;j++){
        cout << s[j];
        if(j < 3) cout << symbol(i & (1 << j));
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
	3 70
	20 30 10
		`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	n, x := nextInt(), nextInt()
	a := nextInts(n)

	sort.Ints(a)

	ans := len(a)

	for i := 0; i < len(a); i++ {
		if x < a[i] {
			ans = i
			break
		}
		x -= a[i]
	}

	if ans == len(a) && x != 0 {
		ans--
	}

	//fmt.Fprintln(out, "[DEBUG]", d)
	fmt.Fprintln(out, ans)
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


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

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<int> a(100002, 0);
	int inn;
	for (int i = 0; i < n; i++) {
		cin >> inn;
		a[inn]++;
	}

	int maxcount = 0;
	for (int i = 2; i < 100002; i++) {
		maxcount = max(maxcount, a[i] + a[i - 1] + a[i - 2]);
	}
	cout << maxcount << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
bool greedy(int X, int Y)
{
    if (X >= Y) { return true; }
    else { return false; }
}
   
   int main()
   {
       int N, cnt = 0, Mx = 0;
       cin >> N;
       vector<int>Arr(N);

       for (int j = 0; j < N; j++)
       {
           cin >> Arr[j];
       }
       
       for (int j = 0; j < N-1 ; j++)
       {
           if (greedy(Arr[j], Arr[j + 1])) { cnt++; }
           else { Mx = max(cnt, Mx); cnt = 0; }
       }
       int Ans = max(Mx, cnt);
       cout <<Ans<< endl;

       return 0;
   }


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

int main()
{
    int K;
    cin >> K;
    int v = 7 % K;
    for(int i=1;i<=K;i++){
        if(v % K == 0){
            cout << i << endl;
            return 0;
        }
        v = (10 * v + 7) % K;
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int main()
{
    ll N,M;
    ll ans=0;
    cin>>N>>M;
    vector<ll> L(M),R(M);

    for(ll i=0;i<M;i++)
    {
        cin>>L[i]>>R[i];
    }
    ll vmin=*min_element(R.begin(),R.end());
    ll vmax=*max_element(L.begin(),L.end());

    if(vmin<vmax)
    {
        cout<<0<<endl;
        return 0;
    }

    ans = vmin -vmax + 1;
    cout<<ans<<endl;
}

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

main(){

  ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  vector<ll> b(m),c(m);
  rep(i,m)cin>>b[i]>>c[i];

  priority_queue<pair<ll,ll>,deque<pair<ll,ll>>,less<>> que;
  rep(i,n)que.emplace(a[i],1);
  rep(i,m)que.emplace(c[i],b[i]);

  ll sum=0,card=0;
  while(card<n){
    ll val,num;
    tie(val,num)=que.top();
    que.pop();
    if(card+num<n){
      sum+=val*num;
      card+=num;
    }
    else{
      while(card<n){
        sum+=val;
        card++;
      }
    }
  }
  cout<<(sum)<<endl;


}


Measured memory_bytes: 5888
import math

std_dev = []
while True:
  n = int(input())
  if n == 0:
    break
  s = list(map(int, input().split()))
  m = sum(s)/n

  disp = 0
  for i in range(n):
    disp += (s[i]-m)**2 / n

  std_dev.append(math.sqrt(disp))

for i in range(len(std_dev)):
  print(std_dev[i])



Measured memory_bytes: 5700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    map<int,int> a,b;
    REP(i,n/2){
        int x,y;
        cin>>x>>y;
        a[x]++;
        b[y]++;
    }
    vector<P> p,q;
    for(auto itr:a){
        p.pb({itr.se,itr.fi});
    }
    for(auto itr:b){
        q.pb({itr.se,itr.fi});
    }
    sort(q.rbegin(),q.rend());
    int ans=n;
    REP(i,p.size()){
        REP(j,q.size()){
            if(p[i].se!=q[j].se){
                chmin(ans,n-p[i].fi-q[j].fi);
                break;
            }else{
                chmin(ans,n-max(p[i].fi,q[j].fi));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6136
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	char pre='\0';
	int cnt =0;
	rep(i,n){
		if(pre!=s[i]){
			cnt++;
			pre=s[i];
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#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++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin >>n;
  int ans=1;
  int key=0;
  for(int i=n;i>1;i--){
    for(int j=1;j<i/2+1;j++){
      for(int k=1;k<10;k++){
     if(key!=1){
      if(pow(j,k)==i) {
        ans=i;
        key++;
      }
     }
    }
  }
  }
      cout  <<ans<<endl;
}

Measured memory_bytes: 384
N = int(input())
D,X = map(int,input().split())
A = [int(input()) for i in range(N)]
ans = []
ans.append(X)
for i in range(1,N + 1):
    work = (D // A[i - 1])
    if D % A[i - 1] != 0:
        work += 1

    ans.append(work)

print(sum(ans))


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<set>
using namespace std;
set<string> st;
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        string str;cin>>str;
        st.insert(str);
    }
    cout<<st.size()<<endl;
    return 0;
}

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

int main ()
{
	int A,B;
	char S[15],T[15],U[15];
	
	scanf ("%s %s",S,T);
	getchar();
	scanf ("%d %d",&A,&B);
	getchar();
	scanf ("%s",U);
	getchar();
	
	if (strcmp(S,U)==0){
		printf("%d %d",A-1,B);
	}
	else if (strcmp(T,U)==0){
		printf("%d %d",A,B-1);
	}
	
	return 0;
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
void _fast () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); }
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

int main() { _fast();
	const int MAX = 200;
	int x, n;
	cin >> x >> n;
	vector<bool> p(MAX, false);
	for (int i = 0; i < n; i++) {
		int e;
		cin >> e;
		p[e] = true;
	}
	
	int ans = -1, d = abs(-1 - x);
	for (int val = 0; val < MAX; val++) {
		if (p[val]) continue;
		int dist = abs(val - x);
		if (dist < d) {
			ans = val; d = dist;
		} else if (dist == d) {
			ans = min(ans, val);
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 char B;
  cin >> B;
  if(B == 'a' || B == 'i' || B == 'u' || B == 'e' || B == 'o'){
   cout << "vowel" <<endl;
  }
  else{
   cout << "consonant" <<endl;
  }
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            for(int i = 0; i < n; i++)
            {
                int a = int.Parse(str[i]);
                if (a % 2 == 0)
                {
                    if(a%3!=0 && a % 5 != 0)
                    {
                        Console.WriteLine("DENIED");
                        return;
                    }
                }
            }

            Console.WriteLine("APPROVED");

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>
#include <queue>

using namespace std;

int main(){
    while(true){
        int H;
        cin >> H;
        if(H == 0) break;

        vector<vector<int>> vec(H, vector<int>(5));
        for(int i = 0; i < H; ++i) for(int j = 0; j < 5; ++j){
            cin >> vec[i][j];
        }

        int ans = 0;
        bool changed = true;
        while(changed){
            changed = false;
            for(int i = 0; i < H; ++i){
                for(int j = 0; j <= 2; ++j){
                    int num = vec[i][j];
                    if(num == 0) continue;
                    int same = 0;
                    for(int k = j + 1; k < 5; ++k){
                        if(num != vec[i][k]){
                            break;
                        }
                        same = k - j + 1;
                    }
                    if(same >= 3){
                        changed = true;
                        ans += num * same;
                        for(int k = 0; k < same; ++k){
                            vec[i][j + k] = 0;
                        }
                    }
                }
            }
            for(int i = H - 1; i > 0; --i){
                for(int j = 0; j < 5; ++j){
                    if(vec[i][j] == 0){
                        for(int k = i; k >= 0; --k){
                            if(vec[k][j] != 0){
                                vec[i][j] = vec[k][j];
                                vec[k][j] = 0;
                                break;
                            }
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;cin >> x;
    cout << x/500*1000+x%500/5*5 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int n,p,q; long long r;

int main() {
  
  p=-10000000; q=10000000;
  
  scanf("%d",&n);
  
  for(int i=0; i<n; i++){
    int a; 
    scanf("%d",&a);
    if(a>p){p=a;}
    if(a<q){q=a;}
    r+=a;
    
    }
  
   printf("%d %d %lld\n",q,p,r);
   

}

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

namespace TYC
{
	typedef long long ll;
	const int N = 1e5 + 5;

	int n, S, X[N];
	ll ans, P[N];

	void getans(const int l, const int r)
	{
		if (l != r && X[l] <= S && S <= X[r])
		{
			if (P[l] >= P[r])
			{
				P[l] += P[r];
				getans(l, r - 1);
				ans += X[r] - S;
				S = X[r];
			}
			else
			{
				P[r] += P[l];
				getans(l + 1, r);
				ans += S - X[l];
				S = X[l];
			}
		}
		else
		{
			if (X[r] <= S)
				ans += S - X[l], S = X[l];
			else
				ans += X[r] - S, S = X[r];
			return;
		}	
	}

	void work()
	{
		scanf("%d%d", &n, &S);
		for (int i = 1; i <= n; i++)
			scanf("%d%lld", &X[i], &P[i]);
		getans(1, n);
		printf("%lld\n", ans);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define fastio {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); }
#define all(v) v.begin(), v.end()
#define pi pair<ll, ll>
using ll = long long;

#define sz(x) (ll)x.size()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i < (b); ++i)

const int d4x[4] = { -1, 0, 1, 0 };
const int d4y[4] = { 0, 1, 0, -1 };
const int MOD = 998244353;
const ll INF = 1e18 + 7;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; } return ans; }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
//ll f[MAXN];
//ll kCn(ll k, ll n) { if (k > n) return 0; return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

const int MAXN = 3e5;

int Node[4 * MAXN + 100];
int n, k;

void update(int pos, int val, int i = 1, int l = 1, int r = MAXN) {
	if (l == r) {
		Node[i] = val;
		return;
	}
	int mid = (l + r) / 2;
	if (pos <= mid)
		update(pos, val, 2 * i, l, mid);
	else
		update(pos, val, 2 * i + 1, mid + 1, r);
	Node[i] = max(Node[2 * i], Node[2 * i + 1]);
}

int getmax(int l1, int r1, int i = 1, int l2 = 1, int r2 = MAXN) {
	if (l2 > r1 || r2 < l1)
		return -1e9;
	if (l2 >= l1 && r2 <= r1)
		return Node[i];
	int mid = (l2 + r2) / 2;
	int a = getmax(l1, r1, 2 * i, l2, mid);
	int b = getmax(l1, r1, 2 * i + 1, mid + 1, r2);
	return max(a, b);
}


void test_case() {
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	for (int i = 0; i < n; ++i) {	
		int l = max(1, a[i] - k);
		int r = min(MAXN, a[i] + k);
		int mx = getmax(l, r);
		update(a[i], mx + 1);
	}
	cout << getmax(1, MAXN);
}

int main() {
	fastio;
	test_case();
	
	return 0;
}

Measured memory_bytes: 8600
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <numeric>
#include <limits>

const long long int Z = 1000000007;
const long long int INF = 1 << 30;
int flag = 0;
using ll = long long;

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

}
 ll lcm(ll a, ll b) {
	 ll g = gcd(a, b);
	 return a / g * b;
 }

int main() {
	int a, b, c, x, ans = 0;
	std::cin >> 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++) {
				if (500 * i + 100 * j + 50 * k == x) {
					ans += 1;
				}
			}
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256