akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> N >> A;
	bool flag = 0;
	for (int i = 0; i <= A; i++) {
		if ((N - i) % 500 == 0) {
			flag = 1; break;
		}
	}
	if (flag)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
lia=[]
lib=[]
lia2=[]
lib2=[]

lia+='R'*(c-a)
lia+='U'*(d-b)
lia2+='D'
lia2+='R'*(c-a+1)
lia2+='U'*(d-b+1)
lia2+='L'

lib+='L'*(c-a)
lib+='D'*(d-b)
lib2+='U'
lib2+='L'*(c-a+1)
lib2+='D'*(d-b+1)
lib2+='R'
li=lia+lib+lia2+lib2
print(''.join(li))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int n = stoi(s);
    char t;
    int dsum =0;
    int tmsum =0;
    
    for(int i=0; i < s.length(); i++){
        t = s[i];
        tmsum = t - '0';
        dsum = dsum + tmsum;
    }
    if(n % dsum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());

        long count = 0;
        long i = 1;
        while(true) {
            count += i;
            if(count >= x) {
                break;
            }
            i++;
        }
        System.out.println(i);
    }   
}

Measured memory_bytes: 21844
from collections import defaultdict


N = int(input())
blue_cards = defaultdict(int)
for _ in range(N):
    blue_cards[input()] += 1
M = int(input())
red_cards = defaultdict(int)
for _ in range(M):
    red_cards[input()] += 1
ans = 0
for string, score in blue_cards.items():
    ans = max(ans, score - red_cards.get(string, 0))
print(ans)


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

long inf = 1000000007;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) or (a == c && a != b) or (b == c && a != b)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int arr [100009];
int dp [100009];
int n,k;
int frog (int f_index)
{
if (f_index + 1 == n)return 0;
if (dp [f_index] != -1)return dp [f_index];
int s = INT_MAX;
for (int i = 1 ;i <= k;i++)
{
if (f_index + i >= n)break;
s = min (s , frog (f_index + i) + abs (arr [f_index + i] - arr [f_index]));
}
return dp [f_index] = s ;
}
int main ()
{
cin >>n>>k;
for (int p = 0;p < 100009;p++)
{
dp [p] = -1;
}
for (int i = 0 ;i<n;i++)
{
cin >> arr [i];
}
cout <<frog (0)<<'\n';

}

Measured memory_bytes: 10620
#include<iostream>
#include<iomanip>
#define N 50;
using namespace std;

int main(){
    int n=N;
    int a[n];
    double b=0;
    double c;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int m=n-1;m>=1;m--){
        int w;
    for(int j=0;j<m;j++){
        if(a[j]>a[j+1]){
            
            w=a[j];
            a[j]=a[j+1];
            a[j+1]=w;
        }

    }
}

for(int i=1;i<n;i++){
    if(i==1){
    b=(double)(a[i-1]+a[i])/2;}
    else{
    b=(double)(b+a[i])/2;}
}
   
    
    cout<<setprecision(10)<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define inf 1e18
#define all(v) (v).begin(),(v).end()
using namespace std;

vector <int> dx = {-1,1,0,0};
vector <int> dy = {0,0,-1,1};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;cin >>n;
	vector<pair<int,int>> v(n);
	for(int i = 0; i < n; ++i) {
		cin >> v[i].first >> v[i].second;
	}
	for(int i = 0; i + 2< n; ++i) {
		if(v[i].first == v[i].second && v[i+1].first == v[i+1].second && v[i+2].first == v[i+2].second){
			cout <<"Yes"<<"\n";
			return 0;
		}
	}
	cout <<"No"<<"\n";
	return 0;
}

Measured memory_bytes: 3656
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    now = 0
    for c in input():
        now += int(c)

    print("Yes" if now % 9 == 0 else "No")
resolve()

Measured memory_bytes: 73640
#include <cstring>
#include <cstdio>
#include <queue>
#define rg register
#define mk(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') f=1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n,dis[maxn];
pii x;
deque<pii> q;
inline int nxt(int x){return x==n-1?0:x+1;}
int main()
{
	read(n);
	memset(dis,0x3f,sizeof(dis));
	q.push_back(mk(1,1));
	while(1)
	{
		x=q.front();q.pop_front();
		if(!getmin(dis[x.first],x.second)) continue;
		if(x.first==0) break;
		if(x.first%10!=9) q.push_back(mk(nxt(x.first),x.second+1));
		q.push_front(mk(x.first*10%n,x.second));
	}
	printf("%d\n",dis[0]);
	return 0;
}

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

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;
    int sum = x + y;
    int abs = x - y;
    int mul = x * y;
    int arr[3];
    arr[0] = sum;
    arr[1] = abs;
    arr[2] = mul;
    sort(arr, arr + 3);
    cout << arr[2];
}


