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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    ll x;
    cin>>x;
    ll m=100;
    ll i;
    for(i=1;m<x;i++){
        m+=m*0.01;
    }
    cout<<i-1<<endl;
    return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int a[22][22];
int score[110000];
int dp[110000];
signed main() {
    cin >> N;
    rep(i, N)rep(j, N) { cin >> a[i][j]; }
    rep(i, bit(N)) {
        rep(j, N) {
            rep(k, j) {
                if (i & bit(j) && i & bit(k)) { score[i] += a[j][k]; }
            }
        }
    }
    rep(i, bit(N)) {
        for (int j = (i + 1) | i; j < bit(N); (j += 1) |= i) {
            chmax(dp[j], dp[i] + score[j & ~i]);
        }
    }
    cout << dp[bit(N) - 1] << endl;
}


Measured memory_bytes: 4636
#include<stdio.h>
int main(void)
{
  int a,b;
  int max,min;
  scanf("%d%d", &a, &b);
  
  if(a<=b) {
    max=b;
    min=a;
  }
  else {
    max=a;
    min=b;
  }
  
  for(int i=0; i<max; i++){
    printf("%d",min);
  }
  
  return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //上に同じ

vector<int> w,v;
vector<vector<long long>> my_max;

long long dp(int y,int x){
  if (y < 0 || x < 0){
    return(LLONG_MIN);
  }
  if (y == 0 || x == 0){
    return(0);
  }
  
  if (my_max[y][x] != -1){
    return(my_max[y][x]);
  }
  my_max[y][x] = max({dp(y-1,x-w[y])+v[y],dp(y-1,x),dp(y,x-1)});
  return(my_max[y][x]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,W;
  cin >> n >> W;
  w.resize(n+1);
  v.resize(n+1);
  my_max.resize(n+1,vector<long long>(W+1,-1));
  for (int i = 1; i <= n; i++){
    cin >> w[i] >> v[i];
  }
  
  cout << dp(n,W) << '\n';
  return 0;
}

Measured memory_bytes: 90108
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a == b && a != c) {

		cout <<  "Yes" << endl;
	}
	else if (a == c && b != c) {

		cout << "Yes" << endl;
	}
	else if (b == c && a != c) {

		cout << "Yes" << endl;
	}
else {
		cout << "No" << endl;
}
	return 0;
}

  

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
	int num,i,j,temp,min,count=0;
	scanf("%d",&num);
	int *p=(int *)malloc(sizeof(int)*num);
	for(i=0;i<num;i++)
	scanf("%d",&p[i]);
	for(i=0;i<num-1;i++)
	{
		min=i;
		for(j=i+1;j<num;j++)
		if(p[min]>p[j])
			min=j;
		if(min!=i)
		{
			temp=p[i];
			p[i]=p[min];
			p[min]=temp;
			count++;
		}
	}
	for(i=0;i<num;i++)
	{
		printf("%d",p[i]);
		if(i+1!=num)
		printf(" ");
	}
	printf("\n%d\n",count);
	return 0;
}

Measured memory_bytes: 1808
#include<bits/stdc++.h>
#define MAXN 310
using namespace std;
int d[MAXN][MAXN];
int d1[MAXN][MAXN];
int q[MAXN][MAXN];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, M, L;
    cin >> N >> M >> L;
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= N; j++)
            d[i][j] = L+1;
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = d[b][a] = min(d[a][b], c);
    }

    for(int k = 1; k <= N; k++)
        for(int i = 1; i <= N; i++)
            for(int j = 1; j <= N; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= N; j++){
            if(d[i][j] <= L)
                d1[i][j] = 0;
            else d1[i][j] = 1e9;
        }
    for(int k = 1; k <= N; k++)
        for(int i = 1; i <= N; i++)
            for(int j = 1; j <= N; j++)
                d1[i][j] = min(d1[i][j], d1[i][k] + 1 + d1[k][j]);

    int Q;
    cin >> Q;
    while(Q--){
        int a, b;
        cin >> a >> b;
        if(d1[a][b] == 1e9)
            d1[a][b] = -1;
        cout << d1[a][b] << "\n";
    }
    return 0;
}

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n;
  cin >> n;
  vt<int> imos(100100, 0);
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    imos[a]++; imos[b + 1]--;
  }

  rep(i, 0, 1e5) imos[i + 1] += imos[i];

  for(int i = 1e5 + 1; i >= 1; --i) {
    if(imos[i] + 1 >= i) return cout << i - 1 << endl, 0;
  }
}


