akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String S = in.next();
        String T = in.next();
        int ans = 0;
        int length = S.length();
        for (int i = 0; i < length; i++) if (S.charAt(i) != T.charAt(i))
            ans++;
        out.println(ans);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 36740
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    if(a==b){
        if(b==c) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    switchs = []
    for _ in range(M):
        ks = list(map(int, input().split()))
        switchs.append(ks[1:])
    p = list(map(int, input().split()))
    ans = 0
    for b in range(1 << N):
        f = True
        for i, s in enumerate(switchs):
            c = 0
            for ss in s:
                if b & (1 << (ss - 1)):
                    c += 1
            if c % 2 != p[i]:
                f = False
                break
        if f:
            ans += 1
    print(ans)

main()

Measured memory_bytes: 3064
#include <iostream>
#include <queue>

using namespace std;

int changes[6]{500,100,50,10,5,1};

int main() {
	int a;
	while(true) {
		cin >> a;
		if(a==0) break;

		int oturi = 1000-a;

		int ans = 0;

		for(int i = 0; i < 6; i++) {
			int coin = changes[i];
			while(oturi-coin>=0) {
				oturi -= coin;
				ans++;
			}
		}

		cout << ans << endl;
	}
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    ans += i;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int i,n,a[100],b[100],cnt=1,l=0,k=0,cnt2=0;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d %d",&a[i],&b[i]);
	for(i=0;i<n;i++){
		if(a[i]==b[i]){
			cnt2++;
			if(cnt2==1) l=i;
			else{
				if(l+1==i){
					l=i;
					cnt++;
				}
			}
			if(cnt==3) k=1;
		}
		else{
			cnt=1;
			cnt2=0;
		}
	}
	if(k==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

sx,sy,tx,ty = map(int, input().split())

res = []

for _ in range(sx,tx):
    res.append("R")
for _ in range(sy,ty):
    res.append("U")
for _ in range(sx,tx):
    res.append("L")
for _ in range(sy,ty):
    res.append("D")
res.append("D")
for _ in range(sx,tx):
    res.append("R")
res.append("R")
for _ in range(sy,ty):
    res.append("U")
res.append("ULU")
for _ in range(sx,tx):
    res.append("L")
res.append("L")
for _ in range(sy,ty):
    res.append("D")
res.append("DR")

print("".join(res))


Measured memory_bytes: 3188
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
const int INF = 1001001001;
const ll LINF = 1e18;
const ll mod = 1e9 + 7;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}


int main() {
    ll N, H, W;
    cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
    return 0;
}



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

const int N = 22;
const ll mod = 1e9 + 7;
int n, dp[N][1 << N], a[N][N];

int solve(int m, int w)
{
	if (m == n)
	{
		if (w == 0)
			return 1;
		return 0;
	}
	if (dp[m][w] != -1)
		return dp[m][w];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		bool okay = ((((1 << i) & w) == 0) ? 0 : 1);
		if (okay && a[m][i])
			ans = (ans + solve(m + 1, (1 << i) ^ w)) % mod;
	}
	return dp[m][w] = ans;
}

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

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> a[i][j];
		}
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(0, ((1 << n) - 1));

	return 0;
}

Measured memory_bytes: 360704
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 1100

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, c[MAX], con[MAX] = {};
	int Q, t, x, d;
	
	cin>>N;
	
	for(int i = 1; i <= N; i++){
		cin>>c[i];
	}
	
	cin>>Q;
	
	for(int i = 0; i < Q; i++){
		cin>>t>>x>>d;
		
		con[x] += d*(t==1?1:-1);

		if(con[x] < 0 || con[x] > c[x]){
			cout<<x<<endl;
			return 0;
		}
	}
	
	cout<<0<<endl;
	
	
	return 0;
}


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

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

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read()[0];
    let mut a: Vec<usize> = read();
    a.sort();
    a.reverse();
    let mut ans = 1;
    for i in 0..n / 2 {
        if a[i * 2] != a[i * 2 + 1] || a[i * 2] != n - i * 2 - 1 {
            ans = 0;
            break;
        }
        ans = ans * 2 % 1_000_000_007;
    }
    if n % 2 == 1 && a[n - 1] != 0 {
        ans = 0;
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
N = int(input())
s_list = [int(input()) for i in range(N)]
s_list.sort()
s = 0
for j in range(N):
    s += s_list[j]

for k in range(N):
    if s%10 != 0:
        break
    elif s_list[k]%10 != 0:
        s -= s_list[k]
        break
    elif k == N-1:
        s = 0
        break
print(s)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int X, A, B;
    cin >> X >> A >> B;
    if (0 >= B - A) cout << "delicious";
    else {
        if (X >= B - A) cout << "safe";
        else cout << "dangerous";
    }

    cout << endl;

    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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 (b<a) { a=b; return 1; } return 0; }

