akhauriyash/Code-Regression huggingface dataset:
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        var d = new int[3];
        d[0] = Math.Abs(a - b);
        d[1] = Math.Abs(b - c);
        d[2] = Math.Abs(c - a);
        Array.Sort(d);
        Console.WriteLine(d[0] + d[1]);
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
const int N=1e3+5, MOD=1e9+7;
using namespace std;
int dp[N][N], n, a, b, c, d, nck[N][N], fact[N], ipw[N][N], ifact[N];
inline int modpow(int base, int exp, int modulo)
{
  base %= modulo;  int result = 1;
  while (exp > 0LL) {
    if (exp & 1LL) result = (result * base) % modulo;
    base = (base * base) % modulo; exp >>= 1;
  }
  return result % modulo;
}
int grp(int gsz, int ng)
{
    int ret = fact[gsz*ng];
    ret *= ipw[gsz][ng];
    ret %= MOD;
    ret *= ifact[ng];
    return ret % MOD;
}
signed main()
{
    fact[0]=1;
    ifact[0]=1;
    for(int i = 0; i < N; i++)
    {
        if(i) fact[i]=(fact[i-1]*i)%MOD;
        if(i) ifact[i] = (ifact[i-1]*modpow(i, MOD-2, MOD))%MOD;
        nck[0][i]=0;
        dp[0][i]=0;
        nck[i][0]=1;
        dp[i][0]=1;
    }
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            ipw[i][j]=modpow(modpow(fact[i], j, MOD), MOD-2, MOD);
        }
    }
    for(int i = 1; i < N; i++)
    {
        for(int j = 1; j < N; j++)
        {
            nck[i][j] = nck[i-1][j-1] + nck[i-1][j];
            nck[i][j] %= MOD;
        }
    }
    cin >> n >> a >> b >> c >> d;
    a--;
    for(int i = 1; i <= b-a; i++)
    {
        for(int j = 1; j <= n; j++)
        {
           // cout << i << " | " << j << endl;
            dp[i][j]=dp[i-1][j];
            for(int k = c; k <= d; k++)
            {
                if(k*(a+i) > j) break;
                int lst = j - (a+i)*k;
                int curr = dp[i-1][lst] * nck[n-lst][(a+i)*k];
                curr %= MOD;
                curr *= grp(a+i, k);
                curr%=MOD;
              //  cout << k << " - " << curr << endl;
                dp[i][j] += curr;
                dp[i][j] %= MOD;
            }
          //  cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
    cout << dp[b-a][n];
}

Measured memory_bytes: 23936
(let ((n (read))
      (temp (read))
      (a (read))
      (ansv 10000000)
      ans
      tmp)
  (loop for i from 1 upto n do
        (setf tmp (- temp (/ (* (read) 6) 1000)))
        (if (< (abs (- tmp a)) ansv) (progn (setf ans i)
                                            (setf ansv (abs (- tmp a))))))
  (princ ans))


Measured memory_bytes: 15080
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

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

int uf[10001];

int find(int x) {
        if(uf[x] == x) return x;
        else return uf[x] = find(uf[x]);
}

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

void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(same(x,y)) return;
        else uf[x] = y;
}

