akhauriyash/Code-Regression huggingface dataset:
H, W, K = map(int,input().split())
C = [list(input()) for i in range(H)]

import itertools, copy

#print(C)
ans = 0

for h in range(H+1):#H+1
    for w in range(W+1):#W+1
        #print(h,w)#行と列 n個選ぶ
        comb_h = list(itertools.combinations(list(range(H)), h))
        comb_w = list(itertools.combinations(list(range(W)), w))

        #comb_H = []if comb_h == [()]
        
        #print(list(comb_h),list(comb_w))
        for ch in comb_h:
            for cw in comb_w:
                C_ = copy.deepcopy(C)
                #print(ch,cw)
                for x in ch:
                    for i in range(W):
                        C_[x][i] = "R"
                for y in cw:
                    for i in range(H):
                        C_[i][y] = "R"
                        
                #print(C_)
                #print
                #for cccc in C_:
                #    print("".join(cccc))

                cnt = 0
                for x in range(H):
                    for y in range(W):
                        if C_[x][y] == "#":
                            cnt += 1
                            
                if cnt == K:
                    ans += 1
                    
                    

print(ans)
        

Measured memory_bytes: 9368
N = int(input())
CSF = [list(map(int, input().split())) for _ in range(N-1)]
for start in range(N):
    t = 0
    for i in range(start, N-1):
        C, S, F = CSF[i]
        if t<S:
            t = S
        else:
            t += (F - (t - S)%F)%F
        t += C
    print(t)

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();
            long[] neta = new long[N];
            long[] oishisa = new long[N];
            for (int i = 0; i < N; i++) {
                neta[i] = in.nextInt();
                oishisa[i] = in.nextInt();
            }

            ArrayList<Sushi> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                list.add(new Sushi(neta[i], oishisa[i]));
            }
            Collections.sort(list);

            long max = 0;

            long sumOishisa = 0;
            HashSet<Long> netaSet = new HashSet<>();
            ArrayList<Integer> duplicationIndexes = new ArrayList<>();

            for (int i = 0; i < K; i++) {
                Sushi poll = list.get(i);

                sumOishisa += poll.oishisa;
                if (netaSet.contains(poll.neta)) {
                    duplicationIndexes.add(i);
                }
                netaSet.add(poll.neta);

                long size = netaSet.size();
                max = Math.max(max, sumOishisa + size * size);
            }
            for (int i = K; i < N; i++) {
                Sushi poll = list.get(i);
                if (netaSet.contains(poll.neta)) {
                    continue;
                }

                boolean remove = false;
                if (duplicationIndexes.size() > 0) {
                    int index = duplicationIndexes.remove(duplicationIndexes.size() - 1).intValue();
                    Sushi state = list.get(index);
                    sumOishisa -= state.oishisa;
                    remove = true;
                }
                if (!remove) {
                    continue;
                }

                sumOishisa += poll.oishisa;
                netaSet.add(poll.neta);

                long size = netaSet.size();
                max = Math.max(max, sumOishisa + size * size);

            }

            System.out.println(max);
        }
    }

}

class Sushi implements Comparable<Sushi> {
    long neta;
    long oishisa;

    public Sushi(long t, long d) {
        super();
        this.neta = t;
        this.oishisa = d;
    }

    @Override
    public int compareTo(Sushi o) {
        if (oishisa > o.oishisa) {
            return -1;
        }
        if (oishisa < o.oishisa) {
            return 1;
        }
        return 0;
    }
}


Measured memory_bytes: 95724
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>

typedef long long int llint;

llint dp[2][6001] = {};

