akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;

  map<int, int> mp;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    mp[a] = b;
  }

  int dp[110][10] = {};
  for (int i = 1; i <= 3; i++) {
    if (mp[1] > 0 && i != mp[1]) continue;
    dp[1][i] = 1;
  }
  for (int i = 1; i <= 3; i++) {
    if (mp[2] > 0 && i != mp[2]) continue;
    for (int j = 1; j <= 3; j++) {
      dp[2][i] += dp[1][j];
    }
  }

  const int mod = 10000;
  for (int i = 3; i <= n; i++) {
    for (int j = 1; j <= 3; j++) {
      if (mp[i] > 0 && j != mp[i]) continue;
      for (int k = 1; k <= 3; k++) {
        if (k == j) continue;
        dp[i][j] += dp[i - 1][k];
        dp[i][j] %= mod;
        if (!dp[i - 1][j]) continue;
        dp[i][j] += dp[i - 2][k];
        dp[i][j] %= mod;
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= 3; i++) {
    ans += dp[n][i];
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3056
#!/usr/local/bin/python3
# coding: utf-8

ha = input()
kita = ha.split(" ")
x = int(kita[0])
y = int(kita[1])
ifAshi = False

if(x == 1):
    if(y == 2 or y == 4):
        ifAshi = True
if(x*2 == y):
    ifAshi = True
for i in range(x):
        
    if((y - 2*i)%4 == 0):
        if((x-i) == ((y - 2*i)/4)):
            ifAshi = True

if(ifAshi):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n;
    cin >> n;
    vector<int> h(n);
    vector<int> dp(n);  // cost up to stone i
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    dp[0] = 0;
    for (int x = 1; x < n; x++) {
        dp[x] = 1e9 + 1;
        if (x - 1 >= 0) {
            dp[x] = min(dp[x], dp[x - 1] + abs(h[x] - h[x - 1]));
        }
        if (x - 2 >= 0) {
            dp[x] = min(dp[x], dp[x - 2] + abs(h[x] - h[x - 2]));
        }
    }
    // for (int i = 0; i < n; i++) {
    cout << dp[n - 1] << endl;
    // }
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	a := make([]int, n)
	parity := 0
	for i := range a {
		a[i] = readInt()
		if a[i] < 0 {
			parity = 1 - parity
			a[i] = -a[i]
		}
	}
	sort.Ints(a)
	var ans int64
	for i := range a {
		if i == 0 && parity == 1 {
			ans -= int64(a[i])
		} else {
			ans += int64(a[i])
		}
	}
	println(ans)
}

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


Measured memory_bytes: 3072
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax=1e5;
int N;
ll K, A[Nmax];

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> A[i];

	ll ans=0, x=0;
	for(int k=60; k>=0; k--){
		ll t = 1L<<k;
		int b=0;
		for(int i=0; i<N; i++){
			if((A[i]&t)) b++;
		}
		if(b < N-b && (t+x) <= K){
			x+=t;
			ans+=(N-b)*t;
		} else {
			ans+=b*t;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Goods = Tuple!(long, "w", long, "v");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto b = aryread();
    b = b[0] ~ b ~ b[$ - 1];
    long ans;
    foreach(i; iota(n))
    {
        ans += min(b[i], b[i + 1]);
    }
    ans.writeln();
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main() {
  //input
  int N;
  cin >> N;
  int h[N];
  for(int i=0; i<N; i++){cin>>h[i];}
  string ans = "Yes";
  
  //main
  for(int i=N-1; i>=0; i--){
    if(i == 0) continue;
    else if(h[i-1]-h[i]  > 1){ans = "No";}
    else if(h[i-1]-h[i] == 1){h[i-1] -= 1;}
  }
  
  //output
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int used[nmax], c1[nmax], cnt[nmax], ans[nmax];
vector<int> a[nmax], go[nmax];
int n, k, l, x, y;

void dfs(int v, int color) {
	used[v] = true;
	go[color].pb(v);
	for (int u : a[v]) {
		if (!used[u]) {
			dfs(u, color);
		}
	}
}

void dfsa(int v, int color) {
	used[v] = true;
	c1[v] = color;
	for (int u : a[v]) {
		if (!used[u]) {
			dfsa(u, color);
		}
	}
}

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	cin >> n >> k >> l;
	for (int i = 0; i < k; i++) {
		scanf("%d%d", &x, &y);
		x--, y--;
		a[x].pb(y);
		a[y].pb(x);
	}
	int top = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			dfs(i, top);
			top++;
		}
	}
	for (int i = 0; i < n; i++) {
		a[i].clear();
		used[i] = false;
	}
	for (int i = 0; i < l; i++) {
		scanf("%d%d", &x, &y);
		x--, y--;
		a[x].pb(y);
		a[y].pb(x);
	}
	int topa = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			dfsa(i, topa);
			topa++;
		}
	}
	for (int i = 0; i < top; i++) {
		for (int u : go[i]) {
			cnt[c1[u]]++;
		}
		for (int u : go[i]) {
			ans[u] += cnt[c1[u]];
		}
		for (int u : go[i]) {
			cnt[c1[u]]--;
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d ", ans[i]);
	}
	return 0;
}



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

using namespace std;

int main() {
	long n;
	long long sum = 0;
	cin >> n;
	
	for (long i = 1; i <= n; ++i) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}
	
	cout << sum;
	
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r)
{
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++)
    {
        if (A[j] <= x)
        {
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    return i + 1;
}

int main()
{
    int i, q;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &A[i]);

    q = partition(0, n - 1);

    for (i = 0; i < n; i++)
    {
        if (i)
            printf(" ");
        if (i == q)
            printf("[");
        printf("%d", A[i]);
        if (i == q)
            printf("]");
    }
    printf("\n");
    return 0;
}


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

