akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=505;
int n,m;
char ch[N];
bool a[N][N],b[N][N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",ch+1);
		for(int j=1;j<=m;j++)
		if(ch[j]=='#')
		{
			a[i][j]=1;
			b[i][j]=1;
		}
	}
	for(int i=1;i<=n;i+=2)
	{
		for(int j=1;j<m;j++)
		a[i][j]=1;
	}
	for(int i=2;i<=n;i+=2)
	{
		for(int j=2;j<=m;j++)
		b[i][j]=1;
	}
	for(int i=1;i<=n;i++)
	{
		a[i][1]=1;
		b[i][m]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		if(a[i][j])
		printf("#");
		else
		printf(".");
		printf("\n");
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		if(b[i][j])
		printf("#");
		else
		printf(".");
		printf("\n");
	}
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll n; cin >> n;
    vl x(n),y(n);
    rep(i,n)cin>>x[i]>>y[i];
    ll res = n;
    rep(i,n){
        rep(j,n){
            if(i == j)continue;
            ll p = x[i] - x[j];
            ll q = y[i] - y[j];
            ll cnt = 0;
            rep(ii,n){
                rep(jj,n){
                    if(ii == jj)continue;
                    if(x[ii] - p == x[jj] && y[ii] - q == y[jj])cnt++;
                }
            }
            res = min(res,n-cnt);
        }
    }
    out(res);
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 2000001

int n=1;

void insert(int *,int);
int extractMax(int  *);
void heapIncreaseKey(int *,int,int);
void my_maxheapify(int *,int);
void my_maxbuild(int *);

int main(){
  int *a,in;
  char input[8];
  a=malloc(sizeof(int)*(N+1));
  while(1){
    scanf("%s",input);
    if(strcmp(input,"insert")==0){
      //INSERT
      scanf("%d",&in);
      insert(a,in);
    }
    if(strcmp(input,"extract")==0){
      //EXTRACT
      extractMax(a);
    }
    if(strcmp(input,"end")==0) break;
  }
  return 0;
}

void my_maxheapify(int *a,int i){
  int l,r,large;
  l=i*2;
  r=i*2+1;
  if(l<=n && a[l]>a[i]) large=l;
  else large=i;
  if(r<=n && a[r]>a[large]) large=r;
  if(large!=i){
    l=a[i];a[i]=a[large];a[large]=l;
    my_maxheapify(a,large);
  }
}

void my_maxbuild(int *a){
  int i;
  for(i=n/2; i>=1; i--){
    my_maxheapify(a,i);
  }
}

void insert(int *a,int k){
  n++;
  a[n]=-9999;
  heapIncreaseKey(a,n,k);
}

int extractMax(int *a){
  if(n<1) return -1;
  int max;
  max=a[1];
  a[1]=a[n];
  n--;
  my_maxheapify(a,1);
  printf("%d\n",max);
  return max;
}

void heapIncreaseKey(int *a,int i,int key){
  int t;
  if(key<a[i]) return;
  a[i]=key;
  while(i>1 && a[i/2]<a[i]){
    t=a[i/2];a[i/2]=a[i];a[i]=t;
    i=i/2;
  }
}



Measured memory_bytes: 5640
#include <stdio.h>
#include <stdbool.h>
#include <string.h>

bool wall[10000][10000][4];
char str[10001];

const int U = 0, R = 1, D = 2, L = 3;
char dirchar[] = "URDL";
int righthand(int x) {return (x+1)%4;}
int lefthand(int x) {return (x+3)%4;}
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

int main() {
  bool firsttime = true;
  int width, height=0;
  int dir = R, x = 0, y = 0, i;

  while (true) {
    scanf("%9999s\n", str);

    if (firsttime) {
      width = strlen(str)+1;
      firsttime = false;
    }

    for (i = 0; i<width; i++)
      wall[i][height][R] = wall[i+1][height][L] = (str[i] == '1');

    if (scanf("%10000s\n", str) == -1)
      break;

    for (i=0; i<width; i++)
      wall[i][height][D] = wall[i][height+1][U] = (str[i] == '1');

    height++;
  }

  firsttime = true;
  while (true) {
    int nextdir;

    if (!firsttime && x == 0 && y == 0)
      break;

    for (nextdir = lefthand(dir); !wall[x][y][nextdir]; nextdir = righthand(nextdir))
      ;

    putchar(dirchar[nextdir]);
    x += dx[nextdir];
    y += dy[nextdir];
    dir = nextdir;
    firsttime = false;
  }

  puts("");
  return 0;
}

Measured memory_bytes: 552
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	int n;
	cin >> n;
	vector<char>s(n);
	rep(i, n)cin >> s[i];
	set<char> m;
	rep(i, n) {
		m.insert(s[i]);
	}
	if (m.size() == 3)cout << "Three";
	else cout << "Four";

	return 0;
}





Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 305;
int n;
char c[maxn][maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%s", c[i]);
  }
  return true;
}