int main() {
    int n,q;
    cin >> n >> q;
    
    rep(i,0,n) uf[i] = i;
    
    int com, x, y;
    rep(i,0,q) {
        cin >> com >> x >> y;
        if(com == 0) { //unite
                unite(x,y);
        }
        
        else if(com == 1) { //same
                cout << same(x,y) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1316
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
const int maxn = 100010;
int c[maxn],a[maxn];
int main(){
	int n=read(),mx=0;
	for(int i=1;i<=n;i++){
		a[i]=read(),c[a[i]]++;
		mx = max(mx,a[i]);
	}
	for(int i=1;i<=mx;i++){
		if(c[i]==0) continue;
		if(c[i]%2) c[i]%=2;
		else c[i]=2;
	}
	int ans=0,cnt=0;
	for(int i=1;i<=mx;i++){
		if(c[i]==1) ans++;
		if(c[i]==2) cnt++;
	}
	if(cnt%2) printf("%d\n",ans+cnt-1);
	else printf("%d\n",ans+cnt);
	return 0;
}

Measured memory_bytes: 1024
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O2")
// #pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
// #define int ll
#define pb push_back
#define pob pop_back
#define __bp __builtin_popcount
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pdd = pair<ld,ld>;
using vint = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
#define F first
#define S second
const int N = 1e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int Inf = 1e9+7;
const ll INF = 1e18+7;
const int Mod = 1e9+7;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("sweets.in", "r", stdin);
//	freopen("sweets.out", "w", stdout);
//	cout << setprecision(7) << fixed;
}

int n;
ll dp[2001][2001];
ll azaz[2001];

void solve()
{
	cin >> n;
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		azaz[0] = dp[i - 1][0];
		for (int j = 1; j <= n; ++j)
			(azaz[j] = azaz[j - 1] + dp[i - 1][j]) %= Inf;
		for (int s = 3; s <= n; ++s)
		{

			dp[i][s] = azaz[s - 3];
			dp[i][s] %= Inf;
/*			for (int x = 3; x <= s; ++x)
			{
				dp[i][s] += dp[i - 1][s - x];
				dp[i][s] %= Inf;
			}
*/			// cerr << i << ' ' << s << ' ' << dp[i][s] << '\n';
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		ans += dp[i][n];
		ans %= Inf;
	}
	cout << ans;
}

signed main()
{
	io();
	int tt = 1;
//	cin >> tt;
	while (tt--) {
		// solve();
		solve();
//		cerr << '\n';

	}
}

Measured memory_bytes: 34932
import java.io.*;
   
public class Main {
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        try {
            String[] str = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            if(a < b){
            System.out.println("a < b");
            }else if(a > b){
            System.out.println("a > b");
            }else{
            System.out.println("a == b");
            }
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 24204
#pragma warning(disable:4996)
#include<bitset>
#include<map>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long

#define lson root<<1
#define rson root<<1|1

#define mem(arr, in) memset(arr, in, sizeof(arr))
using namespace std;

const int INF = 1000;

int n;

int get(int x) {
	int res = 0;
	while (x) {
		res += x % 10;
		x = x / 10;
	}
	return res;
}

int main()
{
	while (cin >> n) {
		int ans = INF;
		for (int i = 1; i <= n / 2; i++) ans = min(ans, get(i) + get(n - i));
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  ll n;
  string s;
  cin >> n>>s;
  int ans=1;
  for (int i =1;i<n;i++){
    if (s.at(i) != s.at(i-1)){
      ans++;
    }
  }
  cout << ans << endl;
}

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

class Stack{
private:
	int sp;
	int S[100];
public:
	Stack(){sp=0;}
	bool isFull() const{return (sp==100);}
	bool isEmpty() const{return (sp==0);}
	void push(int d);
	int top();
	void pop();
};

void Stack::push(int d)
{
	if(isFull())
		return;
	
	S[sp++]=d;
}

int Stack::top()
{
	if(isEmpty())
		return -1;
	
	return S[sp-1];
}

void Stack::pop()
{
	if(isEmpty())
		return;

	sp--;
}

int main()
{
	Stack s;
	
	string expr;
	getline(cin,expr);
	
	istringstream is(expr);

	while(!is.eof()){
		string op;
		is>>op;

		int tmp1,tmp2;

		switch(op[0]){
		case '+':
			tmp1=s.top();s.pop();
			tmp2=s.top();s.pop();
			s.push(tmp2+tmp1);
			break;
		case '-':
			tmp1=s.top();s.pop();
			tmp2=s.top();s.pop();
			s.push(tmp2-tmp1);
			break;
		case '*':
			tmp1=s.top();s.pop();
			tmp2=s.top();s.pop();
			s.push(tmp2*tmp1);
			break;
		default:
			istringstream is2(op);
			is2>>tmp1;
			s.push(tmp1);
			break;
		}
	}
	
	cout<<s.top()<<endl;

	return 0;
}

Measured memory_bytes: 3152
#include<iostream>
using namespace std;
int main(){
  int H,W;
  while(true){
    cin>>H>>W;
    if(H==0&&W==0)break;
    else if(H>0&&W>0){
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          if((i+j)%2==0){
            cout<<"#";
          }else {
            cout<<".";
          }
        }cout<<endl;
      }cout<<endl;
    }
  }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

signed main() {
	int n,m;
	cin >> n >> m;
	if(n==1){
		if(m==1){
			cout << 1 << endl;
		}
		else{
			cout << m-2 << endl;
		}
	}
	else if(m==1){
		if(n==1){
			cout << 1 << endl;
		}
		else{
			cout << n-2 << endl;
		}
	}
	else{
		cout << (n - 2) * (m - 2) << endl;
	}
}

Measured memory_bytes: 256
l,r = map(int,input().split())
lm = l % 2019
rm = r % 2019
if r-l >= 2019:
  print(0)
else :  
  if lm >= rm:
    print(0)
  else:
    min_n = 2020
    for i in range(l,r+1):
      for j in range(i+1,r+1):
        mod = (i*j)%2019
        if mod < min_n:
          min_n = mod
    print(min_n)


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

int count(int n, int x){
	int cnt = 0;
	for ( int i = 1; i <= n-2; i++ ){
		for ( int j = i+1; j <=  n-1; j++ ){
			for ( int k = j+1; k <= n; k++ ){
				if ( i + j + k == x ) cnt++;
			}
		}
	}
	return cnt;
}

int main(){
	int n, x;
	
	while(1){
		cin >> n >> x;
		if ( n == 0 && x == 0 ) break;
		cout << count(n, x) << endl;
	}

	return 0;
}


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

int main(void)
{
	int N, L;
	cin >> N >> L;
	vector<string> vec (N);
	for(int i = 0;i < N;i++){
		cin >> vec.at(i);
	}
	
	sort(vec.begin(),vec.end());
	
	for(int i = 0;i < N;i++){
		cout << vec.at(i);
	}
	cout << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll h=in(),n=in();
    map<ll,ll>waza;
    for(ll i=0;i<n;++i){
        ll a=in(),b=in();
        if(waza.count(a)==0||waza[a]>b)waza[a]=b;
    }

    auto ans=vec2<ll>(waza.size()+1,h+1,1e9);
    ans[0][0]=0;
    auto itr=waza.begin();
    for(ll i=1;i<=waza.size();++i,++itr){
        ll d=itr->first,m=itr->second;
        for(ll j=0;j<=h;++j){
            ans[i][j]=ans[i-1][j];
            for(ll k=0;k<=j/d+(j%d?1:0);++k){
                ans[i][j]=min(ans[i][j],ans[i-1][max(0ll,j-k*d)]+k*m);
            }
        }
    }
    cout<<ans.back().back()<<endl;
}


Measured memory_bytes: 78592
N,M = map(int,input().split())
PY = [list(map(int,input().split())) + [i] for i in range(M)]

PY.sort()

ans = [None for i in range(M)]

x = 1
P = PY[0][0]
for i in range(M):
    if P != PY[i][0]:
        x = 1
        P = PY[i][0]

    ans[PY[i][2]] = (P,x)
    x += 1

for p,x in ans:
    print(str(p).zfill(6) + str(x).zfill(6))


Measured memory_bytes: 35100
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s.size() < 4) {
    cout << "No" << endl;
  }else if(s.at(0) == 'Y' && s.at(1) == 'A' && s.at(2) == 'K' && s.at(3) == 'I') {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static string[] inp;
        static int H;
        static int W;
        static int K;
        static long ans = 0;

        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            //var c = Console.ReadLine();
            var HWK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            //var P = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray()
            H = HWK[0];
            W = HWK[1];
            K = HWK[2];
            inp = new string[H];

            for (int i = 0; i < H; i++)
            {
                inp[i] = Console.ReadLine();
            }


            for (int i = 0; i < Pow(2,H); i++)
            {
                for (int j = 0; j < Pow(2, W); j++)
                {
                    Search(i, j);
                }
            }


            Console.WriteLine(ans);

        }

        static void Search(int i, int j)
        {
            int count = 0;

            for (int l = 0; l < H; l++)
            {
                for (int m = 0; m < W; m++)
                {
                    if (inp[l][m] == '#' && ((((int)Pow(2,l))&i) == 0)  && ((((int)Pow(2, m)) & j) == 0))
                    {
                        count++;
                    }
                }
            }

            if(count == K)
            {
                ans++;
            }
        }
    }

}


Measured memory_bytes: 28624
import java.util.*;
public class Main{
    public static void maxHeapify(long A[], int idx){
        int l = 2*idx;
        int r = 2*idx + 1;
        int largest = 0;
        if(l <= A.length-1 && A[l] > A[idx])
            largest = l;
        else
            largest = idx;
        if(r <= A.length-1 && A[r] > A[largest])
            largest = r;
        if(largest != idx){
            long tmp = A[idx];
            A[idx] = A[largest];
            A[largest] = tmp;
            maxHeapify(A,largest);
        }
            
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        long A[] = new long[H+1];
        for(int i = 1 ; i <= H ; i++)
            A[i] = sc.nextLong();
        for(int i = H/2 ; i > 0 ; i--)
            maxHeapify(A,i);
        for(int i = 1 ; i <= H ; i++)
            System.out.print(" " + A[i]);
        System.out.println();
    }
}


Measured memory_bytes: 171480
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll

int main(){
  string n;cin>>n;
  int ans = 0;
  rep(i,n.size())if(n[i]=='2')ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np

a = int(input())
b = np.array([int(x) for x in input().split()])

if(a!=len(b)):
	print('the array size is different')
else:
	c = b%2
	d = b/2
	count = 0
	while sum(c)==0:
		count += 1
		c = d%2
		d = d/2
	print(count)

Measured memory_bytes: 12468
A, B, C, D = map(int, input().split())

# while A > 0 and B > 0:
#     print(A, C)
#     C -= B
#     if B <= 0:
#         print("Yes")
#         break
#     A -= D
#     if A <= 0:
#         print("No")
#         break

import math
# print(math.ceil(A / D), math.ceil(C / B))
if math.ceil(A / D) >= math.ceil(C / B):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62116
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int h, n, a[max];
    int sum=0;
    
    scanf("%d%d", &h, &n);
    rep(i, n){
        scanf("%d", &a[i]);
        sum+=a[i];
    }
    
    if (h<=sum) {
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <queue>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, x, y;
    cin, n, x, y;
    x--;
    y--;
    vector<vector<int>> g(n);
    REP(i, 0, n - 1) {
        int b = (i + 1) % n;
        g[i].push_back(b);
        g[b].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    auto cost = make_v(n, n, 0LL);
    vector<bool> used(n, false);
    auto dfs = [&](int start) {
        queue<P> q;
        q.emplace(0, start);
        while (q.size()) {
            int c, to;
            tie(c, to) = q.front();
            q.pop();
            if (used[to]) continue;
            cost[start][to] = c;
            used[to] = true;
            for (auto &nxt : g[to]) {
                if (used[nxt]) continue;
                q.emplace(c + 1, nxt);
            }
        }
    };
    REP(i, 0, n) {
        used.assign(n, false);
        dfs(i);
    }
    vector<int> ans(n, 0);
    REP(i, 0, n) {
        REP(j, i + 1, n) {
            ans[cost[i][j] - 1]++;
            dump(i, j, cost[i][j]);
        }
    }
    REP(i, 0, n - 1) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 31744
require 'mathn'

def f(cost, a, b, c, d, e, f, s, m)
    time = a + b + c + (d + e) * m 
    sale = f * s * m 
    (sale - cost) / time
end

loop {
    n = gets.to_i
    break if n == 0
    a = (1..n).map {
        name, *params = gets.split
        [- f(*params.map(&:to_i)), name]
    }   
    puts a.sort.map(&:last)
    puts ?#
}

Measured memory_bytes: 7732
#include <bits/stdc++.h>
using namespace std;
//#define ll long long
#define pb push_back
int main() {
	int n,k,x;
	vector<int>v;
	cin>>n>>k;
	while(n--)
	{
	    cin>>x;
	    v.pb(x);
	}
	sort(v.begin(),v.end());
	cout<<accumulate(v.begin()+v.size()-k,v.end(),0)<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}


int main() {
	int n;
	cin >> n;
	vector<int> num(201, 0);
	for (int i = 0; i < 200;i++) {
		if (i % 2) {
			for (int j = i; j > 0; j--) {
				if (i%j == 0)num[i]++;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (num[i] == 8) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,i,d=0,cnt=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=1;i<=b;i++){
		d=i*a;
		//printf("%d\n",d);
		if(d%b==c) cnt=1;
	}
	if(cnt==1) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int n;
    int h[100];
    int count = 1;
    int i,j;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    
    for(i = 1; i < n; i++){
        for(j = 0; j < i; j++){
            if(h[j] > h[i]){
                break;
            }
        }
        
        if(i == j){
            count++;
        }
    }
    
    printf("%d", count);
    
    return 0;
}

Measured memory_bytes: 128
n = int(input())
t, a = map(int,input().split())
h = list(map(int,input().split()))
temp = 10**10
index = 0
for i in range(n):
    if abs((temp-a)) > abs((t - h[i]*0.006) - a):
        temp = t - h[i]*0.006
        index = i
    #print(abs((temp-a)))
    #print( abs((t - h[i]*0.006) - a))
print(index+1)

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=(res*x)%INF;y=y>>1;x=(x*x)%INF;}return res%INF;} // modular exponent
ll n;
const int N=1e6+6;
const int maxn=1e4+4;
ll a[maxn];
ll cpy[maxn];
ll sieve[N];// largest prime factor of a number is stored
map<ll,ll> maxexp;
void work()
{
  repA(i,2,N-1)
  {
    if(sieve[i]==0)
    {
      sieve[i]=i;
      for(ll j=2;i*j<N;j++)
      {
        sieve[i*j]=i;
      }
    }
  }
}
ll calculate()
{
  rep(i,n)
  {
    if(sieve[a[i]]!=a[i])
    {
      while(a[i]>1)
      {
        ll p=sieve[a[i]];
        ll num=0;
        while(a[i]%p==0)
        {
          a[i]/=p;
          num++;
        }
        if(maxexp.count(p)) maxexp[p]=max(maxexp[p],num);
        else maxexp[p]=num;
      }
    }
    else
    {
      if(maxexp.count(a[i])) maxexp[a[i]]=max(maxexp[a[i]],1ll);
      else maxexp[a[i]]=1ll;
    }
  }
  ll val=1;
  for(auto it:maxexp)
  {
    val*=power(it.fi,it.se);
    val%=INF;
  }
  return val;
}
ll inv(ll c)
{
  return power(c,INF-2);
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision/
    cin>>n;
    rep(i,n)
    {
      cin>>a[i];
      cpy[i]=a[i];
    }
    if(n==1)
    {
      cout<<1<<'\n';
    }
    else
    {
      work();
      ll ans=0;
      ll lc=calculate();
      // watch(lc);
      rep(i,n)
      {
        ll val=(lc*inv(cpy[i]))%INF;
        ans+=val;
        ans%=INF;
      }
      cout<<ans<<'\n';
    }
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 12112
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// 1. stackを用意する
// 2. (が来たらstackに追加
// 3.
// )が来た時stackが空のとき，不整合エラーで空じゃなかったらstackにある(と)をペアにして
// stackからpopする

//不整合
//途中で stack が空なのに右カッコが来る
//最後に stack に左カッコがあまる
int main() {
    string X;
    // Xの長さは偶数であり半分はS,半分はTである
    // STという文字列が苦手なのでSTとなるもののうち最も左側を取り除く
    //最後の文字列の数を出力
    cin >> X;
    int stack = 0;
    int puyo = 0;
    for(int i = 0; i < X.size(); i++) {
        if(X[i] == 'S')
            stack++;
        else if(stack > 0) {
            // stackがあり左括弧
            --stack;
            puyo++;
        }
    }
    cout << X.size() - puyo * 2 << endl;
}


Measured memory_bytes: 640
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

struct edge {
    int next,to;
};

const int maxn=(int)(2e5)+5;
int fr[maxn];
int vi[maxn];
int col[maxn];
edge e[maxn<<1];
int tote=0;

inline void addone(int u,int v) {
    ++tote;
    e[tote].next=fr[u];fr[u]=tote;e[tote].to=v;
}

inline void addedge(int u,int v) {
    addone(u,v);addone(v,u);
}

int cA,cB;
LL A,B,C;

void dfs(int x,int c=0) {
    col[x]=c;vi[x]=1;
    cA++;
    RAL(i,x) if(!vi[e[i].to]) dfs(e[i].to,c^1);
    else if(col[x]==col[e[i].to]) cB=1;
}

int main() {
    int n,m;
    read(n);read(m);
    memset(fr,-1,sizeof(fr));
    REP(i,1,m) {
        int u,v;
        read(u);read(v);
        addedge(u,v);
    }
    REP(i,1,n) if(!vi[i]) {
        cA=cB=0;dfs(i);
        if(cA==1) A++;
        else if(cB) C++;
        else B++; 
    }
    printf("%lld\n",A*(n-A)*2+A*A+B*B*2+C*B*2+C*C);
    return 0;
}

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

int main() {
string S;
  cin>>S;
  for(int i=0; i<3; i++){
    if(S.at(i)=='1')
      S.at(i)='9';
    else if(S.at(i)=='9')
      S.at(i)='1';
    else continue;
  }
  cout<<S<<endl;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    long long N;
    long long K;
    long long det,subtraction;
    
    cin >> N >> K;
    
    det = N % K;
    subtraction = det -K;
    
    if(abs(subtraction) < abs(det)){
        
        cout << abs(det-K);
        
    }else{
        
        cout << det;
    
    }
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int x69[12]={1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
int n,ans;

int dfs(int x){
	int res=1e9,cnt=1;
	if(x>0)
		for(int i=11;i>=0;i--){
			if(cnt>2){
				break;
			}
			if(x-x69[i]>=0){
				cnt++;
				res=min(dfs(x-x69[i]),res);
			}
			
		}
	else
		return 0;
	return res+1;
} 

int main(){
	cin>>n;
	ans=dfs(n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    int h=gi();
	    int w= gi();
	    String[][] x=new String[h+2][w+2];
	    for (int i=0; i<w+2;i++) {
    		x[0][i]=".";
    	}
	    for(int i=1; i<=h;i++) {
	    	x[i][0]=".";
	    	String s=gs();
	    	for (int j=1; j<=w;j++) {
	    		x[i][j]=String.valueOf(s.charAt(j-1));
	    	}
	    	x[i][w+1]=".";
	    }
	    for (int i=0; i<w+2;i++) {
    		x[h+1][i]=".";
    	}
	    
	    for(int i=1; i<=h;i++) {
	    	for (int j=1; j<=w;j++) {
	    		if (x[i][j].equals(".")) {
	    			int c=0;
	    			if (x[i-1][j-1].equals("#"))c++;
	    			if (x[i-1][j].equals("#"))c++;
	    			if (x[i-1][j+1].equals("#"))c++;
	    			if (x[i][j-1].equals("#"))c++;
	    			if (x[i][j+1].equals("#"))c++;
	    			if (x[i+1][j-1].equals("#"))c++;
	    			if (x[i+1][j].equals("#"))c++;
	    			if (x[i+1][j+1].equals("#"))c++;
	    			x[i][j]=String.valueOf(c);
	    		}
	    	}
	    }
	    
	    for(int i=1; i<=h;i++) {
	    	for (int j=1; j<=w;j++) {
	    		System.out.print(x[i][j]);
	    	}
	    	System.out.println();
	    }

	    
	    //System.out.print(c);
//	    if (s.contains("AC")) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

#define F first
#define S second
#define pb push_back
#define endl '\n'

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int N = 1e3 + 10;

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

 	int n, k;
 	cin >> n >> k;
 	int a[n];
 	for (int i = 0; i < n; ++i) {
 		cin >> a[i];
 		if (i >= k) {
 			if (a[i] > a[i - k]) {
 				cout << "Yes\n";
 			} else if ( a[i] <= a[i - k]) {
 				cout << "No\n";
 			}
 		}
 	}   
}

Measured memory_bytes: 4420
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(N):
    x -= A[i]
    if x<0:
        ans = i
        break
else:
    if x!=0:
        print(N-1)
    else:
        print(N)
    exit()
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int n,i;
    scanf("%d",&n);
    long int sum=0;
    for(i=1; i<=n; i++){
        if(i%3==0||i%5==0) continue;
        sum+=i;
    }
    printf("%ld\n",sum);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if (a%3==0 || b%3==0 || (a+b)%3==0 ){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int i;
    if (n == 0) {
        cout << 0;
        return 0;
    } else if (n == 1) {
        cout << 1;
        return 0;
    }
    for (i = 2; i * (i + 1) / 2 < n; ++i);
    cout << i;
    return 0;
}


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

using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> a(n,vector<int>(m));
  for(int i=0;i<n;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++){
      int p;
      cin >> p;
      a[i][p-1]++;
    }
  }
  int cnt=0;
  for(int i=0;i<m;i++){
    bool flag=true;
    for(int j=0;j<n;j++){
      if(a[j][i]==0) flag=false;
    }
    if(flag) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1e18 : 1e9;
const int MOD = 1000000007;
const long double EPS = 1e-8;


int main() {
	int n;
	while(cin >> n, n) {
		int macs = -1, mini = INF, sum = 0, s;
		rep (i, n) {
			cin >> s;
			macs = max(macs, s);
			mini = min(mini, s);
			sum += s;
		}
		cout << (sum - macs - mini) / (n - 2) << endl;
	}
	return 0;
}


Measured memory_bytes: 3000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える(ecnt)
	int id[100010];//適宜変える(vcnt)
}G;
G g;
int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
ll u,v;
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld%lld%lld",&n,&u,&v);
	u--,v--;
	rep(i,0,n-1){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
	}
	g.vcnt=n;
	g.ecnt=2*n-2;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}


ll dp[2][100010];
//dfs
void dfs(int v,int pre,int f){
	rep(i,g.id[v],g.id[v+1]){
		if(g.e[i].g!=pre){
			dp[f][g.e[i].g]=dp[f][v]+1;
			dfs(g.e[i].g,v,f);
		}
	}
}

int main(){
	readgraph();
	dfs(u,-1,0);
	dfs(v,-1,1);
	ll ans=0;
	rep(i,0,g.vcnt)if(dp[0][i]<dp[1][i])ans=max(ans,dp[1][i]-1);
	printf("%lld",ans);
}

Measured memory_bytes: 11716
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)

odd_map = Hash.new(0)
even_map = Hash.new(0)
arr.each_with_index do |v, i|
  if (i + 1) % 2 == 0
    even_map[v] += 1
  else
    odd_map[v] += 1
  end
end
odd_map = Hash[odd_map.sort_by{ |_, v| -v }]
even_map = Hash[even_map.sort_by{ |_, v| -v }]

odd_first = odd_map.first
even_first = even_map.first
if odd_first[0] != even_first[0]
  puts (n / 2) - odd_first[1] + (n / 2) - even_first[1]
else
  odd_map.shift
  even_map.shift
  odd_second = odd_map.empty? ? [0, 0] : odd_map.first
  even_second = even_map.empty? ? [0, 0] : even_map.first
  res1 = (n / 2) - odd_first[1] + (n / 2) - even_second[1]
  res2 = (n / 2) - odd_second[1] + (n / 2) - even_first[1]
  puts [res1, res2].min
end

Measured memory_bytes: 22404
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,n,a[101],b[101],c[101],q=0,w=0,flag=0,ans1=0,ans2=0,ans;
  cin>>x>>n;
  if(n==0)
  {
      cout<<x<<endl;
  }
  else
  {
     for(int i=0;i<n;i++)
  {
      cin>>a[i];
    if((a[i]-x)>=0)
    {
        b[q]=a[i]-x;
       q++;
    }
    if((a[i]-x)<=0)
    {
        c[w]=a[i]-x;
        w++;
    }
        if(a[i]==x)
        {
            flag=1;
        }
  }
    if(flag==0)
    {
        cout<<x<<endl;
    }
   else if(flag==1)
    {
        sort(b,b+q);
        sort(c,c+w);
   for(int i=0;i<q;i++)
   {
       if(b[i]+1!=b[i+1])
       {
           ans1=b[i]+1;
           break;
       }
   }
   for(int i=w-1;i>=0;i--)
   {
        if(c[i]-1!=c[i-1])
        {
            ans2=c[i]-1;
            break;
        }
   }
   ans=min(ans1,-ans2);
    if(ans==-ans2)
        cout<<x+ans2<<endl;
    else
        cout<<x+ans1<<endl;
    }
  }
}

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

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

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

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }
int main() {
    auto dp = make_v(10, 101, 1001, 0LL);
    for (int i = 0; i < 101; ++i) {
        dp[1][i][i] = 1;
    }
    for (int i = 1; i < 9; ++i) {
        for (int j = 0; j < 101; ++j) {
            for (int k = 0; k < 1001; ++k) {
                if(!dp[i][j][k]) continue;
                for (int l = j+1; l < 101; ++l) {
                    dp[i+1][l][k+l] += dp[i][j][k];
                }
            }
        }
    }
    int n, s;
    while(cin >> n >> s, n){
        ll ans = 0;
        for (int j = 0; j < 101; ++j) {
            ans += dp[n][j][s];
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 11372
while True:
    try:
        s = list(map(int, input().split(',')))
    except:
        break
    arrL = [s[i] for i in range(10)]
    v1, v2 = s[10], s[11]
    l = sum(arrL) * (v1 / (v1 + v2))
    total = 0
    ans = 0
    while total < l:
        total += arrL[ans]
        ans += 1
    print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> diameter(N);
  for (int i = 0; i < N; i++) {
    cin >> diameter.at(i);
  }
  sort(diameter.begin(), diameter.end());
  int x = 0;
  for (int i = 0; i < N; i++) {
    if (i > 0 && diameter.at(i - 1) == diameter.at(i)) {
    continue;
    }
    x += 1;
  }
  cout << x << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

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

struct UnionFind {
  vector<int> par, s; 
  UnionFind(int N) : par(N), s(N) { rep(i,N) { par[i] = i; s[i] = 1; } }
  int root(int x) { return par[x]==x ? x : par[x] = root(par[x]); }
  ll size(int x) { return par[x]==x ? s[x] : s[x] = size(root(x)); }
  void unite(int x, int y) { int rx=root(x), ry=root(y); if (rx!=ry) { s[rx] += s[ry]; par[ry] = rx; } }
  bool same(int x, int y) {  int rx=root(x), ry=root(y); return rx==ry; }
};

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

int main() {
  ll N, M; cin >> N >> M;
  UnionFind uf(N);
  rep(i,M) {
    ll A, B; cin >> A >> B; A--; B--;
    uf.unite(A,B);
  }

  ll result = 1;
  rep(i,N) result = max(result, uf.size(i));
  cout << result << endl;
  return 0;
}

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

using namespace std;
const int MOD = 1000000007,MAX = 510000;
long int pow107 = (int)pow(10, 9) + 7,llimit = LONG_MAX,fac[MAX], finv[MAX], inv[MAX];
int ilimit = INT_MAX;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long int COM(long int n,long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2
//コンビネーションCOMinit(),COM(n,m)

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a <= c && c <= b && b <= d){
        cout << b-c << endl;
    }else if(c  <= a && a <= d && d <= b){
        cout << d-a << endl;

    }else if(a <= c && d <= b){
        cout << d-c << endl;
    }else if(c <= a && b <= d){
        cout << b-a << endl;
    }else{
        cout << 0 << endl;
    }

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#define inf 111111111
using namespace std;
int n,p[55],t[55],dp[55][5];
int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        if(n==0) break;
        for(int i=0;i<n;++i) scanf("%d%d",&p[i],&t[i]);
        for(int i=0;i<=n;i++)
            for(int j=0;j<=3;j++) dp[i][j]=inf;
        if(p[0]<=t[0]) dp[0][1]=p[0];
        else {printf("NG 1\n");continue;}
        int ng=-1;
        for(int i=1;i<n;i++)
        {
			for(int j=1;j<=3;j++)
            {
                if(p[i-1]*(j+1)+p[i]<=t[i]-t[i-1]&&dp[i-1][j]<inf)
                {
                    dp[i][1]=min(dp[i][1],dp[i-1][j]+p[i-1]+p[i]);
                }
            }
            for(int j=1;j<=2;j++)
            {
                int tp=abs(p[i-1]-p[i]);
                if(tp*(j+1)<=t[i]-t[i-1]&&dp[i-1][j]<inf) dp[i][j+1]=min(dp[i][j+1],dp[i-1][j]+tp);
            }
            if(dp[i][1]==inf&&dp[i][2]==inf&&dp[i][3]==inf)
            {
                ng=i;
                break;
            }
        }
        if(ng==-1)
        {
            int ans=inf;
            for(int i=1;i<=3;i++) ans=min(ans,dp[n-1][i]+p[n-1]);
            printf("OK %d\n",ans);
        }
        else printf("NG %d\n",ng+1);
    }
    return 0;
}

Measured memory_bytes: 1196
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

sum = 0
for i in range(N):
    sum += B[A[i]-1]
    if i != 0:
        if A[i] == A[i-1] + 1:
            sum += C[A[i-1]-1]

print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    int N;
    cin >> N;
    string s[110];
    rep(i,N) cin >> s[i];
    int M;
    cin >> M;
    string t[110];
    rep(i,M) cin >> t[i];

    int res = 0;
    rep(i,N) {
        string word = s[i];
        int cnt = 0;
        rep(j,N) {
            if (word == s[j]) cnt += 1;
        }
        rep(j,M) {
            if (word == t[j]) cnt -= 1;
        }
        res = max(res, cnt);
    }

    cout << max(res, 0) << endl;
    return 0;
}


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

int main(){
	int n, count = 0;
	set<char> s;
	char in;
	cin >> n;
	rep(i, n){
		cin >> in;
		if(s.count(in) == 0){
			count++;
			s.insert(in);
		}
	}
	if(count == 3) cout << "Three" << endl;
	else cout << "Four" << endl;
	
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
x=[c for c in range(1,n+1)]
for i in range(1,k+1):
  d=int(input())
  s=input().split()
  for b in range(d):
    if int(s[b]) in x:
      x.remove(int(s[b]))
print(len(x))

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

int main(){
    std::vector<int> x(5);
    std::cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
    for(int i = 0; i < 5; i++){
        if(x[i] == 0){
            std::cout << i + 1 << std::endl;
        }
    }
}

Measured memory_bytes: 3544
N, M = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(N)]

def f(x):
    if x == 1:
        return 1
    else:
        return -1

ans = 0
for i in range(1 << 3):
    B = []
    for x, y, z in A:
        B.append(f((i >> 2) & 1) * x + f((i >> 1) & 1) * y + f(i & 1) * z)
    B.sort(reverse = True)
    ans = max(ans, sum(B[:M]))
    
print(ans)

Measured memory_bytes: 3292
(n, m) = [int(x) for x in input().split(' ')]
a = []
b = []
for i in range(n):
  s = input().split(' ')
  a.append(int(s[0]))
  b.append(int(s[1]))
c = []
d = []
for j in range(m):
  s = input().split(' ')
  c.append(int(s[0]))
  d.append(int(s[1]))

for i in range(n):
  mindis = 10 ** 9
  res = 0
  for j in range(m):
    dist = abs(a[i] - c[j]) + abs(b[i] - d[j])
    if dist < mindis:
      mindis = dist
      res = j + 1
  print(res)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=21;
int n,k;
char s[(1<<N)+5];
vector<int> f[N][N];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<=n;i++){
		scanf("%s",s);
		for(int j=0;j<=i;j++) f[i][j].resize(1<<i);
		for(int j=0;j<(1<<i);j++) if(s[j]=='1') f[i][0][j]=1;
	}
	for(int i=n;i>=1;i--){
		for(int j=0;j<i;j++){
			for(int s=0;s<(1<<i);s++){
				if(!f[i][j][s]) continue;
				int a=s&((1<<j)-1),b=s>>j;
				f[j][j][a]+=f[i][j][s];
				if(b) {
					int t=__builtin_ctz(b);
					f[i-t][j+1][(b>>t<<j)|a]+=f[i][j][s];
				}
				if(b!=(1<<(i-j))-1) {
					int t=__builtin_ctz(~b);
					f[i-t][j+1][(b>>t<<j)|a]+=f[i][j][s];
				}
			}
		}
		for(int s=0;s<(1<<i);s++){
			if(f[i][i][s]>=k){
				for(int j=i-1;j>=0;j--)
					if((s>>j)&1) putchar('1');
					else putchar('0');
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 168532