int main(){
  int n=0;
  int d=0;
  int x=0;
  int ans=0;
  cin >> n >> d >> x;
  int a[n];
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  for(int i=0;i<n;++i){
    ans += ((d-1)/a[i])+1;
  }
  cout << ans+x << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

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

	ll L, R;
	cin >> L >> R;

	ll ans = 2019LL;
	for(ll i = L; i <= min(R, L + 2019LL); i++){
		for(ll j = i+1 ; j <= min(R, L + 2019LL); j++){
			ans = min(ans, (i * j) % 2019LL);
		}
	}

	cout << ans << endl;
}


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

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a + b) / 2 << endl;
}



Measured memory_bytes: 3104
fun main(args: Array<String>) = yorukatsu16a()

fun yorukatsu16a() {
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val xList = readLine()!!.split(' ').map { it.toInt() }

    val answer = xList.map { Math.min(Math.abs(it - k), it) }.sum() * 2

    println(answer)
}


Measured memory_bytes: 38128
/**
*    author:  boutarou
*    created: 28.08.2020 09:36:31
**/

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

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

ll a[512][512];
ll b[512][512];
ll INF = 1LL << 60;
struct Edge {
  int src, dest;
  ll weight;
};

inline bool operator<(const Edge& a, const Edge& b) {
  return (a.weight < b.weight);
}
inline bool operator>(const Edge& a, const Edge& b) {
  return b < a;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main() {
  int N; cin>>N;
  priority_queue <Edge, vector<Edge>, less<Edge> > q;
  for(int i = 0; i < N; i++) 
        for(int j = 0; j < N; j++) {
          cin>>a[i][j];
          b[i][j] = a[i][j];
          if(i < j) q.push((Edge){i,j,a[i][j]});
        }
  while (! q.empty()) {
        Edge e = q.top(); q.pop();
        for(int via = 0; via < N; via++) {
          if(via == e.src || via == e.dest) continue;
          if (b[e.src][via] + b[via][e.dest] < b[e.src][e.dest]) {
                cout << -1 << endl;
                return 0;
          }
          if (b[e.src][via] + b[via][e.dest] == b[e.src][e.dest]) {
                b[e.src][e.dest] = INF;
                b[e.dest][e.src] = INF;
                break;
          }
        }
  }
  ll ans = 0;
  for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
          //      cout << b[i][j] << " ";
          if(b[i][j] < INF) ans += b[i][j];
        }
        //      cout << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4340
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int N, M;
    io.read(N, M);
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(M);
    vector<int> d(M);
    for(int i = 0; i < N; i++){
        io.read(a[i], b[i]);
    }
    for(int i = 0; i < M; i++){
        io.read(c[i], d[i]);
    }
    for(int i = 0; i < N; i++){
        int dist = abs(a[i] - c[0]) + abs(b[i] - d[0]);
        int p = 0;
        for(int j = 1; j < M; j++){
            int ndist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(ndist < dist){
                dist = ndist;
                p = j;
            }
        }
        cout << p + 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
def main():
	N = int(input())
	L = list(map(int, input().split()))
	L.sort()

	ans = 0

	for i in range(N - 2):
		for j in range(i + 1, N - 1):
			for k in range(j + 1, N):
				if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
					if L[i] + L[j] > L[k]:
						ans += 1

	print(ans)

 
if __name__ == "__main__":
  	main()

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

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

  in(string, s);
  in(int, k);
  V<string> sub;
  rep(i, s.size()) rep(j, 5) if (i + j < s.size()) {
    sub.push_back(s.substr(i, j + 1));
  }
  sort(all(sub));
  unique(all(sub));
  out(sub[k - 1]);
}


Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
const int N=100005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 
 
 int go(int n)
 {
	 int x=0;
	 for(int i=2;i<=n;i++)
	 {
		 while(n%i==0)
		 {
			 x++;
			 n=n/i;
		 }
	 }
	 return x;
	}
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/







char c;
cin>>c;
if(isupper(c))
cout<<"A";
else
cout<<"a";
}




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