Measured memory_bytes: 3364
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>

void print(T x)
{
	std::cout << x <<" " ;
}


signed main(void) {
	int N,X;
	cin >> N>> X  ;
	vector<int>L;
	L.resize(N);
	rep(i, N) {
		cin >> L[i];
	}
	int ans = 1;
	int sum = 0;
	rep(i, N) {
		sum += L[i];
		if (sum <= X)ans++;
		else break;
	}
	print(ans);
}


Measured memory_bytes: 256
import sys
import bisect
import copy
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
inf = 10**9+1

def dfs(v,prev = -1):
    x = As[v]
    if len(LIS) == 0 or x > LIS[-1]:
        old = inf
        i = len(LIS)
        LIS.append(x)
    else:
        i = bisect.bisect_left(LIS, x)
        old = LIS[i]
        LIS[i] = x

    a = len(LIS)
    ans_array[v] = a
    for u in graph[v]:
        if u == prev:
            continue
        dfs(u,v)
    if old == inf:
        LIS.pop(-1)
    else:
        LIS[i] = old

N = int(input())
As = list(map(int,input().split()))
graph = [[] for _ in range(N)]

for i in range(N-1):
    a,b = list(map(int,input().split()))
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
LIS = []
ans_array = [0] * N
dfs(0)
for i in range(N):
    print(ans_array[i])


Measured memory_bytes: 350604
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())


if A < B:
    A_sum = A + (V * T)
    B_sum = B + (W * T)
    if A_sum >= B_sum:
        print('YES')
    else:
        print('NO')

else:
    A_sum = A - (V * T)
    B_sum = B - (W * T)
    if A_sum <= B_sum:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
const int MOD = 1e9 + 7;

ll dp[100001][13];

signed main(){
    string S;
    cin >> S;
    dp[0][0] = 1;
    REP(i,S.size()){
        REP(j,10){
            int c = S[i] - '0';
            if(S[i] == '?' || c == j){
                REP(k,13){
                    dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                    dp[i + 1][(k * 10 + j) % 13] %= MOD;
                }
            }
        }
    }
    cout << dp[S.size()][5] << endl;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,A,B;
    int max,min;
    cin>>N>>A>>B;
    
    if(A+B<=N){
        min=0;
        if(A>B){
            max=B;
        }else{
            max=A;
        }
    }else if(A+B>N){
        min=(A+B)-N;
        if(A>B){
            max=B;
        }else{
            max=A;
        }
    }
    
    
    cout<<max<<" "<<min<<endl;
    
}


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