int main(void){
  int n, t;
  std::cin >> n >> t;

  std::vector<std::array<int, 2> > foods(n);
  for(int i=0; i<n; i++){
    std::cin >> foods[i][0] >> foods[i][1];
  }

  std::sort(foods.begin(), foods.end());
  //for(const auto& elem: foods){
  //  std::cout << elem[0] << " " << elem[1] << " " << elem[2] << std::endl;
  //}
  /**
  for(const auto& elem: data){
    std::cout << elem[0] << " " << elem[1] << std::endl;
  }
  **/

  int ret = 0;
  for(int i=0; i<n; i++){
    auto food = foods[i];
    for(int j=0; j<t; j++){
      int temp = dp[(i+1)%2][j] + int(food[1]);
      if(temp > dp[i%2][j+int(food[0])])
	dp[i%2][j+int(food[0])] = temp;
      if(dp[(i+1)%2][j] > dp[i%2][j])
	dp[i%2][j] = dp[(i+1)%2][j];
      if(temp > ret) ret = temp;
    }

    
    //for(int i=0; i<60; i++){
    //  std::cout << dp[i%2][i] << " ";
    //}
    //std::cout << std::endl;

  }
  
  /**
  int best = 0;
  for(int i=0; i<n; i++){
    if(data[i][0] >= t) break;
    if(best < data[i][1]) best = data[i][1];

    for(int j=i+1; j<n; j++){
      if(best < data[i][1] + foods[j][2]) best = data[i][1] + foods[j][2];
    }
  }
  **/
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LLINF (1LL<<60)
#define INF (1<<30)
#define F first
#define S second
#define i1(a) cin>>a;
#define i2(a,b) cin>>a>>b;
#define i3(a,b,c) cin>>a>>b>>c;
#define i4(a,b,c,d) cin>>a>>b>>c>>d;
#define i5(a,b,c,d,e) cin>>a>>b>>c>>d>>e;
#define ol(a) cout<<a<<endl;
#define os(a) cout<<a<<" ";
#define o(a) cout<<a;
#define ol(a) cout<<a<<endl;
#define ol2(a,b) cout<<a<<" "<<b<<endl;
#define ol3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl;
using namespace std;
main(){
  long long n,l;
  string ans;
  string S[105];
  cin>>n>>l;
  for(int i=0;i<n;i++){
    cin>>S[i];
  }
  sort(S,S+n);
  for(int i=0;i<n;i++){
    cout<<S[i];
  }
  cout<<endl;
  
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())

days = [[] for _ in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    if A <= M:
        days[A].append(B)

ans = 0
q = []
for j in range(1, M+1):
    for k in days[j]:
        heapq.heappush(q, -k)

    if q:
        tmp = heapq.heappop(q)
        ans -= tmp
    
print(ans)


Measured memory_bytes: 18504
#include<stdio.h>
#define llu unsigned long long
#define ll long long
#define rep(i,p) for(ll i=p;i<=119;i++)

int main(){
  int mag=0;
  llu num;
  scanf("%llu",&num);
  rep(X,0){
    rep(Y,X){
      if(Y==0)continue;
      if(num%(X+Y)==0){
        if((X*X*X*X*X)+(Y*Y*Y*Y*Y)==num){
          printf("%lld %lld",X,-Y);
          mag++;
          break;
        };
      }
      else if(Y!=X){
       if(num%(Y-X)==0){
        if((Y*Y*Y*Y*Y)-(X*X*X*X*X)==num){
          printf("%lld %lld",Y,X);
          mag++;
          break;
        };
      };
      };
    };
    if(mag!=0)break;
  };
};

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

int main() {
  string s, t;
  cin >> s;
  for(int i=0; i<s.size(); i+=2) t+=s[i];
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll gcd(ll a2,ll b2){
	int t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}

ll lcm(ll a1,ll b1){
	if(a1*b1==0){return 0;}
	return (a1*b1/gcd(a1,b1));
}

int main() {

	int n;
	int a[101];

	cin>>n;

	int t=1;
	rep(i,n){
		cin>>a[i];
		t=lcm(t,a[i]);
	}

	ll t2=0;
	rep(i,n){
		t2+=t/a[i];
	}

	cout<<setprecision(15)<<(double(t))/t2<<endl;


	return 0;
}


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

	int main(){
		
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	
		// #ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
		// #endif

		string s,t;
		cin >> s >> t;
		int n=s.length(),m=t.length();
		int dp[m][n];
		pair<int,int> p[m][n];
		memset(dp,0,sizeof(dp));
		for(int i=0;i<n;i++){
			if(s[i]==t[0]){
				dp[0][i]=1;
				p[0][i]={-1,-1};
			}
			else if(i){
				dp[0][i]=dp[0][i-1];
				p[0][i]={0,i-1};
			}
			else{
				p[0][i]={-1,-1};
			}
		}
		for(int i=0;i<m;i++){
			if(s[0]==t[i]){
				dp[i][0]=1;
				p[i][0]={-1,-1};
			}
			else if(i){
				dp[i][0]=dp[i-1][0];
				p[i][0]={i-1,0};
			}
			else{
				p[i][0]={-1,-1};
			}
		}
		for(int i=1;i<m;i++){
			for(int j=1;j<n;j++){
				if(s[j]==t[i]){
					dp[i][j]=1+dp[i-1][j-1];
					p[i][j]={i-1,j-1};
				}
				else{
					if(dp[i-1][j]>dp[i][j-1]){
						p[i][j]={i-1,j};
					}
					else{
						p[i][j]={i,j-1};
					}
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
		stack<char> st;
		int x=m-1,y=n-1;
		while(make_pair(x,y)!=make_pair(-1,-1)){
			// cout << x<< " " << y <<endl;
			if(t[x]==s[y]){
				st.push(t[x]);
			}
			int nx = p[x][y].first,ny=p[x][y].second;
			x=nx;
			y=ny;
		}
		while(!st.empty()){
			cout << st.top();
			st.pop();
		}
		cout << " ";		
	}

Measured memory_bytes: 105728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        sc.close();

        int ans = 0;

        if (a + b < c * 2) {
            ans = a * x + b * y;
        } else {
            int min = Math.min(x, y);
            ans = c * min * 2;
            x -= min;
            y -= min;
            if (a > c * 2) {
                ans += c * 2 * x;
            } else {
                ans += a * x;
            }

            if (b > c * 2) {
                ans += c * 2 * y;
            } else {
                ans += b * y;
            }
        }
        System.out.println(ans);
    }
}

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

int main()
{
	ll A,B,K;
	cin >> A >> B >> K;
	if (A <= K)
	{
		K -= A;
		A = 0;
		if (B <= K)
		{
			B = 0;
		}
		else
		{
			B = B - K;
		}
	}
	else
	{
		A -= K;
	}
	cout << A << " " << B << endl;
	return 0;
}

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

int main(){
    string S, T;
    cin >> S >> T;

    if(S.size() < T.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    vector<string> vec;//候補となる文字列を入れる配列

    for(int i=0; i<S.size() - T.size() + 1; i++){
        string U = S;
        bool check = true;
        int count = 0;
        for(int j=i; j<i + T.size(); j++){
            if(U[j] != '?' && U[j] != T[count]){//もし文字列が合わないなら実行
                check = false;
                break;
            }

            U[j] = T[count];

            count++;
        }

        if(check){
            for(int j=0; j<U.size(); j++){
                if(U[j] == '?') U[j] = 'a';
            }

            vec.push_back(U);
        }
    }

    if(vec.empty()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    sort(vec.begin(), vec.end());//辞書順にソートする

    cout << vec[0] << endl;


}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//最小公倍数、最大公約数
ll gcd(ll a, ll b) {
	return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
//最小公倍数、最大公約数
ll lcm(vector<ll> a) {
	ll tmp = a.front();
	for (int i = 1; i < a.size(); i++) {
		tmp = lcm(tmp, a[i]);
	}
	return tmp;
}
ll gcd(vector<ll> a) {
	ll tmp = a.front();
	for (int i = 1; i < a.size(); i++) {
		tmp = gcd(tmp, a[i]);
	}
	return tmp;
}

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> a(N);
	for (int i = 0; i < N; i++)cin >> a[i];
	ll l = lcm(a);
	bool flag = 0;
	ll cnt = (M * 2) / l;
	if (cnt % 2 == 0)cnt /= 2;
	else cnt = cnt / 2 + 1;
	for (int i = 0; i < N; i++)if ((l / a[i]) % 2 == 0)flag = true;
	if (flag)cnt = 0;
	cout << cnt << endl;
}

Measured memory_bytes: 1792
def getls():
    return [ipt for ipt in input().split()]
def getlsi():
    return [int(ipt) for ipt in input().split()]

s = input()
t = input()
if len(t) == 1:
    print("No")
else:
    if s == t[:len(t)-1]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 61792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int count,count2;
    int win=0;
    int n;
    int maxval=0,maxnum=0,sum=0;
    int l[105];
    scanf("%d",&n);
    for(count=1;count<=n;count++){
        scanf("%d",&l[count]);
    }
 
    for(count=1;count<=n;count++){
        if(maxval<=l[count]){maxval=l[count];maxnum=count;}
    }
 
    for(count=1;count<=n;count++){
        if(count!=maxnum){sum=sum+l[count];}
    }
  //printf("sum=%d\n",sum);
  //printf("maxnum=%d\n",maxnum);
    if(maxval<sum){printf("Yes");}
    else{printf("No");}
    return 0;
 
}
 
int min(int a,int b){
    int ans;
    if(a>b){return b;}
    else {return a;}
}
 
int max(int a,int b){
    int ans;
    if(a>b){return a;}
    else {return b;}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<set>
#define ll long long
#define f(i,l,r) for(ll i=l;i<=r;i++)
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,a;
    set<ll> s;
    cin >> n;
    f(i,1,n){
        cin >> a;
        s.insert(a);
    }
    if(s.size() < n) cout << "NO";
    else cout << "YES";
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll dp[10101];

vector<ll> L = {2, 5, 5, 4, 5, 6, 3, 7, 6};

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

    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    REP(i, M) cin >> A[i];

    REP(i, 10101) dp[i] = -1;
    dp[0] = 0;

    REP(i, 10101){
      if(dp[i]==-1) continue;
      REP(j, M){
        ll hon = L[A[j]-1];
        if(i+hon<10101) chmax(dp[i+hon], dp[i]+1);
      }
    }

    ll now = N;
    string res = "";
    while(now!=0){
      ll ma = (-1);
      ll mhon = -1;
      REP(j, M){
        ll hon = L[A[j]-1];
        if(now-hon>=0 && dp[now-hon]==dp[now]-1){
          if(chmax(ma, A[j])){
            mhon = hon;
          }
        }
      }
      now -= mhon;
      res += to_string(ma);
    }
    cout << res << endl;

    /*
    REP(i, N+1) cerr << dp[i] << " ";
    cerr << endl;
    */
    return 0;
}

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

const int md = 1e9 + 7;

int N;
vector<int> isPair;
vector<vector<int>> adj;
vector<vector<int>> dp;

int solve(int x, int mask) {
    if (x >= N) return 1;
    if (mask == (1 << N) - 1) return 0;
    if (dp[x][mask] != -1) return dp[x][mask];

    int res = 0;
    for (int i = 0; i < N; i++) {
        if (mask & (1 << i)) continue;
        if (!adj[x][i]) continue;
        res = (res + solve(x + 1, mask | (1 << i))) % md;
    }

    return dp[x][mask] = res;
}

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

    cin >> N;
    adj = vector<vector<int>>(N, vector<int>(N));
    isPair = vector<int>(N);
    dp = vector<vector<int>>(N, vector<int>((1<<N), -1));

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> adj[i][j];
        }
    }

    cout << solve(0, 0) << "\n";
}



Measured memory_bytes: 180608
N, T = map(int, input().split())
l = [list(map(int, input().split())) for val in range(N)]
l2 = [l[n][0] for n in range(N) if l[n][1] <= T]
l2.sort()
if not l2:
    print("TLE")
else:
    print(l2[0])

Measured memory_bytes: 3060
n = int(input())

arr = []
arr += [list(map(int,input().split())) for i in range(n-1)]

for j in range(n-1):
    time = 0
    tmp = 0
    for k in range(j, n-1):
        if arr[k][1] >= time:
            time = arr[k][1] + arr[k][0]
        else:
            if time % arr[k][2] == 0:
                time = time + arr[k][0]
            else:
                time = (time // arr[k][2] + 1) * arr[k][2] + arr[k][0]   
    print(time)
print(0)

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    private static ArrayList<Integer> rightAnswers = new ArrayList<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int penalty = 0;
        int correct = 0;
        int[] wrong = new int[n + 1];
        while (m-- > 0) {
            int p = sc.nextInt();
            String s = sc.next();
            if (wrong[p] == -1)
                continue;
            if (s.equals("WA"))
                wrong[p]++;
            else {
                correct++;
                penalty += wrong[p];
                wrong[p] = -1;
            }
        }
        System.out.println(correct + " " + penalty);
    }
}

Measured memory_bytes: 63568
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int a = input.nextInt();
        int b = input.nextInt();

        System.out.println(a *n < b ? a*n:b);
    }
}


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

