akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

double eps = 1e-9;
double pi = acos(-1);

#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define en "\n"
#define ff first
#define ss second
#define sp(x) fixed << setprecision(x)
#define VECT(v)  vector<int>v
#define SCAN(v)  int temp; for(int i=0; i<n; i++) {cin>>temp; v.push_back(temp);}
#define PRINT(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << en;
#define SORT(v)  sort(v.begin(), v.end());
#define RSORT(v) sort(v.begin(), v.end(), greater<>())
#define CASEP(v) cout<<"Case "<<tc<<": "<<v<<"\n"
#define DEBUG(v) cout << v << " "; cout << en;

int main(void)
{
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	fast_io

	int n;
	cin >> n;

	if(n)
		cout << 0 << en;
	else
		cout << 1 << en;

	return 0;
}

Measured memory_bytes: 3580
N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
a.sort()

for i in range(N):
    if x == a[i]:
        count += 1
    elif i == N - 1:
        if x != a[i]:
            break
    elif x - a[i] > 0:
        x -= a[i]
        count += 1
    else:
        break

print(count)

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

using namespace std;

int ans = 1, N, M, ap[409];
char sir[409][409];
const int mod = 1e9 + 7;
vector < int > v[409];

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

void addEdge (int x, int y)
{
    v[x].push_back (y);
    v[y].push_back (x);
}