int main() {
  int n, S[10000];
  int q, T[500];

  cin >> n;
  for(int i=0; i < n; i++) cin >> S[i];
  cin >> q;
  for(int i=0; i < q; i++) cin >> T[i];

  int count = 0;
  for(int i=0; i < q; i++) 
    for(int j=0; j < n; j++) 
      if(S[j] == T[i]) {
        count++;
        break;
      }
  cout << count << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    int maxv = -1e9;
    int minv;
    cin >> minv;
    
    for(int i = 1;i < n;i++){
        int r;
        cin >> r;
        maxv = max(maxv, r - minv);
        minv = min(minv, r);
    }
    cout << maxv << endl;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    int n,m;
    cin>>n;
    int t[n],a[n];
    for(int i=1;i<=n;i++)
      cin>>t[i],a[i]=t[i];
    cin>>m;
    while(m--)
    {
       int sum=0,p,x;
       cin>>p>>x;
       t[p]=x;
       for(int i=1;i<=n;i++)
       {
         sum+=t[i];
       }
       cout<<sum;
       nl;
       t[p]=a[p];
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
    string S;
    cin >> S;
    ll ans = 0;
    REP(i,S.size()){
        ans += (S[i]-'0');
        ans %= 9;
    }
    if(0 == ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3752
n=int(input())
l=[]
for i in range(1,int(n**0.5)+2):
  if n%i==0:
    l.append([i,n//i])

ans=float('inf')
for a,b in l:
  ans=min(max(len(str(a)),len(str(b))),ans)
print(ans)




Measured memory_bytes: 9384
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 3001;
int n;
double p[N];
double ans[N][N][2]; // 0 - tail, 1 - head

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    cout.precision(12);cout << fixed;
    cin >> n;
    rep(i,n) cin >> p[i+1];

    ans[1][1][1] = p[1];
    ans[1][0][0] = 1-p[1];
    repA(i,2,n) {
    	repA(j,0,n) {
    		if(j > i) break;

    		ans[i][j][0] = (ans[i-1][j][0] + ans[i-1][j][1]) * (1-p[i]);
    		if(j != 0)
    			ans[i][j][1] = (ans[i-1][j-1][0] + ans[i-1][j-1][1]) * p[i];
    	}
    }

    double fans = 0;
    repA(i,n/2 + 1, n) {
    	fans += ans[n][i][0] + ans[n][i][1];
    }
    cout << fans << '\n';
}

Measured memory_bytes: 279680
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
num = 1
begin = 0
for j in range(100000):
    for i in range(begin + 1,N):
        wait = T[i] - T[begin]
        if wait > K or i - begin + 1> C:
            num += 1
            begin = i
            break
    else:
        break
print(num)

Measured memory_bytes: 51288
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def bfs():
    dist = [-1]*n
    que = deque([0])
    dist[0] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in g[v]:
            if dist[w[0]] > -1:
                continue
            dist[w[0]] = d + w[1]
            que.append(w[0])
    return dist

n = INT()
g = [[] for i in range(n)]
for i in range(n-1):
    x, y, z = MAP()
    g[x-1].append([y-1, z])
    g[y-1].append([x-1, z])
for k in bfs():
    print(0 if k%2 == 0 else 1)

Measured memory_bytes: 51628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define Mod 1000000007

int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    if(a>=k)ans=k;
    else if(a+b>=k)ans=a;
    else{
        ans=a-(k-a-b);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
n, m, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)

sum_a = Array.new(n+1)
sum_b = Array.new(m+1)

prev = 0
sum_a[0] = 0
a.each.with_index do |x, i|
  sum_a[i+1] = prev + x
  prev = sum_a[i+1]
end

prev = 0
sum_b[0] = 0
b.each.with_index do |x, i|
  sum_b[i+1] = prev + x
  prev = sum_b[i+1]
end

res = 0
sum_a.each.with_index do |x, i|
  t = k - x
  next if t < 0
  q = sum_b.bsearch_index { |y| y >= t }
  next if q.nil?

  if x + sum_b[q] <= k
    r = i+q
    res = [res, r].max
    next
  end
  if q >= 1 && x + sum_b[q-1] <= k
    r = i+q-1
    res = [res, r].max
    next
  end
end

puts res


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

using namespace std;

const int N = 1e5+7;
const int MOD = 1e9+7;

template <int _MOD> struct Mint
{
    int v = 0;
    Mint() {}
    Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
    Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
    Mint operator = (const int _v) { this->v = _v; return *this; }
    Mint operator = (const long long _v) { this->v = static_cast<int>(_v%_MOD); return *this; }
    bool operator < (const Mint &b) const { return v < b.v; }
    bool operator > (const Mint &b) const { return v > b.v; }
    bool operator == (const Mint &b) const { return v == b.v; }
    bool operator != (const Mint &b) const { return v != b.v; }
    bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
    bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
    Mint operator + (const Mint &b) { return Mint(v+b.v); }
    Mint operator - (const Mint &b) { return Mint(v-b.v); }
    Mint operator * (const Mint &b) { return Mint(1ll*v*b.v); }
    Mint operator / (const Mint &b) { return Mint(b.inv()*v); }
    Mint operator += (const Mint &b) { return *this = *this+b; }
    Mint operator -= (const Mint &b) { return *this = *this-b; }
    Mint operator *= (const Mint &b) { return *this = *this*b; }
    Mint operator /= (const Mint &b) { return *this = *this/b; }
    Mint pow(int p) const {
        Mint res(1), x(*this);
        while (p) {
            if (p&1) res = res*x;
            x *= x;
            p >>= 1;
        }
        return res;
    }
    Mint inv() const { return pow(_MOD-2); }
    friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v; }
    friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;

int n;
int a[N], c[3];
mint res = 1;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1, cnt, id; i <= n; ++i) {
        cnt = 0;
        id = -1;
        for (int j = 0; j < 3; ++j) {
            if (a[i] == c[j]) {
                ++cnt;
                id = j;
            }
        }
        res *= cnt;
        ++c[id];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
def func(a):
	val1=0
	if(a%4==0):
		val1=a
	elif(a%4==1):
		val1=1
	elif(a%4==2):
		val1=a+1
	elif(a%4==3):
		val1=0
	return val1
a,b=map(int,input().split())
#print(func(a-1),func(b))
print(func(a-1)^func(b))



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
char a[N];
int main(){
	scanf("%s",a);
	int n=strlen(a),x=0,ans=0;
	for(int i=0;i<n;i++){
		if(x<=0){
			x++;
			if(a[i]=='p') ans--;
		}
		else{
			x--;
			if(a[i]=='g') ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3840
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
r = range

n, x = map(int, input().split())
# n行x列の配列を取得
a = np.array(list(map(int, input().split())))

ret = 0
for i in r(1, n):
    for j in r(2):
        if a[i] + a[i-1] > x:
            tmp = min(a[i-j], a[i] + a[i-1] - x)
            ret += tmp
            a[i-j] -= tmp

print(ret)

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

int main() {
  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(),a.end());
  int ans=0,k=0;
  ans += (a.at(2)-a.at(1))/2;
  a.at(1) += ans*2;
  if(a.at(2)-a.at(1) == 1){
    ans++;
    a.at(1)++;
    a.at(0)++;
  }
  if((a.at(2) - a.at(0))%2 == 0){
    ans += (a.at(2)-a.at(0))/2;
  }
  else {
    ans += (a.at(2) -a.at(0)+1)/2 +1;
  }
  
  cout << ans << endl;
  
  return 0;
}

    
  


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

ll Lucas(ll N,vector<ll> &memo){
  if(memo[N]!=-1){
    return memo[N];
  }
  else{
    memo[N]=Lucas(N-1,memo)+Lucas(N-2,memo);
    return memo[N];
  }
}

int main(){
  ll N;
  cin >> N;
  vector<ll> memo(N+5,-1);
  memo[0]=2;
  memo[1]=1;
  cout << Lucas(N,memo) << endl;
}

Measured memory_bytes: 3604
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=0,g=0,b=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        r++;
        else if(s[i]=='G')
        g++;
        else
        b++;
    }
    int ans=r*g*b;
    for(int i=0;i<n;i++)
    {
        for(int j=1;2*j+i<n;j++)
        {
            if(s[j+i]!=s[i]&&(s[i+(2*j)]!=s[i+j]&&s[i+(2*j)]!=s[i]))
            ans--;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3660
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    String str1 = sc.next();
    String str2 = sc.next();
    int A = Integer.valueOf(str1);
    int B = Integer.valueOf(str2);
    
    int ans =  A * B;
    System.out.println(ans);
  }
}

Measured memory_bytes: 35620
// https://atcoder.jp/contests/agc040/tasks/agc040_a
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    string s;
    cin >> s;
    int len = s.length();
    vector<int> v(len + 1);
    for (int i = -1; i < len; i++) {
        if (i == -1 || i == len - 1 || s[i] == '<' && s[i + 1] == '>') {
            int t1 = 0, t2 = 0;
            int pos = i;
            while (pos >= 0 && s[pos] == '<') {
                t1++;
                pos--;
            }
            pos = i + 1;
            while (pos < len && s[pos] == '>') {
                t2++;
                pos++;
            }
            v[i + 1] = max(t1, t2);
            FOR(j, 1, t1) { v[i - j] = t1 - j; }
            FOR(j, 1, t2) { v[i + j + 1] = t2 - j; }
        }
    }
    cout << accumulate(ALL(v), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 4740
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  m := nextInt()
  l := nextInt()
  vector1 := make([][]int, n)
  for i := 0; i < n; i++ {
    vector1[i] = make([]int, m)
    for j := 0; j < m; j++ {
      vector1[i][j] = nextInt()
	}
  }

  vector2 := make([][]int, m)
  for i := 0; i < m; i++ {
    vector2[i] = make([]int, l)
    for j := 0; j < l; j++ {
      vector2[i][j] = nextInt()
	}
  }

  for i := 0; i < n; i++ {
      for r := 0; r < l; r++ {
		sum := 0
        for q := 0; q < m; q++ {
			  sum = sum +vector1[i][q] * vector2[q][r]
        }
        fmt.Print(sum)
		if r != l - 1{
          fmt.Print(" ")
	    }
      }
      fmt.Println()
  }

}

func getStdin() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}



Measured memory_bytes: 1492
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=1e5+5;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}

int n;
char s[N];

int main()
{
	read(n);
	scanf("%s",s);
	if(n<3200)puts("red");
	else printf("%s\n",s);
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> tasks;
    
    for (int i = 0; i<N; i++){
        int A, B;
        cin >> A >> B;
        tasks.emplace_back(B, A);
    }
    
    sort(tasks.begin(), tasks.end());
    
    int time = 0;
    
    for (int i = 0; i < N; i++){
        time += tasks.at(i).second;
        if (time > tasks.at(i).first){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
}


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

using namespace std;

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

    int n, e, s, w;
    n = e = s = w = -1;
    for (auto c:st) {
        switch (c) {
            case 'N':
                n = 1;
                break;
            case 'E':
                e = 1;
                break;
            case 'W':
                w = 1;
                break;
            case 'S':
                s = 1;
                break;
            default:
                break;
        }
    }

    if (n * s > 0 && e * w > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

const int N = 2e6 + 7, mod = 1e9 + 7;

int POW(int a, int b, int mod) {
	a %= mod; int r = 1;
	for(int i = b; i > 0; i >>= 1) {
		if(i & 1) r = (r * a) % mod;
		a = (a * a) % mod;
	}
	return r;
}

int f[N];


int nCr(int n, int r) {
	if(n < r) return 0;
	return f[n] * POW(f[n - r] * f[r], mod - 2, mod) % mod;
}


int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	f[0] = 1;
	for(int i = 1; i < N; i++) {
		f[i] = (f[i - 1] * i) % mod;
	}	
	int k; string s; cin >> k >> s;
	int ans = 0;
	for(int i = 0; i <= k; i++) {
		ans += nCr(k - i + (int)s.size() - 1, (int)s.size() - 1) * (POW(26, i, mod) * POW(25, k - i, mod) % mod) % mod;
		ans %= mod;
		
	}

	cout << ans << endl;
}

Measured memory_bytes: 19888
point_t = 0
point_h = 0
n = int(input())
for i in range(n):
    card_t, card_h = input().split()
    if card_t > card_h:
        point_t += 3
    if card_t < card_h:
        point_h += 3
    if card_t == card_h:
        point_t += 1
        point_h += 1
print(point_t, point_h)

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

        signed main() {
        int h,w;
        cin>>h>>w;
        if(h%3==0||w%3==0){
            cout<<0;
            return 0;
        }
        int ans=min(h,w);
       int a[3]={};
        for(int i=1;i<h;i++){
            a[0]=i*w;
            a[1]=(h-i)*(w/2);
            a[2]=(h-i)*(w - w/2);
            sort(a,a+3);
            ans=min(ans,a[2]-a[0]);
        }
         for(int i=1;i<w;i++){
            a[0]=i*h;
            a[1]=(w-i)*(h/2);
            a[2]=(w-i)*(h - h/2);
            sort(a,a+3);
            ans=min(ans,a[2]-a[0]);
        }
        cout<<ans;
        }


Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
const long double PI=(acos(-1));
const long double EPS=0.0000000001;
long double a,b,x;
long double f(long double a,long double b,long double theta)
{
    if(theta>PI/2.0-EPS)
        return 0.0;
    long double ret;
    if(a*tan(theta)<=b)
        ret=a*a*b-a*a*a*tan(theta)/2.0;
    else
        ret=b*b/tan(theta)*a/2.0;
    return ret;

}
int main()
{
    cin>>a>>b>>x;
    long double ok=PI/2.0;
    long double ng=0.0;
    for(int i=1;i<=10000;i++)
    {
        long double mid=(ok+ng)/2.0;
        if(f(a,b,mid)<x)
            ok=mid;
        else
            ng=mid;
    }
    cout<<fixed<<setprecision(10)<<ok/PI*180<<endl;
}



















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

int a[12][12];
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int>c(n);
  rep(i,n){
    cin>>c[i];
    rep(j,m)cin>>a[i][j];
  }
  int kotae=INT_MAX;
  rep(s,1<<n){
    vector<int>d(m,0);
    int sum=0;
    rep(i,n){
      if(s>>i&1){
        sum+=c[i];
        rep(j,m)d[j]+=a[i][j];
      }
      bool hantei=true;
      rep(j,m){
        if(d[j]<x){
          hantei=false;
          break;
        }
      }
      if(hantei==true)kotae=min(kotae,sum);
    }
  }
  if(kotae==INT_MAX){
    cout<<-1<<endl;
  }else{
    cout<<kotae<<endl;
  }
  return 0;
}
    

Measured memory_bytes: 3632
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
ll X;
ll hoge;
int main(){
	cin>>N>>X;
	hoge=0;
	int ans=1;
	rep(i,N){
		ll x;
		cin>>x;
		hoge+=x;
		if(hoge<=X)ans++;
	}
	cout<<ans<<endl;
}

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

int main() {
	int n;
	cin>>n;
	for(int i=0,num[3];i<n;i++){
		for(int j=0;j<3;j++)cin>>num[j];
		num[0]-=1;
		num[1]-=1;
		int three=590,ans=num[0]/3*three+num[0]%3*195;
		if((num[0]+1)%3==0)ans+=num[1]*20;
		else ans+=num[1]/2*39+num[1]%2*20;
		cout<<196471-ans-num[2]<<endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
int ta[200010],nt[400010],to[400010],cc[400010];
long long u[200010],ANS[200020],ans[200020];
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
long long pp[200010],ip[200010],M=1e9+7;
int f(int s){//printf("!%d\n",s);
  long long i;
  u[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(u[to[i]])continue;
    ans[s]=ans[s]*f(to[i])%M;
    ans[s]=ans[s]*ip[cc[to[i]]+1]%M;
    cc[s]+=cc[to[i]]+1;
  }
  ans[s]=ans[s]*pp[cc[s]]%M;
  return ans[s];
}
void h(int s,int t){
  ans[s]=ans[s]*ip[cc[s]]%M*pp[cc[t]+1]%M*inv(ans[t],M)%M;
  ans[t]=ans[t]*ip[cc[t]]%M;
  cc[s]-=cc[t]+1;
  cc[t]+=cc[s]+1;
  ans[s]=ans[s]*pp[cc[s]]%M;
  ans[t]=ans[t]*pp[cc[t]]%M*ip[cc[s]+1]%M*ans[s]%M;
}
void g(int s){//printf("!!%d %d\n",s,cc[s]);
  int i;
  u[s]=2;
  ANS[s]=ans[s];
  for(i=ta[s];i+1;i=nt[i]){
    if(u[to[i]]==2)continue;
    //printf("%d %d %d %d %lld %lld\n",s,to[i],cc[s],cc[to[i]],ans[s],ans[to[i]]);
    h(s,to[i]);
    //printf("%d %d %d %d %lld %lld\n",s,to[i],cc[s],cc[to[i]],ans[s],ans[to[i]]);
    g(to[i]);
    h(to[i],s);
  }
}
int main(){
  int n,a,b,i;
  scanf("%d",&n);
  for(i=0;i<=n;i++)ta[i]=-1;
  pp[0]=1;
  for(i=1;i<=n;i++)pp[i]=(pp[i-1]*i)%M;
  for(i=0;i<=n;i++)ip[i]=inv(pp[i],M);
  for(i=1;i<=n;i++)ans[i]=1;
  for(i=0;i<n-1;i++){
    scanf("%d %d",&a,&b);
    nt[i    ]=ta[to[i+n-1]=a];
    nt[i+n-1]=ta[to[i    ]=b];
    ta[b]=i+n-1;
    ta[a]=i;
  }
  f(1);
  //for(i=0;i<=10;i++)printf("%lld\n",pp[i]);printf("\n");
  //for(i=0;i<=n;i++)printf("%d\n",cc[i]);
  //printf("%d\n",f(1));
  //for(i=0;i<=n;i++)printf("%d\n",cc[i]);
  //for(i=1;i<=n;i++)printf("%3d ",i);printf("\n");
  //for(i=1;i<=n;i++)printf("%3lld ",ans[i]);printf("\n");
  //for(i=1;i<=n;i++)printf("%3d ",cc[i]);printf("\n");
  g(1);
  for(i=1;i<=n;i++)printf("%lld\n",ANS[i]);
  return 0;
}


Measured memory_bytes: 15360
#include<stdio.h>

int n,nn[100],x,y,z;

int main()
{
    for(x=0;x<=25;x++){
        for(y=0;y<=14;y++){
            if(x*4+y*7<=100){
                nn[x*4+y*7]=1;
            }
        }
    }

    scanf("%d",&n);
    if(nn[n])printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 128
def solve(zeikomi: int):
    for zeinuki in range(zeikomi + 1):
        if int(zeinuki * 1.08) == zeikomi:
            return zeinuki
    return None


zeikomi = int(input().strip())
zeinuki = solve(zeikomi)
if zeinuki is not None:
    print(zeinuki)
else:
    print(':(')


Measured memory_bytes: 2940
gets
xs = gets.split(' ').map(&:to_i)
c2 = xs.select{|v| v % 2 == 0 && v % 4 != 0}.length
c4 = xs.select{|v| v % 4 == 0}.length

c4 += c2 / 2
puts xs.length / 2 <= c4 ? "Yes" : "No"


Measured memory_bytes: 9220
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,m;
	cin>>n>>m;
	vector<int> a,L,R;
	int ans=n;
	for(int i=0;i<n;i++)
	{
		a.push_back(0);
	}
	for(int i=0;i<m;i++)
	{
		int l,r;
		cin>>l>>r;
		L.push_back(l);
		R.push_back(r);
	}
	sort(L.begin(),L.end());
	sort(R.begin(),R.end());
	int t=-L[L.size()-1] + R[0]+1;
	if(t>0)
	{
		cout<<t;
	}
	else
	cout<<"0";
	cout<<endl;
}

Measured memory_bytes: 1912
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0,A,B,x, tmp;

void solve(){

    if(A > 0)
        cout << B / x  - (A - 1)/x << endl;
    else
        cout << B/x + 1 << endl;
    
}

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

    solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

bool expectS(int index1, int index2, bool s) {
    return (abs(index1 - index2) % 2 == 0) ? s : !s;
}


int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    string s;

    cout << 0 << endl << flush;
    cin >> s;

    if (s == "Vacant")
        return 0;
    
    bool firstS = (s == "Male");
    int first = 0;
    int last = n - 1;
    int count = 0;

    while (count < 20) {
        int index = first + (last - first + 1) / 2;

        cout << index << endl << flush;
        cin >> s;
        if (s == "Vacant")
            return 0;
    
        bool indexS = (s == "Male");

        if (indexS == expectS(index, first, firstS)) {
            first = index;
            firstS = indexS;
        } else {
            last = index;
        }
        count++;
    }
    
    return 0;
}


Measured memory_bytes: 852
// 2020-08-29 21:10:06
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct DisjointSet {
  std::map<int, int> parent, rank, num;

  void makeSet(int x) {
    parent[x] = x;
    rank[x] = 0;
    num[x] = 1;
  }

  bool same(int x, int y) {
    return findSet(x) == findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x), findSet(y));
  }

  void link(int x, int y) {
    if(rank[x] < rank[y]) {
      parent[x] = y;
      num[y] += num[x];
    } else {
      parent[y] = x;
      num[x] += num[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  int numberOf(int x) {
    return num[findSet(x)];
  }

  int findSet(int x) {
    if(x == parent[x]) return x;
    else return parent[x] = findSet(parent[x]);
  }
};

// clang-format on
void answer() {
  int n, m;
  cin >> n >> m;
  DisjointSet ds;
  rep(i, n) ds.makeSet(i);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (!ds.same(a, b)) ds.unite(a, b);
  }
  int ans = 0;
  rep(i, n) chmax(ans, ds.numberOf(i));
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x) 
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define fo(i, a, b) for (int i = a; i <= b; ++i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, c; cin >> n >> c;
    int w[n], v[n];
    rep(i, n) cin >> w[i] >> v[i];

    #define INF 200000000000
    ll dp[n+1][100005];
    for (int i = 0; i <= n; ++i) dp[i][0] = 0;
    for (int x = 1; x <= 100000; ++x) dp[n][x] = INF;
    for (int i = n-1; i >= 0; --i) {
        for (int x = 0; x <= 100000; ++x) {
            dp[i][x] = dp[i+1][x];
            if (v[i] <= x) dp[i][x] = min(dp[i][x], dp[i+1][x-v[i]] + w[i]);
        }
    }

    ll mini;
    for (int x = 100000; x >= 0; --x) if (dp[0][x] <= c) {
        mini = x;
        break;
    }
    cout << mini << '\n';
}



Measured memory_bytes: 79232
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 998244353
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
ll bit[2*N];
// ll b[2*N];
int n;
void upd(int id,ll val){
	while(id<=n){
		bit[id]=(bit[id]+val)%MOD;
		id+=(id&(-id));
	}
}
ll query(int id){
	ll ans=0;
	while(id>0){
		ans=(ans+bit[id])%MOD;
		id-=(id&(-id));
	}
	return ans;
}
ll qr(int l,int r){
	return (query(r)-query(max(0,l-1))+MOD)%MOD;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int k;
cin>>n>>k;
pii arr[k];
for(int i=0;i<k;i++){
	int l,r;
	cin>>l>>r;
	arr[i].first=l;
	arr[i].second=r;
}
sort(arr,arr+k);
// b[1]=1;
upd(1,1);
for(int i=2;i<=n;i++){
    for(int j=0;j<k;j++){
    	if(i-1<arr[j].first)break;
    	else if(i-1<=arr[j].second){
    		ll tmp=qr(1,i-arr[j].first);
    		// b[i]=(b[i]+tmp)%MOD;
    		upd(i,tmp);
            break;
    	}
    	else{
    		ll tmp=qr(i-arr[j].second,i-arr[j].first);
    		// b[i]=(b[i]+tmp)%MOD;
    		upd(i,tmp);

    	}
    }
    // cout<<qr(i,i)<<endl;
    // cout<<b[i]<<endl;
    // upd(i,b[i]);
}
cout<<qr(n,n)%MOD<<endl;
return 0;
}

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

using namespace std;

int main() {
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    bool c = false;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            c = true;
            break;
        }
    }
    if (c) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include"bits/stdc++.h"
using namespace std;

int mcm(int N, vector<int>& p, vector<vector<int>>& M)
{
	for (int l = 1; l < N; l++)
	{
		for (int i = 1; i <= N - l; i++)
		{
			int j = i + l;
			M[i][j] = (1 << 21);
			for (int k = i; k < j; k++)
			{
				M[i][j] = min(M[i][j], M[i][k] + M[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	return M[1][N];
}

int main(void)
{
	int N;
	cin >> N;
	vector<int> p;
	vector<vector<int>> M(N + 1, vector<int>(N + 1, 0));

	for (int i = 0; i < N; i++)
	{
		int x, z;
		cin >> x >> z;
		if (!i) p.push_back(x);
		p.push_back(z);
	}

	cout << mcm(N, p, M) << endl;

	return 0;
}


Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int f = int.Parse(Console.ReadLine());
            int g = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());
            int i = int.Parse(Console.ReadLine());
            int j=  int.Parse(Console.ReadLine());
            int[] sss = {a,b,c,d,e,f,g,h,i,j};
            Array.Sort(sss);
            Console.Write("{0}\n",sss[9]);
            Console.Write("{0}\n", sss[8]);
            Console.Write("{0}\n", sss[7]);
            
        }
    }
}

Measured memory_bytes: 9348
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int a[101], dp[100001][101], pre[100001][101];

signed main(){
    IOS;
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 0; i <= n; i++) {
        dp[0][i] = 1;
        pre[0][i] = 1;
    }
    for (int i = 1; i <= k; i++) {
        dp[i][0] = 0;
        pre[i][0] = (dp[i][0] + pre[i-1][0]) % MOD;
    }
    for (int j = 1; j <= n; j++) {
        for (int i = 1; i <= k; i++) {
            if (i - a[j] - 1 >= 0) dp[i][j] = (pre[i][j-1] - pre[i-a[j]-1][j-1] + MOD) % MOD;
            else dp[i][j] = pre[i][j-1];
            pre[i][j] = (pre[i-1][j] + dp[i][j]) % MOD;
        }
    }
    cout << dp[k][n] << endl;
    return 0;
}

Measured memory_bytes: 158080
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int r = 0,l = 0;
  for(int i = 0;i<S.size();i++){
    if(S.at(i) == 'R' && S.at(i+1) == 'R' && i != S.size()-1){
      cout << 0 << " ";
      r++;
    }
    else if(S.at(i) == 'R' && S.at(i+1) == 'L'){
      r++;
      while( i<S.size()-1 && S.at(i+1) == 'L'){
        l++;
        i++;
      }
      cout << l/2+r-r/2 << " " << r/2+l-l/2 << " ";
      for(int k = 0;k<l-1;k++){
        cout << 0 << " ";
      }
      r = 0;
      l = 0;
    }
  }
  return 0;
}

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

using namespace std;

const int max_n = 2e5 + 5;

int k,n;
int a[max_n];
int mn = 1e9;

int cdist(int l,int r)
{
	if(l > r)
		return (a[r] - a[l] + k);
	return (a[r] - a[l]);
}

int ccdist(int l,int r)
{
	if(l > r)
		return (a[l] - a[r]);
	return (a[l] - a[r] + k);
}

int main()
{
	cin >> k >> n;
	for(int i=0;i<n;++i)
		cin >> a[i];
	mn = min(cdist(0,n-1),ccdist(n-1,0));
	for(int i=1;i<n;++i)
		mn = min(mn,min(cdist(i,i-1),ccdist(i-1,i)));
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 1024