akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class CSyntheticKadomatsu {
public:
    int func(int index, int a, int b, int c) {
        if (index == n) {
            if (a == 0 || b == 0 || c == 0)
                return INT16_MAX;
            else {
                return abs(a - A) + abs(b - B) + abs(c - C);
            }
        }
        int res = func(index + 1, a, b, c);
        return min(
                {
                        res,
                        func(index + 1, a + vec[index], b, c) + (a != 0 ? 10 : 0),
                        func(index + 1, a, b + vec[index], c) + (b != 0 ? 10 : 0),
                        func(index + 1, a, b, c + vec[index]) + (c != 0 ? 10 : 0)
                });
    }

    void solve(std::istream &cin, std::ostream &cout) {
        cin >> n >> A >> B >> C;
        vec.resize(n);
        for (int i = 0; i < n; ++i) {
            cin >> vec[i];
        }
        int ans = func(0, 0, 0, 0);

        cout << ans << endl;
    }

    int n, A, B, C;
    vector<int> vec;
};


int main() {
    CSyntheticKadomatsu solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y,z;
	scanf("%d %d",&a,&b);
	while(a!=0 && b!=0) {
		c=b-a;
		x=0;
		y=0;
		z=0;
		while(!(c<1000)) {
			c=c-1000;
			z+=1;
		}
		while(!(c<500)) {
			c=c-500;
			y+=1;
		}
		while(!(c<100)) {
			c=c-100;
			x+=1;
		}
		printf("%d %d %d\n",x,y,z);
	scanf("%d %d",&a,&b);
	}
	return 0;
}

Measured memory_bytes: 600
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

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

    int l=0, r=0;
    string t = S;
    REP(i,N) {
        if (S[i] == '(') l++;
        else r++;

        if (l < r) {
            t = "(" + t;
            l++;
        }
    }

    while(l>r) {
        t += ")";
        r++;
    }

    string ans = t;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▒██▒██▒▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▒██▒██▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████▒▒▒▒▒██▒▒████▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████▒▒▒▒███▒▒████▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▒▒████▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒███▒▒▒▒▒████▒▒████▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒███▒▒▒▒▒████▒▒▒███▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒████▒▒▒▒▒█████▒▒███▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒████▒▒▒▒▒████▒▒▒▒▒▒████▒▒███▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒████▒▒▒▒▒▒████▒▒███▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒████████▒▒▒▒▒▒███▒▒▒▒▒▒████▒▒███▒▒▒▒▒▒
			▒▒▒▒▒▒▒█████████▒▒▒▒▒▒███▒▒▒▒▒▒▒███▒▒███▒▒▒▒▒▒
			▒▒▒▒▒▒█████▒████▒▒▒▒▒▒████▒▒▒▒▒▒███▒▒███▒▒▒▒▒▒
			▒▒▒▒▒████▒▒▒████▒▒▒▒▒▒████▒▒▒▒▒▒███▒▒███▒▒▒▒▒▒
			▒▒▒▒▒████▒▒▒████▒▒▒▒▒▒████▒▒▒▒▒▒███▒▒███▒▒▒▒▒▒
			▒▒▒▒████████████▒▒▒▒▒▒████▒▒▒▒▒▒███▒▒███▒▒▒▒▒▒
			▒▒▒▒███████████████▒████████▒▒█████▒▒███▒▒▒▒▒▒
			▒▒▒▒██████████████████████████████▒▒▒███▒▒▒▒▒▒
			▒▒▒▒▒███████▒████████████████████▒▒▒▒███▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒██████████▒█████████▒▒▒▒██▒▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒██████▒▒▒▒▒▒██▒▒▒▒▒▒▒
			▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒*/
/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                                          |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                                          ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main()
{
	optimization();
	ll x,y;
	cin >> x>>y;
	cout <<x+(y/2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=400+10;
typedef long long LL;
const int dx[]={-1,0,1,0};
const int dy[]={0,1,0,-1};
int n,m;
char mp[N][N];
bool vis[N][N];
LL black,white;
 
void dfs(int x,int y) {
	vis[x][y]=1;
	if (mp[x][y]=='#') black++; else white++;
	for (int i=0;i<4;i++) {
		int nx=x+dx[i],ny=y+dy[i];
		if (nx<1 || nx>n || ny<1 || ny>m || vis[nx][ny] || mp[x][y]==mp[nx][ny]) continue;
		dfs(nx,ny);
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",mp[i]+1);
	
	LL ans=0;
	memset(vis,0,sizeof(vis));
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (!vis[i][j] && mp[i][j]=='#') {
				black=0; white=0;
				dfs(i,j);
				ans+=black*white;
			}
	cout<<ans;		
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i <= 50000; ++i)
    {
        int x = i * 1.08;
        if(x > 50000)
        {
            cout << ":(" << endl;
            break;
        }
        else if(x == n)
        {
            cout << i << endl;
            break;
        }
        
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int[][] g = new int[n][n];
        for (int i = 0; i < n - 1; i++) {
            g[i][i + 1] = 1;
            g[i + 1][i] = 1;
        }
        g[x - 1][y - 1] = 1;
        g[y - 1][x - 1] = 1;
        x--;
        y--;
        int[] ans = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                int v = Math.min(j - i, Math.min(Math.abs(x - i) + 1 + Math.abs(y - j), Math.abs(y - i) + 1 + Math.abs(x - j)));
                ans[v - 1]++;
            }
        }
        for (int a : ans) {
            System.out.println(a);
        }
    }
}