Measured memory_bytes: 256
import itertools
N,M = map(int, input().strip().split(' '))
C = [list(map(int, input().strip().split(' '))) for _ in range(N)]

ans = 0
for sx,sy,sz in itertools.product([-1,1], repeat=3):
  ans = max(ans, sum(sorted([cx*sx+cy*sy+cz*sz for cx,cy,cz in C], reverse=True)[:M]))
print(ans)


Measured memory_bytes: 40304
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	if (!S.compare("SUN")){
		cout<<7<<endl;
	}else if (!S.compare("MON")){
		cout<<6<<endl;
	}else if (!S.compare("TUE")){
		cout<<5<<endl;
	}else if (!S.compare("WED")){
		cout<<4<<endl;
	}else if (!S.compare("THU")){
		cout<<3<<endl;
	}else if (!S.compare("FRI")){
		cout<<2<<endl;
	}else if (!S.compare("SAT")){
		cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int ans = 0;
            for (int i = 1; i <= n; i++)
            {
                if (cal(i) % 2 == 1)
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }

        static int cal(int num)
        {
            int tmp = 0;
            while (num != 0)
            {
                num /= 10;
                tmp++;
            }
            return tmp;
        }
    }
}


Measured memory_bytes: 11092
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,K = LI()
A = LI()

if K == N:
    ans = 1
    for i in range(N):
        ans *= A[i]
        ans %= mod
    print(ans)
    exit()

plus = []
minus = []
zeros = []

for i in range(N):
    if A[i] > 0:
        plus.append(A[i])
    elif A[i] < 0:
        minus.append(-A[i])
    else:
        zeros.append(A[i])

plus.sort(reverse=True)
minus.sort(reverse=True)

if len(plus):
    if K%2:
        ans = plus[0]
        p_place = 1
        m_place = 0
        K -= 1
    else:
        ans = 1
        p_place = 0
        m_place = 0
    while K:
        val1 = plus[p_place]*plus[p_place+1] if p_place <= len(plus)-2 else -float('inf')
        val2 = minus[m_place]*minus[m_place+1] if m_place <= len(minus)-2 else -float('inf')
        if val1 == val2 == -float('inf'):
            if p_place == len(plus)-1:
                ans *= plus[p_place]
                ans %= mod
                K -= 1
            if K:
                print(0)
                exit()
        else:
            K -= 2
            if val1 == -float('inf'):
                ans *= val2
                ans %= mod
                m_place += 2
            elif val2 == -float('inf'):
                ans *= val1
                ans %= mod
                p_place += 2
            elif val1 >= val2:
                ans *= val1
                ans %= mod
                p_place += 2
            else:
                ans *= val2
                ans %= mod
                m_place += 2
    print(ans)
else:
    if K%2:
        if len(zeros):
            print(0)
        else:
            ans = 1
            for i in range(K):
                ans *= -minus[len(minus)-1-i]
                ans %= mod
            print(ans)
    else:
        m_place = 0
        ans = 1
        while K:
            if m_place <= len(minus)-2:
                ans *= minus[m_place]*minus[m_place+1]
                ans %= mod
                m_place += 2
                K -= 2
            else:
                print(0)
                exit()
        print(ans)

Measured memory_bytes: 112344
a = int(input())
b = list(input().split(" "))

for i in range(a):
    b[i] = int(b[i])

c = 0
for i in range(a):
    for j in range(i,a):
        for k in range(j,a):
            if (b[i] != b[j]) and (b[i] != b[k]) and (b[j] != b[k]) and (b[i] < b[j] + b[k]) and (b[j] < b[i] + b[k]) and (b[k] < b[i] + b[j]):
                c += 1

print(c)


Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int mygcd(int a, int b) {
	if (!b)
		return a;
	return mygcd(b, a%b);
}

