akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ESequenceDecomposing solver = new ESequenceDecomposing();
        solver.solve(1, in, out);
        out.close();
    }

    static class ESequenceDecomposing {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int col = 0;
            // 塗れる大きさのうち最も大きいものを使う、存在しないのであれば新しい色を使えばよい。
            // 塗れるうち最も大きいものを探すには二分探索をすればいいことがわかる。
            // TreeMap.lowerKeyがいい感じであるのでこれを利用してみる。
            // 重複不可能なので死
            TreeMap<Integer, Integer> tm = new TreeMap<>();
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                if (tm.lowerKey(a) == null) {
                    // 新しい色を使わざるを得ない
                    col++;
                } else {
                    int lk = tm.lowerKey(a);
                    tm.merge(lk, -1, Integer::sum);
                    if (tm.get(lk) == 0) {
                        tm.remove(lk);
                    }
                }
                tm.merge(a, 1, Integer::sum);
                // out.println(tm.toString());
            }
            out.println(col);
        }

    }
}



Measured memory_bytes: 66732
#71
s = list(set(input()))
s.sort()
x = list("abcdefghijklmnopqrstuvwxyz")
for i in range(min(len(s),len(x))):
    if s[i] !=x[i]:
        print(x[i])
        break
    if i==25:
        print("None")
        break
    if i+1 == min(len(s),len(x)):
        print(x[i+1])
        break

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;

int main() {
  ll n, d;
  cin >> n >> d;
  ll ans = 0;
  REP(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n;
lli a[maxN];

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    set<lli> all;
    for (int i = 0; i < n; i ++)
    {
      scanf("%lld", &a[i]);
      all.insert(a[i]);
    }

    printf("%s\n", all.size() == n ? "YES" : "NO");
  }
  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(0,min(b,d)-max(a,c))<<'\n';
}




Measured memory_bytes: 3600
from itertools import combinations_with_replacement
N = int(input())
box = []
for i in range(1, 101):
    box.append(i)

temp = []

for cr in combinations_with_replacement(box, 3):
    st = set()
    x, y, z = cr
    st.add(x)
    st.add(y)
    st.add(z)
    if len(st) == 2:
        temp.append([x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x, 3])
    elif len(st) == 3:
        temp.append([x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x, 6])
    else:
        temp.append([x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x, 1])
temp = sorted(temp, reverse=True)

for i in range(1, N+1):
    ans = 0
    while temp[-1][0] == i:
        ans += temp[-1][1]
        temp.pop()
    print(ans)

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

using namespace std;

int main (void)
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, l;
  cin >> n >> l;
  vector<string> vs;
  vs.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> vs[i];
  }
  sort(begin(vs), end(vs));
  for (int i = 0; i < n; i++) {
    cout << vs[i];
  }    
  return 0;
}
// created: 20.07.2020 16:50:01 IST 



Measured memory_bytes: 3668
n = int(input())
shop_list = []
for i in range(n):
    temp_list = list(input().split())
    temp_list[1] = int(temp_list[1])
    temp_list.append(i+1)
    shop_list.append(temp_list)

shop_list_sorted = sorted(shop_list,key=lambda x:(x[0],-x[1]))
for k in range(n):
    print(shop_list_sorted[k][2])

Measured memory_bytes: 9132
from collections import defaultdict