Measured memory_bytes: 54612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define repr(i,n) for(int i=0, i##_len=(n); i<i##_len; --i)
#define REP(i,m,n) for(int i=int(m), i##_len=(n); i<i##_len; ++i)
#define VV(T) vector<vector<T>>
#define co(P) cout << P << endl
#define ci(P) cin >> P
#define pb push_back
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;
using d = double;

int main(){
  int A, B;
  cin >> A >> B;
  co(A*B);
}

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

char str[233];

int main()
{
	scanf("%s",str+1);
	int len=strlen(str+1),tot=0;
	for(int i=1;i<=len;i++)
		tot+=str[i]=='x';
	if(tot>=8)
		puts("NO");
	else
		puts("YES");
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	cin >> n;
	while (n--) {
		string s[2];
		cin >> s[0] >> s[1];
		int num[2] = { 0 };
		REP(j,2){
			REP(i, s[j].length()) {
				if (!isdigit(s[j][i])) {
					int mal;
					if (s[j][i] == 'm')mal = 1000;
					if (s[j][i] == 'c')mal = 100;
					if (s[j][i] == 'x')mal = 10;
					if (s[j][i] == 'i')mal = 1;
					if (i != 0 && isdigit(s[j][i - 1])) {
						num[j] += (s[j][i - 1] - '0')*mal;
					}
					else {
						num[j] += mal;
					}
				}
			}
		}
		num[0] += num[1];
		REP(i,4) {
			int mal = 1;
			REP(j, (3 - i))
				mal *= 10;
			if ((num[0] / mal)%10 > 0) {
				char c;
				if (i == 0)c = 'm';
				if (i == 1)c = 'c';
				if (i == 2)c = 'x';
				if (i == 3)c = 'i';
				if((num[0] / mal) % 10!=1)
				cout << (num[0] / mal) % 10 << c;
				else
					cout << c;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 3096
#include<stdio.h>
#include<string.h>
 
int main(void){
    int i,s[6],tmp,l;
    char m[101];
     
    for(i=0;i<6;i++){
        scanf("%d", &s[i]);
    }
     
    scanf("%s", m);
    l = strlen(m);
    for(i=0;i<l;i++){
                 
         if(m[i] == 'E'){
                tmp  = s[0];
                s[0] = s[3];
                s[3] = s[5];
                s[5] = s[2];
                s[2] = tmp; 
          }
             
          if(m[i] == 'N'){
                tmp  = s[0];
                s[0] = s[1];
                s[1] = s[5];
                s[5] = s[4];
                s[4] = tmp; 
          }
             
          if(m[i] == 'S'){
                tmp  = s[0];
                s[0] = s[4];
                s[4] = s[5];
                s[5] = s[1];
                s[1] = tmp; 
          }
                 
          if(m[i] == 'W'){
                tmp  = s[0];
                s[0] = s[2];
                s[2] = s[5];
                s[5] = s[3];
                s[3] = tmp; 
          }
 
       
    }
     
    printf("%d\n", s[0]);
     
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>

int main() {
    int N, M;
    std::cin >> N >> M;
    std::vector<bool> A(N + 1, true);
    for (int i = 1; i <= M; ++i) {
        int a;
        std::cin >> a;
        A[a] = false;
    }

    std::vector<int> dp(N + 1, 0);
    dp[0] = 1;
    dp[1] = A[1] ? 1 : 0;
    for (int i = 2; i <= N; ++i) {
        int sum = dp[i - 1] + dp[i - 2];
        sum %= 1000000007;
        dp[i] = A[i] ? sum : 0;
    }
    int ans = dp[N];

    std::cout << ans << "\n";
    return 0;
}


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

int main() {
	int n, A[100];	//配列を宣言
	cin >> n;		//配列の要素数を読み込む
	for (int i = 0; i < n; i++)cin >> A[i];	//nの値分まで配列要素を宣言

	for (int i = n - 1; i >= 0; i--) {
		if (i != n - 1)cout << " ";
		cout << A[i];
	}
	cout << endl;

	return 0;
}


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

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

    int ans = 0;

    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x)
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {
  var(int, n);
  auto a = in.Array(n * 3);

  sort(rall(a));
  ll sum = 0;
  n *= 3;
  int now = n;
  rep(i, now) if (i + 1 < now) {
    sum += a[i + 1];
    err(sum, i, now);
    i++;
    now--;
  }
  cout << (sum) << endl;
}


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

int main() {
  int a,b,m;
  cin >> a >> b >> m;
  
  vector<int> refs(a);
  vector<int> renges(b);
  for(int i = 0; i < a; i++) {
     cin >> refs.at(i);
  }
  
  for(int i = 0; i < b; i++) {
     cin >> renges.at(i); 
  }
  
  int ans = refs.at(0) + renges.at(0);
  for(int i = 0; i < m; i++) {
   int aIndex,bIndex,discount;
    cin >> aIndex >> bIndex >> discount;
    int tempAns = refs.at(aIndex - 1) + renges.at(bIndex - 1) - discount;
    
    if(tempAns < ans) {
      ans = tempAns;
    }
  }
  
  std::sort(refs.begin(), refs.end());
  std::sort(renges.begin(), renges.end());
  
  int noDiscount = refs.at(0) + renges.at(0);
  
  if(noDiscount < ans) {
    cout << noDiscount << endl;
  } else {
    cout << ans << endl;
  }
  
  return 0;
}

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

#define ll long long
#define pb push_back
#define iter std::vector<int>::iterator

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

	int n;
	string s;
	cin >> n >> s;

	if (s.size() <= n) {
		cout << s;
		return 0;
	}

	string res = s.substr(0, n);
	res += "...";
	cout << res;

	return 0;	
}

Measured memory_bytes: 3640
#include <stdio.h>


int main(void)
{
  char n[5];
  int number, x, ans, max=0;

  fgets(n, sizeof(n), stdin);
  sscanf(n, "%d", &number);
  ans = number;

  for (int i=0; i <= number; i++) {
    x = 0;
    for (int j=i; j%2 == 0 && j != 0; j /= 2) { x++; }

    if (x > max) {
      max = x;
      ans = i;
    }

  }

  printf("%d\n", ans);
  
  return 0;
}


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

int solve(int n);
int N;

int main(){
  cin >> N;
  int result = 0;
  for(int i = 0; i<N+1; i++){
    result += solve(i);
  }
  cout << result <<endl;
}

int solve(int n){
  int count = 0;
  while(true){
    if(n == 0){
      break;
    }
    n /= 10;
    count++;
  }
  if(count % 2 == 0){
    return 0;
  }else{
    return 1;
  }
}


Measured memory_bytes: 256
use proconio::fastout;
use whiteread::parse_line;

#[fastout]
fn main() {
    let n: usize = parse_line().unwrap();
    let mut s: Vec<char> = parse_line::<String>().unwrap().chars().collect();

    let mut left = 0;
    let mut right = n - 1;
    let mut ret = 0;
    loop {
        while left < n && s[left] != 'W' {
            left += 1;
        }
        while s[right] != 'R' {
            if right == 0 {
                break;
            }
            right -= 1;
        }
        if left >= n || (right == 0 && s[0] == 'W') || right < left {
            break;
        }
        s[left] = 'R';
        s[right] = 'W';
        ret += 1;
    }
    println!("{}", ret);
}


Measured memory_bytes: 3124
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
// const input = fs.readFileSync('./input.txt', 'utf8');

_a(input);

function _a(input: string) {
  const [D, T, S] = input.split(' ').map((s) => parseInt(s));

  console.log(D <= T * S ? 'Yes' : 'No');
}


Measured memory_bytes: 29680
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    ll N;
    cin>>N;
    ll t,bef=0,cnt=0;
    bool swpf=false;
    REP1(i,N){
        cin>>t;
        if(swpf)t=bef;
        //sl(i,t)
        if(t==i){
            swpf=true;
            cnt++;
        }else swpf=false;
        bef=t;
    }
    
    
    cout<<fixed<<setprecision(10)<<cnt;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 1e5+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

char c[maxn];
int ans[maxn];
int main(){
	int k,m,n;
	scanf("%s",c+1);
	n=strlen(c+1);
	int i=1;
	while(i<=n){
		int x1=i,x2,y1,y2,num1,num2,num;
		while(c[i+1]=='R')i++;
		x2=i;num1=x2-x1+1;
		i++;y1=i;
		while(c[i+1]=='L')i++;
		y2=i;num2=y2-y1+1;
		i++;
		if(num1%2){
			ans[x2]+=num1/2+1;
			ans[y1]+=num1/2;
		}
		else {
			ans[x2]+=num1/2;
			ans[y1]+=num1/2;
		}
		if(num2%2){
			ans[x2]+=num2/2;
			ans[y1]+=num2/2+1;
		}
		else {
			ans[x2]+=num2/2;
			ans[y1]+=num2/2;
		}
	}
	for(register int i=1;i<=n;i++)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int n,m,k;
int a[10][10][10];
int cnt[10][10];

bool check2(int x, int y, int z, int dx, int dy, int dz, int s, int t) {
  if(a[x][y][z]!=t) return false;
  if(s==m) return true;
  return check2(x+dx,y+dy,z+dz,dx,dy,dz,s+1,t);
}
bool check(int t) {
  bool ck=false;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int l=0; l<n; l++) {
	if(ck) continue;
	if(a[i][j][l]==t) {
	  if(j<=n-m) {
	    if(check2(i,j,l,0,1,0,1,t)) ck=true;
	    if(l<=n-m) {
	      if(check2(i,j,l,0,1,1,1,t)) ck=true;
	    }
	    if(l>=m-1) {
	      if(check2(i,j,l,0,1,-1,1,t)) ck=true;
	    }
	  }
	  if(i<=n-m) {
	    if(check2(i,j,l,1,0,0,1,t)) ck=true;
	    if(l<=n-m) {
	      if(check2(i,j,l,1,0,1,1,t)) ck=true;
	    }
	    if(l>=m-1) {
	      if(check2(i,j,l,1,0,-1,1,t)) ck=true;
	    }
	  }
	  if(i<=n-m && j<=n-m) {
	    if(check2(i,j,l,1,1,0,1,t)) ck=true;
	    if(l<=n-m) {
	      if(check2(i,j,l,1,1,1,1,t)) ck=true;
	    }
	    if(l>=m-1) {
	      if(check2(i,j,l,1,1,-1,1,t)) ck=true;
	    }
	  }
	  if(i>=m-1 && j<=n-m) {
	    if(check2(i,j,l,-1,1,0,1,t)) ck=true;
	    if(l<=n-m) {
	      if(check2(i,j,l,-1,1,1,1,t)) ck=true;
	    }
	    if(l>=m-1) {
	      if(check2(i,j,l,-1,1,-1,1,t)) ck=true;
	    }
	  }
	  if(l<=n-m) {
	    if(check2(i,j,l,0,0,1,1,t)) ck=true;
	  }
	}
      }
    }
  }
  return ck;
}

int main() {
  while(cin >> n >> m >> k && n) {
    memset(a,0,sizeof(a));
    memset(cnt,0,sizeof(cnt));
    int T=1;
    int ans=0;
    for(int i=1; i<=k; i++) {
      int x,y;
      cin >> x >> y;
      x--;y--;
      a[x][y][cnt[x][y]]=T;
      cnt[x][y]++;
      if(ans) continue;
      if(check(T)) {
	ans=i;
	continue;
      }
      if(T==1) T=2;
      else T=1;
    }
    if(!ans) cout << "Draw" << endl;
    else {
      if(T==1) cout << "Black " << ans << endl;
      else cout << "White " << ans << endl;
    }
  }
  return 0;
}

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

int main(){
    string c;
    int ans;

    cin >> c;
    
    if(c == "SUN"){
        ans = 7;
    }else if(c == "MON"){
        ans = 6;
    }else if(c == "TUE"){
        ans = 5;
    }else if(c == "WED"){
        ans = 4;
    }else if(c == "THU"){
        ans = 3;
    }else if(c == "FRI"){
        ans = 2;
    }else if(c == "SAT"){
        ans = 1;
    }
    cout << ans << endl;


}




Measured memory_bytes: 256
/* 
    AtCoder Beginner Contest 069
    A:i18n
    AC
*/

#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main(void)
{
    int i;
    string s;
    cin >> s;
    int size = int(s.length());
    cout << s[0] << size-2 << s[size-1] <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll up[200005],un[200005];
ll MD=1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m,tot=0;

	cin >> n >> k;
	vector<ll>neg,pos,zer;
	for(i=0;i<n;i++)
	{
		cin >> x;
		if(x>0)
			pos.pb(x);
		if(x<0)
			neg.pb(x);
		if(x==0)
			zer.pb(x);
	}

	sort(all(pos)),sort(all(neg));
	reverse(all(pos));

	i=0,j=0;

	if(k%2 && sz(pos))
		tot++,up[i++]=1;

	while(i<sz(pos)-1 && j<sz(neg)-1 && tot<=k-2)
	{
			// cout<<"gw"<<endl;
		if( (pos[i]*pos[i+1]) > (neg[j]*neg[j+1]) )
			up[i]=1,up[i+1]=1,i+=2,tot+=2;
		else
			un[j]=1,un[j+1]=1,j+=2,tot+=2;
	}
	while( j<(sz(neg)-1) && tot<=(k-2))
		un[j]=1,un[j+1]=1,j+=2,tot+=2;
	while( i<sz(pos) && tot<k)
		up[i++]=1,tot++;

	if(tot<k)
	{
		if(sz(zer))
		{
			cout<<0<<endl;
			return 0;
		}
		else
		{
			x=1;
			for(j=sz(neg)-1;j>=0;j--)
			{
				if(k==0)
					break;
				neg[j]=((neg[j]%MD)+MD)%MD;
				x=(((x*neg[j])%MD)+MD)%MD;
				k--;
			}
			for(j=sz(pos)-1;j>=0;j--)
			{
				if(k==0)
					break;
				pos[j]=((pos[j]%MD)+MD)%MD;
				x=(((x*pos[j])%MD)+MD)%MD;
				k--;	
			}
			cout<<x<<endl;
			return 0;
		}
	}

	x=1;
	for(j=sz(neg)-1;j>=0;j--)
	{
		if(!un[j])
			continue;
		neg[j]=((neg[j]%MD)+MD)%MD;
		x=(((x*neg[j])%MD)+MD)%MD;
	}
	for(j=sz(pos)-1;j>=0;j--)
	{
		if(!up[j])
			continue;
		x=(x*pos[j])%MD;
	}
	cout<<x<<endl;
	return 0;
}

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

int main(){
    int k,n;
    cin >> k >> n;
    int a[n];
    int result=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int max_length = k - a[n-1] + a[0];
    for(int i=1; i<n; i++){
        max_length = max(max_length, a[i]-a[i-1]);
    }
    
    cout << k - max_length << endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>vector<T> vec(int len, T elem) { return vector<T>(len, elem); } // auto dp = vec(52, vec(103, vec(103, INF)));
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
template<class T>inline T emod(T a, T p) { return (a%p + p) % p;}
//-------------------
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);
    int h, w, m; cin >> h >> w >> m;
    // unordered_map<PII, int> mp;
    set<PII> st;
    vector<int> yy(h+1, 0);
    vector<int> xx(w+1, 0);
    rep(i, m) {
        int y,x; cin >> y >> x;
        y--; x--;
        // mp[{y,x}]++;
        st.insert({y, x});
        yy[y]++;
        xx[x]++;
    }

    vector<int> xi;
    vector<int> yi;

    int xmx = *max_element(ALL(xx));
    int ymx = *max_element(ALL(yy));

    rep(i, h) {
        if(yy[i] == ymx) yi.push_back(i);
    }
    rep(i, w) {
        if(xx[i] == xmx) xi.push_back(i);
    }

    if(yi.size() * xi.size() > m) {
        cout << ymx + xmx << endl;
    }

    else {
        bool ok = false;
        rep(i, yi.size()) {
            rep(j, xi.size()) {
                if(st.count({yi[i],xi[j]})==0) ok = true;
            }
        }
        if(ok) cout << ymx + xmx << endl;
        else cout << ymx + xmx - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 23712
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 2e5+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

    
int main()
{
    
     
        int n;
        scf(n);
        
        
        int ans=(1000-n%1000)%1000;
        
    
          
        prin(ans);
        
    
        
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N; cin >> N;
  map<int,bool> mp;

  rep(i,N) {
    int A; cin >> A;
    mp[A] = !mp[A];
  }

  int res = 0;
  for(auto x:mp) {
    if(x.se)res++;
  }
  cout << res << endl;


  return 0;
}


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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << endl;
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

const int MAXN=100005;
	
	void solve() {
        long int n,k;
        cin>>n>>k;
        long int a[n];
        for(long int i=0;i<n;i++){
            cin>>a[i];
        }

        for(long int i=k;i<n;i++){
            if(a[i]>a[i-k])
                cout<<"Yes\n";
            else
                cout<<"No\n";
        }
	}
	
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
    	// cout<<"Case #"<<tt<<": ";
    	solve();
    }
    cerr << "Time : " << 1000 * ((double) clock()) / (double) CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 5356
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
const int inf = 0x3f3f3f3f;
const int maxn = 2e5+7;
const int M = 1e9+7;
int n,m,k,ok;

int a[maxn],s[maxn],ans[maxn],id[maxn],pre[maxn],sz[maxn];

int find(int x)
{
    return x==pre[x]?x:pre[x]=find(pre[x]);
}

void unite(int x,int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return;
    sz[x] += sz[y];
    pre[y] = x;
}

signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    int top = 0;
    for(int i = 1,x,y; i <= n; i++) 
    {
        cin>>x>>y;
        a[x] = y;
        id[x] = i;
    }
    for(int i = 1; i <= n; i++) 
    {
        pre[i] = i;
        sz[i] = 1;
    }
    for(int i = 1; i <= n; i++) 
    {   
        int mi = a[i];
        while(top && a[s[top]] < a[i])
        {   
            unite(s[top],i);
            mi = min(mi,a[s[top]]);
            top--;
        }
        a[i] = mi;
        s[++top] = i;
    }
    for(int i = 1; i <= n; i++) 
    {
        ans[id[i]] = sz[find(i)];
    }
    for(int i = 1; i <= n; i++) 
    {
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 11400
#include <bits/stdc++.h>
using namespace std;
int main(void){
    deque<char> res;
    string s; cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'B'){
            if(res.size() != 0)
                res.pop_back();
        }
        else{
            res.push_back(s[i]);
        }
    }
    for(int i=0;i<res.size();i++)
    cout << res[i];
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define eb emplace_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define cinarr(A,len) for(int i=0;i<len;i++){cin>>A[i];}
#define coutarr(A,len) for(int i=0;i<len;i++){cout<<A[i]<<' ';}cout<<endl
#define coutin(V) for(auto& i : V){cout << i << ' ';}cout<<endl // for vect and set
#define coutmap(U) for(auto& i : U){cout << i.first << "->" << i.second << ", ";}cout<<endl // for map
#define deb(x) cout << #x << '\t' << x << endl
const int imax = numeric_limits<int>::max(), imin = numeric_limits<int>::min();
const long long	lmax = numeric_limits<long long>::max(), lmin = numeric_limits<long long>::min();
/*========================================================================*/
/* strategi/note:



/================================*/




bool Svd=0;
void solve(){Svd=1;
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = a*c;
    ans = max(ans,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans << endl;
}


/*========================================================================*/

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
//cout<<fixed<<setprecision( ); // iomanip **

 solve();
 //int t;cin>>t;while(t--){solve();}

if(!Svd)cout<<"solve() function blm dipanggil!"<<endl;
//cout.flush(); cin.get();
return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int count=0;
	int roop,judge,jn;
	for(roop=0;roop<n;roop++){
		cin >> judge;
		if(judge==2||judge==3){
			count++;
			continue;
		}else if(judge%2){
			jn=3;
			while(judge%jn){
				if(judge<jn*jn){
					count++;
					break;
				}
				jn+=2;
			}
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
long long a;
long long d[500005];
int main()
{
    scanf("%lld",&a);
    long long ans=0;
    long long mi;
    int f=0;
    for(int i=0;i<a;i++)
        scanf("%lld",&d[i]);
    sort(d,d+a);
    long long q=0,r=a-1;
    long long t;
    for(int i=0;i<a;i++)
    {
        //cout<<d[q]<<" "<<d[r]<<endl;
        if(i%2==0)
        {
            if(d[r]>=d[q])
                t=d[r]-d[q++];
            else
                t=d[q++]-d[r];
            if(t<mi||f==0)
            {
                mi=t;
                f=1;
            }
            ans+=t;
        }
        else
        {
            if(d[r]>=d[q])
                t=d[r--]-d[q];
            else
                t=d[q]-d[r--];
            if(t<mi||f==0)
            {
                mi=t;
                f=1;
            }
            ans+=t;
        }
        if(q==r)
        {
            r=0;
        }
    }
    long long ans1=ans-mi;
    ans=0;
    f=0;
    sort(d,d+a,greater<long long>());
    q=0,r=a-1;
    for(int i=0;i<a;i++)
    {
        //cout<<d[q]<<" "<<d[r]<<endl;
        if(i%2==0)
        {
            if(d[r]>=d[q])
                t=d[r]-d[q++];
            else
                t=d[q++]-d[r];
            if(t<mi||f==0)
            {
                mi=t;
                f=1;
            }
            ans+=t;
        }
        else
        {
            if(d[r]>=d[q])
                t=d[r--]-d[q];
            else
                t=d[q]-d[r--];
            if(t<mi||f==0)
            {
                mi=t;
                f=1;
            }
            ans+=t;
        }
        if(q==r)
        {
            q=0;
        }
    }
    long long ans2=ans-mi;
    if(ans2<ans1)
        ans=ans1;
    else
        ans=ans2;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define F first
#define S second
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
class UnionFind{
  public:
    vector<int> par;
    vector<int> siz;

  UnionFind(int n){
    siz=vector<int>(n,1);
    par=vector<int>(n,-1);
  }

  int root(int x){
    if(par[x]==-1){
      return x; //根
    }else{
      return par[x]=root(par[x]); //経路圧縮
    }
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }

  void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(siz[y]<siz[x])swap(x,y);
    siz[y]+=siz[x];
    par[x]=y;
  }
  int size(int x){
    return siz[x];
  }
};
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<int> a(m),b(m);
  rep(i,m) cin >> a[i] >> b[i];
  UnionFind uf(n);
  rep(i,m){
    a[i]--; b[i]--;
    uf.unite(a[i],b[i]);
  }
  int ans = 0;
  rep(i,n){
    ans = max(ans,uf.siz[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6348
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   H : Integer;
   W : Integer;
   A : Integer;
   B : Integer;
begin
   Get (H);
   Get (W);
   Get (A);
   Get (B);
   Put_Line (Integer'Image ((H-A)*(W-B)));
end Solve;

Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    cin>>n;
    cin>>k;
    vector<int> trees(n);
    for(int i=0;i<n;i++)
	cin>>trees[i];
    sort(trees.begin(),trees.end());
    int hmin=trees.back()-trees.front();
    for(int i=0;i<=n-k;i++){
	int h=trees[i+k-1]-trees[i];
	if(h<hmin)
	    hmin=h;
    }
    cout<<hmin<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long p = sc.nextLong();
        long ans = 1;
        if (n == 1)
            ans = p;
        else {
            for (long i = 2; Math.pow(i, n) <= p; i++) {
                if (p % Math.pow(i, n) == 0) {
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22736
a = []
for i in range(5):
    a.append(int(input()))
b =[]
c = []
for i in range(5):
    b.append(int(a[i]))
for i in range(5):
    while b[i] > 10:
        b[i] = b[i] - 10
if min(b) == 10:
    ans = sum(a)
else:
    for i in range(5):
                c.append(int(a[i]) +10 -int(b[i]))
    d = sum(c)
    mini = min(b)
    ans = d - 10 + mini
print(ans)

Measured memory_bytes: 3064
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();

    let mut count = 0;
    for (i, c) in s.chars().enumerate() {
        if i % 2 == 0 {
            for easy in ['R', 'U', 'D'].iter() {
                if c == *easy {
                    count += 1;
                    continue;
                }
            }
        } else {
            for easy in ['L', 'U', 'D'].iter() {
                if c == *easy {
                    count += 1;
                    continue;
                }
            }
        }
    }

    let ans = if count == s.len() { "Yes" } else { "No" };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int grid[2001][2001];
int a[2001][2001];
int b[2001][2001];
int c[2001][2001];
int main(void)
{
	int n,m,q,x1,x2,y1,y2,s1,s2,s3,i,j;
	char t;
	scanf("%d%d%d%*c",&n,&m,&q);
	FOR(i,1,n+1){
		FOR(j,1,m+1){
			scanf("%c",&t);
			grid[i][j]=t-'0';
		}
		scanf("%*c");
	}
	FOR(i,1,n+1){
		FOR(j,1,m+1){
			a[i][j]=grid[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1];
			b[i][j]=(grid[i][j]==1&&grid[i][j-1]==1)+b[i-1][j]+b[i][j-1]-b[i-1][j-1];
			c[i][j]=(grid[i][j]==1&&grid[i-1][j]==1)+c[i-1][j]+c[i][j-1]-c[i-1][j-1];
		}
	}
	FOR(i,0,q){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		s1=a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
		s2=b[x2][y2]-b[x1-1][y2]-b[x2][y1]+b[x1-1][y1];
		s3=c[x2][y2]-c[x1][y2]-c[x2][y1-1]+c[x1][y1-1];
		printf("%d\n",s1-s2-s3);
	}
	return 0;
}

Measured memory_bytes: 64256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 class Program
    {
        static void Main(string[] args)
        {
         	IDictionary<long, long> map = new Dictionary<long, long>();
            string[] inputA = Console.ReadLine().Split(' ');
            string[] inputB = Console.ReadLine().Split(' ');
            long ind = 0;
            long k = long.Parse(inputA[1]);
            long[] arr = inputB.Select(s => long.Parse(s)).ToArray();
            long nowInd = 0;
            long nowValue = arr[nowInd];
            if(nowValue == 1)
            {
                Console.WriteLine(1);
                return;
            }
            long findInd = 0;
            long a = 0;    
            map.Add(nowInd+1,ind);
            for (long i = 2; i <= k; i++)
            {
                nowInd = nowValue - 1;
                nowValue = arr[nowInd];
                ind++;
                map.Add(nowInd + 1, ind);
                if (map.ContainsKey(nowValue))
                {
                    findInd = map[nowValue];            
                    a = (k - findInd) % (i - findInd) + findInd;
                    var pair = map.FirstOrDefault(c => c.Value == a);
                    long indAns = pair.Key;
                    Console.WriteLine(indAns);
                    return;
                }
                
            }
            Console.WriteLine(nowValue);
        }
}

Measured memory_bytes: 46584
#include<stdio.h>
int solve(int, int);
int n,A[2000],q,m[2000],i,res1,res2;
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
 for(i=0;i<q;i++){
    if(solve(0,m[i])==1)printf("yes\n");
    else printf("no\n");
  }
 return 0;
}

  int solve(int i, int m){
    if(m==0)return 1;
    if (i>n)return 0;
    res1=solve(i+1,m);
    if(res1==1)return 1;
    res2=solve(i+1,m-A[i]);
    if(res2==1)return 1;
    return 0;
  }

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,ans=0,i;
	cin>>n>>x;
	vector<int> a;
	int A;
	for(i=0;i<n;i++){
		cin>>A;
		a.push_back(A);
	}
	sort(a.begin(),a.end());
	for(i=0;i<n&&x>=a[i];i++,ans++) x-=a[i];
	if(ans==n&&x!=0) cout<<ans-1<<endl;
	else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#define FILEIO(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout);
#include <stdio.h>

typedef long long ll;

const int N=200005;
const int cIz=1000000007;
const int INF=1000000007;

int n,x,y,c[N],w[N],mn[N],cnt[N];

int fac[N],inv[N],ifac[N];
void init() {
	fac[0]=ifac[0]=1;
	fac[1]=inv[1]=ifac[1]=1;
	for(int i=2;i<=n;++i) {
		fac[i]=(ll)fac[i-1]*i%cIz;
		inv[i]=(ll)(cIz-cIz/i)*inv[cIz%i]%cIz;
		ifac[i]=(ll)ifac[i-1]*inv[i]%cIz;
	}
}

int main() {
	int g1=0,g2=0;
	scanf("%d%d%d",&n,&x,&y);
	init();
	for(int i=0;i<=n;++i) mn[i]=INF;
	for(int i=1;i<=n;++i) {
		scanf("%d%d",c+i,w+i);
		if(w[i]<mn[c[i]]) mn[c[i]]=w[i];
	}
	for(int i=1;i<=n;++i) {
		if(mn[i]<=mn[g1]) {
			g2=g1; g1=i;
		} else if(mn[i]<mn[g2]) {
			g2=i;
		}
	}
	for(int i=1;i<=n;++i) {
		if(c[i]==g1) {
			if(w[i]+mn[c[i]]<=x||(w[i]+mn[g2]<=y&&mn[g2]+mn[g1]<=y)) {
				++cnt[c[i]];
			}
		} else {
			if(w[i]+mn[g1]<=y||(w[i]+mn[c[i]]<=x&&mn[c[i]]+mn[g1]<=y)) {
				++cnt[c[i]];
			}
		}
	}
	int sum=0,ans=1;
	for(int i=1;i<=n;++i) {
		ans=(ll)ans*ifac[cnt[i]]%cIz;
		sum+=cnt[i];
	}
	ans=(ll)ans*fac[sum]%cIz;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	cin>>n;
	while(n--)
	{
		cin>>x;
		if(!(x&1))
			if(x%3&&x%5)
			{
				cout<<"DENIED";
				return 0;
			}
	}
	cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 256
package main

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

const (
	symbol = "#"
)

var scan = bufio.NewScanner(os.Stdin)

func main() {
	scanWords()

	for {
		height := readNextInt()
		width := readNextInt()
		if height == 0 && width == 0 {
			break
		}
		printRectangle(height, width)
		fmt.Println()
	}

}

func printRectangle(height, width int) {
	for h := 0; h < height; h++ {
		for w := 0; w < width; w++ {
			fmt.Print(symbol)
		}
		fmt.Println()
	}
}

func scanWords() {
	scan.Split(bufio.ScanWords)
}

func readNextInt() int {
	scan.Scan()

	input, err := strconv.Atoi(scan.Text())
	if err != nil {
		panic(err)
	}
	return input
}



Measured memory_bytes: 1084
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
?????\???
?????? namei ??¨????????????????????? timei ????????? n ???????????????????????????????????????????????§????????????
??????????????????????????±?????\???????????°??¨?????°????????????????????§??????CPU ?????????????????????????????????????????????
???????????????????????§ q ms?????????????????????????????¨???????????????????????????????????????????????????
q ms ????????????????????£????????????????????????????????????????????????????????°???
??????????????????????????????????°?????§??????????CPU ????¬??????????????????????????????????????????????

??????????????????????????±?????\???????????°???????????\??¬????????????????????°????????????????????????????????????
"""

# ?????????
n,q = list(map(int,input().strip().split()))
QUE = []
CNP = []
for i in range(n):
    a = list(input().strip().split())
    a[1] = int(a[1])
    QUE.append(a)

total = 0
while len(QUE) > 0:
    p = QUE.pop(0)
    pt = p[1] - q
#    print("unshift p={} t={} q={} pt={}".format(p[0],p[1],q,pt))
    if pt < 1:
        total += p[1]
        CNP.append([p[0],total])
#        print("end p={} t={}".format(p[0],total))
    else:
        p[1] = pt
        QUE.append(p)
#        print("push p={} t={}".format(p[0],p[1]))
        total += q
for i in CNP:
    print("{} {}".format(i[0],i[1]))

Measured memory_bytes: 18408
#include<iostream>
#include<cstdio>
using namespace std;int f[500005],l[500005];char str[500005];
int main() {int n;scanf("%d%s",&n,str+1);
	for (register int i=1;i<=n;++i) l[i]=(str[i]^48?l[i-1]:i);
	for (register int i=1;i<=n;++i) {f[i]=f[i-1];if (str[i]==48) continue;
		if (str[i-2]==49&&str[i-1]==48) f[i]=max(f[i],
		max(f[l[i-2]]+i-2-l[i-2],f[l[i-2]+1]+i-3-l[i-2]));
		else if (l[i]>1&&str[l[i]-1]==49) f[i]=max(f[i],f[l[i]-2]+i-l[i]);
	}printf("%d",f[n]);return 0;
}

Measured memory_bytes: 4608