int main() {
	ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	int g = mygcd(a, b);
	long long ans = a;
	ans *= b;
	ans /= g;
	cout << ans << '\n';
	//system("pause");
	return 0;
}

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

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

    for(int i=0;i<w+2;i++)cout<<"#";
    cout<<endl;
    for(int i=0;i<h;i++){
        string s; cin>>s;
        cout<<"#"<<s<<"#"<<endl;
    }
    for(int i=0;i<w+2;i++)cout<<"#";
    cout<<endl;
    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    constexpr int M = 100010;
    vector<long long> C(M, 0);
    long long Ans = 0;
    for (int i = 0; i < N; i++) {
        int x; cin >> x; C[x]++;
        Ans += x;
    }
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        int b, c; cin >> b >> c;
        Ans += C[b] * (c - b);
        C[c] += C[b]; C[b] = 0;
        cout << Ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 3984
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    ll n;
    cin>>n;
    string str;
    set<string>ss;
    while(n--){cin>>str; ss.ins(str);}
    cout<<ss.size()<<endl;























return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 19280
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define max(a, b) ((a>b)?a:b)
typedef long long ll;

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> H(n);
	ll tot = 0;
	for(int i=0; i<n; ++i){
		scanf("%d", &H[i]);
		tot += H[i];
	}
	sort(H.begin(), H.end());
	for(int i=n-1; i>=n-k && i>=0; --i){
		tot -= H[i];
	}
	printf("%lli\n", tot);
}

Measured memory_bytes: 3664
N, K = map(int, input().split())
di = K * 2
l = []
for i in range (di):
    l.append(input().split())
l1 = []
x = 1
while x < di:
    for j in l[x]:
        l1.append(j)
    x += 2
l1 = set(l1)
print(N - len(l1))

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

using namespace std;

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

const int MOD = 1e9 + 7;