class UnionFindTree:
    def __init__(self):
        self.p = {}
        self.rank = {}

    def make(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def find(self, x):
        if x in self.p:
            if self.p[x] != x:
                # 経路圧縮
                self.p[x] = self.find(self.p[x])
            return self.p[x]
        return None

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        return self._unite(self.find(x), self.find(y))

    def _unite(self, x, y):
        if self.rank[x] < self.rank[y]:
            self.p[x] = y
            return y
        else:
            self.p[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            return x


utf = UnionFindTree()

N, M = map(int, input().split())
for n in range(N):
    utf.make(n + 1)

for m in range(M):
    x, y, z = map(int, input().split())
    utf.unite(x, y)

h = defaultdict(int)
for n in range(N):
    x = utf.find(n + 1)
    h[x] += 1

ans = 0
rest = N
for k, v in h.items():
    ans += 1
    rest -= v
print(ans + rest)


Measured memory_bytes: 31112
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
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; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n,m;
  cin>>n>>m;
  int l,r;
  cin>>l>>r;
  for(int i=1;i<m;i++){
    int a,b;
    cin>>a>>b;
    l=max(l,a);
    r=min(r,b);
  }
  int count=0;
  for(int i=1;i<=n;i++){
    if(l<=i&&i<=r) count++;
  }
  cout<<count;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
 
int main()
{
  long long a;
  float b;
  cin>>a;
  cin>>b;
  b=b*100;
  long long c=(long long)round(b);
  long long r=a*c;
  r=r/100;
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 3732
#include<iostream>
using namespace std;
class Cube {
public:
	int f[6];
	Cube(){}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
	void move(char ch) {
		if (ch == 'E')for (int i = 0; i < 3; i++)roll_y();
		if (ch == 'W')roll_y();
		if (ch == 'N')roll_x();
		if (ch == 'S')for (int i = 0; i < 3; i++)roll_x();
	}	
};
int main() {
	Cube c;
	string com;
	for (int i = 0; i < 6; i++)cin >> c.f[i];
	cin >> com;
	for (int i = 0; i < com.size(); i++)c.move(com[i]);
	cout << c.f[0] << endl;
	return 0;
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
int a[300000];
ll former[100001], latter[100001];
//former[i]:0からN-1+i番目までで作られる数列で，上位N個の数の和
//latter[i]:3*N-1から2*N-i番目までで作られる数列で，下位N個の数の和

int main()
{
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i,0,3*N) cin >> a[i];
    //i番目で区切って得点を計算する．
    priority_queue<int, vector<int>, greater<int> > fq; //小さい順に取り出せるpriority_queue
    priority_queue<int> lq;
    REP(i,0,N){
        former[0] += a[i];
        latter[0] += a[3*N-1-i];  
        fq.push(a[i]);
        lq.push(a[3*N-1-i]);       
    }
    REP(i,1,N+1){
        fq.push(a[N-1+i]); lq.push(a[2*N-i]);
        int f_small, l_large;
        f_small = fq.top(); fq.pop();
        l_large = lq.top(); lq.pop();
        former[i] = former[i-1] - f_small + a[N-1+i];
        latter[i] = latter[i-1] - l_large + a[2*N-i];
    }
    ll ans = -1e14;
    REP(i,0,N+1){
        ll score = former[i]-latter[N-i];
        ans = max(ans, score);
    }
    /*
    REP(i,0,N+1){
        cout << former[i] << ' ';
    }
    cout << endl;
    REP(i,0,N+1){
        cout << latter[i] << ' ';
    }
    */
    cout << endl;
    CO(ans);
    return 0;
}

Measured memory_bytes: 3956
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
      	int[][] matrix = new int[3][3];
		int[][] count = new int[3][3];
      
      	for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
            	matrix[i][j] = in.nextInt();  
            }
        }      
        int num = in.nextInt();
      	for (int m = 0; m < num; m++) {
			int n = in.nextInt();
          	for (int i = 0; i < 3; i++) {
              for (int j = 0; j < 3; j++) {
                  if (matrix[i][j] == n) count[i][j]++;  
              }
        	}
        }
        
      	boolean exist = false;
      
      	if (count[0][0] == 1 && count[1][1] == 1 && count[2][2] == 1) 
			exist = true;
        if (count[0][2] == 1 && count[1][1] == 1 && count[2][0] == 1) 
			exist = true;
      	if (count[0][0] == 1 && count[0][1] == 1 && count[0][2] == 1) 
			exist = true;
      	if (count[1][0] == 1 && count[1][1] == 1 && count[1][2] == 1) 
			exist = true;     
      	if (count[2][0] == 1 && count[2][1] == 1 && count[2][2] == 1) 
			exist = true;     
      	if (count[0][0] == 1 && count[1][0] == 1 && count[2][0] == 1) 
			exist = true;
      	if (count[0][1] == 1 && count[1][1] == 1 && count[2][1] == 1) 
			exist = true;     
      	if (count[0][2] == 1 && count[1][2] == 1 && count[2][2] == 1) 
			exist = true;
      	System.out.println(exist ? "Yes" : "No");
 
    }
 
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define in freopen("in.txt","r",stdin)
//#define out freopen("out.txt","w",stdout) 
#define N 1e9+10;
ll n,m,i,j,k,t,l,r;
ll a,b,c,d;
char A,C,X,Y,Z;
ll ans,MAX,MIN,sum;
ll ax[2000500];
char cx[500];
ll dx[12];
ll bx[500];