void printArray(int A[], int N)
{
    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i != N - 1) {
            cout << ' ';
        }
    }
    cout << endl;
}

int bubbleSort(int A[], int N)
{
    int sw = 0;
    bool flag = 1;

    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    int A[100], N, i, sw;
    cin >> N;
    for (i = 0; i < N; i++) {
        cin >> A[i];
    }

    sw = bubbleSort(A, N);

    printArray(A, N);
    cout << sw << endl;
    return 0;
}

Measured memory_bytes: 3104
//defalt
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;


signed main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>=22) cout << "bust" << endl;
  else cout << "win" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
#define N 4011
using namespace std;
int fa[N],vist[N],indexx[N],tot,ans,que[N],d[N],n,m,used[N],Mark[N];
set<int> V[N];
set<int>::iterator it;
struct point{
	int sx,sy,x,y,sit;
	void init(int k){
		scanf("%d%d",&x,&y);
		sx=x,sy=y;
		V[x].insert(k);
		V[y].insert(k);
	}
	void tranc(int u,int v){
		if(x==u) x=v;
		if(y==u) y=v;
	}
}P[N];
struct apple{
	int v,nxt;
}edge[N*4];
void addedge(int x,int y){
	edge[++tot].v=y;
	edge[tot].nxt=indexx[x];
	indexx[x]=tot;
}
int dfs(int u,int fa,int t1,int t2){
	int ret=0;
	if(u==t1) ret++;
	if(u==t2) ret++;
	int t=indexx[u],vv;
	while(t){
		vv=edge[t].v;
		if(vv!=fa){
			int k=dfs(vv,u,t1,t2);
			ret+=k;
			if(k==2) Mark[(t+1)/2]=1;
		}
		t=edge[t].nxt;
	}
	return ret;
}
void solve(){
	int head=0,tail=0;
	for(int i=1;i<=n;i++){
		if(d[i]==1) que[++tail]=i;
	}
	while(head<tail){
		int u=que[++head];
		used[u]=1;
		int t=indexx[u],vv,flag=1;
		while(t){
			vv=edge[t].v;
			if(!used[vv]){
				flag=0;
				break;
			}
			t=edge[t].nxt;
		}
		if(flag) break;
		t=(t+1)/2;
		if(Mark[t]) ans+=2;
		d[vv]--;
		if(d[vv]==1) que[++tail]=vv;
		if(!V[u].size()) continue;
		if(V[u].size()==1 || Mark[t]){
			if(!Mark[t]) ans+=1;
			for(it=V[u].begin();it!=V[u].end();it++){
				int k=*it;
				P[k].tranc(u,vv);
				if(P[k].x!=P[k].y) V[vv].insert(k);
				else V[vv].erase(k);
			}
			V[u].clear();
		}
		else{
			ans+=2;
			int x=*V[u].begin();V[u].erase(V[u].begin());
			int y=*V[u].begin();V[u].erase(V[u].begin());
			if(P[x].y==u) P[x].sit^=1,swap(P[x].x,P[x].y);
			if(P[y].y==u) P[y].sit^=1,swap(P[y].x,P[y].y);
			V[P[x].y].erase(x),V[P[y].y].erase(y);
			P[x].x=P[y].y;fa[y]=x;
			if(P[x].x!=P[x].y) V[P[x].x].insert(x),V[P[x].y].insert(x);
			P[y].sit^=1^P[x].sit;
			dfs(u,0,P[x].x,P[x].y);
			for(it=V[u].begin();it!=V[u].end();it++){
				int k=*it;
				P[k].tranc(u,vv);
				if(P[k].x!=P[k].y) V[vv].insert(k);
				else V[vv].erase(k);
			}
		}
	}
}
int Find(int u){
	if(!fa[u]) return P[u].sit;
	if(vist[u]) return P[u].sit;
	vist[u]=1;
	P[u].sit^=Find(fa[u]);
	return P[u].sit;
}
int main(){
	int x,y;
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		d[x]++,d[y]++;
		addedge(x,y);
		addedge(y,x);
	}
	for(int i=1;i<=m;i++){
		P[i].init(i);
	}
	solve();
	printf("%d\n",ans);
	for(int i=1;i<=m;i++){
		Find(i);
		if(P[i].sit) swap(P[i].sx,P[i].sy);
		printf("%d %d\n",P[i].sx,P[i].sy);
	}
	return 0;
} 

