akhauriyash/Code-Regression huggingface dataset:
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);
int pri[mxN];
void factorization(int n){
    for(int i=2;i*i<=n;i++){
        while(n%i==0)
            pri[i]++,n/=i;
    }
    if(n>1)pri[n]++;
}
int cnt(int num){
    int ret=0;
    for(auto x:pri)
        ret+=(x>=num-1);
    return ret;
}
void solve(){
    int n;
    cin>>n;
    loop(n+1,i,2)
        factorization(i);
    cout<<cnt(75)+cnt(15)*(cnt(5)-1)+cnt(25)*(cnt(3)-1)+cnt(5)*(cnt(5)-1)*(cnt(3)-2)/2<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 3660
package main

import "fmt"

func main() {
	var n, m, c int
	fmt.Scan(&n, &m, &c)
	b := make([]int, m)
	for i := range b {
		fmt.Scan(&b[i])
	}
	a := make([][]int, n)
	for i := range a {
		tmp := make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scan(&tmp[j])
		}
		a[i] = tmp
	}

	cnt := 0
	for i := range a {
		sum := 0
		for j := range a[i] {
			sum += a[i][j] * b[j]
		}
		if sum+c > 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(void){
	string s;
	cin>>s;
	s[5]=' ';
	s[13]=' ';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int i = sc.nextInt();
		String s = sc.next();

		if (s.length() > i) {
			System.out.println(s.substring(0, i) + "...");
		} else {
			System.out.println(s);
		}
	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

Measured memory_bytes: 36520
let n, l = Scanf.scanf " %d %d" @@ fun a b -> a, b
let base = n * (2 * l + n - 1) / 2
let d = ref max_int
let ans = ref 0
let _ =
  for i = 1 to n do
    let v = l + i - 1 in
    if !d > abs @@ base - (base - v) then (d := abs @@ base - (base - v); ans := base - v) done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;

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

    ll x;
    cin >> x;
    cout << x*x;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    long long int n,d;
    cin>>n>>d;
    d*=d;
    long long int ans=0;
    while(n--){
        long long int x,y;
        cin>>x>>y;
        if(x*x+y*y<=d) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut ans = 0;
    for _ in 0..n {
        let l: usize = read();
        let r: usize = read();
        ans += r - l + 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a = c - a; b = d - b;
	swap(a, b);
	for (int e = 0; e < a; e++)cout << 'U';
	for (int e = 0; e < b; e++)cout << 'R';
	for (int e = 0; e < a; e++)cout << 'D';
	for (int e = 0; e < b; e++)cout << 'L';
	cout << 'L';
	for (int e = 0; e <= a; e++)cout << 'U';
	for (int e = 0; e <= b; e++)cout << 'R';
	cout << 'D';
	cout << 'R';
	for (int e = 0; e <= a; e++)cout << 'D';
	for (int e = 0; e <= b; e++)cout << 'L';
	cout << 'U';
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {

	int N; cin >> N;
	V<int> h(N);
	REP(i,N) cin >> h[i];
	int ans = *min_element(ALL(h));
	REP(i,N) h[i] -= ans;
	while(accumulate(ALL(h),0)){
		int flg = 1;
		for(int i = 0; i < N && flg; ++i){
			if(h[i]){
				for(int j = i; j < N && h[j];++j) h[j]--;
				ans++;
				flg = 0;
			}
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
S=input()
T=input()

s_len =len(S)
t_len =len(T)

flg=False

if s_len >= t_len:
    for head in range(len(S)-t_len,-1,-1):
        flg=True
        for s,t in zip(S[head:head+t_len],T):
            if not(s==t or "?"==s):
                flg=False
        if flg:
            break


if flg:
    S=list(S)
    S[head:head+t_len] = T
    S="".join(S)
    S=S.replace("?","a")
    print(S)
else:
    print("UNRESTORABLE")

Measured memory_bytes: 38256
// Aizu Vol-3 0318: Secret Investigation
// 2017.8.25

#include <stdio.h>

#define A 1
#define B 2
#define C 4
int p[103];

int main()
{
	int N, i, k, x;

	scanf("%d", &N);
	for (i = 1; i <= N; i++) p[i] = 0;
	scanf("%d", &k); for (i = 0; i < k; i++) scanf("%d", &x), p[x] |= A;
	scanf("%d", &k); for (i = 0; i < k; i++) scanf("%d", &x), p[x] |= B;
	scanf("%d", &k); for (i = 0; i < k; i++) scanf("%d", &x), p[x] |= C;
	for (k = 0, i = 1; i <= N; i++)
		if ((!(p[i] & A) || (p[i] & B)) && (p[i] & C)) k++;
	printf("%d\n", k);
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

const int mod = 1000000007;

int n, k;
int A[100];
int dp[100001];


int main(){
  int i, j;
  scanf("%d%d", &n, &k);
  for(i=0;i<n;i++) scanf("%d", A+i);
  dp[0] = 1;
  for(i=0;i<n;i++){
    int sum[100001];
    sum[0] = 0;
    for(j=0;j<=A[i];j++){
      sum[j+1] = sum[j]+dp[j];
      if(sum[j+1] >= mod) sum[j+1] -= mod;
      dp[j] = sum[j+1];
    }
    for(;j<=k;j++){
      sum[j+1] = sum[j]+dp[j];
      if(sum[j+1] >= mod) sum[j+1] -= mod;
      dp[j] = sum[j+1]-sum[j-A[i]];
      if(dp[j]<0) dp[j] += mod;
    }

  }
  printf("%d\n", dp[k]);

  return 0;
}


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


static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];


void floyd() {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (d[i][k] == INFTY) continue;
            for (int j = 0; j < n; j++) {
                if (d[k][j] == INFTY) continue;
                d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main()
{
    //E: number of edges, U, V: start vertex, target vertex
    int E, U, V, cost;
    std::cin >> n >> E;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            d[i][j] = ((i == j) ? 0 : INFTY);
        }
    }


    for (int i = 0; i < E; i++) {
        std::cin >> U >> V >> cost;
        d[U][V] = cost;
    }

    floyd();
    bool isNegativeCycle = false;
    for (int i = 0; i < n; i++)
        if (d[i][i] < 0) isNegativeCycle = true;
    if (isNegativeCycle) {
        std::cout << "NEGATIVE CYCLE" << std::endl;
    } else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j) std::cout << " ";
                if (d[i][j] == INFTY) std::cout << "INF";
                else std::cout << d[i][j];
            }
            std::cout << std::endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3200
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	char class_[9][20];
	int a, b, fee[9], kazu[9];
	for (int i = 0; i < 9; i++){
		cin >> class_[i];
		cin >> a >> b;
		kazu[i] = a + b;
		fee[i] = a * 200 + b * 300;
 	}
	for (int i = 0; i < 8; i++){
		cout << class_[i] << " " << kazu[i] << " " << fee[i] << endl;
	}
	cout << class_[8] << " " << kazu[8] << " " << fee[8] << endl;
	return 0;
}

Measured memory_bytes: 1168
# ABC 129, c
n, m = map(int, input().split())
dp = [0 for i in range(n+1)]
dp[0] = 1
dp[1] = 1
for j in [int(input()) for j in range(m)]:
    dp[j] = -1
for i in range(n + 1):
    if i < 2:
        if dp[i] == -1:
            dp[i] = 0
    else:
        if dp[i] == -1:
            dp[i] = 0
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
print(dp[n])


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

int	main(void)
{
	int a, b, c, n;
	int answer = 0;
	cin >> a >> b >> c >> n;

	if (a >= n)
	{
		cout << n << endl;
	}
	else
	{
		answer += a;
		n -= a;
		if (b >= n)
		{
			cout << answer << endl;
		}
		else
		{
			n  -= b;
			cout << (answer - n) << endl;
		}
	}

	return (0);
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define fore(i, b, e)      for(int i = b; i < e; i++)
#define forr(i, b, e)      for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define F first
#define S second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef pair<int, ii>  iii;
typedef vector<int>     vi;

typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double PI = acos(-1);
const double EPS = 1e-9;
#define tam 1234567
ll minn=1e13;
ll get(ll a,ll b)
{
    if (a==0|| b==0)
        return -minn;
    if (a<b)
        return get(b,a);
    minn=min(minn,a);
    minn=min(minn,b);
    return ll(a/b)*b*2+get(a-ll(a/b)*b,b);

}
int main()
{
    ll n,x;
    cin>>n>>x;
    
    
        cout<<get(n-x,x)+n<<endl;
    
}
// PLUS ULTRA!

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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<int, int> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll h, w;
  cin >> h >> w;

  vvll a(h, vll(w));
  rep(y, h) {
    rep(x, w) {
      cin >> a[y][x];
    }
  }

  rep(y, h) {
    rep(x, w) {
      ll tmp;
      cin >> tmp;
      a[y][x] = abs(a[y][x] - tmp);
    }
  }

  const int max_val = 80 * (h + w);
  using vvvi = vector<vvi>;
  vvvi dp(h, vvi(w, vi(max_val + 1)));

  using vvb = vector<vb>;
  vvb visited(h, vb(w));

  queue<P> que;
  dp[0][0][a[0][0]] = 1;
  que.emplace(0, 1);
  que.emplace(1, 0);

  while (!que.empty()) {
    auto q = que.front();
    que.pop();
    int x = q.first;
    int y = q.second;

    if (x > 0) {
      for (int i = 0; i <= max_val; i++) {
        dp[y][x][i + a[y][x]] |= dp[y][x - 1][i];
        dp[y][x][abs(i - a[y][x])] |= dp[y][x - 1][i];
      }
    }
    if (y > 0) {
      for (int i = 0; i <= max_val; i++) {
        dp[y][x][i + a[y][x]] |= dp[y - 1][x][i];
        dp[y][x][abs(i - a[y][x])] |= dp[y - 1][x][i];
      }
    }

    if (y < h - 1) {
      if (!visited[y + 1][x]) {
        visited[y + 1][x] = true;
        que.emplace(x, y + 1);
      }
    }

    if (x < w - 1) {
      if (!visited[y][x + 1]) {
        visited[y][x + 1] = true;
        que.emplace(x + 1, y);
      }
    }
  }

  int ans = 123456;
  for (int i = 0; i <= max_val; i++) {
    if (dp[h - 1][w - 1][i]) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 324736
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,m;
    int a[1020], b[1024] = {};
    cin>>n>>m;
    for(int i = 0;i < n;i++){
        cin>>a[i];
    }
    for(int i = 0;i < m;i++){
        int x;
        cin>>x;
        for(int j = 0;j < n;j++){
            if(a[j] <= x){
                b[j]++;
                break;
            }
        }
    }
    int best = -1, ans = 0;
    for(int i = 0;i < m;i++){
        if(best < b[i]){
            best = b[i];
            ans = i;
        }
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,count=0;
  cin>>n;
  int a[n];
  for(int i =0;i<n;i++){
    cin>>a[i];
    
    if(a[i]%2==1&&i%2==0)
    count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(a+b > c+d) cout << "Left" << endl;
  if(a+b < c+d) cout << "Right" << endl;
  if(a+b == c+d) cout << "Balanced" << endl;

 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
char s[200];
int count,out=0;
scanf("%s",s);
for(count=0;;){
  if(s[count]=='\0'){break;}

      if(s[count]=='R'||s[count]=='D'||s[count]=='U'){}
      else{out++;}
count++;
if(s[count]=='\0'){break;}
      if(s[count]=='L'||s[count]=='D'||s[count]=='U'){}
      else{out++;}
      count++;
}
if(out==0){printf("Yes");}
else{printf("No");}

return 0;

}

Measured memory_bytes: 128
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define int ll 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
int n,dp[mxN],a[mxN],k ;
void solve(){
  cin >> n >>  k;
  For(i,n)
    cin >> a[i];
  mems(dp,0x3f) ;dp[0]=0;
  for(int i=1;i<k;i++)
    for(int j=0;j<i;++j)
      dp[i]=min(abs(a[i]-a[j])+dp[j],dp[i]) ;
  for(int i=k;i<n;i++) 
    for(int j=i-k;j<i;++j)  
      dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]) ;
  cout << dp[n-1] << endl ;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (long long i = x; i < n; i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
// using ll = long long;
typedef long long ll;

int main() {
    ll n;
    ll x;
    vector<ll> resVec;
    bool isLoop = true;

    while (isLoop) {
        cin >> n >> x;
        if (n == 0 && x == 0) {
            isLoop = false;
        } else {
            ll res = 0;
            arep(i, 1, n + 1) {
                arep(j, i + 1, n + 1) {
                    arep(k, j + 1, n + 1) {
                        ll sum = i + j + k;

                        if (sum == x) {
                            res++;
                        }
                    }
                }
            }

            // resVec.push_back(res);
            cout << res << endl;
        }
    }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

namespace mymod {
    constexpr ll modulus = 1000000007LL;

    ll add(ll a, ll b);

    ll sub(ll a, ll b);

    ll mul(ll a, ll b);

    ll power(ll a, ll b);

    ll div(ll a, ll b);
}

ll mymod::add(ll a, ll b){return (a + b) % modulus;}
ll mymod::sub(ll a, ll b){return (a + modulus - b) % modulus;}
ll mymod::mul(ll a, ll b){return ((a % modulus) * (b % modulus)) % modulus;}
ll mymod::power(ll a, ll b){
    if (b == 0) return 1;
    else if (b == 1) return a % modulus;
    else if (b % 2 == 0){ll p = power(a, b / 2); return p * p % modulus;}
    else return a * power(a, b-1) % modulus;
}
ll mymod::div(ll a, ll b){return mul(a, power(b, modulus-2));}

ll hoge(vector<ll> ls){
    ll k{ls.size()};
    vector<ll> d(k-1, k-2);
    if (k == 1){return ls.at(0);}

    for (auto &&i: boost::irange(0LL, k-2)){
        d.at(i+1) = d.at(i) - 2;
    }
    vector<ll> r(k, k);
    for (auto &&i: boost::irange(0LL, k-1)){
        r.at(i+1) = mymod::add(r.at(i), d.at(i));
    }
    for (auto &&i: boost::irange(0LL, k)){
        ls.at(i) = mymod::mul(ls.at(i), r.at(i));
    }
    ll ret{0};
    for (auto &&i: boost::irange(0LL, k)){
        ret = mymod::add(ret, ls.at(i));
    }
    return ret;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> xs(n, 0), ys(m, 0);
    for (auto && i: boost::irange(0LL, n)){
        cin >> xs.at(i);
    }
    for (auto && i: boost::irange(0LL, m)){
        cin >> ys.at(i);
    }
    vector<ll> d_xs(n-1, 0), d_ys(m-1, 0);
    for (auto &&i: boost::irange(0LL, n-1)){
        d_xs.at(i) = xs.at(i+1) - xs.at(i);
    }
    for (auto &&i: boost::irange(0LL, m-1)){
        d_ys.at(i) = ys.at(i+1) - ys.at(i);
    }

    cout << mymod::mul(hoge(d_xs), hoge(d_ys));
    return 0;
}

Measured memory_bytes: 6496
while True:
    a, op, b = input().split()
    if op == "?":
        break
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()

int main() 
{    ll a,b;
    cin>>a>>b;
    cout<<a*b /(__gcd(a,b))<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long int a,b,i,kotae=0;
  cin>>a>>b;
  if(b-a<4){
    for(i=a;i<=b;i++){
      kotae=kotae^i;
    }
    cout<<kotae;
    return 0;
  }
  for(i=a;i<=((a/4)*4)+3;i++){
    kotae=kotae^i;
  }
  for(i=b;i>=(b/4)*4;i--){
    kotae=kotae^i;
  }
  cout<<kotae;
}


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

using namespace std;

long long n;

int main() {
	cin >> n;
	if(n & 1) {
		puts("0");
	} else {
		long long ans = 0;
		while(n) {
			ans += n / 10;
			n /= 5;
		}
		cout << ans << endl;
	}
	return 0;
}

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

const static int Max = 100;

int bubblesort(int* A, int N) {
	int flag = 1;
	int times = 0;

	while (flag) {
		flag = 0;
		for (int i = N-1; i>0; --i) {
			if (A[i] < A[i - 1]) {
				int v = A[i];
				A[i] = A[i - 1];
				A[i - 1] = v;
				++times;
				flag = 1;

			}
		}
	}

	return times;
}

void show(int* A, int N) {
	for (int i = 0; i < N; ++i) {
		if (i > 0) { cout << ' '; }
		cout << A[i];
	}
	cout << endl;
}

int main() {
	int N;
	int A[Max];

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

	int times = bubblesort(A, N);

	show(A, N);
	cout << times << endl;

	
}


Measured memory_bytes: 3096
class Problem
  attr_accessor :a, :b, :c, :n, :m, :h, :w, :x, :y, :ans
  def initialize
    @n = gets.to_s.to_i
  end

  def solve
    puts calc == 0 ? 0 : 1000 - calc
  end

  def calc
    n % 1000
  end
end

pb = Problem.new
pb.solve

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

#define F first
#define S second
#define ll long long
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()

using namespace std;

typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> pii;
typedef vector<int> vi;

int n;

string s;

map<char,int> x;

string al;

main(){
	for(char c = 'A'; c <= 'Z'; c++){
		al += c;
		x[c] = c - 'A';
	}
	for(char c = 'A'; c <= 'Z'; c++) al += c;
	cin >> n >> s;
	for(int i = 0; i < s.size(); i++){
		s[i] = al[x[s[i]] + n]; 
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<math.h>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
int main(){
  int n,l,sum=0;
  cin>>n>>l;
  int left=l,right=l+n-1,eat;
  if(right<=0)
    eat=right;
  else if(left>=0)
    eat=left;
  else
    eat=0;
  int ans=(l+right)*(right-l+1)/2-eat;
  cout<<ans;
  //cout<<maxi;
  return 0;
}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N, L;
    cin >> N >> L;

    ll sum = 0;
    ll l;
    ll m = INF, k = INF;
    REP(i,0,N) {
        l = L + i;
        sum += l;
        if(m > abs(l)) {
            m = abs(l);
            k = l;
        }
    }
    _PR(sum-k);
    return 0;
}

/*



*/

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

using namespace std;

void func(int &y, int &m, int &d){
  d++;
  if(y%3==0){
    if(d>20)m++,d=1;
  }
  else if(m%2==1){
    if(d>20)m++,d=1;
  }
  else if(d>19)m++,d=1;
  
  if(m>10)y++,m=1;    
}

int main(void){

  int n;
  cin >> n;
  while(n--){
    int y,m,d;
    cin >> y >> m >> d;
    int ans=0;
    while(!(y==1000 && m==1 && d==1)){
      func(y,m,d);
      ans++;
    }
    cout << ans << endl;
  }
  
  return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;

    int ans = a-b*2;
    if(ans < 0) ans = 0;
    cout << ans << endl;;
    return 0;
}

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

int main() {
	bool cards[4][14];
	int n, rank;
	char suit;

	//二次元配列の初期化
	for (int s = 0; s < 4; s++) {
		for (int r = 1; r <= 13; r++) {
			cards[s][r] = 0;
		}
	}
	
	//入力ゾーン
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> suit >> rank;
		if (suit == 'S') cards[0][rank] = 1;
		if (suit == 'H') cards[1][rank] = 1;
		if (suit == 'C') cards[2][rank] = 1;
		if (suit == 'D') cards[3][rank] = 1;
	}

	//足りないカードを出力
	for (int s = 0; s < 4; s++) {
		for (int r = 1; r <= 13; r++) {
			if (cards[s][r]) continue;
			if (s == 0) suit = 'S';
			if (s == 1) suit = 'H';
			if (s == 2) suit = 'C';
			if (s == 3) suit = 'D';
			cout << suit << " " << r <<endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3096
/*
{

AuThOr Gwj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int main(){
	fastio;
	string s;
	cin>>s;
	LL sum=0;
	rep(i,s.length()){
		sum+=s[i]^48;
	}
	cout<<(sum%9? "No":"Yes");
	return 0;
}



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

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n;
		long  power=1;
		n=s.nextInt();
		for(int i=1;i<=n;i++) {
			power=(power*i)%(1000000007);
		}
		System.out.println(power);

	}

}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	int n,m;
	cin>>n>>m;
	int a[n];
    int sum=0;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<m;i++)sum+=a[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3616
memo =[1]*(10**5+1)
memo[0]=0
memo[1]=0
for i in range(2,len(memo)):
    if memo[i]==0:
        continue
    else:
        for j in range(i*2,len(memo),i):
            memo[j]=0
memo_like2017 = [0]*(10**5+1)
for i in range(3,len(memo),2):
    if memo[i]==1 and memo[(i+1)//2] ==1:
        memo_like2017[i]=1
sum_memo=[0]*(10**5+1)
for i in range(1,len(memo)):
    sum_memo[i] = sum_memo[i-1]+memo_like2017[i]

Q = int(input())
for _ in range(Q):
    l,r = map(int,input().split())
    print(sum_memo[r]-sum_memo[l-1])


Measured memory_bytes: 13004
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

int dfs(vector<vector<int>>& to, vector<bool> visited, int s = 0) {
  visited[s] = true;
  if (!EXIST(visited, false)) return 1;
  int ret = 0;
  for (auto& v : to[s]) {
    if (visited[v]) continue;
    ret += dfs(to, visited, v);
  }
  return ret;
}

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n, vector<int>());
  rep(i, m) {
    int a, b; cin >> a >> b; a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vector<bool> visited(n, false);
  int ans = dfs(to, visited);
  cout << ans << endl;

  return 0;
}


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

int main() {
    long long N,W;
    cin >> N >> W;
    vector<long long>w(N+1,0);
    vector<long long>v(N+1,0);
    
    for(long long i=1;i<=N;i++){
        cin >> w[i] >> v[i];
    }
    
    vector<vector<long long>>dp(N+1, vector<long long>(W+1, 0));
    
    for(long long i=1;i<=N;i++){
        for(long long j=1;j<=W;j++){
            if(w[i] > j){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
            }
        }
    }
    
    cout << dp[N][W]<< endl;
	return 0;
}


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

int main() {
    int n,k;
    cin >> n >> k ;
    vector<int> x(n);
    for (int i=0;i<n;i++){
        cin >>x.at(i);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
    int tmp = min(x[i],k-x[i]);
    ans += tmp;
    }
    cout <<ans*2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



int main(void){
    int x,k;
    cin>>k>>x;
    if(500*k>=x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

ull N;

int main(void) {

    ull big = powl(10, 18);

    cin >> N;

    ull ans = 1;

    vecull a;
    rep(i, N) {
        ull n;
        cin >> n;
        a.emplace_back(n);
        if (n == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    rep(i, N) {
        if (a[i] == 1) {
            continue;
        }

        ll pre = ans;
        ans *= a[i];
        if (pre > ans || ans > big) {
        cout << -1 << endl;
        return 0;
        }
    }

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


Measured memory_bytes: 4320
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	int n;
	int sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if (i%15==0)
		sum+=600;
		
		else
		sum+=800;
	}
	cout<<sum;	
	return 0;
}

Measured memory_bytes: 256
import copy
import sys
from collections import deque
H, W = map(int,input().split())
C = list(map(lambda x: int(x) - 1, input().split()))
D = list(map(lambda x: int(x) - 1, input().split()))
S = [input() for _ in range(H)]
check_visited = [[False] * W for _ in range(H)]
dq = deque([[0, C[0], C[1]]])
while dq:
   d, i, j = dq.popleft()
   if [i, j] == D:
      print(d)
      exit()
   if check_visited[i][j]:
      continue
   check_visited[i][j] = True
   for move_h, move_w in [[-1,0], [1,0], [0,-1], [0,1]]:
      new_i = i + move_h
      new_j = j + move_w
      if 0 <= new_i <= H-1 and 0 <= new_j <= W-1 and S[new_i][new_j] == '.' and (not check_visited[new_i][new_j]) :
         dq.appendleft([d, new_i, new_j])
   for move_h in range(-2, 3):
      for move_w in range(-2, 3):
         if [move_h, move_w] == [0, 0]:
            continue
         new_i = i + move_h
         new_j = j + move_w
         if 0 <= new_i <= H-1 and 0 <= new_j <= W-1 and S[new_i][new_j] == '.' and (not check_visited[new_i][new_j]) :
            dq.append([d+1, new_i, new_j])
print(-1)
#コードに関しては, sotanishyさんのコードを参考にした.
#writing this, I referred to Mr.sotanishy's submitted code.

Measured memory_bytes: 236524
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var m = int.Parse(Console.ReadLine());
 
            if(m >= 3)
            {
                Console.WriteLine(m / 3);
            }
            else
            {
                Console.WriteLine(0);
            }
                
 
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main {
    public static void main(String args []) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer>  A = new ArrayList<>();
        ArrayList<Integer> B = new ArrayList<>();
        ArrayList<Integer> C = new ArrayList<>();
        int N = sc.nextInt();
        for(int i=0;i<N;i++) A.add(sc.nextInt());
        for(int i=0;i<N;i++) B.add(sc.nextInt());
        for(int i=0;i<N-1;i++) C.add(sc.nextInt());
        int opt = 0;
        for(int i=0;i<N;i++){
            int now = A.get(i);
            opt += B.get(now-1);
            if(i!=N-1&&now==A.get(i+1)-1) opt+=C.get(now-1);
        }
        System.out.println(opt);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }
};


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

    //友達集合を作る
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }

    //最大の友達集合を求める
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, UF.size(i));
    }

    cout << ans << endl;
}

Measured memory_bytes: 4048
import collections

N = int(input())

A = list(map(int, input().split()))

A_count = collections.Counter(A)

Q = int(input())

total = sum(A)

for i in range(Q):
    B, C = map(int, input().split())
    total += C * A_count[B]
    total -= A_count[B] * B

    A_count[C] += A_count[B]
    A_count[B] = 0

    print(total)

Measured memory_bytes: 88972
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
void solve()
{
	ll n;
	cin>>n;
	ll a;
	vector<pll> v;
	rep(i,1,n+1)
	{
		cin>>a;
		v.pb(mp(a,i));
	}
	sort(all(v));
	rep(i,0,n)
	{
		cout<<v[i].sec<<" ";
	}
}
int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 2544
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        A: usize,
        B: usize,
        M: usize,
        a: [i64; A],
        b: [i64; B],
        xyc: [(usize1, usize1, i64); M],
    }
    let min_a = a.iter().min().unwrap();
    let min_b = b.iter().min().unwrap();
    let mut ans = min_a + min_b;
    for (x, y, c) in xyc {
        ans = min(ans, a[x] + b[y] - c);
    }
    println!("{}", ans);
}

Measured memory_bytes: 14456
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;

int main() {
	ll n,m;
	string s,t;
	cin>>n>>m;
	cin>>s>>t;
	ll a=n,b=m;
	while(1){
		if(a<b){
			ll d=a;
			a=b;
			b=d;
		}
		if(b==0)break;
		a%=b;
	}
	bool ans=false;
	ll x=0,y=0;
	while(1){
		if(x>=n||y>=m)break;
		if(x*(m/a)==y*(n/a)){
			if(s[x]!=t[y])ans=true;
			if(x<n-1)x++;
			else y++;
		}else{
			if(x*(m/a)>y*(n/a))y++;
			else if(x*(m/a)<y*(n/a))x++;
		}
	}
	if(!ans)cout<<(n/a)*m<<endl;
	else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 512
import sys

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

def gcd(a, b):
    while b > 0:
        a %= b
        tmp = b
        b = a
        a = tmp
    return a


(a,b)=na()

print(a // gcd(a,b) * b)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const int P = 998244353;

int Sum(int a, int b) {
    return (a + b) % P;
}

int Mult(int a, int b) {
    return (a * (long long) b) % P;
}

int main () {
    ios_base::sync_with_stdio(0);
//  freopen("_input.txt", "rt", stdin);
//  freopen("_output.txt", "wt", stdout);

    int a1, b1, a2, b2;
    cin >> a1 >> b1 >> a2 >> b2;

    vector<vector<int>> res(a2 + 1, vector<int>(b2 + 1));
    res[a1][b1] = 1;

    for (int i = a1 + 1; i <= a2; ++i) {
        res[i][b1] = Mult(res[i - 1][b1], b1);
    }

    for (int i = b1 + 1; i <= b2; ++i) {
        res[a1][i] = Mult(res[a1][i - 1], a1);
    }

    for (int i = a1 + 1; i <= a2; ++i) {
        for (int j = b1 + 1; j <= b2; ++j) {
            res[i][j] = Sum(Mult(res[i - 1][j], j), Mult(res[i][j - 1], i));
            res[i][j] = Sum(res[i][j], P - Mult(res[i - 1][j - 1], Mult(i - 1, j - 1)));
        }
    }

    cout << res[a2][b2] << "\n";

    return 0;
}


Measured memory_bytes: 38568
#include <bits/stdc++.h>
#include <math.h>
#include <ostream>
#include <stdio.h>
using namespace std;

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


Measured memory_bytes: 3636
//还不是特别懂emm.....
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
const int MAXN=100000;
int a[MAXN+5],deg[MAXN+5],f[MAXN+5];
priority_queue<pair<int,int> > que;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
		scanf("%d",&a[i]),deg[a[i]]++;
	for(int i=1;i<=n;i++)
		if(!deg[i])
			que.push(make_pair(0,i));
	while(!que.empty())
	{
		int x=que.top().second;
		que.pop();
		f[a[x]]=max(f[a[x]],f[x])+1;
		deg[a[x]]--;
		if(!deg[a[x]])
			que.push(make_pair(-f[a[x]],a[x]));
	}
	printf("%d\n",f[1]);
	return 0;
}
/*
如果我们把打败关系看成一棵树的话，显然每次我们要选择一个叶节点和它的父亲比赛然后把它删掉。 
设f[x]表示以x为根的子树最少比赛多少场后只剩下x。 
假设我们删掉一个叶节点lea，其父亲为fa，那么有f[fa]=max(f[fa],f[lea])+1。 
为了使f[1]尽量小，显然我们应该每次找f最小的叶子删掉。 
用一个堆来维护叶子即可。
*/

Measured memory_bytes: 1912