int main(){
    ll A,B,K;
    cin >> A >> B >> K;
  	ll e=min(A+K,max(1LL,B-K+1));
    rep(i,A,e){
        cout<<i<<endl;
    }
  	ll s=max(A,max(1LL,B-K+1)); 
    rep(i,s,B+1){
        cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long h=max(c,d);
    d=min(c,d);
    c=h;

    long long k=__gcd(c,d);
    k=d/k;
    k=k*c;
    long long sc=a/c;
    if(a%c){sc++;}
    long long ec=b/c;

    long long sd=a/d;
    if(a%d){sd++;}
    long long ed=b/d;

    long long sk=a/k;
    if(a%k){sk++;}
    long long ek=b/k;

    long long tans=ec+ed+sk-ek-sc-sd+1;
    long long ans=b-a+1-tans;
    cout<<ans;
}


Measured memory_bytes: 256
N = int(input())
A,B = [-1]*N, [-1]*N
for i in range(N):
    a,b = map(int, input().split())
    A[i] = a
    B[i] = b
    
ans = 0
for a,b in zip(A[::-1],B[::-1]):
    a = a+ans
    if a%b==0:
        continue
    else:
        ans += b*(a//b+1)-a
print(ans)

Measured memory_bytes: 12532
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		int[]a = new int[5];
		for(int i=0;i<5;i++) {
			a[i] = in.nextInt();
			if(a[i]==0) {
				System.out.println(i+1);
				break;
			}
		}



	}

}