int main() {
	int K,T;
	cin >> K >> T;
	vector<int> A(T);
	rep(i,T) cin >> A[i];
	sort(A.begin(),A.end(),greater<int>());
	int acc = 0;
	for(int i=1; i<T; i++) acc+=A[i];
	int ans = max(0, A[0]-acc-1);
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 2e5 + 100;

void solve() {
    int n;
    cin >> n;
    if (n % 10 == 7) {
        cout << "Yes";
        return;
    }
    n /= 10;
    if (n % 10 == 7) {
        cout << "Yes";
        return;
    }

    n /= 10;
    if (n % 10 == 7) {
        cout << "Yes";
        return;
    }

    cout << "No";
}

#else

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        cout << "Case #" << (i++)  << ":} ";
        solve();
        cout << endl;
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

Measured memory_bytes: 3656
import math



    
    
def isPrime(x):
        if x==2:
            return True
            
        if x<2 or x%2==0:
            return False
        a=int(math.sqrt(x))
        for i in range(3,a+1,2):
            if x%i==0:
                return False
            i+=2
        return True
    
x=int(input())
ans=0
for i in range(x):
    ans+=int(isPrime(int(input())))
    
print(ans)


Measured memory_bytes: 5672
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    xs = na()
    for i in range(5):
        if xs[i] == 0:
            print(i+1)
            return
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 61708
import heapq

n, m = map(int, input().split())
dic = {}
for i in range(n):
    ai, bi = map(int, input().split())
    if ai in dic:
        dic[ai].append(bi)
    else:
        dic[ai] = [bi]

for key in dic.keys():
    dic[key] = sorted(dic[key])

ans = 0
hp = []
heapq.heapify(hp)
for i in range(1, m+1):
    if i in dic:
        heapq.heappush(hp, (-dic[i].pop(), i))
    if hp != []:
        maxi = heapq.heappop(hp)
        ans += -maxi[0]
        if dic[maxi[1]] != []:
            heapq.heappush(hp, (-dic[maxi[1]].pop(), maxi[1]))
print(ans)

Measured memory_bytes: 26292
def cs(n, p, c):
    global count, m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(cs(n - c[0], p + 1, c), cs(n, p, c[1:]))
    else:
        return cs(n, p, c[1:])

n, m = map(int, input().split())
c = list(map(int, input().split()))
c.sort(reverse = True)
count = n
print(cs(n, 0, c))


Measured memory_bytes: 5604
N = int(input())
list_A = list(map(int, input().split()))

list_Ai = []
for i in range(N):
    list_Ai.append((list_A[i], i + 1))
list_Ai.sort()

list_i = []
for i in list_Ai:
    list_i.append(str(i[1]))

print(" ".join(list_i))


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

int64_t Q=1000000007;

int64_t jyo(int64_t x,int64_t y){
  int64_t H=y; //ここから
       int64_t a=1,b=0,c=1;
       while(H>0){
         a*=2;
         if(H%a!=0){
           H-=a/2;
           int64_t d=x;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      } //ここまで
  return c;
}



int main() {
  int N;
  cin>>N;
  int64_t M=0,Z=0;
  for(int i=0;i<N;i++){
    int64_t a;
    cin>>a;
    Z+=(Q*Q-a*a);
    Z%=Q;
    M+=a;
    M%=Q;
  }
  Z+=((M*M)%Q);
  Z%=Q;
  Z*=jyo(2,Q-2);
  Z%=Q;
  cout<<Z<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void)
{
   int a, b, i;

   scanf("%d%d",&a,&b);

   if(a<b)
      for(i=0;i<b;i++)
         printf("%d",a);

   else
      for(i=0;i<a;i++)
         printf("%d",b);

   printf("\n");
   return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
  int n,m,c;
  scanf("%d %d %d ",&n,&m,&c);
  int a[n][m];
  int b[m];
  for (int i=0;i<m;i++) {
    scanf("%d ",b+i);
  }
  for (int i=0;i<n;i++) {
    for (int j=0;j<m;j++) {
      scanf("%d ",&a[i][j]);
    }
  }
  int ans = 0;
  long buf;
  
  for (int i=0; i<n; i++) {
    buf = c;
    for (int j=0; j<m; j++) {
      buf += a[i][j] * b[j];
    }
    if (buf>0) ans++;
  }
  printf("%d\n", ans++);
  return 0;
}
  

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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);
        ECommonSubsequence solver = new ECommonSubsequence();
        solver.solve(1, in, out);
        out.close();
    }

    static class ECommonSubsequence {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] s = new int[n + 1];
            int[] t = new int[m + 1];
            s[0] = 0;
            t[0] = 0;
            ModInt[][] sum = new ModInt[n + 1][m + 1];
            ModInt[][] dp = new ModInt[n + 1][m + 1];

            for (int i = 1; i <= n; i++) {
                s[i] = in.nextInt();
            }

            for (int i = 1; i <= m; i++) {
                t[i] = in.nextInt();
            }

            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= m; j++) {
                    if (i == 0 || j == 0) {
                        sum[i][j] = new ModInt(0);
                    } else {
                        sum[i][j] = sum[i - 1][j].add(sum[i][j - 1]).sub(sum[i - 1][j - 1]);
                        if (s[i] == t[j]) {
                            sum[i][j] = sum[i][j].add(sum[i - 1][j - 1]).add(1);
                        }
                    }
                }
            }


            out.println(sum[n][m].getVal() + 1);
        }

    }

    static class ModInt {
        long val;
        int MOD = (int) 1e9 + 7;

        public ModInt(long i) {
            this.val = (i + MOD) % MOD;
        }

        public ModInt add(long l) {
            return new ModInt(this.val + l);
        }

        public ModInt add(ModInt m) {
            return new ModInt(this.val + m.getVal());
        }

        public ModInt sub(ModInt m) {
            return new ModInt(this.val - m.getVal());
        }

        public long getVal() {
            return val;
        }

        public String toString() {
            return Long.toString(val);
        }

    }
}