int main() {
  int N, M;
  cin >> N >> M;
  vector<P> drinks(N);
  for (int i = 0; i < N; ++i) {
    cin >> drinks[i].first >> drinks[i].second;
  }
  sort(drinks.begin(), drinks.end());
  ll res = 0;
  for (int i = 0; i < N; ++i) {
    ll A = drinks[i].first;
    ll B = drinks[i].second;
    if (M >= B) {
      M -= B; 
      res += A * B;
    }
    else {
      res += A * M;
      M = 0;
      break;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int x, y, X, Y;
  ci(x, y, X, Y);
  int a = X - x;
  int b = Y - y;
  co(X - b, Y + a, x - b, y + a);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

ll n, k;
  
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k)
{
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll func(const vector<ll> &A)
{
    ll res = 0;
    for(int i = 0; i < A.size(); i++)
    {
        ll val = (A[i] * COM(i, k - 1)) % MOD;
        res = (res + val) % MOD;
    }
    return res;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    cin >> n >> k;
    vector<ll> A(n);
    for(ll i = 0; i < n; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll M = func(A);
    reverse(A.begin(), A.end());
    ll m = func(A);
    cout << (M - m) % MOD << endl;
    return 0;
}


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

void lazy_add(int k,vector<int>& node,vector<int>& lazy,int n) {
	node[k] += lazy[k];
	if (k < n - 1) {//n - 1
		lazy[2 * k + 1] += lazy[k];
		lazy[2 * k + 2] += lazy[k];
	}
	lazy[k] = 0;
}

void add(int a, int b, int x, int k, int l, int r,vector<int>&node, vector<int>& lazy,int n) {
	if (r <= a || b <= l)return;
	if (a <= l && r <= b) {
		lazy[k] += x; 
		lazy_add(k, node, lazy,n);
		return;
	}
	else {
		lazy_add(k, node, lazy, n);
		add(a, b, x, 2 * k + 1, l, (l + r) / 2, node, lazy, n);
		add(a, b, x, 2 * k + 2, (l + r) / 2, r, node, lazy, n);
		return;
	}
}

int get(int x, vector<int>& node, vector<int>& lazy,int n) {
	add(x, x + 1, 0, 0, 0, n, node, lazy, n);
	return node[n - 1 + x];
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n_, q;  cin >> n_ >> q;
	int n = 1;
	while (n < n_) n *= 2;
	vector<int> node(2 * n - 1, 0);
	vector<int> lazy(2 * n - 1, 0);

	for (int i = 0; i < q; i++) {
		int com; cin >> com;
		if (com == 0) {
			int s, t, x; cin >> s >> t >> x;
			add(s - 1, t, x, 0, 0, n, node, lazy, n);
		}
		else {
			int x; cin >> x;
			cout << get(x - 1, node, lazy, n) << endl;
		}
	}
}

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

#define all(x) (x).begin(), (x).end()
#define X real()
#define Y imag()

typedef array<int, 3> tri;
typedef long long ll;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; cout << '\n'; return O;}


void _main() {
        int x; cin >> x;
        cout << (x >= 30 ? "Yes" : "No");
}

int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
bool chmax(ll& a, ll b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
  cin>>n;
  ans=INF;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0)ans=i+n/i-2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

class Tree():
    def __init__(self, parent, child, sibling):
        self.parent = parent
        self.child = child  # 最も左の子left child
        self.sibling = sibling  # すぐ右の兄弟right sibling
        self.depth = -1

    def gettreetype(self):
        if self.parent == -1:
            return "root"
        if self.child == -1:
            return "leaf"
        return "internal node"


def setdepth(id, depth, trees):
    trees[id].depth = depth
    child = trees[id].child
    if child >= 0:
        setdepth(child, depth + 1, trees)
    sibling = trees[id].sibling
    if sibling >= 0:
        setdepth(sibling, depth, trees)


def getroot(trees, n):
    for i in range(n):
        if trees[i].parent == -1:
            return i


def getsiblings(tree, trees):
    siblings = []
    sibling = tree.sibling
    while sibling > -1:
        siblings.append(sibling)
        sibling = trees[sibling].sibling
    return siblings


def getchildren(tree, trees):
    children = []
    child = tree.child
    if child > -1:
        children.append(child)
        sibling = trees[child].sibling
        while sibling > -1:
            children.append(sibling)
            sibling = trees[sibling].sibling
    return children


def settree(node_info, trees):
    id = node_info[0]
    dim = node_info[1]
    children = node_info[2:]
    trees[id].child = children[0]
    for i in range(dim):
        trees[children[i]].parent = id
        trees[children[i]].sibling = children[i + 1]


def printtrees(trees, n):
    for i in range(n):
        tree = trees[i]
        parent = tree.parent
        depth = tree.depth
        tree_type = tree.gettreetype()
        children = getchildren(tree, trees)
        print("node {}: parent = {}, depth = {}, {}, [{}]".format(
            i, parent, depth, tree_type, ", ".join(map(str, children))))


def main():
    n = int(input())
    trees = [Tree(-1, -1, -1) for _ in range(n)]
    for _ in range(n):
        node_info = input().split(" ")
        node_info = list(map(int, node_info)) + [-1]
        settree(node_info, trees)
    root = getroot(trees, n)
    setdepth(root, 0, trees)
    printtrees(trees, n)


if __name__ == "__main__":
    main()



Measured memory_bytes: 125704
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

bool check(string s){
    rep(i, s.size()-1){
        if(s[i] > s[i+1] || s[i+1]-s[i] != 1) return false;
    }
    return true;
}

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    int ans = -1;
    rep(i, n)For(j, i+1, n)if(check(to_string(a[i]*a[j]))){
        chmax(ans, a[i]*a[j]);
    }
    printf("%d\n", ans);
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MOD = (int)1e9 + 7;
const int N = (int)2e5 + 9;

int dp[N];
int las[N];

int main(){
    fastIO;
    int n;
    cin >> n;
    int c;
    for(int j = 0 ; j < N ; j ++ )
        las[j] = -1;
    dp[0] = 1;
    for(int i = 1 ; i <= n; i ++ ){
        cin >> c;
        set<int> pos;
        pos.insert(i-1);
        if(las[c] != -1)pos.insert(las[c]);
        for(auto x : pos){
            dp[i] = (dp[i] + dp[x]) % MOD;
        }
        las[c] = i;
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1792
words = lambda t : list(map(t, input().split()))
n = int(input())
xys = []
for i in range(n):
    (x,y) = words(int)
    xys.append((x,y))

min_score = -1
for i in range(n):
    xy1 = xys[i]
    for j in range(i,n):
        a = set(xys)
        xy2 = xys[j]
        p = xy1[0] - xy2[0]
        q = xy1[1] - xy2[1]
        score = 0
        while len(a) > 0:
            score += 1
            (x,y) = a.pop()
            xup = x + p
            yup = y + q
            while (xup,yup) in a:
                a.remove((xup,yup))
                xup += p
                yup += q
            xdn = x - p
            ydn = y - q
            while (xdn,ydn) in a:
                a.remove((xdn,ydn))
                xdn -= p
                ydn -= q
        if min_score == -1:
            min_score = score
        else:
            min_score = min(min_score,score)
print(min_score)


Measured memory_bytes: 45296
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ld x=0.5;
    ll a=n/2;
    if (n%2==0)
    {
        cout<<fixed<<setprecision(15)<<x<<"\n";
    }
    else
    {
        cout<<fixed<<setprecision(15)<<((a)+1)/(ld)n<<"\n";
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
set<string> vis;
ll dp[200001][3][3][2];
void brute(string S) {
	vis.insert(S);
	for (int i = 0; i + 1 < S.size(); i++) {
		if (S[i] == S[i + 1]) continue;
		string T = S;
		T[i] = T[i + 1] = 3 - S[i] - S[i + 1];
		if (vis.find(T) == vis.end()) {
			vis.insert(T);
			brute(T);
		}
	}
}
int main() {
	string S;
	cin >> S;
	int m = 0;
	for (int i = 0; i < S.size(); i++) {
		S[i] -= 'a';
		(m += S[i]) %= 3;
	}
	bool dif = 0, same = 0;
	for (int i = 1; i < S.size(); i++) {
		if (S[i] != S[i - 1]) dif = 1;
		else same = 1;
	}
	if (!dif) {
		cout << 1 << endl;
		return 0;
	}
	if (S.size() <= 3) {
		brute(S);
		cout << vis.size() << endl;
		return 0;
	}
	dp[1][0][0][0] = dp[1][1][1][0] = dp[1][2][2][0] = 1;
	for (int i = 1; i < S.size(); i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				for (int l = 0; l < 3; l++) {
					if (k == l) {
						(dp[i + 1][(j + l) % 3][l][1] += dp[i][j][k][0]) %= MOD;
						(dp[i + 1][(j + l) % 3][l][1] += dp[i][j][k][1]) %= MOD;
					}
					else {
						(dp[i + 1][(j + l) % 3][l][0] += dp[i][j][k][0]) %= MOD;
						(dp[i + 1][(j + l) % 3][l][1] += dp[i][j][k][1]) %= MOD;
					}
				}
			}
		}
	}
	ll ans = dp[S.size()][m][0][1];
	(ans += dp[S.size()][m][1][1]) %= MOD;
	(ans += dp[S.size()][m][2][1]) %= MOD;
	if (!same) ans++;
	cout << ans << endl;
}

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

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> ab, ba;
  
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    if(a == 1) ab.push_back(b);
    if(b == 1) ab.push_back(a);
    if(a == N) ba.push_back(b);
    if(b == N) ba.push_back(a);
  }
  
  sort(ab.begin(), ab.end());
  sort(ba.begin(), ba.end());
  
  bool flag = false;
  int i ,j = 0;
  while(i < ab.size() && j < ba.size()){
    if(ab[i] == ba[j]){
      flag = true;
      break;
    }else if(ab[i] > ba[j]){
      j++;
    }else if(ab[i] < ba[j]){
      i++;
    }
  }
  if(flag) cout << "POSSIBLE";
  else cout << "IMPOSSIBLE";
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n, 0);
    rep(i, n) cin >> v[i];
    int ans = 0;
    rep(i, 1, n - 1)
    {
        vector<int> v2 = {v[i - 1], v[i], v[i + 1]};
        sort(v2.begin(), v2.end());
        if (v2[1] == v[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: u64,
        B: u64,
        K: usize,
    }
    let mut ans = vec![0;0];
    for i in 1..101{
        if A%i==0 && B%i==0{
            ans.push(i);
        }
    }
    ans.sort();
    ans.reverse();
    println!("{}",ans[K-1]);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int a[8008],b[8008];
	while(~scanf("%d",&n)){
       for(int i=0;i<n;i++){
       	scanf("%d",a+i);
	   }
	   sort(a,a+n);
	   int l=n;
	   int s=0,p=-1;
	   for(int i=0;i<l;i++){
	   	for(int j=i+1;j<l;j++){
	   		for(int k=j+1;k<l;k++){
	   			if(a[i]+a[j]>a[k])
	   			s++;
			   }
		   }
	   }
	   printf("%d\n",s);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int ans;
    if(s  == "SUN"){
        ans = 7;
    }else if(s == "MON"){
        ans = 6;
    }else if(s == "TUE"){
        ans = 5;
    }else if(s == "WED"){
        ans = 4;
    }else if(s == "THU"){
        ans = 3;
    }else if(s == "FRI"){
        ans = 2;
    }else if(s == "SAT"){
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F0(i, n) for (int i = 0; i < n; i++)
#define F1(i, n) for (int i = 1; i < n; i++)
#define Fi(n, a) for (int i = 0; i < n; i++) a[i] = gi()
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

template<class T>
T gcd(T a, T b) {
    return (b == 0 ? a : gcd(b, a%b));
}

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

#define MD 1000000007
char s[200004], t[200004];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scanf("%s", s);
    scanf("%s", t);
    int n = strlen(s);
    int r = 0;
    F0(i, n) if (s[i] != t[i])
        r++;
    printf("%d\n", r);

    return 0;
}


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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i=a;i>b;i--)
#define int long long

//constant--------------------------------------------------------------------------------------
const int inf = 100100100100000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

//general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr){vector<int> ret = arr;rep(i,1,arr.size()){ret[i] += ret[i-1];}return ret;}
int ceil(int a, int b){if(a%b == 0) return a/b;else return a/b + 1;}
int digitlen(int i){int t = i;int count = 0;while(t){count += 1;t /= 10;}return count;}
int gcd(int m, int n){if((0== m)||(0 == n))return 0;while(m != n){if(m > n)m = m - n;else n = n - m;}return m;}
int lcm(int n, int m){return n*m/gcd(n,m);}
int sum(vector<int> arr){int cnt = 0;rep(i,0,arr.size()){cnt += arr[i];}return cnt;}

//io_method-------------------------------------------------------------------------------------
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
void print(int n){cout << n << endl;}
void print(vector<int> arr){cout << arr[0];rep(i,1,arr.size()) cout << " " << arr[i];cout << endl;}
void print(string s){cout << s << endl;}
void print(pair<int, int> p){cout << p.first << " " << p.second;}
void print(vector<vector<int>> arr){rep(i,0,arr.size()){print(arr[i]);}}


//main------------------------------------------------------------------------------------------



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

    
    string s = raw_input();

    map<char, int> mp;
    for(char e: alpha){
        mp[e] = 0;
    }

    for(char e: s){
        mp[e]++;
    }

    for(char e:alpha){
        if(mp[e] == 0){
            cout << (char)e << endl;
            return 0;
        }
    }
    print("None");



}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> f(n);
    vector<vector<ll>> p(n, vector<ll>(11));
    rep(i, n){
        rep(j, 10){
            ll x; cin >> x;
            f[i] += (x << 10-j-1);
        }
    }
    ll res = -INF, r;
    rep(i, n) rep(j, 11) cin >> p[i][j];
    for(int bit=0;bit<(1<<10);++bit){
        if(!((bit >> 9) & 1 | (bit >> 8) & 1 || (bit >> 7) & 1 | (bit >> 6) & 1 || (bit >> 5) & 1 | (bit >> 4) & 1 || (bit >> 3) & 1 | (bit >> 2) & 1 || (bit >> 1) & 1 | (bit >> 0) & 1)) continue;
        ll r = 0;
        rep(i, n){
            r += p[i][__builtin_popcount(bit & f[i])];
        }
        chmax(res, r);
    }
    cout << res;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
long long gcd(long long a,long long b)
{
	if(b==0)   return a;
	return gcd(b,a%b);
}
long long n,m;
int main()
{
    while(cin>>n>>m)
	{
		cout<<gcd(n,m)<<" "<<n*m/gcd(n,m)<<endl;
	}
    return 0;
}

Measured memory_bytes: 3084
s = input()
if s == 'SAT':
    print(1)
elif s == 'FRI':
    print(2)
elif s == 'THU':
    print(3)
elif s == 'WED':
    print(4)
elif s == 'TUE':
    print(5)
elif s == 'MON':
    print(6)
else:
    print(7)

Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
    x=0;char ch;bool flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 10010;
bool f[maxn];
int main(){
    int n;read(n);
    f[0] = true;
    int x;
    rep(i,1,n){
	read(x);
	per(j,maxn-10,0){
	    if(f[j] && j + x <= maxn-10){
		f[j+x] = true;
	    }
	}
    }
    per(i,maxn-10,0){
	if(f[i] && (i % 10) != 0){
	    printf("%d\n",i);
	    return 0;
	}
    }puts("0");
    return 0;
}


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

int Parent[200005],Rank[200005];
map<int,int>mp;

void MakeSet(int n)
{
    Parent[n]=n;
    Rank[n]=1;
}
int Find(int x)
{
    if(Parent[x]!=x)
    {
        Parent[x]=Find(Parent[x]);
    }
    return Parent[x];
}
int Union(int xset,int yset)
{
    if(xset==yset)
        return Rank[xset];
    else
    {
        if(Rank[xset]>Rank[yset])
        {
            Rank[xset]=Rank[xset]+Rank[yset];
            Parent[yset]=xset;
            return Rank[xset];
        }
        else
        {
            Rank[yset]=Rank[yset]+Rank[xset];
            Parent[xset]=yset;
            return Rank[yset];
        }
    }
}
int main()
{
    int n,m,a,b,k=0,mx=1;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a>>b;
        int yy;
        yy=mp[a];
        if(yy==0)
        {
            mp[a]=++k;
            MakeSet(mp[a]);
        }
        yy=mp[b];
        if(yy==0)
        {
            mp[b]=++k;
            MakeSet(mp[b]);
        }
        int x=mp[a];
        int y=mp[b];

        int xset= Find(x);
        int yset= Find(y);

        int ans=Union(xset,yset);

        mx=max(mx,ans);
    }

    cout<<mx<<endl;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		vi cs(n,1),fs(n); fs[0]=1;
		rep(_,m){
			int x,y; cin>>x>>y; x--,y--;
			fs[y]|=fs[x];
			if(cs[x]==1) fs[x]=0;
			cs[x]--; cs[y]++;
		}
		cout<<count(all(fs),1)<<endl;
	}
}


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

int main() {
  int N, A;
  cin >> N >> A;
  int K = N%500;

  if (N<500 && N<=A){
    cout << "Yes" << endl;
  }
  
  else if (N>500 && K<=A){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func sum(n int) int {
	ret := 0
	for n > 0 {
		ret += n % 10
		n /= 10
	}
	return ret
}

func main() {
	var n int
	var min int = -1
	fmt.Scan(&n)

	for a := 1; a <= n - 1; a++ {
		b := n - a
		s := sum(a) + sum(b)
		if min == -1 || min > s {
			min = s
		}
	}

	fmt.Println(min)
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
    var persons, days, leftovers int
    fmt.Scanf("%d", &persons)
    fmt.Scanf("%d %d", &days, &leftovers)

    a := make([]int, persons)
    for i := 0; i < persons; i++ {
        fmt.Scanf("%d", &a[i])
    }

    var sum int = leftovers
    for i := 0; i < persons; i++ {
        sum += days/a[i]
        if days%a[i] != 0 {
            sum++
        }
    }

    fmt.Println(sum)
}


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

int main()
{
ll n , m ;
cin >> n >> m ;
multiset<ll> a;
rep(i, n){
  ll aa;
  cin >>aa ;
  a.insert(aa);
}
rep(i,m){
  auto t=a.end();
  t--;
  a.erase(t);
  a.insert(*t/2);
}
for(auto r:a){
  ans+=r;
}
cout << ans << endl;
return 0;
}

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

const int NMAX = 3e5 + 5;
int n,m,arb[4 * NMAX + 66],poz,val,start,finish,maxim, dp[NMAX], sol, v[NMAX], x;
void actualizare(int nod,int st,int dr)
	
{
	
    int mij;
	
    if(st==dr)
	
    {
	
        arb[nod]=val;
	
        return;
	
    }
	
    mij=(st+dr)/2;
	
    if(poz<=mij)
	
    {
	
        actualizare(2*nod,st,mij);
	
    }
	
    else
	
    {
	
        actualizare(2*nod+1,mij+1,dr);
	
    }
	
    arb[nod]=max(arb[2*nod],arb[2*nod+1]);
	
}
	
void interogare(int nod,int st,int dr)
	
{
	
    int mij;
	
    if(start<=st && dr<=finish)
	
    {
	
        if(maxim<arb[nod])
	
        {
	
            maxim=arb[nod];
	
        }
	
        return;
	
    }
	
    mij=(st+dr)/2;
	
    if(start<=mij)
	
    {
	
        interogare(2*nod,st,mij);
	
    }
	
    if(mij<finish)
	
    {
	
        interogare(2*nod+1,mij+1,dr);
	
    }
	
}
	
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> x;
        x++;
        start = max(1, x - m);
        finish = min(300001, x + m);
        maxim = 0;
        interogare(1, 1, 300001);
        dp[i] = 1 + maxim;
        sol = max(sol, dp[i]);
        if(v[x] < dp[i]) {
            v[x] = dp[i];
            poz = x;
            val = v[x];
            actualizare(1, 1, 300001);
        }
    }
    cout << sol;
    return 0;
}

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

ll d;
ll p[20];
int dx1[20], dx2[20];
vector<ll> v;

void dfs(int s, int e, vector<pi> &w, ll val, ll cnt){
	if(s == e){
		w.push_back(pi(val, cnt));
		return;
	}
	for(int i=-9; i<=9; i++){
		dfs(s+1, e, w, val + i * v[s], cnt * (s == 0 ? dx2[i + 10] : dx1[i + 10]));
	}
}

ll solve(int l){
	v.clear();
	for(int i=0; l-1-i > i; i++){
		v.push_back(p[l-1-i] - p[i]);
	}
	vector<pi> v1, v2;
	dfs(0, (v.size()+1) / 2, v1, 0, 1);
	dfs((v.size()+1) / 2, v.size(), v2, 0, 1);
	ll ans = 0;
	map<ll, ll> mp;
	for(auto &i : v2) mp[i.first] += i.second;
	for(auto &i : v1){
		ans += mp[i.first + d] * i.second;
	}	
	if(l % 2 == 1) ans *= 10;
	return ans;
}

int main(){
	p[0] = 1;
	for(int i=1; i<20; i++) p[i] = p[i-1] * 10;
	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			dx1[i-j+10]++;
		}
	}
	for(int i=1; i<10; i++){
		for(int j=0; j<10; j++){
			dx2[i-j+10]++;
		}
	}
	cin >> d;
	ll ans = 0;
	for(int i=2; i<=18; i++) ans += solve(i);
	cout << ans << endl;
}