int sz = 0;
void dfs (int nod)
{
    sz ++, ap[nod] = 1;
    for (auto it : v[nod])
        if (ap[it] == 0)
            dfs (it);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d\n", &N, &M);
for (int i=1; i<=N; i++)
    scanf ("%s", sir[i] + 1);
if (N == 1 || M == 1)
{
    int ans = 0;
    for (int i=1; i<=N; i++)
        for (int j=1; j<=M; j++)
            ans |= (sir[i][j] != sir[N + 1 - i][M + 1 - j]);
    printf ("%d\n", ans + 1);
    return 0;
}
int fac[10], inv[10];
inv[0] = fac[0] = 1;
for (int i=1; i<=4; i++)
    fac[i] = mul (fac[i - 1], i),
    inv[i] = power (fac[i], mod - 2);
for (int i=1; i<=N / 2; i++)
    for (int j=1; j<=M / 2; j++)
    {
        int c1 = sir[i][j], c2 = sir[N + 1 - i][j], c3 = sir[i][M + 1 - j], c4 = sir[N + 1 - i][M + 1 - j];
        map < char, int > mp;
        mp[c1] ++, mp[c2] ++, mp[c3] ++, mp[c4] ++;
        int curr = 24;
        for (auto it : mp)
            curr = mul (curr, inv[it.second]);
        if (curr != 24) ans = mul (ans, curr);
        else ans = mul (ans, 12), addEdge (i, N / 2 + j);
    }
if (N & 1)
{
    bool any = 0;
    for (int j=1; j<=M; j++)
        any |= (sir[N / 2 + 1][j] != sir[N / 2 + 1][M + 1 - j]);
    if (any) ans = mul (ans, 2);
}
if (M & 1)
{
    bool any = 0;
    for (int i=1; i<=N; i++)
        any |= (sir[i][M / 2 + 1] != sir[N + 1 - i][M / 2 + 1]);
    if (any) ans = mul (ans, 2);
}
int p2[N / 2 + M / 2 + 1];
p2[0] = 1;
for (int i=1; i<=N / 2 + M / 2; i++)
    p2[i] = add (p2[i - 1], p2[i - 1]);
for (int i=1; i<=N / 2 + M / 2; i++)
    if (ap[i] == 0)
    {
        sz = 0, dfs (i);
        ans = mul (ans, p2[sz - 1]);
    }
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 512
def prime_list(n):
    p = [True for i in range(n)]
    p[0] = False
    p[1] = False
    for j in range(4, n, 2):
            p[j] = False
    i = 3
    while i*i < n:
        if p[i]:
            for j in range(2*i, n, i):
                p[j] = False
        i += 2
    p_list = [2*i+1 for i in range(1,n//2) if p[2*i+1]]
    p_list.append(2)
    return p_list

def main():
    p_list = set(prime_list(1000000))

    while True:
        a,d,n = [int(x) for x in input().split()]
        if a == 0 and d == 0 and n == 0:
            exit()
        cnt = 0
        a -= d
        while cnt < n:
            a += d
            if a in p_list:
                cnt += 1
        print(a)

if __name__ == '__main__':
    main()

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;

    string s;
    while( N > 0 ){
       char c;
       if( N%26 == 0 ){
            c = 'z';
       }else{
            c = 'a' + (N%26-1);
       }
       N=(N-1)/26;
       s += c;
    }

    reverse(s.begin(), s.end());

    cout << s << endl;
}


Measured memory_bytes: 3604
import Data.List
import Data.Ord

main = interact $ unlines . map (show' . winner) . read' . lines
 where
  read' ("0":_) =[]
  read' (n:cs:xs) = (read n, words cs) : read' xs
  show' = maybe "TIE" (\(c,d) -> [c] ++ " " ++ show d)

winner (n,cs) = winner' [] cs
 where
  winner' vs [] = Nothing
  winner' vs (c:cs)
   | projected (c++vs) = Just (elected (c++vs), n - length cs)
   | otherwise = winner' (c++vs) cs
  projected vs = case reverse $ sortBy (comparing length) $ group $ sort vs of
   [_]     -> length vs > div n 2 
   (f:s:_) -> length f - length s > n - length vs
  elected = head . last . sortBy (comparing length) . group . sort

Measured memory_bytes: 5528
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    string S; //3-99文字（長さは奇数）

    //標準入力
    cin >> S;

    //チェック長さ
    int chk_flag = 0;
    int chk_len = 0;
    chk_len = ((S.length()-1)/2);

    //S自体の回文チェック
    for(int i=0; i<S.length(); i++)
    {
        if( S[i] != S[S.length()-1-i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    //回文チェック（前半）
    for(int i=0; i<(chk_len/2); i++)
    {
        if( S[i] != S[chk_len -1 -i])
        {
            // cout << "1" << i << endl;
            // cout << "2" << (chk_len - i) << endl;
            chk_flag = 1;
            break;
        }
    }

    //cout << chk_flag << endl;

    //回文チェック（後半）
    int chk_start = 0;
    int last_str = 0;
    chk_start = ((S.length()+3)/2);

    //cout << chk_start << endl;
    chk_start -= 1; //0オリジン調整
    last_str = S.length() -1; //0オリジン調整

    for(int i=0; i<(chk_len/2); i++)
    {
        if( S[chk_start + i] != S[last_str - i])
        {
            // cout << "1" << (chk_start - 1 + i) << endl;
            // cout << "2" << (S.length() - i) << endl;
            chk_flag = 1;
            break;
        }
    }

    if(chk_flag == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

def is_ok(x):
    tmp = 0
    for a, f in zip(A, F):
        y = a * f
        if y > x:
            tmp += a - x // f
    return tmp <= k

ok = 10 ** 16
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 113896
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc135_a.cpp
 * time   : Sat May  2 01:24:57 2020
 * quest  : A - Harmony
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if ((a & 1 && b & 1) || (!(a & 1) && !(b & 1)))
    cout << (a + b) / 2 << "\n";
  else
    cout << "IMPOSSIBLE\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
  int N;
  while(cin >> N,N)
    {
      int G[N+1][N+1];
      for(int i=1;i<=N;i++)
	for(int j=0;j<=N;j++)
	  cin >> G[i][j];

      int dp[(1<<17)];
      for(int i=0;i<(1<<17);i++)
	dp[i] = (1<<29);

      dp[0] = 0;

      for(int i=0;i<=(1<<(N+1))-2;i++)
	{
	  for(int j=1;j<=N;j++)
	    {
	      if((i>>j)&1)
		continue;
	      for(int k=0;k<=N;k++)
		{	      
		  if(k == 0 || ( (i>>k)&1 ))
		    {
		      dp[i|(1<<j)] = min(dp[i|(1<<j)],dp[i]+G[j][k]);
		    }
		}
	    }
	}

      cout << dp[(1<<(N+1))-2] << endl;

    }
  return 0;
}

Measured memory_bytes: 1668
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

struct H {
  int r,c,s,i;
  H(){}
  H(int r,int c,int s,int i):r(r),c(c),s(s),i(i){}
};

vector<H> v;

int main(void)
{
  int p,q,R,C,S,d,k;
  char g[88];
  for(;;) {
    v.clear();
    scanf("%d%d",&p,&q); if(p+q==0)break;
    R = C = S = 0;
    for( int i = 0; i < p; i++ ) {
      scanf("%s",g);
      k = d = 0;
      while( g[k] == '.' ) ++k;
      d = k;
      v.push_back(H(R,C,S,d));
      while( g[k] ) {
        if( g[k] == '(' ) ++R;
        if( g[k] == ')' ) --R;
        if( g[k] == '{' ) ++C;
        if( g[k] == '}' ) --C;
        if( g[k] == '[' ) ++S;
        if( g[k] == ']' ) --S;
        k++;
      }
    }
  
    R = C = S = 0;
    for( int i = 0; i < q; i++ ) {
      scanf("%s",g);
      k = d = 0;
      while( g[k] == '.' ) ++k;
      d = k;
      int id[11111] = {};
      for( int r = 1; r <= 20; r++ ) {
        for( int c = 1; c <= 20; c++ ) {
          for( int s = 1; s <= 20; s++ ) {
            bool ok = true;
            for( int j = 0; j < int(v.size()); j++ ) {
              if( v[j].r*r + v[j].c*c + v[j].s*s == v[j].i ) {
              
              } else ok = false;
            }
            if( ok ) id[R*r+C*c+S*s]++;
          }
        }
      }
      int aa = 0,res;
      for( int j = 0; j < 11111; j++ ) {
        if( id[j] ) ++aa,res=j;
      }
      printf("%d%c",aa==1?res:-1,i==q-1?'\n':' ');
      while( g[k] ) {
        if( g[k] == '(' ) ++R;
        if( g[k] == ')' ) --R;
        if( g[k] == '{' ) ++C;
        if( g[k] == '}' ) --C;
        if( g[k] == '[' ) ++S;
        if( g[k] == ']' ) --S;
        k++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=200005; //check this
const db PI= 3.14159265359;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    if(n%10==3)cout<<"bon";
    else if(n%10==0 || n%10==1 || n%10==6 ||n%10==8)cout<<"pon";
    else cout<<"hon";
    
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(ll i=0;i<n;i++)
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    string s,t;
    cin>>s>>t;
    ll ans=0;
    forn(i,s.size()){
        ans = ans+ (s[i]!=t[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3752
# include<bits/stdc++.h>
# define ll long long
# define fo(i,n)for(int i=0;i<n;i++)
# define fo1(i,n)for(int i=1;i<=n;i++)
# define pb push_back
# define endl "\n"
# define mod 1000000007ll
# define pi  3.1415926535897932384626
using namespace std;

vector<vector<int>>adj(100005);
vector<int>vis(100005,0);
void dfs(int i)
{
  if(!vis[i])
  {
    vis[i]=1;
    for(auto v:adj[i])
    {
      dfs(v);
    }
  }
}
void solve()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int cnt=0;
  for(int i=1;i<=n;i++)
  {
    if(!vis[i])
    {
      cnt++;
      dfs(i);
    }
  }
    cout<<cnt-1;
}
int main()
{
 # ifndef ONLINE_JUDGE
   freopen("input1.txt","r",stdin);
   freopen("output1.txt","w",stdout);
 #endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();
    cout<<endl;
    return 0;
}

Measured memory_bytes: 9536
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();
		System.out.println(N / X * T + (N % X == 0 ? 0 : T));
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 32424
def main():
    N = int(input())
    count = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

    for _ in range(N):
        S = input()
        count[S] += 1
    ans = f"""AC x {count["AC"]}
WA x {count["WA"]}
TLE x {count["TLE"]}
RE x {count["RE"]}"""
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
n,m = map(int, input().split())
x=list(map(int, input().split()))

x.sort()
x_d=[]
prv=x[0]
for xi in x[1:]:
  x_d.append(xi-prv)
  prv=xi
x_d.sort(reverse=True)
ans=sum(x_d)
for i in range(min(m-1, n-1)):
  ans-=x_d[i]
print(ans)



Measured memory_bytes: 13964
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

 
int main() {
    fastio
    int x;
    cin>>x;
    if(x>=30)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
}

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

int main()
{
    int w, h;
    while (cin >> h >> w) {
        if (h == 0 && w == 0) break;

        for (int i = 0; i < w; i++)
            cout << '#';
        cout << endl;

        for (int i = 1; i < h - 1; i++) {
            cout << '#';
            for (int j = 1; j < w - 1; j++) {
                cout << '.';
            }
            cout << '#' << endl;
        }

        for (int i = 0; i < w; i++)
            cout << '#';
        cout << endl << endl;
    }
}



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

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

typedef long long int64;

int64 euclidean_gcd(int64 a, int64 b) {
  if(a < b) return euclidean_gcd(b, a);

  int64 r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

  int64 ans = b - a + 1;

  int64 p = c*d/euclidean_gcd(c,d);

  ans -= b/c + b/d - b/p;
  ans += (a-1)/c + (a-1)/d - (a-1)/p;

  cout << ans << endl;

  return 0;
}

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

string S;

int main() {
    cin >> S;
    
    map<char, int> mp;
    for (int i = 0; i < S.length(); i++) {
        mp[S[i]]++;
    }

    bool is_yes = true;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        int val = itr->second;
        if (val % 2 == 1) {
            is_yes = false;
            break;
        } 
    }

    cout << (is_yes ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;

int a[200010];
int rev[200010];

const int inf = 1e9;
struct SEG{
	const static int M = 262144;
	int tree[M<<1];
	SEG(){ for(int& x:tree) x=inf; }
	void put(int p, int v){
		for(p+=M; p; p/=2) tree[p]=min(tree[p], v);
	}
	int rmin(int l, int r){
		l+=M; r+=M; int ret=inf;
		while(l<=r){
			if(l%2==1) ret=min(ret, tree[l++]);
			if(r%2==0) ret=min(ret, tree[r--]);
			l/=2; r/=2;
		}
		return ret;
	}
} seg[2];

int Ind;
pp data[200010];
vector<int> edge[200010];

int solve(int l, int r){
	if(l>r) return -1;
	int m = seg[l%2].rmin(l, r); m = rev[m];
	int rb = seg[1-m%2].rmin(m+1, r); rb = rev[rb];
	int i = ++Ind;
	data[i] = {a[m], a[rb]};
	int t=solve(l, m-1); if(~t) edge[i].pb(t);
	t=solve(m+1, rb-1); if(~t) edge[i].pb(t);
	t=solve(rb+1, r); if(~t) edge[i].pb(t);
	return i;
}

priority_queue<pp>pq;

int main()
{
	read(n);
	for(int i=1; i<=n; ++i){
		read(a[i]);
		rev[a[i]]=i;
		seg[i%2].put(i, a[i]);
	}
	int p = solve(1, n);
	pq.push({0, p});
	while(pq.size()){
		int i = pq.top().second; pq.pop();
		printf("%d %d ", data[i].x, data[i].y);
		for(int j:edge[i]){
			pq.emplace(-data[j].x, j);
		}
	}
	
	return 0;
}


Measured memory_bytes: 22784
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = INT_MAX;
	long D, G; cin >> D >> G; // D帯 , G点
	long p[100], c[100]; for (int i = 0; i < D; i++) cin >> p[i] >> c[i];

	for (int i = 0; i < (1 << D); i++) { //2のD乗通りの列挙
		long sum = 0;
		long moves = 0;
		for (int j = 0; j < D; j++) { //コンプリート桁列挙
			if (i & (1 << j)) { sum += 100 * (j + 1) * p[j] + c[j]; moves += p[j]; }
		}
        
		long hest = INT_MAX; //解かれていない最上位
		for (int k = D - 1; k >= 0; k--) if (i & (1 << k)); else{ hest = k; break; }
        
        if (i == (1 << D) - 1){ res = min(res , moves); break;}
        
		for (int r = 0; r < p[hest]; r++) {if (sum + 100 * (hest + 1) * r >= G) res = min(res, moves + r);}
		
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
using namespace std;
typedef pair<int, int> P;
const int INF = 100000000;
// " ", ' '

// プロトタイプ宣言
// int myfunc(int, vector<vector<int>>);

// グローバル変数

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int A, B, K;
 	cin >> A >> B;
  
  	if ((A+B)%2==1 || A==B) cout << "IMPOSSIBLE";
  	else {
      K = (A+B)/2;
	  cout << K << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;
int A,B,C,x,y,z,n;
ll sum[1001];
ll sum2[1002];
ll res[1001];

int main(void){
	scanf("%d%d%d%d%d%d%d",&x,&y,&z,&A,&B,&C,&n);
	sum[0]=1;
	ll len=1;
	while(1){
		ll outw=A-len;
		ll oute=(x-1-A)-len;
		ll outn=B-len;
		ll outs=(y-1-B)-len;
		ll prev=sum[len%n];
		sum[len%n]+=(ll)max(0LL,len-1LL+min(0LL,outw+1)+min(0LL,outn+1));
		sum[len%n]+=(ll)max(0LL,len-1LL+min(0LL,oute+1)+min(0LL,outn+1));
		sum[len%n]+=(ll)max(0LL,len-1LL+min(0LL,outw+1)+min(0LL,outs+1));
		sum[len%n]+=(ll)max(0LL,len-1LL+min(0LL,oute+1)+min(0LL,outs+1));
		if(outw>=0)sum[len%n]++;
		if(oute>=0)sum[len%n]++;
		if(outn>=0)sum[len%n]++;
		if(outs>=0)sum[len%n]++;
		if(prev==sum[len%n])break;
		len++;
	}
	for(int i=0;i<n;i++){
		sum2[i+1]=sum2[i]+sum[i];
	}
	ll outu=C;
	for(int i=0;i<n;i++){
		res[i]+=sum2[n]*(outu/n);
		ll rest=(outu)%n;
		if(i>=rest)res[i]+=sum2[i]-sum2[i-rest];
		else res[i]+=sum2[i]+sum2[n]-sum2[n-(rest-i)];
	}
	ll outd=z-C-1;
	for(int i=0;i<n;i++){
		res[i]+=sum2[n]*(outd/n);
		ll rest=(outd)%n;
		if(i>=rest)res[i]+=sum2[i]-sum2[i-rest];
		else res[i]+=sum2[i]+sum2[n]-sum2[n-(rest-i)];
	}
	for(int i=0;i<n;i++){
		printf("%lld%c",res[i%n]+sum[i%n],i==n-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];

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


    REP(i, n-1){
        if(h[i] <= h[i+1]-1){
            --h[i+1];
        }
        if(h[i] > h[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#define endl "\n"
using namespace std;

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

  char s[20];
  cin >> s;
  s[5]= 32;
  s[13]= 32;
  cout << s << endl;
  return 0;
}


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

int main(){
  int n, ans = 0, max = 0, x;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x;
    ans += x;
    if(x > max){
      max = x;
    }
  }
  cout << ans-(max/2);
}

Measured memory_bytes: 256
# -*- Coding: utf-8 -*-

nums = int(input())
a = [int(input()) for i in range(nums)]

minv = a[0]
maxv = -2000000000

for i in range(1, nums):
    maxv = max(maxv, a[i] - minv)
    minv = min(minv, a[i])

print(maxv)



Measured memory_bytes: 13596
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<cmath>
#include<string>
#include<vector>
#include<cstring>
#define ll long long
#define pb push_back
// #define memset(a,n) memset(a,n,sizeof(a))
#define mp make_pair
using namespace std;
const int maxn = 2e5 + 100;

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



int main()
{
    FAST();
    int a[maxn];int n,m;scanf("%d%d",&n,&m);
    ll sum = 0;
    for(int i = 0 ; i < m;i++) {
        scanf("%d",&a[i]);sum += a[i];
    }
    printf("%d\n",n >= sum ? n - sum : -1);
    // system("pause"); // 测试专用，提交勿忘注释掉
    return 0;
}

Measured memory_bytes: 3904
inv_count = 0

def Merge(A, left, mid, right):
    global inv_count

    sentinel = 2000000000
    n1 = mid - left
    n2 = right - mid
    L = A[left : left + (mid - left)] + [sentinel] 
    R = A[mid : mid + (right - mid)] + [sentinel]
    i = 0
    j = 0

    for k in range(left, right):
        if L[i] <= R[j] :
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            inv_count += (n1 - i)

def MergeSort(A, left, right):

    if left + 1 < right :
        mid = int((left + right)/2)
        MergeSort(A, left, mid)
        MergeSort(A, mid, right)
        Merge(A, left, mid, right)

def Main():
    N = input()
    A = [int(a) for a in input().split()]
    MergeSort(A, 0, len(A))
    global inv_count
    print(inv_count)

Main()


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

int main() {
  string S;
  bool safe;
  int score=0;
  cin >> S;
  for(int i=0;i<S.size();i++){
    for(int j=0;j<S.size()-i;j++){
      safe=true;
      for(int k=0;k<S.size()-i-j;k++){
        if(S.at(i+k)=='A'||S.at(i+k)=='T'||S.at(i+k)=='C'||S.at(i+k)=='G'){}else{
          safe=false;
          break;
        }
      }
      if(safe&&score<S.size()-i-j) score=S.size()-i-j;
    }
  }
  cout << score << endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

ll dist(char c,string s){
    ll count=0;
    while(1){
        if(s.size()==1){return count;}
        bool j=true;
        for(int i=0;i<s.size();i++){
            if(s[i]!=c){j=false;}
        }
        if(j){return count;}
        for(int i=0;i<s.size()-1;i++){
            if(s[i+1]==c){s[i]=c;}
        }
        s.pop_back();
        count++;
    }
    return -1;
}


int main(){
    string s;
    cin>>s;
    ll count=s.size();
    for(int i='a';i<='z';i++){
        count=min(count,dist(i,s));
    }
    cout<<count<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  long long n;
  cin>>n;
  if(n==0){
    cout<<0<<endl;
    return 0;
  }
  
  long long div=2;
  long long l=1;
  //long long m=0;
  string ans="";
  
  while(n!=0){
    if(n%div==0){
      ans = "0" + ans;
    }else{
      ans = "1" + ans;
      n -= l;
    }
    div *=2;
    l *=-2;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int a, b;
    cin >> a >> b;
    if (a == b) cout << "a == b" << endl;
    else if (a > b) cout << "a > b" << endl;
    else if (a < b) cout << "a < b" << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main(){
    int N,M,C;
    cin >> N >> M >> C;
    
    int A[N][M],B[M],ans = 0,tmp = 0;
    for(int i=0;i<M;i++){
        cin >> B[i];
    }
    
    for(int i=0;i<N;i++){
        for(int k=0;k<M;k++){
            cin >> A[i][k];
            tmp += A[i][k]*B[k];
        }
        if(tmp>-C) ans++;
        tmp = 0;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
        double v;

        while (cin >> v) {
                double t = v / 9.8;
                double y = 4.9 * t * t;
                double n = (y + 5) / 5;
                cout << (int)ceil(n) << endl;
        }

        return 0;
}

Measured memory_bytes: 3152
#include <iostream>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    for (size_t i = 0; i < s.size(); i++)
    {
        char t = (int(s[i]) - int('A') + n) % 26 + int('A');
        cout << t;
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

ll a[200010];

void solve(){

    ll n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    ll pointer = 1;
    rep(i,n){
        if(a[i]==pointer){
            pointer++;
        }
    }
    if(n+1-pointer!=n) cout << n+1-pointer << endl;
    else cout << -1 << endl;

}

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


Measured memory_bytes: 1792
{-# LANGUAGE OverloadedStrings #-}

import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad

main = breads >>= flip replicateM B.getLine . head >>= mapM_ B.putStr . sort >> B.putStrLn ""

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)


Measured memory_bytes: 636
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    sort(all(s));
    int m = unique(all(s)) - s.begin();
    cout << (n == m ? "yes" : "no");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<int> A, D1, D2;
  ll sum = 0;
  for(int i=0; i<N; i++){
    int in;
    cin >> in;
    A.push_back(in);
    if(i == 0){
      int d1 = abs(in);
      D1.push_back(d1);
      sum += d1;
    } else {
      int d1 = abs(in - A[i-1]);
      D1.push_back(d1);
      sum += d1;
    }

    if(i > 0){
      if(i == 1){
        int d2 = abs(in);
        D2.push_back(d2);
      } else {
        int d2 = abs(in - A[i-2]);
        D2.push_back(d2);
      }
    }
  }
  sum += abs(A[N-1]);
  D1.push_back(abs(A[N-1]));
  D2.push_back(abs(A[N-2]));

  for(int i=0; i<N; i++){
    cout << sum - D1[i] - D1[i+1] + D2[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 2668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

#define no {printf("NO\n"); return 0;}

typedef long long ll;

const ll MOD = 1e9+7;

int a[100005];

vector <int> v[100005];

int br[100005];

void dfs(int x, int par) {
	int uk = a[x] + a[x] * (v[x].size() > 1);
	for (int i=0 ; i<v[x].size() ; i++) {
		if (v[x][i] == par) continue;
		dfs(v[x][i], x);
		uk -= br[v[x][i]];
		if (br[v[x][i]] > a[x]) {
			br[x] = -1;
			return ;
		}
	}
	br[x] = uk;
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i=1 ; i<=n ; i++) {
		scanf("%d", a+i);
	}
	for (int i=0 ; i<n-1 ; i++) {
		int x,y;
		scanf("%d%d", &x, &y);
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1, 0);
	//for (int i=1 ; i<=n ; i++) cout <<br[i]<<" ";
	if (br[1]) no;
	for (int i=2 ; i<=n ; i++) {
		if (br[i] > a[i] or br[i] < 0) no;
	}
	printf("YES\n");
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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 main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;
  int n = sz(s);
  stack<char> t;
  rep(i,n) {
    if(t.empty()) t.push(s[i]);
    else if(t.top() != s[i]) t.pop();
    else t.push(s[i]);
  }
  int ans = n - sz(t);
  cout << ans << endl;
}

Measured memory_bytes: 512
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*
int inv[1000001]={0};int invf[1000001]={0};
void findinverse(){
	inv[0]=1;
	inv[1] = 1;
	for(int i = 2; i <=1e6 ; ++i)
		inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
	invf[0]=1;invf[1]=1;
	for(int i=2;i<=1e6;i++){
		invf[i]=invf[i-1]*inv[i]%mod;
	}
}*/
using namespace std;
int n,m;
set<int> g;
vi adj[200005];
bool vis[200005];
void dfs(int s){
	g.insert(s);
	vis[s]=true;
	for(int i=0;i<adj[s].size();i++){
		if(vis[adj[s][i]]==false)
			dfs(adj[s][i]);
	}
}
int mx=-1e9;
int solve()
{
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	for(int i=0;i<=n;i++)
		vis[i]=false;
	for(int i=1;i<=n;i++){
		if(vis[i]==false){
			g.clear();
			dfs(i);
			mx=max(mx,(ll)g.size());
		}
	}
	cout<<mx<<endl;
	return 0;
}
signed main(){
	fastio;
	solve();
}

Measured memory_bytes: 30368
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

class ModCalc
{
    LLONG m_mod;
    vector<LLONG> m_fac;
    vector<LLONG> m_ifac;

public:

    ModCalc(const LLONG mod)
    {
        m_mod = mod;
    }

    ModCalc(const int max, const LLONG mod)
    {
        m_mod = mod;
        m_fac = vector<LLONG>(max + 1);
        m_ifac = vector<LLONG>(max + 1);
        m_fac[0] = m_ifac[0] = 1;
        for (int i = 0; i < max; ++i)
        {
            m_fac[i + 1] = m_fac[i] * (i + 1) % mod;    // n! (mod M)
            m_ifac[i + 1] = m_ifac[i] * ModPow(i + 1, mod - 2) % mod;   // k!^(M-2) (mod M)
        }
    }

    const LLONG ModAdd(LLONG a, LLONG b) const
    {
        return (a + b) % m_mod;
    }

    const LLONG ModSubtract(LLONG a, LLONG b) const
    {
        LLONG diff = a - b;
        return diff >= 0 ? diff : diff + m_mod;
    }

    const LLONG ModMulti(LLONG a, LLONG b) const
    {
        LLONG prod = a * b % m_mod;
        return prod >= 0 ? prod : prod + m_mod;
    }

    const LLONG ModDiv(LLONG a, LLONG b) const
    {
        LLONG c = m_mod, u = 1, v = 0;
        while (c)
        {
            LLONG t = b / c;
            b -= t * c; swap(b, c);
            u -= t * v; swap(u, v);
        }
        u %= m_mod;
        if (u < 0) u += m_mod;
        return (a % m_mod) * u % m_mod;
    }

    const LLONG ModPow(LLONG x, LLONG n) const
    {
        LLONG ret = 1;
        while (n != 0)
        {
            if (n & 1) ret = ret * x % m_mod;
            x = x * x % m_mod;
            n = n >> 1;
        }
        return ret;
    }

    const LLONG ModComb(LLONG n, LLONG r) const
    {
        if (n == 0 && r == 0) return 1;
        if (n < r || n < 0) return 0;
        LLONG tmp = m_ifac[n - r] * m_ifac[r] % m_mod;
        return tmp * m_fac[n] % m_mod;
    }
};

int main()
{
    LLONG n, k; cin >> n >> k;
    ModCalc mod(2 * 100001, MOD);
    LLONG ans = 0;
    for (LLONG m = 0; m <= min(n - 1, k); ++m)
    {
        LLONG tmp = mod.ModComb(n, m);
        tmp = mod.ModMulti(tmp, mod.ModComb(n - 1, n - m - 1));
        ans = mod.ModAdd(ans, tmp);
    }
    cout << ans << endl;
}

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

const int MAX_V = 50;
const int MAX_S = MAX_V * 50 + 5;
const ll INF = 1e18;

struct Edge {
    int to, a, b;
    Edge(int to, int a, int b)
        : to(to)
        , a(a)
        , b(b)
    {
    }
};

struct Data {
    int v, s;
    ll x;
    Data(int v, int s, ll x)
        : v(v)
        , s(s)
        , x(x)
    {
    }
    bool operator>(const Data& a) const
    {
        return x > a.x;
    }
};

vector<Edge> g[MAX_V];
ll dist[MAX_V][MAX_S + 5];

int main()
{
    int n, m, s;
    cin >> n >> m >> s;
    rep(i, m)
    {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u;
        --v;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }
    rep(i, n) rep(j, MAX_S + 5) dist[i][j] = INF;
    s = min(s, MAX_S);
    priority_queue<Data, vector<Data>, greater<Data>> q;
    auto push = [&](int v, int s, ll x) {
        if (s < 0)
            return;
        if (dist[v][s] <= x)
            return;
        dist[v][s] = x;
        q.emplace(v, s, x);
    };
    vector<int> c(n), d(n);
    rep(i, n) cin >> c[i] >> d[i];
    push(0, s, 0);
    while (!q.empty()) {
        Data hoge = q.top();
        q.pop();
        int v = hoge.v, s = hoge.s;
        ll x = hoge.x;
        if (dist[v][s] != x)
            continue;
        {
            int ns = min(s + c[v], MAX_S);
            push(v, ns, x + d[v]);
        }
        for (Edge e : g[v]) {
            push(e.to, s - e.a, x + e.b);
        }
    }
    for (int i = 1; i < n; ++i) {
        ll ans = INF;
        rep(j, MAX_S + 5)
        {
            ans = min(ans, dist[i][j]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6248
import sys

N, M = map(int, input().split())
if M == 0:
    print(0, 0)
    sys.exit()

p_S = []
for _ in range(M):
    p_S.append(input().split())
    
p = []
S = []


for i in range(M):
    p_S[i][0] = int(p_S[i][0])
    p_S[i][1] = int(p_S[i][1] =='AC')
    
p_S.sort(key=lambda x: x[0])

for i in range(M):
    p.append(p_S[i][0])
    S.append(p_S[i][1])

p = list(map(int, p))
S = list(map(int, S))

flag_p = p[0]
flag_ac = 0
AC_sum = 0
WA_sum = 0
WA = 0

for i in range(M):

    if flag_p == p[i]:
        if S[i] == 0 and flag_ac == 0:
            WA += 1
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            flag_ac = 1
    else:
        flag_p = p[i]
        flag_ac = 0
        WA = 0
        if S[i] == 0 and flag_ac == 0:
            WA += 1
        elif S[i] == 1 and flag_ac == 0:
            AC_sum += 1
            WA_sum += WA
            flag_ac = 1

print(AC_sum, WA_sum)

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 384
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; ++i )
#define         rep1(i,n)      for ( i=1 ; i<=n ; ++i )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         vcl            vector<ll>
#define         pb             push_back
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         sc             second
#define         spc            ' '
#define         nn             '\n'
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){Faysal

    lli ans,sum,tot,cnt,mx,mn,idx,chk,tmp,mid,lft,rgt,pos;
    lli tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    cin>>n>>k;
    if(n<k)
        cout<<min(n,k-n)<<endl;
    else{

        x=n%k;
        cout<<min(x,k-x)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256