Measured memory_bytes: 200060
N = int(input())
s = [0]*N
t = [0]*N
for i in range(0,N):
    s[i],t[i] = input().split()
    t[i] = int(t[i])
X = input()

total = 0
for i in range(N-1,-1,-1):
    if s[i] == X:
        break
    total += t[i]
print(total)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
#define             ll  long long
#define            ull  unsigned long long
#define            P_B  push_back
#define            M_P  make_pair
#define         DBG(x)  printf("%s %d\n", #x, x)
#define       DBGLL(x)  printf("%s %lld\n", #x, x)
#define         SCI(x)  scanf("%d",&x)
#define         SCD(x)  scanf("%lf",&x)
#define         SCS(x)  scanf("%s",x)
#define         CLR(x)  memset(x, 0, sizeof(x))
#define        CLRN(x)  memset(x, -1, sizeof(x))
#define        SCLL(x)  scanf("%lld", &x)
#define      FOR(i, n)  for(int i = 0; i < n; i++)
#define  FORR(i, m, n)  for(int i = m; i < n; i++)
#define     SCI2(m, n)  scanf("%d%d", &m, &n)
#define  SCI3(m, n, o)  scanf("%d%d%d",&m, &n, &o)
#define     SCD2(m, n)  scanf("%lf%lf",&m,&n)
#define  SCD3(m, n, o)  scanf("%lf%lf%lf",&m,&n,&o)
#define    SCLL2(m, n)  scanf("%lld%lld", &m, &n)
#define SCLL3(m, n, o)  scanf("%lld%lld%lld",&m, &n, &o)
#define             vi  vector<int>
#define            vii  vector<pair<int, int> >
#define            vll  vector<pair<ll, ll> >
#define            Mod  998244353
#define            INF  1000000000
 
int n;
int w[105][2];
int m;
int dp[105];
int fl[105];