long long gcd(long long a,long long b)
{
		if(a<b)
		{
			long long temp=a;
			a=b;
			b=temp;
		}
		
		long long t=0;
		if(b!=0)
		{
			return gcd(b,a%b);
		}
		else
		    return a;
 } 

int main()
{
    t=1;
    //scanf("%lld",&t);
    while(t--)
    {
        sum=0;
        scanf("%lld",&n);
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n;j++)
            {
                for(k=1;k<=n;k++)
                {
                    sum+=gcd(gcd(i,j),k);
                }
            }
        }
        printf("%lld\n",sum);
    }
	return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int cnt[10005];
int main(){
  int n;
  cin>>n;
  for(int i=1;i<100;i++)
    for(int j=1;j<100;j++)
      for(int k=1;k<100;k++){
        int t=i*i+j*j+k*k+i*j+j*k+k*i;
        if(t<=10000)
          cnt[t]++;
      }
  for(int i=1;i<=n;i++)
    cout<<cnt[i]<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 h, w, a, b;
int main() {
  cin >> h >> w >> a >> b;
  vector<vector<i64>> res(h);

  if (a == 1 && b == 1) {
    cout << "No\n";
    return 0;
  }

  const i64 C = 1000000000;
  i64 x = (C - 1) / (a * b - 1);

  for (i64 i = 0; i < h; ++i) res[i].assign(w, x);

  for (i64 i = a - 1; i < h; i += a) {
    for (i64 j = b - 1; j < w; j += b) {
      res[i][j] = -C;
    }
  }

  i64 sum = 0;
  for (i64 i = 0; i < h; ++i) {
    for (i64 j = 0; j < w; ++j) {
      sum += res[i][j];
    }
  }

  if (sum > 0) {
    cout << "Yes\n";
    for (i64 i = 0; i < h; ++i) {
      for (i64 j = 0; j < w; ++j) {
        cout << res[i][j] << ' ';
      }
      cout << '\n';
    }
  } else {
    cout << "No\n";
  }
  return 0;
}

// 1  1 1  1
// 1 -4 1 -4
// 1  1 1  1


Measured memory_bytes: 4864
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
p = [int(x) for x in input().strip().split()]
par = [i for i in range(N+1)]
rank = [0] * (N+1)

def find(x):
    if x == par[x]:
        return x
    par[x] = find(par[x])
    return par[x]

def isSame(x, y):
    return find(x) == find(y)

def union(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 

    if rank[x] >= rank[y]:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
    else:
        par[x] = y

for m in range(M):
    x, y = [int(x) for x in input().strip().split()]
    union(x, y)

ans = 0
for i in range(1, N+1):
    if isSame(p[i-1], i):
        ans += 1
print(ans)

Measured memory_bytes: 13812
#include<iostream>
#include<algorithm>
using namespace std;
int main ()
{
	int n,m,cnt=0;
	int st,en,syo;
	int tmp,a;
	int hi[100000];
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> hi[i];
/*
		for(int j=0;j<i;j++)
		{
			if(hi[j]>hi[i])
			{
				tmp=hi[i];
				hi[i]=hi[j];
				hi[j]=tmp;
			}
		}
*/
	}
	sort(hi,hi+n);
	cin >> m;
	for(int i=0;i<m;i++)
	{
		st=0;
		en=n;
		cin >> a;
		while(st!=en && st<en)
		{
			syo=st+((en-st)/2);
			if(a==hi[syo])
			{
				cnt++;
				break;
			}
			else
			{
				if(hi[syo]>a)	en=syo-1;
				else	st=syo+1;
			}
		}
		if(st==en)
		{
			if(hi[st]==a)	cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3504
let n = Scanf.scanf " %d" (+) 0
let hs = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let c, ans = ref 0, ref 0
let _ = Array.fold_left (fun p h -> if h <= p then (incr c; ans := max !ans !c) else c := 0; h) 0 hs |> ignore; Printf.printf "%d\n" !ans

Measured memory_bytes: 5248
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>

typedef struct{
  double x;
  double y;
}point;

void koch(int n, point p1, point p2){
  if(n==0) return;

  point s,t,u;
  double th  = M_PI/3;

  s.x = (2.0*p1.x + 1.0*p2.x)/3;
  s.y = (2.0*p1.y + 1.0*p2.y)/3;
  t.x = (1.0*p1.x + 2.0*p2.x)/3;
  t.y = (1.0*p1.y + 2.0*p2.y)/3;
  u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
  u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

  koch(n-1, p1, s);
  printf("%lf %lf\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%lf %lf\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%lf %lf\n", t.x, t.y);
  koch(n-1, t, p2);
}

int main(void){
  point p1,p2;
  int n;

  scanf("%d",&n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y  = 0;

  printf("%lf %lf\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%lf %lf\n", p2.x, p2.y);

  return 0;
}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b == c+d){
  cout << "Balanced";
  }else if(a+b >= c+d){
  cout << "Left";
  }else {
  cout << "Right";
  }
}


Measured memory_bytes: 256
def gcd(a, b, c):
  x = gcd2(a, b)
  y = gcd2(b, c)
  return gcd2(x, y)

def gcd2(x, y):
    if y == 0:
        return x
    else:
        return gcd2(y,x%y)

def main():
  K = int(input())
  ans = 0
  for p in range(1, K+1):
    for s in range(p, K+1):
      for k in range(s, K+1):
        if p == s == k:
          ans += p
        elif p == s or s == k or p == k:
          ans += 3 * gcd(p, s, k)
        else:
          ans += 6 * gcd(p, s, k)
  print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 9060
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 2e5 + 9;
vi adjL[N];
int n, mod = 1e9 + 7;
ll fact[N], show[N];
pair<ll, ll> mem[N], store[N];

ll fpow(ll x, ll p) {
	if (!p)
		return 1;
	ll sq = fpow(x, p / 2);
	sq *= sq;
	sq %= mod;
	if (p & 1)
		sq *= x;
	return sq % mod;
}
ll cdiv(ll num, ll dem) {
	num %= mod;
	return (num * fpow(dem % mod, mod - 2LL)) % mod;
}
pair<ll, ll> solve(int u, int par) {
	if (mem[u] != make_pair(-1LL, -1LL)) return mem[u];
	ll sizeofR = 0;
	ll NumofWays = 1, down = 1;
	for (auto& v : adjL[u]) {
		if (v == par) continue;
		pair<ll, ll> Com = solve(v, u);
		sizeofR += Com.second;
		NumofWays *= Com.first, down *= fact[Com.second];
		NumofWays %= mod, down %= mod;
	}
	store[u] = { NumofWays, down };
	ll ans = cdiv(fact[sizeofR], down);
	ans *= NumofWays;
	ans %= mod;
	return mem[u] = { ans ,sizeofR + 1 };
}

void Final(int u, int par) {
	if (par == -1)
		show[u] = mem[u].first;
	else {
		ll upove = n - mem[u].second - 1;
		ll ParWays = cdiv(store[par].first, mem[u].first);
		ll Pardown = cdiv(store[par].second, fact[mem[u].second]);
		ll All = cdiv(fact[upove], Pardown);
		All *= ParWays;
		All %= mod;
		ll NumofWays = (store[u].first * All) % mod;
		ll down = (store[u].second * fact[upove + 1]) % mod;
		store[u] = { NumofWays, down };
		show[u] = (NumofWays * cdiv(fact[n - 1LL], down)) % mod;
	}
	for (auto& v : adjL[u]) {
		if (v != par)
			Final(v, u);
	}
}
int main() {
	//file();
	fast();
	memset(mem, -1LL, sizeof mem);
	fact[0] = fact[1] = 1;
	for (int i = 2; i < N; i++)
		fact[i] = (i * fact[i - 1]) % mod;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v; cin >> u >> v;
		adjL[u].push_back(v);
		adjL[v].push_back(u);
	}
	solve(1, -1);
	Final(1, -1);
	for (int i = 1; i <= n; i++)
		cout << show[i] << endl;
	return 0;
}


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

int main(void){
    string T;
    int n=0;
    int h=0;
    int shuffle;
    while(1){
        shuffle=0;
        cin>>T;
        if(T=="-"){
            return 0;
        }
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>h;
            shuffle+=h;
        }
        shuffle=shuffle%((int)T.length());
        cout<<T.substr(shuffle,(int)T.length()-shuffle)<<T.substr(0,shuffle)<<endl;
    }
}



Measured memory_bytes: 3196
#include<iostream>

using namespace std;

int main(){
    int a,b;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op =='+'){
            cout<<a+b<<endl;
        }else if(op=='-'){
            cout<<a-b<<endl;
        }else if(op=='*'){
            cout<<a*b<<endl;
        }else if(op=='/'){
            cout<<a/b<<endl;
        }else{
            break;
        }
    }
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
#include<set>
#include <fstream>
#include<list>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)