Measured memory_bytes: 205936
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
string s;
cin>>s;
long long x=s.size();
long long t_cnt=0;

for(long long i=s.size();i>=0;i--){
    if(s[i]=='S' && t_cnt>0){
        x-=2;
        t_cnt--;
    }
    else if(s[i]=='T'){
        t_cnt++;
    }
}
cout<<x<<endl;
return 0;

}
/*
TSTTSS

4

SSTTST

0

TSSTTTSS

4


*/


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

const int N  = 1111111;

char s[N];

int ans , res = 0 , A[N] , B[N] , n;

int main() {
	cin >> n;
	scanf("%s" , s + 1);
	n = strlen(s + 1);
	for(int i = 1;i <= n;++ i)
	A[i] = (s[i] == 'W')  , 
	B[i] = (s[i] == 'E');
	for(int i = 1;i <= n;++ i)
	A[i] += A[i - 1];
	for(int i = n;i >= 1;-- i)
	B[i] += B[i + 1];
	res = 2e9;
	for(int i = 1;i <= n;++ i)
	res = min(res , A[i - 1] + B[i + 1]);
	cout << res << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> modNums(K, N / K);//N以下の正の整数で、Kで割った余りがindexとなる数
    for(int i = 1; i <= N % K; i++)
    {
        modNums.at(i)++;
    }
    //可能なケースの通り数をそれぞれ加算
    ll answer = 0;
    //三つとも余りが0(元々Kの倍数の場合)
    answer += modNums.at(0) * modNums.at(0) * modNums.at(0);
    //Kが偶数なら余りが1/2の場合
    ll half = -1;
    if(K % 2 == 0)
    {
        half = K / 2;
        answer += modNums.at(half) * modNums.at(half) * modNums.at(half);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 1792