Measured memory_bytes: 4404
use proconio::{fastout, input};
use proconio::marker::Usize1;
use std::cmp::max;

#[allow(unused_macros)]
macro_rules! multi_vec {
    ( $elem:expr; $num:expr ) => (vec![$elem; $num]);
    ( $elem:expr; $num:expr, $($rest:expr),* ) => (vec![multi_vec![$elem; $($rest),*]; $num]);
}

#[allow(unused_macros)]
macro_rules! chmax {
    ($a:expr, $b:expr) => {$a = std::cmp::max($a, $b)}
}

#[allow(unused_macros)]
macro_rules! chmin {
    ($a:expr, $b:expr) => {$a = std::cmp::min($a, $b)}
}

#[fastout]
fn main() {
    input! {
        r: usize,
        c: usize,
        k: usize,
        items: [(Usize1, Usize1, i64); k],
    }

    let mut board = multi_vec![0; r, c];
    for item in items {
        let (i, j, v) = item;
        board[i][j] = v;
    }

    let mut dp = multi_vec![0i64; r, c, 4];
    dp[0][0][1] = board[0][0];
    for i in 0..r {
        for j in 0..c {
            // 拾わない
            for k in 0..=3 {
                if j + 1 < c {
                    chmax!(dp[i][j + 1][k], dp[i][j][k]);
                }
                if i + 1 < r {
                    chmax!(dp[i + 1][j][0], dp[i][j][k]);
                }
            }
            // 拾う
            for k in 0..=3 {
                if j + 1 < c && k + 1 <= 3 {
                    chmax!(dp[i][j + 1][k + 1], dp[i][j][k] + board[i][j + 1]);
                }
                if i + 1 < r {
                    chmax!(dp[i + 1][j][1], dp[i][j][k] + board[i + 1][j]);
                }
            }
        }
    }

    let mut ans = 0;
    for k in 0..=3 {
        chmax!(ans, dp[r - 1][c - 1][k]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 708448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
 
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2);

int main()
{
  int N,M;cin>>N>>M;
  vector<int> L(M+1);
  vector<int> R(M+1);
  
  int l,r;
  for (int i=1;i<=M;i++)
  {
    cin>>L[i]>>R[i];
    if (i==1)
    {
      l = L[i];
      r = R[i];
    }
    else
    {
      if (l<=L[i]) l=L[i];
      if (R[i]<=r) r=R[i];
    }
  }
  
  if (r-l+1<0) cout<<0<<endl; 
  else{
  	cout<<r-l+1<<endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int A[5], min_com=10, ans=0;
    for(auto &a:A){
        a=read();
        ans+=a/10;
        int com=a%10;
        if(com!=0){
            ans+=1;
            min_com = min(min_com, com);
        }
    }
    if(min_com!=10)ans = (ans-1)*10+min_com;
    else ans*=10;
    printf("%d", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
PII num[3030];
LL dp[2020][2020];
int main(){
	int i,j,k,l,a,b,c,d;
	scanf("%d",&a);
    FOR(i, 1, a) scanf("%d",&num[i].x), num[i].y = i;
    sort(num+1, num+1+a, greater< PII >() );
    FOR(i,0,a) FOR(j,0,a) dp[i][j] = -1e16;
    dp[0][0] = 0;
    FOR(i, 1, a){
        FOR(j, 0, i){
            c = a-(i-j)+1;
            if(j) dp[i][j] = max(dp[i][j], dp[i-1][j-1]+(LL)num[i].x*(num[i].y-j));
            if(c) dp[i][j] = max(dp[i][j], dp[i-1][j]+(LL)num[i].x*(c-num[i].y));
        }
    }
    LL ans = 0;
    FOR(i, 0, a) ans = max(ans, dp[a][i]);
    printf("%lld",ans);
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 35428
A, B, K = map(int,input().split())
tmp = 0
Turn = "A"

def processing_A():
    global A,B,Turn,tmp
    tmp = A//2
    A = A//2
    B += tmp
    Turn = "B"
def processing_B():
    global A,B,Turn,tmp
    tmp = B//2
    B = B//2
    A += tmp
    Turn = "A"

for i in range(K):
    if Turn == "A":
        if A % 2 == 1:
            A -= 1
            processing_A()
        else:
            processing_A()
    else:
        if B % 2 == 1:
            B -= 1
            processing_B()
        else:
            processing_B()
print(A,B)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int, int>;

void solve_1() {//14m
	int a, b;
	cin >> a >> b;
	int total;
	int n = 0;
	while (!((a-1)*n + 1 >= b)) {
		n++;
	}
	cout << n << endl;

}

void solve_2() {//30m
	int n;
	cin >> n;
	vector<int> x;
	int total = 0;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
		total += tmp;
	}
	int p1 = (double(total)/double(n)*2 - 1.0) / 2;
	int p2 = (double(total)/double(n)*2 - 1.0) / 2 + 1;
	int point_sum1 = 0, point_sum2= 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;

}

void solve_2re() {
	int n;
	cin >> n;
	vector<int> x(n);
	int total = 0;
	rep(i, n) {
		cin >> x[i];
		total += x[i];
	}
	int p1 = total / n;
	int p2 = total / n + 1;
	int point_sum1 = 0, point_sum2 = 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;
}

void solve_3() {//17m
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int sum = a + b;
	rep(i, n) {
		if (s[i] == 'a') {
			cout << (sum > 0 ? "Yes" : "No") << endl;
			if (sum>0) {
				sum--;
			}
		}
		else if (s[i] == 'b') {
			cout << (sum > 0 && b > 0 ? "Yes" : "No") << endl;
			if (sum > 0 && b > 0) {
				if (b>0) {
					sum--;
					b--;
				}
				else {
					sum--;
				}
			}
		}
		else if (s[i] == 'c') {
			cout << "No" << endl;
		}
	}
}

void solve_4() {//7m
	int n;
	cin >> n;
	rep(i, 50000) {
		if (int(i*1.08) == n) {
			cout << i;
			return;
		}
	}
	cout << ":(";
}

void solve_4re() {
	int n;
	cin >> n;
	int x = ceil(n/ 1.08);
	if (int(x*1.08)==n) {
		cout << x;
	}
	else
	{
		cout << ":(";
	}
}

void solve_5() {
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	int score;
	int count = 0;
	rep(i, m) cin >> b[i];
	rep(i, n) {
		score = c;
		rep(i, m) {
			int a;
			cin >> a;
			score += b[i] * a;
		}
		if (score>0) {
			count++;
		}
	}
	cout << count;

}

void solve_6() {

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//solve_1();
	//solve_2();
	//solve_2re();
	//solve_3();
	//solve_4re();
	solve_5();
	//solve_6();
	return 0;
}

Measured memory_bytes: 256
// 2020-08-31 20:07:47
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const int V = 200020, inf = 1e9;
vector<P> G[V];  // to, d
int xs[V];
bool visited[V];
bool dfs(int u, int x) {
  if (visited[u]) return xs[u] == x;
  visited[u] = true;
  xs[u] = x;
  for (auto [v, d] : G[u]) {
    if (!dfs(v, xs[u] + d)) return false;
  }
  return true;
}
void answer() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].emplace_back(b, c);
    G[b].emplace_back(a, -c);
  }
  rep(i, n) {
    if (visited[i]) continue;
    if (!dfs(i, 0)) {
      cout << "No" << '\n';
      return;
    }
  }
  cout << "Yes" << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 17836
p = 10**9+7
N,K = map(int,input().split())
a = (((N+1)*(N+2))//2)%p
a = (a*(N+1))%p
b = (((K-1)*K)//2)%p
b = (b*(N+1))%p
c = (((N+1)*(N+2)*(2*N+3))//6)%p
d = (((K-1)*K*(2*K-1))//6)%p
e = (N-K+2)%p
ans = (a-b-c+d+e)%p
print(ans)

Measured memory_bytes: 61956
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,int> P;
vector<P> itv;
bool ap[100000];
int max(int a,int b){return a>b?a:b;}
int main(){
	int n,k;
	int i,j;
	while(1){
	bool white=false;
	scanf("%d %d",&n,&k);
	if(n==0)return 0;
	itv.clear();
	for(i=0;i<n;i++)ap[i]=false;
	for(i=0;i<k;i++){
		int x;
		scanf("%d",&x);
		if(x==0)white=true;
		else ap[x-1]=true;
	}
	for(i=0;i<n;i++){
		if(ap[i]){
			int s=i;
			while(i<n&&ap[i])i++;
			i--;
			itv.push_back(P(s,i));
		}
	}
	int ans=0;
	if(white){
		for(i=0;i<itv.size();i++){
			int len=itv[i].second-itv[i].first+1;
			if(i<itv.size()-1&&itv[i].second+2==itv[i+1].first){
				int nlen=itv[i+1].second-itv[i+1].first+1;
				ans=max(ans,len+nlen+1);
			}
			ans=max(ans,len+1);
		}
	}
	else{
		for(i=0;i<itv.size();i++)ans=max(ans,itv[i].second-itv[i].first+1);
	}
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 1268
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
    int n, m, a, b;
    cin >> n >> m;
    vector<vector<int>> G(n+1);
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> ans(n+1, -1);
    queue<int> q;
    q.push(1);
    ans[1] = 1;
    while(q.empty() != true){
        int v = q.front();
        q.pop();
        for(int x : G[v]){
            if(ans[x] == -1){
                q.push(x);
                ans[x] = v;
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 2; i < n+1; i++) cout << ans[i] << endl;
    return 0;
}

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

template <class T>
class SegTree {
    int n;
    vector<T> data;
    T def;
    function<T(T,T)> operation;
    function<T(T,T)> update;

    T _query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return data[k];
        else {
            T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
            T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
            return operation(c1, c2);
        }
    }
  public:
    SegTree(size_t _n, T _def, function<T(T,T)> _operation, function<T(T,T)> _update)
    : def(_def), operation(_operation), update(_update) {
            n = 1;
            while(n < _n) {
                n *= 2;
            }
            data = vector<T>(2*n-1, def);
    }

    void set(int i, T x) {
        data[i+n-1] = x;
    }

    void build() {
        for(int k = n-2; k >= 0; --k) {
            data[k] = operation(data[2*k+1], data[2*k+2]);
        }
    }

    void change(int i, T x) {
        i += n-1;
        data[i] = update(data[i], x);
        while(i > 0) {
            i = (i-1)/2;
            data[i] = operation(data[2*i+1], data[2*i+2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    T operator[](int i) {
        return data[i+n-1];
    }
};

long long gcd(long long a, long long b) {
    return b ? gcd(b, a%b) : a;
}


int main() {
    int n;
    cin >> n;
    SegTree<long long> st(n, 0, [](long long a, long long b) {return gcd(a,b); },
                          [](long long a, long long b) {return b; });
    rep(i,n) {
        int a;
        cin >> a;
        st.set(i,a);
    }
    st.build();
    long long res = 1;
    rep(i,n) {
        long long l = st.query(0,i);
        long long r = st.query(i+1, n);
        res = max(res, gcd(l,r));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5364
from itertools import accumulate
import bisect
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = []
ans = 0
c = 0
for i in range(n):
  d = A[i]-B[i]
  if d > 0:
    C.append(d)
  elif d < 0:
    ans += 1
    c -= d
Q = list(accumulate(sorted(C, reverse=True)))
if c == 0:
  print(0)
elif sum(A) < sum(B):
  print(-1)
else:
  t = bisect.bisect_left(Q, c)
  ans += t+1
  print(ans)

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

using namespace std;

int main() {
	char b;
	cin >> b;
	switch(b){
		case 'A':
			cout << "T\n";
			break;
		case 'T':
			cout << "A\n";
			break;
		case 'C':
			cout << "G\n";
			break;
		case 'G':
			cout << "C\n";
			break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int H, W, M;
    cin >> H >> W >> M;
    int row[H], col[W];
    memset(row, 0, sizeof(row));
    memset(col, 0, sizeof(col));
    set<P> bombs;
    rep(i, M) {
        int h, w;
        cin >> h >> w;
        --h; --w;
        row[h]++; col[w]++;
        bombs.insert(P(h, w));
    }
    int maxRow = *max_element(row, row + H);
    int maxCol = *max_element(col, col + W);
    set<int> stRow, stCol;
    rep(i, H) {
        if (row[i] == maxRow) stRow.insert(i);
    }
    rep(i, W) {
        if (col[i] == maxCol) stCol.insert(i);
    }
    int ans = maxRow + maxCol;
    bool flag = false;
    for (int r : stRow) {
        for (int c : stCol) {
            if (bombs.find(P(r, c)) == bombs.end()) {
                flag = true; break;
            }
        }
        if (flag) break;
    }
    cout << (flag ? ans : ans - 1) << '\n';
    return 0;
}

Measured memory_bytes: 48044
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

struct UnionFind{
    n: usize,
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind{
    fn new(n: usize ) -> UnionFind{
        let mut parent = vec![0; n];
        for i in 0..n {
            parent[i] = i;
        }
        let size = vec![1; n];
        UnionFind{n, parent, size}
    }

    fn root(&mut self, x: usize) -> usize{
        if x == self.parent[x]{
            self.parent[x]
        }else{
            let res = self.root(self.parent[x]);
            self.parent[x] = res;
            self.parent[x]
        }
    }

    fn unite(&mut self, x: usize, y: usize){
        let a = self.root(x);
        let b = self.root(y);
        if a == b{
            return;
        }
        if self.size[a] <= self.size[b]{
            self.parent[b] = a;
            self.size[a] += self.size[b];
        }else{
            self.parent[a] = b;
            self.size[b] += self.size[a];
        }
    }

    fn is_same(&mut self, x: usize, y: usize) -> bool{
        self.root(x) == self.root(y)
    }

    fn get_size(&mut self, x: usize) -> usize{
        let a = self.root(x);
        self.size[a]
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    }
    let mut uf = UnionFind::new(n);

    for i in 0..m{
        let t = ab[i];
        uf.unite(t.0, t.1);
    }
    let mut ans = 0;
    for i in 0..n {
        ans = max(ans, uf.get_size(i));
    }
    let ans = (0..n).map(|i| uf.get_size(i)).max().unwrap();
    println!("{}", ans);
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var abc = new List<int []>();
            for(var i=0;i<N;i++)
            {
                abc.Add(Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray());
            }
            var memo = new List<int[]>();
            for(var i=0;i<N;i++)
            {
                memo.Add(new int[] { 0, 0, 0 });
            }
            Action<List<int>, int, int> chmin =
                (ls, index, val) =>
                {
                    if (val < ls[index]) ls[index] = val;
                };
            Action<List<int[]>, int, int, int> chmax =
                (ls, i1, i2, val) =>
                {
                    if (ls[i1][i2] < val) ls[i1][i2] = val;
                };
            memo[0][0] = abc[0][0];
            memo[0][1] = abc[0][1];
            memo[0][2] = abc[0][2];
            for (var i = 1; i < N; i++)
            {
                for (var j = 0; j < 3; j++)
                {
                    for (var k = 0; k < 3; k++)
                    {
                        if (j == k) continue;
                        chmax(memo, i, j, memo[i - 1][k] + abc[i][j]);
                    }
                }
            }
            var ans = Math.Max(Math.Max(memo[N-1][0], memo[N - 1][1]),memo[N - 1][2]);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 29996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
// map<int,int> mp;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> L(m), R(m);
  REP(i, m) { cin >> L[i] >> R[i]; }

  int LM = 0, RM = 100000;
  for (int i = 0; i < m; i++) {
    LM = max(LM, L[i]);
    RM = min(RM, R[i]);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (LM <= i && i <= RM) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    s_list = list(S)
    dic = {}
    for st in s_list:
        if st in dic:
            dic[st] += 1
        else:
            dic[st] = 1
    is_ok = True
    for key, val in dic.items():
        if val != 2:
            is_ok = False
    if len(dic) != 2:
        is_ok = False
    if is_ok:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n,k; cin>>n>>k;
    if (k>=n){
        cout << 0;
        return 0;
    }
    vi h(n);
    FOR(i,n) cin>>h[i];
    sort(h.begin(),h.end(),greater<int>());
    ll ret=0;
    for(int i=k;i<n;++i) ret+=h[i];
    cout << ret;
    return 0;
}



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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
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; }

// 約数の列挙
vector<ll> divisor(ll n)
{
	vector<ll> res;

	for (ll i = 1; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			res.push_back(i);
			if (i != n / i)
				res.push_back(n / i);
		}
	}

	return res;
}

int main()
{
	ll N;
	vector<ll> factor;

	cin >> N;

	factor = divisor(N);
	sort(factor.begin(), factor.end());

	if (factor.size() % 2 == 0)
		cout << factor[factor.size() / 2] - 1 + factor[factor.size() / 2 - 1] - 1<< endl;
	else
		cout << factor[factor.size() / 2] - 1+ factor[factor.size() / 2] - 1 << endl;

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

#define N 1000000

static int p[ N + 1 ] = { 0 };
static int h[ N + 1 ];
static int c = 0;

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( i = 2; i * i <= N; ++i )
  {
    if ( p[ i ] ) continue ;

    for ( j = i * i; j <= N; j += i )
    {
      p[ j ] = 1;
    }
  }
  for ( i = 3; i <= N; ++i )
  {
    if ( p[ i ] ) continue ;

    h[ c++ ] = i;
  }

  for ( ; ; )
  {
    int res = 0;
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; h[ i ] * 2 <= n; ++i )
    {
      res += !( p[ n - h[ i ] ] );
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
    int A, B, i;
    scanf("%d%d", &A, &B);
    for (i=0; i<10000; i++) {
        if (i*8/100==A && i*10/100==B) {
            printf("%d", i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto& v : a) {
		cin >> v;
	}

	sort(begin(a), end(a));

	map<int, int> mp;
	for (auto v : a) {
		mp[v]++;
	}

	int cardNum = mp.size();
	cout << (cardNum % 2 == 0 ? cardNum - 1 : cardNum) << endl;

	// cardNum - 1
	// 1
	// 1 2 3 7

	// cardNum
	//
	// 1 2 
	// 1 2 3
	return 0;
}


Measured memory_bytes: 5376
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        char [] cs = sc.nextLine().toCharArray();
        for(int i = 0; i < cs.length; i++) {
            if(cs[i] >= 'A' && cs[i] <= 'Z') cs[i] = (char)(cs[i] + 0x20);
            else if(cs[i] >= 'a' && cs[i] <= 'z') cs[i] = (char)(cs[i] - 0x20);
        }
        System.out.println(new String(cs));
    }
}

Measured memory_bytes: 17140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main() {
    int n;
    int x, y;
    while (cin >> n >> x >> y) {
        int ma = min(x, y);
        int mi = max(0, x + y - n);
        cout << ma << ' ' << mi << endl;
    }
}


Measured memory_bytes: 256