#define nl cout<<"\n";
#define ll long long int
#define mod  1000000007


using namespace std;

int main()
{

	ios :: sync_with_stdio(false);
	cin.tie(nullptr);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s;
	cin >> s;
	int n = s.size();
	int sum = s[0] - '0';
	for (int i = 1; i < n; i++)
	{
		sum += s[i] - '0';
		if (sum > 10)
		{
			sum = sum % 10 + 1;
		}

	}

	if (sum == 9 || sum == 0)
		cout << "Yes";
	else
		cout << "No";


	return 0;
}

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll d,t,s;
    cin>>d>>t>>s;
    if(d<=(t*s))
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n,greater<ll>());
    ll ans=0;
    if(n%2==0){
        ans+=a[0];
        rep(i,1,n/2-1){
            ans=ans+a[i]*2;
        }
    }else{
        ans+=a[0];
        rep(i,1,n/2-1){
            ans=ans+a[i]*2;
        }
        ans+=a[n/2];
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5164
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        s: chars,
    }
    let mut v = vec![];
    let mut count = 1;
    let mut prev = s[0];
    for &c in s.iter().skip(1) {
        if c == prev {
            count += 1;
        } else {
            v.push(count);
            count = 1;
        }
        prev = c;
    }
    v.push(count);

    if v.len() == 1 {
        if k >= 1 {
            println!("{}", v[0]);
        } else {
            if s[0] == '0' {
                println!("0");
            } else {
                println!("{}", v[0]);
            }
        }
        return;
    }

    //let mut scores = vec![-1; v.len()];
    let mut max = 0;
    let start = if s[0] == '0' { 0 } else { 1 };
    let mut i = start;
    while i < v.len() {
        let score = v[if i == 0 { 0 } else { i - 1 }..std::cmp::min(i + 2 * k, v.len())]
            .iter()
            .fold(0, |sum, x| sum + x);
        if max < score {
            max = score;
        }
        i += 2;
    }
    println!("{}", max);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    b();
  }

  public static void b() {
    try (Scanner sc = new Scanner(System.in)) {
      int x = Integer.parseInt(sc.next());
      int y = Integer.parseInt(sc.next());
      int kame = 4;
      int tsuru = 2;
      int kamegoukei = 0;
      int tsurugoukei = 0;
      String hantei = "No";

      for (int a = 0; a <= x; a++) {
        kamegoukei = a * kame;
        tsurugoukei = (x - a) * tsuru;
        if (kamegoukei + tsurugoukei == y) {
          hantei = "Yes";
        }
      }
      System.out.println(hantei);

    } catch (Exception E) {
      System.out.println("エラー");
    }
  }
}