int main()
{
	CLR(fl);	
	int hudai = SCI2(n, m);
	FOR(i, n)hudai = SCI2(w[i][0], w[i][1]);
	int x[1000005];
	CLRN(x);
	FOR(i, n){
		for(int j = 1000000; j > 0; j--){
			if(x[j] != -1){
				if(x[j] + w[i][0] <= m){
					if(x[j + w[i][1]] != -1)
						x[j + w[i][1]] = min(x[j] + w[i][0], x[j+w[i][1]]);
					else
						x[j + w[i][1]] = x[j] + w[i][0];
				}
			}
		}
		if(w[i][0] <= m){
			if(x[w[i][1]] != -1)x[w[i][1]] = min(x[w[i][1]], w[i][0]);
			else x[w[i][1]] = w[i][0];
		}
	}
	int y = 0;
	for(int i = 1000000; i >= 0; i--) 
		if(x[i] > 0){
			y = i;
			break;	
		}
	printf("%d\n", y);
}

Measured memory_bytes: 4096
import sys

readline = sys.stdin.buffer.readline

N = int(readline())
XY = []
for i in range(N):
    a = int(readline())
    XY.append(tuple(tuple(map(int, readline().split())) for _ in range(a)))


# 正直者の人数を返す(矛盾　-> -1)
def honest():
    num = 0
    for i in range(N):
        if bit>>i & 1:
            for x, y in XY[i]:
                x -= 1
                if bit>>x & 1 != y:
                    return -1
            num += 1
    return num


max_honest = 0
for bit in range(2 ** N):
    max_honest = max(max_honest, honest())
print(max_honest)


Measured memory_bytes: 44636
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  s.append(list(map(int, input().split())))
  
sdictlist = []
sdictlistsorted = []
for i in range(D):
  onedict = {}
  for j in range(26):
    onedict[j] = s[i][j]
  sdictlist.append(onedict)
  onesorteddict = sorted(onedict.items(), key=lambda x:x[1], reverse=True)
  sdictlistsorted.append(onesorteddict)

cignorelen = 3
csorted = sorted(c)
csorted = csorted[:cignorelen]
ignorelist = []
for i in range(26):
  if(c[i] in csorted):
    ignorelist.append(i+1)
    
lenpastmax = 20 #26まで設定できる
#26 -> 145419
#25 -> 18657778
#24 -> 40796238
#23 -> 54875726
#22 -> 63195752
#21 -> 66843963
#20 -> 67734290, ign=5 -> 3733319, ign=3 -> 
pastlist = []
for i in range(D):
  j = 0
  while(sdictlistsorted[i][j][0] in pastlist or sdictlistsorted[i][j][0]+1 in ignorelist):
    j += 1
  print(sdictlistsorted[i][j][0]+1)
  pastlist.append(sdictlistsorted[i][j][0])
  if(len(pastlist)==lenpastmax):
    pastlist.pop(0)

Measured memory_bytes: 10324
#include<bits/stdc++.h>
using namespace std;
 