void solve() {
  int res = 0;
  for (int it = 0; it < n; it++) {
    bool ok = true;
    for (int i = 0; i < n && ok; i++) {
      for (int j = 0; j < n && ok; j++) {
        if (c[i][j] != c[j][i]) {
          ok = false;
        }
      }
    }
    if (ok) {
      res += n;
    }
    for (int i = 0; i < n; i++) {
      rotate(c[i], c[i] + 1, c[i] + n);
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, x;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            x = a * n;
            if (x > b)
                x = b;

            Console.WriteLine(x);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
from collections import defaultdict
N,M = map(int,input().split())
dic = defaultdict(list)
for i in range(M):
    p,s = input().split()
    dic[p].append(s)
nAC = 0
nWA = 0
for k in dic.keys():
    if 'AC' in dic[k]:
        for s in dic[k]:
            if s == 'AC':
                nAC += 1
                break
            nWA += 1
print(nAC,nWA)

Measured memory_bytes: 31884
object Main {
  import scala.io.StdIn._
  def main(args: Array[String]): Unit = {
    val Array(s,t) = readLine().split(" ")
    val Array(a,b) = readLine().split(" ").map(_.toInt)
    readLine match {
      case x if x == s => println(s"${a - 1} ${b}")
      case x => println(s"${a} ${b-1}")
    }
  }
}

Measured memory_bytes: 25532
"""
カウンターの回り方はパターンが多すぎるので、考えない方がよい。
考え方１：
残っている寿司のうち、そこにたどり着くまでのエネルギー <= そこにたどり着くまでに摂取できる寿司のカロリー
となるような寿司があるかどうか。


考え方２：
二分探索。
X以上カロリーを得できるか、という二分探索。

考え方３：
動き方のパターンは4つある。
時計回りに動いて、どこかのタイミングで退店
半時計周りに動いて、どこかのタイミングで退店
時計回りに動いた後、反時計回りに動いて退店
反時計回りに動いた後、時計回りに動いて退店
それぞれのパターンで動く場合の最大価値を求める。
これで行こう
"""

N,C = map(int,input().split())
#sushi[i] => スタート地点から時計回りに動いたときにi番目にある寿司の情報
#sushiR[i] => スタート地点から反時計回りに動いたときにi番目にある寿司の情報
sushi = []
sushiR = []
for _ in range(N):
    x,v = map(int,input().split())
    sushi.append([x,v])
    sushiR.append([C-x,v])
sushiR = sushiR[::-1]

ans = 0
"""
まずは時計回りに動いてどこかのタイミングで退店する場合を考える。
これは、時計回りに寿司を見て行って、各寿司にたどり着いた時の、摂取カロリーの累積和と消費カロリーを求めればよい。
"""

cal = 0
for x,v in sushi:
    cal += v
    ans = max(ans,cal-x)

"""
次に反時計回りに動いてどこかのタイミングで退店する場合を考える。
"""
cal = 0
for x,v in sushiR:
    cal += v
    ans = max(ans,cal-x)


"""
時計回りに動いた後、反時計回りに動いて退店する場合を考える。
これは、時計回りでどこまで動くか（つまりどこで折り返すか）で場合わけし、
各地点で折り返す場合に、反時計回りでどこまで行くのがベストなのかをaccumSushiRをつかって判断する
"""
from heapq import heappop,heappush
sushiRQue = []
cal = 0
for i in range(N):
    x,v = sushiR[i]
    cal += v
    heappush(sushiRQue,(-(cal-x),i))

cal = 0
for i in range(N-1):
    x,v = sushi[i]
    cal += v
    while sushiRQue[0][1]+i >= N-1:
        heappop(sushiRQue)
    ans = max(ans,cal-x*2+(-sushiRQue[0][0]))

"""
時計回りに動いた後、反時計回りに動いて退店する場合を考える。
これは、時計回りでどこまで動くか（つまりどこで折り返すか）で場合わけし、
各地点で折り返す場合に、反時計回りでどこまで行くのがベストなのかをaccumSushiRをつかって判断する
"""
sushiQue = []
cal = 0
for i in range(N):
    x,v = sushi[i]
    cal += v
    heappush(sushiQue,(-(cal-x),i))

cal = 0
for i in range(N-1):
    x,v = sushiR[i]
    cal += v
    while sushiQue[0][1]+i >= N-1:
        heappop(sushiQue)
    ans = max(ans,cal-x*2+(-sushiQue[0][0]))

print(ans)

Measured memory_bytes: 115820
N = int(input())						# 5
a = list( map(int, input().split()) )


from collections import defaultdict
d = defaultdict(int)


for i in a:
	d[i] += 1

#print(d)

ans = 0
for i in d.keys():
	x = d[i]
#	print(i, x)
	if x == i: continue
	if x < i: ans += x
	if x > i: ans += (x - i)

#print(d)
print(ans)

Measured memory_bytes: 18168
#include <iostream>

int main() {
    long long int money;
    scanf("%lld",&money);
    long long int happy1000;
    long long int happy5;
    happy1000 = money /500 ;
    happy5 = (money % 500) / 5;

    printf("%lld",happy1000*1000+happy5*5);

}

int A(){
    char Word[256];
    scanf("%s",&Word);
    if(Word[2]==Word[3] && Word[4] == Word[5]){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
 
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    
    //cin >> tc;
    while (tc--)
    {
        int x;
        cin >> x;
        int f = 0;
        vector<int> v;
        int a, b;
        for (int i = 0; i <= 1000;i++){
            int k = pow(i, 5);
            for (int j = 0; j <= 1000;j++){
                int l = pow(j, 5);
                if(x==k+l){
                    a = i;
                    b = -j;
                }
                if(x==(k-l)){
                    a = i;
                    b =  j;
                }
                if(x==(l-k)){
                    a = i;
                    b = j;
                }
            }
        }
        cout << a << " " << b << endl;
    }

    return 0;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define N 2000001
#define MAX 10000
using namespace std;
int n=0;
vector<int> A(N,0),B(N,0),C(N,0);

void CountingSort(){
	//for(int i=0;i<MAX;i++) C.at(i) = 0;
	
	/* C[i] に i の出現数を記録する */
	//for(int j=1;j<=n;j++) C.at(A.at(j))++;
	
	/* C[i] に i 以下の数の出現数を記録する*/
	for(int i=1;i<MAX;i++) C.at(i) += C.at(i-1);
	
	for(int j=1;j<=n;j++){
		/*(int j=n;j>0;j--)*/
		B.at(C.at(A.at(j))) = A.at(j);
		C.at(A.at(j))--;
	}
	for(int i=1;i<=n;i++){
		if(i == n) cout << B.at(i) << endl;
		else cout << B.at(i) << " ";
	}
}

int main(){
	cin >> n;
	for(int i=0;i<MAX;i++) C.at(i) = 0;
	for(int i=0;i<n;i++){
		cin >> A.at(i+1);
		/* C[i] に i の出現数を記録する */
		C.at(A.at(i+1))++;
	}
	CountingSort();
}


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

int main(){
    int N;
    cin >> N;
    double sum = 0;
    for(int i=0; i<N; i++){
        double a;
        cin >> a;
        sum += 1/a;
    }
    cout << fixed << setprecision(10) << (1/sum) << endl;
    return 0;
}


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

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

  int n,h;
  cin >> n >> h;

  int ma = 0;
  vector<int> B;
  rep(i, n) {
    int a,b; cin >> a >> b;
    ma = max(ma, a);
    if(b > ma) {
      B.push_back(b);
    }
  }

  int ans = 0;
  sort(B.begin(), B.end(), greater<int>());
  rep(i, B.size()) {
    if(B[i] > ma) {
      ans++;
      h -= B[i];
      if(h <= 0) break;
    }
  }
  if(h > 0) {
    ans += ceil((double)h / (double)ma);
  }

  cout << ans << endl;
}


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

int H, N;
ll A[10100];
ll B[10100];
ll memo[10100];

ll rec(int h) {
    if (memo[h]!=-1) return memo[h];
    
    ll res = INF;
    
    for (int i=0; i<N; i++) {
        if (h-A[i]<=0) res = min(res, B[i]);
        else res = min(res, rec(h-A[i])+B[i]);
    }
    
    return memo[h] = res;
}

int main() {
    cin >> H >> N;
    for (int i=0; i<N; i++) cin >> A[i] >> B[i];
    for (int i=0; i<=H; i++) memo[i] = -1;
    
    cout << rec(H) << endl;
}

Measured memory_bytes: 768
#include<stdio.h>

int main(){
	int data_num;
	int X, Y, W, H;
	int x, y, cat_num, cat_campus;
	int i,j;

	scanf("%d",&data_num);

	for(i=0; i<data_num; i++){

		scanf("%d %d %d %d", &X, &Y, &W, &H);
		scanf("%d",&cat_num);

		cat_campus=0;
		for(j=0; j<cat_num; j++){
			scanf("%d %d", &x, &y);
			if(X <= x && x <= W+X && Y <= y && y <= H+Y)
				cat_campus++;
		}
		printf("%d\n",cat_campus);
	}
	return 0;

}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
 
int main()
{
	char a[4];
	cin >> a;
	for (int i = 0; i < 3; i++)
	{
		switch (a[i])
		{
		case '1':a[i] = '9';
			break;
		case '9':a[i] = '1';
			break;
		default:a[i]=a[i];
            break;
		}
	}
	cout << a;
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
def sub(x,y):
    xx = 0
    yy = 0
    for tx,ty in xy:
        if x*tx+y*ty>0:
            xx += tx
            yy += ty
    return (xx*xx+yy*yy)**0.5
ans = -1
for i,(x,y) in enumerate(xy):
    for x2,y2 in xy:
        ans = max(ans, sub((x+x2)/2,(y+y2)/2))
print(ans)

Measured memory_bytes: 74420
import java.util.*;

class Main {
	Scanner sc;
	
	private void calc() {
		sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) A[i] = sc.nextInt();
		
		int i = 1;
		for (int j = 0; j < N; j++) {
			if (A[j] == i) i++;
		}
		if (i == 1) System.out.println(-1);
		else System.out.println(N-i+1);
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 87484
#include <stdio.h>
#define Not_Found 0
#define Found 1
#define MAX 10000
#define max 500

int n;

int LinerSearch(int *,int);

int main(){

	int S[MAX],T[max],q,count,i;

	scanf("%d",&n);
	for( i = 0; i < n; i++) scanf("%d",&S[i]);
	scanf("%d",&q);
	for( i = 0; i < q; i++){
		scanf("%d",&T[i]);
		if(LinerSearch(S,T[i]) == Found) count++;
	}

	printf("%d\n",count);

	return 0;

}


int LinerSearch(int *A,int key){

	int i = 0;

	/*A[n] = &key;

	while(A[i] != key){
		i++;
		if(i == n) return Not_Found;
	}
	return Found;*/

	for( i = 0; i < n; i++){
		 if(A[i] == key) return Found; 
	}
	return Not_Found;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x;
	cin >> x;
    string ans;
    if(x<1200)ans="ABC";
    else if(x<2800)ans="ARC";
    else ans = "AGC";
      cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC132
{
	class Program
	{
		static void Main(string[] args)
		{
			char[] charArray = Console.ReadLine().ToCharArray();
			Dictionary<char, int> keyValuePairs = new Dictionary<char, int>();
			for(int i = 0; i < 4; i++)
			{
				if (keyValuePairs.ContainsKey(charArray[i]))
				{
					keyValuePairs[charArray[i]]++;
				}
				else
				{
					keyValuePairs.Add(charArray[i], 1);
				}
			}

			if (keyValuePairs.Count == 2 && keyValuePairs.ContainsValue(2))
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}


Measured memory_bytes: 13268
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, x ] <- readInts
	as <- sort <$> readInts
	print $ solve x as

solve 0 [] = 0
solve _ [] = -1
solve x (a:as)
	| a <= x = 1 + solve ( x - a ) as
	| otherwise = 0

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;

    vector<int> d(n);
    rep(i, n) {
        cin >> d[i];
    }

    if(24 <= n) {
        cout << 0 << endl;
        return 0;
    }

    if(n == 23) {

        sort(d.begin(), d.end());

        for(int i = 0; i <= 20; i += 2) {
            int k = i/2 + 1;
            if(d[i] != k || d[i+1] != k) {
                cout << 0 << endl;
                return 0;
            }
        }

        if(d[22] != 12) {
            cout << 0 << endl;
            return 0;
        }

        cout << 1 << endl;
        return 0;
    }

    int ans = 0;
    for(int b = 0; b < (1<<n); b++) {

        vector<int> t(n+1);
        rep(i, n) {
            if(b & 1<<i) {
                t[i] = 24-d[i];
            }
            else {
                t[i] = d[i];
            }
        }

        int u = 30;
        rep(i, n) {
            for(int j = i+1; j <= n; j++) {
                int x = abs(t[i] - t[j]);
                int y = min(x, 24-x);
                u = min(u, y);
            }
        }

        ans = max(ans, u);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		
		// 計算
		int result = 0;
		int[] list = new int[101];
		for(int i = 1; i <= N; i++){
		    int n = i;
    		for(int m = 2; m <= sqrt(n); m++){
    		    if(n == 1) break;
    		    if(n%m == 0){
    		        while(n%m == 0){
    		            n = n/m;
    		            list[m]++;
    		        }
    		    }
    		}
    		if(n != 1) list[n]++;		    
		}
		int[] cnt = new int[5];
		for(int i : list){
		    if(i >= 74){
		        cnt[4]++;
		    }else if(i >= 24){
		        cnt[3]++;
		    }else if(i >= 14){
		        cnt[2]++;
		    }else if(i >= 4){
		        cnt[1]++;
		    }else if(i >= 2){
		        cnt[0]++;
		    }
		}
		//System.out.println(Arrays.toString(list));
		//System.out.println(Arrays.toString(cnt));
		result += cnt[4];
		//System.out.println(result);
		result += cnt[1]*(cnt[2]+cnt[3]+cnt[4]) + (cnt[2]+cnt[3]+cnt[4])*(cnt[2]+cnt[3]+cnt[4]-1);
		//System.out.println(result);
		result += (cnt[0]+cnt[1]+cnt[2])*(cnt[3]+cnt[4]) + (cnt[3]+cnt[4])*(cnt[3]+cnt[4]-1);
		//System.out.println(result);
		result += (int)(cnt[0]*combination(cnt[1]+cnt[2]+cnt[3]+cnt[4], 2) + (cnt[1]+cnt[2]+cnt[3]+cnt[4])*combination(cnt[1]+cnt[2]+cnt[3]+cnt[4]-1, 2));

		// 出力
		System.out.println(result);
	}
	
	public static long fact(long n) {
	    if(n == 0) return 1;
	    return n * fact(n - 1);
	}
	
	public static long combination(long n, long k) {
	    if(n < k) return 0;
	    return fact(n)/(fact(k)*fact(n - k));
	}
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n,h;
  cin >> n >> h;
  vector<ll> swing_s(n),throw_s(n);
  rep(i,n){
    cin >> swing_s[i] >> throw_s[i];
  }
  ll ans=0;
  sort(all(swing_s));
  sort(all(throw_s));
  reverse(all(throw_s));
  reverse(all(swing_s));

  rep(i,n){
    if(throw_s[i]>=swing_s[0]){
      h-=throw_s[i];
      ans++;
    }
    if(h<=0) break;
  }

  if(h>0) ans+=(h+swing_s[0]-1)/swing_s[0];
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1792
matrixA = []
matrixB = []
resultC = []
n, m = map(int, input().split())
for i in range (n):
    matrixA.append(list(map(int, input().split())))
for i in range (m):
    matrixB.append(int(input()))
for i in range (n):
    num = 0
    for j in range (m):
        num += matrixA[i][j]*matrixB[j]
    resultC.append(num)
for i in range (n):
    print(resultC[i])



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

int N;

int main() {
    scanf("%d", &N);

    int ans = 0;
    for(int i = 0; i < N; i++) {
        int t; scanf("%d", &t);
        ans |= (t & 1);
    }
    if(ans) printf("first");
    else printf("second");
}


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

int main(){
    int n;
    cin >> n;

    // n要素の整数の配列a
    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }

    // aは全て正の整数なので、求めたい値は(aの最大値 - aの最小値)
    // aを昇順(小さい順)に並び替えておけば、(最後の要素 - 最初の要素)
    sort(a.begin(), a.end());

    cout << a[n - 1] - a[0] << endl;

    return 0;
}

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

#define lp( i, L, U ) for(int i=(int)L ; i<=(int)U ; i++ )
#define rlp( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define SQR(x) ((x)*(x))
#define nl "\n"
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define Max3(a,b,c)           max(a,max(b,c))
#define Min3(a,b,c)           min(a,min(b,c))
#define pb push_back
#define mkp make_pair

#define INF INT_MAX


#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<vector<int> > vvc;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<string, string> mss;
typedef map<string, char> msc;

int gcd(int a, int b)
{
    return b==0?a:gcd(b, a%b);
}
int main()
{
    int k; cin >> k;
    ll ans = 0;
    for(int i=1; i<=k; ++i) {
        for(int j=1; j<=k; ++j) {
            for(int g=1; g<=k; ++g) ans += gcd(i, gcd(j, g));
        }
    }
    cout << ans << nl;
    return 0;
}





Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const double PI = 3.14159265358979323846;


int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int k, p;
        cin >> k >> p;
        {
            int temp = k % p;
            cout << ((temp == 0) ? p : temp) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  map <ll, ll> score;
  rep(i, n) {
    ll tmp = i+1;
    ll j = 2;
    while (tmp != 1) {
      if (tmp%j == 0) {
        if (score.count(j)) {
          score.at(j)++;
        } else {
          score[j] = 1;
        }
        tmp /= j;
      } else {
        j++;
      }
    }
  }
  ll res = 1;
  for (auto p : score) {
    res *= p.second+1;
    res %= mod;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9

#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)

int main(){
  while(1){
    int r0,w0,c,r;
    cin>>r0>>w0>>c>>r;
    if(r0==0) break;
    int R,W;
    if(w0*c <=r0) cout<<0<<endl;
    else{
      int ans=0;
      while(w0*c > r0){
	ans++;
	r0+=r;
      }
      cout<<ans<<endl;
    }
  }
    return 0;
}



Measured memory_bytes: 3080
S = list([i for i in input().split()][0])
Q = [int(i) for i in input().split()][0]

r = 0
firstS = []
lastS = []
for q in range(Q):
  row = input().split()
  if len(row) == 1:
    r = (r+1) % 2
  else:
    f = int(row[1])
    c = row[2]
    if r == 0:
      if f == 1:
        firstS.append(c)
      else:
        lastS.append(c)
    else:
      if f == 2:
        firstS.append(c)
      else:
        lastS.append(c)
        
if r % 2 == 0:
  S = firstS[::-1] + S + lastS
else:
  S = lastS[::-1] + S[::-1] + firstS 
print("".join(S))
  
      
    



Measured memory_bytes: 9988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    map<int,int>mp;
    int over=0;
    rep(i,n){
        int tmp;cin>>tmp;if(tmp>=3200){over++;continue;}
        else{mp[tmp/400]++;}
    }
    int ans1 = mp.size()==0?1:mp.size();
    int ans2 = mp.size()+over;
    cosp(ans1);co(ans2);
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  double n;
  cin >> n;
  cout << 2*n*3.141592 << endl;
  return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(void){
    int n,a,b;
    cin >> n >> a >> b;
    string ans;
    if((b-a)%2==0){
        ans ="Alice";
    }else{
        ans="Borys";
    }
    cout << ans << endl;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll range = 26;
    ll num = 1;
    while (N>0){
        if (N <= range) break;
        N -= range;
        range*=26;
        num++;
    }
    string ans;
    N--;
    for (int i=0;i<num;i++){
        ans = (char)(N%26 + 'a') + ans;
        N/=26;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 998244353;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

//n -> big, a -> small
mint choose(int n,int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    int max_depth = 0;
    map<int,int> mii;
    rep(i,n){
        int d;
        cin >> d;
        mii[d]++;
        max_depth = max(max_depth, d);
        if(i == 0 && d !=0){
            cout << 0 << endl;
            return 0;
        }
    }
    if(max_depth >= n){
        cout << 0 << endl;
        return 0;
    }
    if(mii[0] > 1){
        cout << 0 << endl;
        return 0;
    }
    rep(i,max_depth+1){
        if(mii[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    mint ans = 1;
    rep(i,max_depth) ans *= mint(mii[i]).pow(mii[i+1]);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 8340
//Twitter@KonoLv1 2020年春からエンジニア見習いデビュー！
 
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
 
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z; 
    int count1,count2,count;   //  カウント用に使用
    int flg,mode;
    i = j = x = y = z = count1 = count2 = count = flg = mode = 0;
    int n;
    double dx,dy;
    int box[1024] = {};
    int box2[1024] = {};
    char s[200001] = {};        //  文字列
    char s2[200001] = {};        //  文字列
    char s3[200001] = {};        //  文字列
 
    //  入力処理
    

    scanf("%d",&n); // 整数
    scanf("%s",s); // 文字列
    // scanf("%lf",dx); // 小数
    
    /*
    for (i = 0; i < n; i++){
        scanf("%d"  
    }
    */
    //  計算処理

    if (n % 2 == 0){
        for(j = 0; j < n / 2; j++){
            s2[j] = s[j];
            s3[j] = s[j + (n / 2)];
        }
        if(strcmp(s2,s3)==0){
            printf("Yes");
        }else{
            printf("No");
        }
    }else{
        printf("No");
    }
    


 
    //  出力処理

}



    /* 資材置き場 */
    /*
    「dx」に入っているDouble型の数値の下1桁（それ以下四捨五入）表示
     printf("%.1f",dx);
    
    
    文字列[s]に入っている文字に「a」が含まれる場合、全て「b」に変更する
    while(1){
        if (s[i] == '\0'){
            break;
        }
        
        if (s[i] == 'a'){
            s[i] = 'b';
        }
        i++;
    }
    
    
    */



Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int fpow(int x,int y,int mod)
{
	if(y==0)
		return 1;
	int ret=fpow(x,y>>1,mod);
	ret=(long long)ret*ret%mod;
	if(y&1)
		ret=(long long)ret*x%mod;
	return ret;
}
int s[3030][3030];
int c[3030][3030];
int cnt[3030];
int main()
{
	int n,m,h,hh;
	scanf("%d%d",&n,&m);
	s[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		s[i][0]=1;
		for(int j=1;j<=i;j++)
			s[i][j]=((long long)s[i-1][j]*(j+1)+s[i-1][j-1])%m;
	}
	memset(c,0,sizeof(c));
	c[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%m;
	}
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<=n;i++)
	{
		h=fpow(2,n-i,m);
		hh=1;
		for(int j=0;j<=i;j++)
		{
			cnt[i]=((long long)s[i][j]*hh+cnt[i])%m;
			hh=(long long)hh*h%m;
		}
	}
	for(int i=0;i<=n;i++)
		cnt[i]=(long long)cnt[i]*fpow(2,fpow(2,n-i,m-1),m)%m*c[n][i]%m;
	for(int i=n;i>=0;i--)
		for(int j=i+1;j<=n;j++)
			cnt[i]=(m-(long long)cnt[j]*c[j][i]%m+cnt[i])%m;
	printf("%d",cnt[0]);
	return 0;
}

Measured memory_bytes: 72064
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const int N = 4001;

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

  vector<ll> ps(N);
  rep(i, N){
    ps[i] = (ll)i*i*i*i*i;
  }

  int a, b;
  rep(i, N){
    for(int j=i+1;j<N;j++){
      if (ps[j] - ps[i] == x){
        a = j; b = i;
        break;
      }
      if (ps[j] + ps[i] == x){
        a = j; b = -i;
        break;
      }
    }
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int ans=0,n;
	cin>>n;
	string s;
	cin>>s;
	for (int i=1;i<n;i++)
	{
		int cnt=0;
		for (char c='a';c<='z';c++)
		{
			bool left=false,right=false;
			for (int j=0;j<i;j++)
			{
				if (s[j]==c)  left=true;
			}
			for (int j=i;j<n;j++)
			{
				if (s[j]==c)  right=true;
			}
			if (left&&right)  cnt++;
		}
		if (cnt>ans)  ans=cnt;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> a(9);
    for(int i = 0; i < 9; i++)
    {
        cin >> a[i];
    }
    int a1 = 0;
    int b1 = a[0] - a1;
    int b2 = a[1] - a1;
    int b3 = a[2] - a1;
    int a2 = a[3] - b1;
    int a3 = a[6] - b1;

    if(a[4] != a2 + b2) 
    {
      cout << "No" << endl;
      return 0;
    }
    if(a[5] != a2 + b3) 
    {
      cout << "No" << endl;
      return 0;
    }
    if(a[7] != a3 + b2) 
    {
      cout << "No" << endl;
      return 0;
    }
    if(a[8] != a3 + b3) 
    {
      cout << "No" << endl;
      return 0;
    }

    cout << "Yes" << endl;
}


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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 2e5 + 5;
vector<set<ll>> adj(N);
int vis[N];
ll n , m, f, d, cnt;
void dfs(ll node){
    vis[node] = 1;
    cnt++;
    for(auto v : adj[node]){
        if(!vis[v]){
            dfs(v);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>m;
    for(int i = 0; i < m; i++){
        ll u , v;
        cin>>u>>v;
        adj[u].insert(v);
        adj[v].insert(u);
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(!vis[i]){
            dfs(i);
            ans = max(ans , cnt);
            cnt = 0;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 38260
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


int main(){
    ll x,y,z,t,K; cin >> x >> y >> z >> K;
    ll k=0;
    vl v[3];
    rep(i,x){
        cin >> t; v[0].push_back(t);
    }
    rep(i,y){
        cin >> t; v[1].push_back(t);
    }
    rep(i,z){
        cin >> t; v[2].push_back(t);
    }
    
    priority_queue<pair<ll, vl>> pq;
    rep(i,3) sort(v[i].rbegin(), v[i].rend());
    vl ans(K,0);
    vl index(3);
    pq.push(make_pair(v[0][0] + v[1][0] + v[2][0], vl({0,0,0})));
    set<vl> s;
    while(k < K){
        auto tmp = pq.top(); pq.pop();
        ans[k] = tmp.first;
        rep(i,3){
            index = tmp.second;
            if(index[i] + 1 < v[i].size()){
                index[i]++;
                if(s.find(index) == s.end()){
                    pq.push(make_pair(v[0][index[0]] + v[1][index[1]] + v[2][index[2]], index));
                    s.insert(index);
                }
            }
        }
        k++;
    }
    rep(k,K){
        cout << ans[k] << endl;
    }
}


Measured memory_bytes: 1280
#include<iostream>

using namespace std;

int main(){

  int n;

  cin >> n;

  for(int i=1 ;;i++){
    int co = 0;

    for(int j=1;j<=i;j++){
      if(i%j==0){co++;}
    }
    if(co==n){
      cout << i << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 1160
while True:
	n = input()
	if n == 0: break
	accounts = [set(map(int, raw_input().split()[1:])) for i in xrange(n)]
	leaks = set(map(int, raw_input().split()[1:]))
	suspect = []
	for i, ac in enumerate(accounts):
		diff = leaks.difference(ac)
		if not diff:
			suspect += [i + 1]
	if len(suspect) == 1:
		print suspect[0]
	else:
		print -1

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

int main(){
  int i,j;
  double n500,n1000;
  while(cin >> n500 >> n1000){
    if(n500 < 35.50 && n1000 < 60*1+11.0) cout << "AAA" << endl;
    else if(n500 < 37.50 && n1000 < 60*1+17.0) cout << "AA" << endl;
    else if(n500 < 40.0 && n1000 < 60*1+23.0) cout << "A" << endl;
    else if(n500 < 43.0 && n1000 < 60*1+29.0) cout << "B" << endl;
    else if(n500 < 50.0 && n1000 < 60*1+45.0) cout << "C" << endl;
    else if(n500 < 55.0 && n1000 < 60*1+56.0) cout << "D" << endl;
    else if(n500 < 70.0 && n1000 < 60*2+28.0) cout << "E" << endl;
    else  cout << "NA" << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define line pair<long long,long long>

int n;
long long C, h[200007];
long long dp[200007];
const long long inf = 1e18;

class ConvexHullTrick{
public:
	deque <line> cur;
	bool bad(line a,line b,line c){
		return ((a.se-b.se)*(c.fi-a.fi)>(b.fi-a.fi)*(a.se-c.se));
	}
	void add(long long A,long long B){
		line p=mp(A,B);
		while((int)cur.size()>=2 && bad(cur[(int)cur.size()-2],cur[(int)cur.size()-1],p)){
			cur.pop_back();
		}
		cur.push_back(p);
	}
	long long query(long long x){
		if(cur.empty()) return inf;
		while((int)cur.size()>=2 && cur[0].fi*x+cur[0].se > cur[1].fi*x+cur[1].se) cur.pop_front();
		return cur[0].fi*x+cur[0].se;
	}
} slope;

int main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> C;
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	dp[1] = 0;
	slope.add(-2LL * h[1], dp[1] + C + h[1] * h[1]);
	for(int i = 2; i <= n; i++){
		dp[i] = slope.query(h[i]) + h[i] * h[i];
		slope.add(-2LL * h[i], dp[i] + C + h[i] * h[i]);
	}
	cout << dp[n];
}


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

int main(){
    int n, k; cin >> n >> k;
    bool have[n];
    rep(i, n) have[i] = false;
    rep(i, k){
        int d; cin >> d;
        rep(j, d){
            int a; cin >> a;
            have[--a] = true;
        }
    }

    int ans = 0;
    rep(i, n) if(!have[i]) ans++;
    cout << ans << endl;


    return 0;
}

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define INF INT_MAX
#define NINF INT_MIN
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}
#define int ll

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "\n";
    err(++it, args...);
}

const int MAX_N = 3000+100, DIM = 2;;

int dp[MAX_N][MAX_N][DIM], a[MAX_N];
int n;

int32_t main() {

	cin >> n;

	tik(i,1,n+1)
		cin >> a[i];

	tik(i,1,n+1) {
		dp[i][i][0] = a[i];
		dp[i][i][1] = 0; 
	}

	tok(i,n,1) {
		tik(j,i+1,n+1) {
			if(a[i] + dp[i+1][j][1] > a[j] + dp[i][j-1][1]) {
				dp[i][j][0] = a[i] + dp[i+1][j][1];
				dp[i][j][1] = dp[i+1][j][0];
			}
			else {
				dp[i][j][0] = dp[i][j-1][1] + a[j];
				dp[i][j][1] = dp[i][j-	1][0];
			}
		}
	}

	cout << dp[1][n][0] - dp[1][n][1];
}

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

int N, K;
vector<int> D;
vector<int> LsumD;
vector<int> RsumD;
vector<int> mLsumD;
vector<int> mRsumD;

int AtCoder(int a, int b) {
  int ans = LsumD[a] + RsumD[b];
  int n = K - a - b;
  vector<int> vec;
  for (int i = 0; i < N; i++)
  {
    if (a <= i and i < N - b) continue;
    if (D[i] < 0) vec.push_back(D[i]);
  }
  sort(vec.begin(), vec.end());

  for (int i = 0; i < n and i < vec.size(); i++)
  {
    ans -= vec[i];
  }
  return ans;
}

int main() {
  cin >> N >> K;

  int sum = 0;
  LsumD.push_back(sum);
  for (int i = 0; i < N; i++) {
    int tmp; cin >> tmp;
    D.push_back(tmp);
    sum += tmp;
    LsumD.push_back(sum);
  }

  sum = 0;
  RsumD.push_back(sum);
  for (int i = N - 1; i >= 0; i--)
  {
    sum += D[i];
    RsumD.push_back(sum);
  }

  int ans = 0;
  for (int i = 0; i <= K; i++)
  {
    for (int j = 0; j <= K; j++)
    {
      if (i + j > K or i + j > N) break;
      ans = max(ans, AtCoder(i, j));
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	llint n,T,i,j;
	cin>>n>>T;T++;
	vector<tuple<double,llint,llint>> mise;//A>0
	vector<llint>bbb;//A==0;
	llint dp[40]={};
	for(i=0;i<n;i++){
		llint a,b;cin>>a>>b;b++;
		if(a==0){bbb.pub(b);}
		else{mise.pub(mt(1.0*b/a,a,b));}
	}
	SO(mise);
	dp[0]=1;
	for(j=1;j<40;j++){dp[j]=inf;}
	
	for(i=0;i<mise.size();i++){
		double poiu;llint a,b;tie(poiu,a,b)=mise[i];
		for(j=38;j>=0;j--){chmin(dp[j+1],dp[j]*(a+1)+b);}
	}
	bbb.pub(0);
	SO(bbb);
	for(i=0;i+1<bbb.size();i++){bbb[i+1]+=bbb[i];}
	int ans=0;
	for(j=0;j<=38;j++){
		if(dp[j]>T){continue;}
		chmax(ans,j+UBI(bbb,T-dp[j])-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8560