Measured memory_bytes: 35676
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int H[N];
    for(int i=0;i<N;i++){
        cin >> H[i];
    }

    int dp[N];

    dp[0] = 0;
    dp[1] = abs(H[1] - H[0]);

    for(int i=1;i<N-1;i++){
        dp[i+1] = min((dp[i] + abs(H[i+1] - H[i])), (dp[i-1] + abs(H[i+1] - H[i-1])));
    }

    cout << dp[N-1] << endl;
    return 0;

}

Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, N):
        self.parent = [x for x in range(N+1)]
        self.rank = [1 for x in range(N+1)]

    def find(self, x):
        p = x
        while self.parent[p] != p:
            p = self.parent[p]
        self.parent[x] = p
        return p

    def union(self, r, l):
        x, y = self.find(r), self.find(l)
        if x == y:
            return
        rx, ry = self.rank[x], self.rank[y]
        if rx > ry:
            self.parent[y] = x
        elif rx == ry:
            self.parent[y] = x
            self.rank[x] += 1
        else:
            self.parent[x] = y

def main():
    N, K, L = map(int, input().split())
    
    rails = UnionFind(N)
    for _ in range(K):
        p, q = map(int, input().split())
        rails.union(p, q)

    loads = UnionFind(N)
    for _ in range(L):
        p, q = map(int, input().split())
        loads.union(p,q)
    RL = [(rails.find(u), loads.find(u)) for u in range(1, N+1)]
    from collections import Counter
    c = Counter(RL)

    print(*(c[x] for x in RL))