int main(){

    string s;
    cin >> s;


    for(int i = 0; s.length() > i; ++i){
        if(s[i] == '9'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,t,mx,cnt,mn=(1ll<<30);
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>t;
    for(ll i=0,a;i<n;i++){
        cin>>a;
        mn=min(mn,a);
        if(a-mn>mx)mx=a-mn,cnt=1;
        else if(a-mn==mx)cnt++;
    }
    cout<<cnt;
}



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

struct Kruskal{

  struct UnionFind{
    Int n;
    vector<Int> r,p;
    UnionFind(){}
    UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
    Int find(Int x){
      return (x==p[x]?x:p[x]=find(p[x]));
    }
    bool same(Int x,Int y){
      return find(x)==find(y);
    }
    void unite(Int x,Int y){
      x=find(x);y=find(y);
      if(x==y) return;
      if(r[x]<r[y]) swap(x,y);
      r[x]+=r[y];
      p[y]=x;
    }
  };
  
  struct edge{
    Int from,to;
    double cost;
    Int used;
    char color;
    edge(){}
    edge(Int from,Int to,double cost,char color):
      from(from),to(to),cost(cost),used(0),color(color){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  Int n;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(Int sz):n(sz){}
  
  Int build(Int k=-1){
    sort(edges.begin(),edges.end());
    UnionFind uf(n+1);
    double res=0;
    Int cnt=0;
    for(Int i=0;i<(Int)edges.size();i++){
      edge &e=edges[i];
      if(!uf.same(e.from,e.to)){
	e.used=1;
	res+=e.cost;
	uf.unite(e.from,e.to);
	cnt++;
      }
    }
    if(cnt+1!=n) return -1;
    return res;
  }
};

signed main(){
  Int n,m,k;
  while(cin>>n>>m>>k,n){
    Kruskal kr(n);
    auto edges=kr.edges;
    for(Int i=0;i<m;i++){
      Int u,v,w;
      char c;
      cin>>u>>v>>w>>c;
      u--;v--;
      edges.emplace_back(u,v,w,c);
    }
    double ub=1e12,ans;
    auto check=[&](double x){
      x-=ub;
      kr=Kruskal(n);
      for(auto e:edges){
	if(x>0&&e.color=='A') e.cost+=x; 
	if(x<0&&e.color=='B') e.cost-=x; 
	kr.edges.emplace_back(e);
      }
      
      ans=kr.build();
      if(ans<0) return Int(-1);
      if(x>0) ans-=x*k;
      if(x<0) ans+=x*(n-1-k);
      
      Int res=0;
      for(auto e:kr.edges)
	res+=(e.used&&e.color=='A');
      return res;
    };
    double l=0,r=2*ub;
    if(check(l)<k||check(r)>k){
      cout<<-1<<endl;
      continue;
    }
    for(Int i=0;i<2000;i++){
      double m=(l+r)/2;
      if(check(m)>=k) l=m;
      else r=m;
    }
    check(l);
    cout<<(Int)ceil(ans)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3212
import java.util.Scanner;

public class Main {

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

    long cnt = 0;
    for (long i = x - 1; i > 0; i--) {
      cnt = cnt + i;
    }
    System.out.println(cnt);

  }
}


Measured memory_bytes: 21844
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main() {
  int record[4][2] = {0};
  double eye;  

  int i = 0;
  while(cin >> eye) {
    if(eye >= 1.1) record[0][i%2]++;
    else if(eye >= 0.6) record[1][i%2]++;
    else if(eye >= 0.2) record[2][i%2]++;
    else record[3][i%2]++;
    i++;
  }
  REP(i, 4) cout << record[i][0] << ' ' << record[i][1] << endl;
}

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

int main() {
  long long int N, K;
  std::cin >> N >> K;

  if (K == 0) {
    std::cout << N * N << std::endl;
    return 0;
  }

  long long int answer = 0;

  for (int b = K+1; b <= N; b++) {
    const int p = N / b;
    const int r = N % b;

    answer += p * std::max(0LL, b - K);
    answer += std::max(0LL, r - K + 1);
  }

  std::cout << answer << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
using namespace std;
 
int main(){
    
    int A,B;
    cin >> A>>B;

    if(A<=5){
        cout << 0 <<endl;
    }else if(A<=12){
        cout << B/2 <<endl;
    }else{
        cout << B <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
#include <cmath>
#include<unordered_map>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 2000000000000000ll
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  10000000
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){

    int n;
    I(n);
    if(n==3||n==5||n==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
a,b=map(int, input().split())

A = int(a/0.08)
B = int((b+1)/0.1)
l =['-1']

for i in range(A,B+1):
    if int(i*0.08) == a and int(i*0.1) == b:
        l.append(i)
        break
        
print(l[-1])

Measured memory_bytes: 9124
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
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; }



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;


int main() {
	
	int n, m;
	ll ans = 0;
	cin >> n >> m;
	priority_queue<ll> pq;
	rep(n) {
		ll p;
		cin >> p;
		pq.push(p);
	}
	while (m>0) {
		m--;
		ll ue = pq.top();
		pq.pop();
		ue /= 2;
		pq.push(ue);

	}
	while (!pq.empty()) {
		ll ue = pq.top();
		pq.pop();
		ans += ue;
	}
	cout << ans << endl;

	return 0;
}


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

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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<int,int>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
    int N,M;
    cin>>N>>M;
    if(N%2!=0){
        rep(i,M){
            cout<<i+1<<" "<<N-i<<endl;
        }
    }
    else {
        rep(i,M){
            if(N-i-i-1>N/2) cout<<i+1<<" "<<N-i<<endl;
            else cout<<i+1<<" "<<N-i-1<<endl;
        }
    }
}

Measured memory_bytes: 3580
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;
constexpr char newl = '\n';

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define debug(x) cout << #x << ": " << x << '\n';

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int a = C / B;
  if (C % B > 0) a++;
  int b = A / D;
  if (A % D > 0) b++;

  cout << (a <= b ? "Yes" : "No");
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>



int main() {
	long long int x, a, b; std::cin >> x >> a >> b;
	if (b <= a) {
		std::cout << "delicious\n";
	}
	else if (b <= a + x) {
		std::cout << "safe\n";
	}
	else {
		std::cout << "dangerous\n";
	}
}

Measured memory_bytes: 256
xp1, yp1, xp2, yp2 = map(int, input().split())
q = int(input())

r = [xp2 - xp1, yp2 - yp1]

def a(p1,p2):
    s = (p1-xp1,p2-yp1)
    d = r[0] * s[0] + r[1] * s[1]
    a = xp1 + r[0] * d / (r[0]**2 + r[1]**2)
    b = yp1 + r[1] * d / (r[0]**2 + r[1]**2)
    return a,b

for i in range(q):
    x, y = map(int, input().split())
    x2,y2 = a(x, y)
    print(x + 2 * (x2 - x), y + 2 * (y2 - y))

Measured memory_bytes: 7816
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Ki
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int ds[MAX_N], prts[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }

  while (qn--) {
    int p, x;
    scanf("%d%d", &p, &x);
    p--;
    ds[p] += x;
  }

  prts[0] = -1;
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = prts[u],  &du = ds[u];
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (v != up) {
	prts[v] = u;
	ds[v] += du;
	q.push(v);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    printf("%d", ds[i]);
  }
  putchar('\n');
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mem(a,b) memset(a,b,sizeof(a))
#define shutdown ios::sync_with_stdio(false)
#define MAX 10e18+1000
#define INF 0x3f3f3f3f
#define MAR 10e5+100

int main() {
    shutdown;
    LL a,b,d=2;
    cin>>a>>b;
    LL c=pow(d,b);
    cout<<(b*1900+(a-b)*100)*c<<endl;
    return 0;
}



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

int main() {
  int D,G,i,ans=1000;
  cin>>D>>G;
  vector<int> p(D),c(D);
  for(i=0;i<D;i++)cin>>p[i]>>c[i];
  
  for(int tmp=0;tmp<(1<<D);tmp++){
    bitset<10> x(tmp);
    int scr=0,sum=0,m=-1;
    
    for(i=0;i<D;i++){
      if(x.test(i)){
        scr+=100*(i+1)*p[i]+c[i];
        sum+=p[i];
      }else{m=i;}
      if(sum>=ans||scr>=G)break;
    }
    
    if(scr<G&&sum<ans){
      if(scr+p[m]*100*(m+1)>=G){
        sum+=(G-scr+100*m)/(100*(m+1));
        scr=G;
      }
    }
    
    if(scr>=G)ans=min(ans,sum);
    //cout<<sum<<","<<ans<<","<<scr<<endl;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  vector<int> t(n+1),x(n+1),y(n+1);
  t[0]=0;
  x[0]=0;
  y[0]=0;
  for(int i=0; i<n; i++){
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }
  
  string ans = "Yes";
  for(int i=0; i<n; i++){
    int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if ((dist>t[i+1]-t[i])||((abs(dist-t[i+1]+t[i])%2)==1)){
      ans = "No";
      break;
    }
  }
  cout<< ans  <<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> L(2*N);
    for(int i=0; i<2*N; i++){
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans=0;
    for(int i=0; i<N; i++){
        ans+=L[2*i];
    }
    cout << ans;
}

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

int main() {
    // cout << "------------------" << endl;

    int n;
    cin >> n;

    vector<int> t(n + 1), x(n + 1), y(n + 1);
    rep(i, n) {
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }

    bool flg = true;
    rep(i, n) {
        int div = t[i + 1] - t[i] - abs(x[i + 1] - x[i]) - abs(y[i + 1] - y[i]);
// cout << "i: " << i << ", div: " << div << endl;
        if (div < 0) {
            flg = false;
            break;
        }

        if (div % 2 != 0) {
            flg = false;
            break;
        }
    }

    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4576
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

template<class T>
void print(vector<T>v){
	ll size=v.size();
	for(int i=0;i<size;i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
}



int main(){
    init();
	ll n,m;cin>>n>>m;
	vector<pair<ll,ll>>v;
	for(int i=0;i<n;i++){
		ll a,b;cin>>a>>b;
		v.push_back(make_pair(a,b));
	}
	sort(v.begin(),v.end());

	ll i=0;
	ll ans=0;
	ll sum=0;
	while(sum<m){
		if(m-sum<v[i].second)ans+=v[i].first*(m-sum);
		else ans+=v[i].first*v[i].second;
		sum+=v[i].second;
		i++;
		//cout<<sum<<" "<<ans<<endl;
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 2420
s = input()
K = int(input())

from heapq import heappush, heappop

Q = set()
u = set()
N = len(s)
for i in range(N):
    for j in range(i+1, i+K+1):
        ss = s[i:j]
        if ss in u:
            continue
        u.add(ss)
        Q.add(ss)
        if len(Q) > K:
            Q.remove(max(Q))
l = sorted(Q)
print(l[K-1])


Measured memory_bytes: 42332
#include <bits/stdc++.h>  
using namespace std;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
using graph =vector<vector<int>>;
using ll = long long int;
/*
ll lucas(ll n){
  if(n==0){return 2;}
  if(n==1){return 1;}
  return lucas(n-1)+lucas(n-2);
}
*/
int  main(){
  ll n;cin>>n;
  ll a=2,b=1,c;
  
  if(n==1)cout<<b;
  else{
    rep(i,n-1){c=a+b;a=b;b=c;}
    cout<<c;
  }
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n;
    ll idx = 1;
    while (true) {
        if (pow(idx, 2) <= n) idx++;
        else break;
    }

    idx--;
    MSG(fixed << setprecision(0) << pow(idx, 2));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;

int nCrevenoroddfinder(int n,int r)
{
    int a=r;
    int b=n-r;
    for(int i=0;i<30;i++)
    {
        int x=1<<i;
        if((x&a)&&(x&b))
        {
            return 0;//even
        }
    }
    return 1;//odd
}

ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}
vil v[200009];
  bool vis[200009];
    ll cp=INT_MIN;
void ans(ll s,ll &h){
      vis[s]=true;
      for(auto x:v[s]){
            if(!vis[x]) h++,ans(x,h);
      }
}void dfs(int n){
      memset(vis,false,sizeof(vis));
      ll cnt=0;
      for(int i=1;i<=n;i++){
            if(!vis[i]){
                  ll h=0;
                  ans(i,h);
                  cp=max(cp,1+h);
            }
      }
     
}

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n,m;
  cin>>n>>m;
  ll cnt=0;
  for(int i=0;i<m;i++){
        ll x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
  }
 dfs(n);
  cout<<cp;
  
 // cout<<res;
}



  

Measured memory_bytes: 24172
import itertools
n,m=map(int,input().split())
G=[[0]*n for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  G[a-1][b-1]=1
  G[b-1][a-1]=1
S=""
for i in range(1,n):
  S=S+str(i)
ans=0
for x in itertools.permutations(S):
  a=0
  if G[0][int(x[0])]==0:
    a=1
  for i in range(n-2):
    if G[int(x[i])][int(x[i+1])]==0:
      a=1
  if a==0:
    ans=ans+1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(void){
    int h, w;
    int h_ans, w_ans;
    int l;
    int l1 = 22500;
    int i, j;


    while(1){
        scanf("%d",&h);
        scanf("%d",&w);
        if(h==0 && w==0){
            break;
        }

        l = h * h + w * w;

        for(i=1;i<=150;i++){
            for(j=i+1;j<=150;j++){
                if(l == i * i + j * j && i > h){
                    h_ans = i;
                    w_ans = j;
                    goto loopend;
                }

                else if(l < i * i + j * j && i * i + j * j < l1){
                    l1 = i * i + j * j;
                    h_ans = i;
                    w_ans = j;
                }
            }
        }
        loopend:

        printf("%d %d\n",h_ans,w_ans);

        l1 = 22500;

    }

    return 0;
}


Measured memory_bytes: 2052
#include<iostream>
#include<math.h>
#include<stdio.h>
#define M_PI 3.14159265358979 /* 円周率 */

using namespace std;

int main(){
	int len, deg;
	int deg_now = 90;
	double x = 0, y = 0;

	while (1){
		scanf("%d,%d", &len, &deg);
		if (len == 0 && deg == 0) break;
		x += len*cos(deg_now* M_PI / 180);
		y += len*sin(deg_now* M_PI / 180);
		deg_now -= deg;
	}

	cout << (int)x << endl << (int)y << endl;

	return 0;

}

Measured memory_bytes: 1212
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	string s = in<string>();
	reverse(ALL(s));
	do {
		if (s.front() == 'm') {
			if (s.length() < 5 || s.substr(0, 5) != "maerd") {
				cout << "NO" << endl;
				return 0;
			} else {
				s = s.substr(5);
			}
		} else if (s.front() == 'e') {
			if (s.length() < 5 || s.substr(0, 5) != "esare") {
				cout << "NO" << endl;
				return 0;
			} else {
				s = s.substr(5);
			}
		} else if (s.front() == 'r') {
			if (s.length() < 3) {
				cout << "NO" << endl;
				return 0;
			} else {
				if (s[2] == 'm') {
					if (s.length() < 7 || s.substr(0, 7) != "remaerd") {
						cout << "NO" << endl;
						return 0;
					} else {
						s = s.substr(7);
					}
				} else if (s[2] == 's') {
					if (s.length() < 6 || s.substr(0, 6) != "resare") {
						cout << "NO" << endl;
						return 0;
					} else {
						s = s.substr(6);
					}
				} else {
					cout << "NO" << endl;
					return 0;
				}
			}
		}
	} while (s.length() > 0);
	cout << "YES" << endl;
}

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

int main() {
	int H, W;
	while(true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
		cout << endl;
		}
	cout << endl;
	}
	return 0;	
}


Measured memory_bytes: 3108
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.nextLine());
		
		String[] nico = sc.nextLine().split(" ");
		
		long[] maki = new long[n];
		for (int i = 0; i < n; i++) {
			maki[i] = Long.parseLong(nico[i]);
		}
		
		long total = 0;
		
		while (true) {
			Arrays.sort(maki);
			long count = 0;
			
			if (maki[n - 1] > (n - 1)) {
				count = maki[n - 1] / n;
				maki[n - 1] = maki[n - 1] % n;
				
				total = total + count;
			} else {
				break;
			}
			
			for (int i = 1; i < n; i++) {
				int index = n - i - 1;
				
				maki[index] = maki[index] + count;
			}
		}
		System.out.println(total);
	}
}

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

typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



ll solve(){
    
    ll a; cin >> a;
    string b; cin >> b;
    int n = b.length();
    int x = 0;
    for(int i = 0; i < n; i++){
        if(b[i] == '.'){
            continue;
        }
        x = x*10 + (b[i] - '0');
    }
    a = a * x / 100;
    return a;
}


int main(){
	boost;
	int t = 1;
// 	cin >> t;
	
	while(t--){
		cout << solve() << '\n';
	}
	
	return 0;
}

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

using namespace std;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {

ll n;cin >> n;
ll h[n];
for (int i = 0; i < n; ++i)
{
    cin >> h[i];
}

ll dp[n];dp[0]= 0;dp[1]=h[1]-h[0];
if(h[1]-h[0]<0) dp[1] = h[0]-h[1];

for (int i = 2; i < n; ++i)
{
    int sub1=h[i]-h[i-1];
    int sub2=h[i]-h[i-2];
    if (h[i]-h[i-1]<0) sub1=-h[i]+h[i-1];
    if (h[i]-h[i-2]<0) sub2=-h[i]+h[i-2];
    
    //cout << sub1 << sub2 << "\n";
    if(dp[i-1]+sub1<dp[i-2]+sub2) dp[i] = dp[i-1]+sub1;
    else dp[i] = dp[i-2]+sub2;
   // cout << i<<" "<<dp[i]<<"\n";
}

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

}




Measured memory_bytes: 1792
#include <iostream>
#include <string.h>
#include<string>
using namespace std;
int main()
{
	int n;
	string s;
	cin >> n >> s;
	int count = 0;
	for (int i = 0; i < n - 2; i++)
	{
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
		{
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    if 500*i > x:
        break
    for j in range(b+1):
        if 500*i + 100*j > x:
            break
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

Measured memory_bytes: 3064