Measured memory_bytes: 35724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

  vector<int> a(n);
  vector<int> cnt(n+1);
  vector<long> cmb(n+1);
  rep(i,n) {
    cin >> a.at(i);
    cnt.at(a.at(i))++;
  }

  long ans=0;
  rep(j,n+1){
      long val = cnt.at(j);

      if(val>=2) {
        ans += val * (val-1) / 2;
        cmb.at(j) = val * (val-1) / 2;
      }
  }

  rep(i,n){
    long num = a.at(i);

    long cnt_t = cnt.at(num) - 1;
    
    if(cnt_t == 0){
     cout << ans << endl;
    }else{
      long diff = cnt_t * (cnt_t-1) /2;
      cout << ans-cmb.at(num)+diff << endl;
    }
  }
} 

Measured memory_bytes: 5760
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x,y;
		while(true) {
			x = sc.nextInt();
			y = sc.nextInt();
			
			if (x == 0 && y == 0) {
				break;
			}
			
			System.out.println(Math.min(x, y) + " " + Math.max(x, y));
			
		}

	}

}


Measured memory_bytes: 36100
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A,B=MAP()

if (A+B)%2==0:
    print((A+B)//2)
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define caseout(i, x) cout << "Case #" << i << ": " << x << endl;



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a==b&&a==c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    return 0;
}

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