main()



Measured memory_bytes: 47504
x,n = map(int,input().split())
 
if n != 0:
    p = list(map(int,input().split()))
 
s = []
 
for i in range(-1,102):
    s.append(i)
    
if n != 0:
    for i in p:
        s.remove(i)
 
if n == 0:
    print(x)
else:
    if x in s:
        print(x)
    elif x<s[0]:
        print(s[0])
    elif x>s[-1]:
        print(s[-1])
    else:
        for i in range(len(s)-1):
            if s[i]<=x<=s[i+1]:
                if abs(x-s[i])<abs(x-s[i+1]):
                    print(s[i])
                elif abs(x-s[i])==abs(x-s[i+1]):
                    print(s[i])
                else:
                    print(s[i+1])
                break

Measured memory_bytes: 9256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	ll c;
	cin >> n >> c;
	vector<pair<ll, ll>> x(n);
	rep(i, n) cin >> x[i].fi >> x[i].se;
	ll res = 0;
	rep(k, 2){
		vector<ll> opt(n + 1, -1e18);
		//rep(i, n) cout << x[i].fi << " " << x[i].se << endl;
		if(k){
			rep(i, n) x[i].fi = c - x[i].fi;
			sort(all(x));
		}
		ll dist = 0;
		ll tot = 0;
		ll best = 0;
		for(int i = n - 1; i >= 0; i--){
			dist = c - x[i].fi;
			tot += x[i].se;
			ll now = max(0LL, tot - dist);
			opt[i] = max(now, opt[i + 1]);
			best = max(best, opt[i]);
		}
		ll maxDist = 0;
		ll sum = 0;
		rep(i, n){
			maxDist = x[i].fi;
			sum += x[i].se;
			ll cur = max(0LL, sum - maxDist);	
			//debug(i);
			//debug(cur);
			if(i != (n - 1)){
				ll gd = opt[i + 1];
				//debug(gd);
				//debug(maxDist);
				cur += max(0LL, gd - maxDist); //don't have to
			}
			best = max(best, cur);
		}	
		res = max(best, res);
	}
	cout << res << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 2672
var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var S = lines[0].split("");
    var K = Number(lines[1]);

    var word = Array(S.length).fill("").map(i => i = Array(S.length).fill(""))
    var dictionary = [];

    // 開始文字
    for (var i = 0; i < S.length; i++) {
        // 終了文字
        for (var j = i; j < S.length; j++) {
            if (K <= word[i][j].length) { break; }
            else {
                word[i][j + 1] = word[i][j] + S[j];
                dictionary.push(word[i][j + 1]);
            }
        }
    }

    dictionary = dictionary.filter((value, index, array) => {
        return (array.indexOf(value) === index);
    })

    dictionary.sort();
    console.log(dictionary[K - 1]);


});

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


vector<ll> divisor(ll x) {
	vector<ll> result;
	ll i=1;
	for( ; i*i<x; i++) {
		if(x%i) continue;
		result.push_back(i);
		result.push_back(x/i);
	}
	if(i*i==x&&x%i==0)
		result.push_back(i);
	
	sort(result.begin(),result.end());
	return result;
}

int A,B,K;

void input() {
	cin>>A>>B>>K;
}

void solve() {
	llvec v=divisor(__gcd(A,B));
	cout<<v[v.size()-K]<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long n = stdIn.nextLong();
		long min = n;
		long cnt = 1;
		for (long i = 1; i < n / cnt; i++) {
			if (n % i == 0) {
				long a = i + n / i - 2;
				if (min > a) {
					min = a;
				}
			} else {
				cnt = i;
			}
		}

		System.out.println(min);
	}
}

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

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;
}

int main() {
	int N, M;
	int temp;

	std::vector<int> A_vec;

	cin >> N >> M;

	for (int i = 0; i < N; i++) {
		cin >> temp;

		A_vec.push_back(temp);
	}

	int sum = 0;
	double threshold = 0;

	for(int i = 0; i < N; i++){
		threshold += A_vec[i];
	}
	threshold /= (4*M);

	for (int i = 0; i < N; i++) {
		if(A_vec[i] >= threshold){
			sum++;
		}
	}

	if(sum >= M){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}


}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var dict = new Dictionary<char, int>();

            foreach (var c in S)
            {
                if (dict.ContainsKey(c))
                    dict[c]++;
                else
                    dict[c] = 1;
            }

            if (S.Length == 1)
            {
                Console.WriteLine("YES");
                return;
            }
            else if (dict.Count == 1)
            {
                Console.WriteLine("NO");
            }
            else if (dict.Count == 2)
            {
                if (S.Length == 2)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
            else
            {
                var max = 0;
                var count = 0;
                foreach (var d in dict.OrderByDescending(z => z.Value))
                {
                    if (count == 0) max = d.Value;
                    else
                    {
                        if (max - d.Value >= 2)
                        {
                            Console.WriteLine("NO");
                            return;
                        }
                    }

                    count++;
                }

                Console.WriteLine("YES");
            }
        }
    }
}

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

int main() {
	int n, m;
	cin >> n >> m;
	int** A = new int* [n]; 
	for (int i = 0; i < n; i++)
		A[i] = new int[m];
	int* b = new int[m];
	int* Ab = new int[n];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> A[i][j];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++) {
		Ab[i] = 0;
		for (int j = 0; j < m; j++)
			Ab[i] += A[i][j] * b[j];
		cout << Ab[i] << endl;
	}
	return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,V,X,Y;
const int MAX_N = 50;
const double G = 9.8;
int L [MAX_N],B [MAX_N],R [MAX_N],T [MAX_N];
const double EPS = 1e-10;

double calc(double t,double v)
{
	return v * t - G * t * t / 2;
}

int cmp(double lb,double ub,double a)
{
	if(a < lb + EPS) return -1;
	if(a < ub - EPS) return 0;
	return 1;
}

bool check(double px,double py)
{
	double a = G * G / 4,b = py * G - V * V,c = px * px + py * py;
	double D = b * b - 4 * a * c;
	if(D < 0.0 && D > -EPS) D = 0;
	if(D < 0.0) return false;
	for(int d = -1;d <= 1;d += 2){
		double t2 = (-b + d * sqrt(D)) / (2 * a);
		if(t2 < 0.0 && t2 > -EPS) t2 = 0.0;
		if(t2 < 0.0) continue;
		double t = sqrt(t2);
		double vx = px / t,vy = sqrt(V * V - vx * vx);
		if(abs(vx) < EPS || abs(vy) < EPS) continue;
		double yt = calc(X / vx,vy);
		if(yt < Y - EPS) continue;

		bool ok = true;
		FOR(i,0,N){
			if(L [i] >= X) continue;
			if(R [i] == X && Y <= T [i] && B [i] <= yt + EPS) ok = false;
			int yL = cmp(B [i],T [i],calc(L [i] / vx,vy));
			int yR = cmp(B [i],T [i],calc(R [i] / vx,vy));
			int xH = cmp(L [i],R [i],vx * (vy / G));
			int yH = cmp(B [i],T [i],calc(vy / G,vy));
			if(xH == 0 && yH >= 0 && yL < 0) ok = false;
			if(yL * yR <= 0) ok = false;
		}
		if(ok) return true;
	}
	return false;
}