int main(){
   int n, k;
   cin>>n>>k;
   vector<int> p(n);
   rep(i, n) cin>>p[i];

   vector<int> ki2(n);
   rep(i, n) ki2[i]=(p[i]+1);

   int sum=0;
   rep(i, k) sum+=ki2[i];
   int mx=0;
   for(int i=0; i+k-1<n; i++){
      mx=max(mx, sum);
      if(i+k<n) sum+= -ki2[i] +ki2[i+k];
   }

   double ans=(double)mx/2;
   cout<<std::setprecision(15)<<ans<<endl;
   return 0;
}


Measured memory_bytes: 4840
n = int(input())
total = {}
for i in range(1, n+1):
    a = i
    cnt = 0
    while a % 2 == 0:
        a /= 2
        cnt += 1
    total[i] = cnt

total = sorted(total.items(), key=lambda x:x[1])
print(total[-1][0])

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int A,B;
    cin>>A>>B;
    int ans = 0;
    if (A>B) {
        ans += A;
        A --;
    }
    else {
        ans += B;
        B --;
    }
    if (A>B) {
        ans += A;
        A --;
    }
    else {
        ans += B;
        B --;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

D,G = imn()
pc = [iln() for _ in range(D)]

ans = 10**10

for i in range(2**D):
    tmp = i
    point = 0
    count = 0
    complete_set = set()
    for j in range(D):
        if tmp & 1 == 1:
            complete_set.add(j)
            point += pc[j][0] * (100*(j+1)) + pc[j][1]
            count += pc[j][0]
        tmp = tmp >> 1
    for j in range(D-1, -1, -1):
        if j not in complete_set:
            for k in range(pc[j][0]-1):
                if point >= G: break
                point += 100*(j+1)
                count += 1
    if point >= G:
        ans = min(ans, count)
print(ans)




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

int main(){
    long long N, A, B;
    scanf("%lld%lld%lld", &N, &A, &B);

    assert(A <= B);

    if(A%2 == B%2){
        printf("%lld\n", abs(B-A)/2);
        return 0;
    }else{
        long long C = min(A, B);
        long long D = max(A, B);
        printf("%lld", min(C-1+(abs(B-A)+1)/2, N-D+(abs(B-A)+1)/2));
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
h, n = map(int, input().split())
a = []
b = []
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)

dp = [10**9] * (h+1)
dp[0] = 0

for i in range(1, h+1):
    for j in range(n):
        dp[i] = min(dp[i], dp[max(i-a[j], 0)] + b[j])

print(dp[-1])


Measured memory_bytes: 42348
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int L=500005,M=500005;
typedef long long ll;
const int base=10;
struct BigInt{
    int a[M];
    int len;
    BigInt(){}
    BigInt(char *s){
        memset(a,0,sizeof a);
        len=strlen(s+1);
        for(int i=len;i>=1;i--)
            a[i]=s[len-i+1]-'0';
    }
};
int ans;
void operator +=(BigInt& x,int y){
    x.a[1]+=y;
    ans+=y;
    for(int i=1;i<=x.len;i++){
        if(x.a[i]>=base){
            if(i==x.len)
                x.len++;
            ans-=x.a[i];
            ans-=x.a[i+1];
            x.a[i+1]++;
            x.a[i]-=base;
            ans+=x.a[i];
            ans+=x.a[i+1];
        }
        else
            break;
    }
}
BigInt operator *(BigInt x,int y){
    int r=0;
    for(int i=1;i<=x.len;i++){
        x.a[i]*=y;
        x.a[i]+=r;
        if(x.a[i]>=base){
            r=x.a[i]/base;
            x.a[i]%=base;
        }
        else
            r=0;
    }
    x.len++;
    x.a[x.len]+=r;
    while(x.len>0&&x.a[x.len]==0)
        x.len--;
    return x;
}
int sum(BigInt x){
    int res=0;
    for(int i=1;i<=x.len;i++){
        res+=x.a[i];
    }
    return res;
}
char s[L];
int main()
{
    //freopen("z.in","r",stdin);
    scanf("%s",s+1);
    BigInt x(s);
    x=x*9;
    ans=sum(x);
    for(int k=1;;k++){
        x+=9;
        //if(k%10000==0)
        //    puts("!");
        if(ans<=9*k){
            printf("%d\n",k);
            return 0;
        }
    }
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000LL
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue
 
#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)
 
#define MN 3005
int r, g, b, n;

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

    ll tot = 0;

    cin >> r >> g >> b >> n;

    F0R(i, n+1){
        F0R(j, n+1){
            int cur = r*i+j*g;
            int amt = (n-cur);
            if(amt >= 0 && amt % b == 0) tot++;
        }
    }

    cout << tot << "\n";

    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;

  vector<pair<int, int> > a, b;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    a.push_back(make_pair(x, y));
  }

  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    b.push_back(make_pair(x, y));
  }

  vector<vector<pair<int, int> > > manhat(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      int dis = abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second);
      manhat[i].push_back(make_pair(dis, j + 1));
    }
  }

  for (int i = 0; i < N; i++) sort(manhat[i].begin(), manhat[i].end());

  for (int i = 0; i < N; i++) cout << manhat[i][0].second << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Mod=998244353;