int main()
{
	scanf("%d%d%d%d",&N,&V,&X,&Y);
	FOR(i,0,N){
		scanf("%d%d%d%d",&L [i],&B [i],&R [i],&T [i]);
		chmin(R [i],X);
	}

	bool ans = check(X,Y);
	FOR(i,0,N){
		ans |= check(L [i],T [i]) || check(R [i],T [i]);
	}
	puts(ans ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10) cout << a * b << '\n';
    else cout << -1 << '\n';
}


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

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> sizes; // size[i]:iの属する木の要素数

  UnionFind(int N) : par(N), sizes(N,1) { //最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x){
      return x;
    }
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(sizes[rx]>sizes[ry]){ // 小さい方を大き方にくっつける
      par[ry]=rx;
      sizes[rx]+=sizes[ry];
    }
    else{
      par[rx]=ry;
      sizes[ry]+=sizes[rx];
    }
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }

  int size(int x){
    return sizes[x]=sizes[root(x)];
  }
};

int main(){
  int N,M;
  cin >> N >> M;
  UnionFind fri(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >>b;
    fri.unite(a,b);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    ans=max(ans,fri.size(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4712
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string S;
    ll K;
    cin >> S >> K;

    set<char> st;
    for (char c : S) {
        st.insert(c);
    }

    if (st.size() == 1) {
        cout << (S.size() * K) / 2 << endl;
        return 0;
    }

    auto best = [](string& s) {
        ll result = 0;
        for (ll i = 1; i < s.size(); i++) {
            if (s[i] == s[i - 1]) {
                result++;
                s[i] = '-';
            }
        }
        return result;
    };

    if (K < 3) {
        string concat;
        for (ll i = 0; i < K; i++) {
            concat += S;
        }
        cout << best(concat) << endl;
    } else {
        string concat;
        for (ll i = 0; i < 3; i++) {
            concat += S;
        }
        best(concat);
        ll ans = 0;
        ll inner = 0;
        for (ll i = 0; i < S.size(); i++) {
            if (concat[i] == '-') {
                ans++;
            }
            if (concat[i + S.size()] == '-') {
                inner++;
            }
            if (concat[i + 2 * S.size()] == '-') {
                ans++;
            }
        }
        ans += inner * (K - 2);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<i64,i64>;

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> score(N, K-Q);
    rep(i,Q){
        int x;
        cin >> x;
        x--;
        score[x]++;
    }

    for(int p : score) {
        if(p <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}


Measured memory_bytes: 1024
# include<cstdio>
# include<iostream>
# include<algorithm>
# include<cmath>
# include<cstring>
# include<string>
using namespace std;
typedef long long ll;
bool vis[1000];
int main()
{
    int n;
    cin>>n;int a,ans=0;
    for(int i=1;i<=n;i++){
        cin>>a;
        if(vis[a]) continue;
        else{
            ans++;
            vis[a]=true;
        }

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int c[100010],n;
int main(){
	int p=0,q=114514,a=0,b=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c[i];
		p=max(p,c[i]);
		q=min(q,c[i]);
	}
	for(int i=0;i<n;i++){
		if(c[i]==p)a++;
		if(c[i]==q)b++;
	}
	bool ans=false;
	if(p==q){
		if(1<=p&&q<=a/2)ans=true;
		if(p==n-1)ans=true;
	}
	if(p==q+1){
		if(1+b<=p&&p<=a/2+b)ans=true;
		if(a==1)ans=false;
	}
	if(ans==true)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	while (b) {
		int r = a % b; a = b; b = r;
	}
	return a;
}
void solve() {
	int k; cin >> k;
	ll ans = 0;
	rep1(a, k)rep1(b, k)rep1(c, k) {
		ans += gcd(gcd(a, b), c);
	}
	cout << ans << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 3796