int k,n,ans[4100],C[4100][4100];
int calc(int x,int k,int n){
	int tmp,sum=0;
	for (int i=0;i<=(x-1)/2&&n-i*2>=0;i++){
		if (!k) tmp=0;
		else tmp=(ll)C[(x-1)/2][i]*C[n-i*2+k-1][k-1]%Mod;
		if (i&1) sum=(sum-tmp+Mod)%Mod;
		else sum=(sum+tmp)%Mod;
	}
	return sum;
}
int main(){
	C[0][0]=1;
	for (int i=1;i<=4000;i++){
		C[i][0]=1;
		for (int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%Mod;
	}
	scanf("%d%d",&k,&n);
	for (int i=2;i<=k+1;i++)
		if (!(i&1)) ans[i]=(calc(i,k-1,n)+calc(i,k-1,n-1))%Mod;
		else ans[i]=calc(i,k,n);
	for (int i=2;i<=k;i++) printf("%d\n",ans[i]);
	printf("%d\n",ans[k+1]);
	for (int i=k;i>=2;i--) printf("%d\n",ans[i]);
	return 0;
}


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

int main()
{
	string s, res;
	cin >> s;
	for (char c : s) {
		if (c == '0') {
			res += '0';
		}
		else if (c == '1') {
			res += '1';
		}
		else {
			if (!res.empty()) {
				res.erase(res.end() - 1);
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
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 INFLL = 1LL<<62;
const int INF = 1<<30;
int main(){
    int k,t;
    int ans=0;
    cin >>k>>t;
    vector<int>a(t,0);
    rep(i,t){
        cin>>a[i];
    }
    sort(all(a),greater<int>());

    cout<<max(a[0]-(k-a[0])-1,0)<<endl;
}

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

int main(){
  string S; cin >> S;
  int MAX = 0;
  int temp = 0;
  for(int i=0;i<S.size();i++){
    if(S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T'){
      temp++;
      if(temp > MAX)  MAX = temp;
    }else{
      temp = 0;
    }
  }
  cout << MAX << endl;
}

Measured memory_bytes: 3556
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static ArrayList<Integer> s = new ArrayList<Integer>();
    static ArrayList<Integer> h = new ArrayList<Integer>();
    static ArrayList<Integer> c = new ArrayList<Integer>();
    static ArrayList<Integer> d = new ArrayList<Integer>();


    public static void main(String[] args) {
        for (int i = 1; i <= 13; i++){
            s.add(i);
            h.add(i);
            c.add(i);
            d.add(i);
        }
        for (int i = 0; i < n; i++){
            String str = sc.next();
            int num = sc.nextInt();
            if (str.equals("S"))
                s.remove(s.indexOf(num));
            else if (str.equals("H"))
                h.remove(h.indexOf(num));
            else if (str.equals("C"))
                c.remove(c.indexOf(num));
            else if (str.equals("D"))
                d.remove(d.indexOf(num));
        }
        for (int ss : s)
            System.out.println("S " + ss);
        for (int hh : h)
            System.out.println("H " + hh);
        for (int cc : c)
            System.out.println("C " + cc);
        for (int dd : d)
            System.out.println("D " + dd);
    }
}



Measured memory_bytes: 26148
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int,input().split()))

    total = sum(A)
    num = 1
    totali = 0
    for j in range((N-1)//2):
        if num >= N:
            num -= N
        totali += A[num]
        num += 2
    ans= total - 2*totali
    print(ans,end = " ")
    for i in range(1,N,1):
        ans = (A[i-1] - ans//2)*2
        print(ans,end = " ")


if __name__ == "__main__":
    main()

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<int,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI s(n);
	for(auto& is: s) cin >>is;
	
	vector<uint8_t> zp(100*101);
	zp[0]=1;
	rep(i, n) repr(j, 10010, 0) if(zp[j]>0){
		if(j + s[i] <= 10010) zp[j + s[i]] = 1;
	}
	int ans = 100*101;
	repr(i, 10010, 0) if(zp[i]>0 && i%10){
		cout << i <<"\n";
		return 0;
	}
	puts("0");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define INF 1<<30

 typedef struct{
              int go;
              int back;
              int cost;
              }Date;

 int n,d[MAX];
 Date a[500000];

 void root(int x){
            int i;
            int judge=1;

            for(i=0;i<n;i++){
                       d[i]=INF;
                       }
            d[0]=0;

            while(judge!=0){
                    judge=0;
                    for(i=0;i<x;i++){
                               if(a[i].cost+d[a[i].back]<d[a[i].go]){
                                                      d[a[i].go]=a[i].cost+d[a[i].back];
                                                      judge=1;
                                                      }
                               }
                    }
           }

 int main(){
         int i,j,k,l;
         int count = 0;

         scanf("%d",&n);
         for(i=0;i<n;i++){
                     scanf("%d%d",&k,&l);

                     for(j=0;j<l;j++){
                              a[count].back=k;
                              scanf("%d%d",&a[count].go,&a[count].cost);
                              count++;
                              }
                     }
         root(count);
         for(i=0;i<n;i++){
                      printf("%d %d\n",i,d[i]);
                      }
         return 0;
         }









Measured memory_bytes: 7632
# C - たくさんの数式
# https://atcoder.jp/contests/arc061/tasks/arc061_a
S = input()
n = len(S)
ans = 0
# 計算量: O(2**n*n)
for i in range(1 << n - 1):
    # 0からn-1番目までの数のうち、何番目の後にj番目に+を挿入するか
    x = S[0]
    for j in range(n - 1):
        if i & 1 << j:
            # +をjとj+1の間に挿入する
            x += '+'
        x += S[j + 1]
    ans += sum(map(int, x.split('+')))
print(ans)


Measured memory_bytes: 9144
#include <algorithm>
#include <iostream>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    repeat(i, N) cin >> A[i];
    long long res = 0;
    repeat_from(i, 1, N) {
        if (A[i - 1] > A[i]) {
            res += A[i - 1] - A[i];
            A[i] = A[i - 1];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main(){
  char a,b;
  cin >> a>>b;
  if(a == b) cout << 'H' << endl;
  else cout << 'D' << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>

#define MAX_N 200'000

using namespace std;

int B[MAX_N];

int main() {
  int n;
  cin >> n;
  int j = n / 2;
  int k = 1;
  if (n % 2 == 0) {
    k = -1;
  }
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    B[j] = a;
    j += k * i;
    k = -k;
  }
  for (int i = 0; i < n; ++i) {
    printf("%d ", B[i]);
  }
  printf("\n");
}

Measured memory_bytes: 4008
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll v[1000000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
int main() {
	cin>>N;
	map<ll,ll> m1;
	map<ll,ll> m2;
	rep(i,0,N){
		cin>>v[i];
		if(i%2){
			m1[v[i]]++;
		}else{
			m2[v[i]]++;
		}
	}
	vector<pair<ll,ll> > v1;
	vector<pair<ll,ll> > v2;
	rep(i,1,100001){
		v1.push_back(make_pair(m1[i],i));
		v2.push_back(make_pair(m2[i],i));
	}
	sort(v1.begin(),v1.end(),greater<pair<ll,ll> >());
	sort(v2.begin(),v2.end(),greater<pair<ll,ll> >());
	
	if(v1[0].second != v2[0].second){
		cout<<N-v1[0].first-v2[0].first<<endl;
	}else{
		if(v2[1].first==0)v2[1].first=0;
		if(v1[1].first==0)v1[1].first=0;
		cout<<min(N-v1[0].first-v2[1].first,N-v1[1].first-v2[0].first)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 16736
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int count=0;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
      count++;
      ans=max(ans,count);
    }
    else count=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define pb push_back
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fs(s) for(ll i=0;s[i]!='\0';i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define gcd(a,b) __gcd(a,b)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define c1(x) __builtin_popcountll(x)
#define setprs(x) cout << fixed << setprecision(x);
#define endl '\n'
const ll mod=1e9 + 7;
const ll sz=2e5 + 100;
const double PI =3.14159265;
ll power(ll a, ll b, ll m = mod){if(b==0)return 1;else if(b==1)return a%m;else{ll t=power(a,b>>1,m);t=((t%m)*(t%m))%m;if(b&1)return ((t%m)*(a%m))%m;else return t%m;}}
 
//--------------------------------------------------------

int parent[sz], siz[sz];

int findparent(int n){
    if(parent[n] == n){
        return n;
    }
    parent[n]=findparent(parent[n]);
    return parent[n];
}

void merge(int x, int y){
    int p1 = findparent(x);
    int p2 = findparent(y);
    if(p1 == p2)return;
    if(siz[p1] > siz[p2]){
        parent[p2] = p1;
        siz[p1] += siz[p2];
    }else{
        parent[p1] = p2;
        siz[p2] += siz[p1];
    }
    // cout << x << " " << y;
}

void solve()
{
    int n, m;
    cin >> n >> m;
    f(i,0,n+1)parent[i] = i;
    f(i,0,n+1)siz[i] = 1;
    while(m--){
        int x,y;
        cin >> x >> y;
        merge(x, y);
    }
    int mx = 0;
    f(i,0,n){
        mx = max(mx , siz[i]);
    }
    cout << mx;

} 
 
int32_t main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
#define endl '\n'
#define _USE_MATH_DEFINES
using namespace std;

int main() {
	
	ios::sync_with_stdio(false);
    cin.tie(0);
    
    int i,n,q;
	long long  int total = 0;
    int store[100001] = {0};
    cin>>n;
    for(i = 0;i<n;i++){
    	int tmp;
    	cin>>tmp;
    	store[tmp]++;
    	total += tmp;
	}
	cin>>q;
	for(i = 0;i<q;i++){
		int b,c,sub;
		cin>>b>>c;
		sub = c-b;
		total += sub*store[b];
		store[c] += store[b];
		store[b] = 0;
		cout<<total<<endl;
	}
    
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int a = 0;
    int b = 0;
    vector<int> card(N);

    rep(i,N){
        cin >> card[i];
    }
    sort(card.begin(), card.end(), greater<int>());
    rep(i,N){
        if(i%2 == 0){
            a += card[i];
        }
        else{
            b += card[i];
        }
    }

    cout << a - b << endl;
}


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

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        if(n[0] < 6)
            WriteLine("0");
        else if(n[0] < 13)
            WriteLine(n[1] / 2);
        else
            WriteLine(n[1]);
    }
}


Measured memory_bytes: 19020
const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = input.trim().split("\n").map(Number)
while (lines.length > 1) {
    let idx = lines.shift()
    let i = 0
    let point = []
    while (i < idx) {
        point.push(lines.shift())
        i++
    }
    point.sort((a,b) =>  a - b)
    point.shift()
    point.pop()
    const sum = point.reduce((sum, value) => sum + value, 0)
    console.log(Math.floor(sum/(idx - 2)))
}


Measured memory_bytes: 16420
N,K = map(int,input().split())
V = list(map(int,input().split()))

ans = 0
for l in range(N):
  for r in range(N-l+1):
    arr = V[:l] + ([] if r==0 else V[-r:])
    k = len(arr)
    if k > K: continue
    score = sum(arr)
    arr.sort()
    i = 0
    while k < K and i < len(arr):
      if arr[i] >= 0: break
      score -= arr[i]
      k += 1
      i += 1
    ans = max(ans, score)
print(ans)

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

int main(){
  ll a,b,k;cin>>a>>b>>k;
  
  if(a>=k){
    a-=k;
  }else{
    if(b>=k-a) b-=(k-a);
    else b=0;
    a=0;
  }

  cout<<a<<" "<<b;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] a = new int[m];
    int[] b = new int[m];
    int[] c = new int[n];
    for (int i = 0; i < m; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    for (int i = 0; i < n; i++) {
      c[i] = 0;
    }
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i] == j + 1) {
          c[j]++;
        }
        if (b[i] == j + 1) {
          c[j]++;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      System.out.println(c[i]);
    }
  }
}

Measured memory_bytes: 35804
import numpy as np
A = np.array([list(map(str, input().split())) for _ in range(3)])
N = int(input())
b = [input() for _ in range(N)]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            A[i][j] = 'X'

if A[0][0] == A[1][1] == A[2][2] == 'X':
    print('Yes')
    exit()

if A[0][2] == A[1][1] == A[2][0] == 'X':
    print('Yes')
    exit()

if A[0][0] == A[0][1] == A[0][2] == 'X':
    print('Yes')
    exit()

if A[1][0] == A[1][1] == A[1][2] == 'X':
    print('Yes')
    exit()

if A[2][0] == A[2][1] == A[2][2] == 'X':
    print('Yes')
    exit()

# t
if A[0][0] == A[1][0] == A[2][0] == 'X':
    print('Yes')
    exit()
if A[0][1] == A[1][1] == A[2][1] == 'X':
    print('Yes')
    exit()
if A[0][2] == A[1][2] == A[2][2] == 'X':
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 21656
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline lli getint(){
    lli n;
    scanf("%lld",&n);
    return n;
}

inline vector<lli> getints(int n){
    vector<lli> a(n);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    return a;
}

inline string getstr(){
  string s;
  cin>>s;
  return s;
}

void dumpints(vector<lli> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  string X=getstr();
  stack<char> s;
  int c=X.size();
  FOR(i,X.size()){
    if(!s.empty()&&s.top()=='S'&&X[i]=='T'){
      c-=2;
      s.pop();
    }else{
      s.push(X[i]);
    }
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 644