akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        left = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]):
            left[i, ] = np.arange(G.shape[1])
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.zeros(G.shape, np.int16)
        for i in range(G.shape[0]): 
            right[i, ] = np.arange(G.shape[1])
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()


Measured memory_bytes: 59408
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] x = new long[N];
        long[] sortedX = new long[N];

        for (int i = 0; i < N; i++) {
            long v = sc.nextLong();
            x[i] = v;
            sortedX[i] = v;
        }
        Arrays.parallelSort(sortedX);

        long highMid = sortedX[N/2];
        long lowMid = sortedX[(N/2) - 1];

        for (int i = 0; i < N; i++) {
            if (x[i] <= lowMid) {
                System.out.println(highMid);
            } else {
                System.out.println(lowMid);
            }
        }
    }
}

Measured memory_bytes: 94264
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){return *(int*)a-*(int*)b;}
int main(){
    int k, n;
    scanf("%d%d",&n,&k);
    int p[n];
    for(int i = 0; i < n; i++)
        scanf("%d",&p[i]);
    qsort(p,n,sizeof(int),cmp);
    int ans = 0;
    for(int i = 0; i < k; i++)
        ans += p[i];
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		int co=0;
		while(n!=1){
			if(n%2)n=n*3+1;
			else n/=2;
			co++;
		}
		cout<<co<<endl;
	}
}

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

struct point{ int x, y, id; };

point init(int pos_x, int pos_y, int index)
{
    point p; 
    p.x = pos_x, p.y = pos_y, p.id = index; 
    return p; 
}

bool cmp_x(const point &P1, const point &P2){ if(P1.x != P2.x){ return P1.x < P2.x; } return P1.y < P2.y; }
bool cmp_y(const point &P1, const point &P2){ if(P1.y != P2.y){ return P1.y < P2.y; } return P1.x < P2.x; }

void kd_tree(point *S, point *T, point *U, int left, int right, int d)
{
    if(right - left < 2) return;

    int mid = ((left + right) >> 1);
    int a = left, b = mid + 1;

    if((d & 1) == 0){
        for(int i = left; i < right; i++){
            if(cmp_x(T[i], S[mid])){
                U[a++] = T[i];
            }else if(S[mid].id == T[i].id){
                U[mid] = T[i];
            }else{
                U[b++] = T[i];
            }
        }
        for(int i = left; i < right; i++){ T[i] = U[i]; }

    }else{
        for(int i = left; i < right; i++){
            if(cmp_y(S[i], T[mid])){
                U[a++] = S[i];
            }else if(T[mid].id == S[i].id){
                U[mid] = S[i];
            }else{
                U[b++] = S[i];
            }
        }
        for(int i = left; i < right; i++){ S[i] = U[i]; }
    }
    kd_tree(S, T, U, left, mid, d + 1);
    kd_tree(S, T, U, mid + 1, right, d + 1);
}

int cnt;

void find_pt(int *Q, point *S, int sx, int tx, int sy, int ty, int left, int right, int d)
{
    if(left >= right) return;

    int mid = ((left + right) >> 1);
    point p = S[mid];
    int a = p.x, b = p.y;

    if(sx <= a && a <= tx && sy <= b && b <= ty){
        Q[cnt++] = p.id;
    }

    if((d & 1) == 0){
        if(sx < a || (sx == a && sy <= b)){ find_pt(Q, S, sx, tx, sy, ty, left, mid, d + 1); }
        if(a < tx || (a == tx && b <= ty)){ find_pt(Q, S, sx, tx, sy, ty, mid + 1, right, d + 1); }
    }else{
        if(sy < b || (sy == b && sx <= a)){ find_pt(Q, S, sx, tx, sy, ty, left, mid, d + 1); }
        if(b < ty || (b == ty && a <= tx)){ find_pt(Q, S, sx, tx, sy, ty, mid + 1, right, d + 1); }
    }
    return;
}

int main()
{
    point *S, *T, *U;
    int Q[100];
    int i, pos_x, pos_y, n;
    scanf("%d", &n);

    S = new point [n], T = new point [n], U = new point [n];

    for(i = 0; i < n; i++){
        scanf("%d %d", &pos_x, &pos_y);
        S[i] = init(pos_x, pos_y, i);
        T[i] = S[i];
    }
    sort(S, S + n, cmp_x);
    sort(T, T + n, cmp_y);

    kd_tree(S, T, U, 0, n, 0);

    int sx, tx, sy, ty, q;
    scanf("%d", &q);
    while(q){
        cnt = 0;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        find_pt(Q, S, sx, tx, sy, ty, 0, n, 0);
        sort(Q, Q + cnt);
        for(int i = 0; i < cnt; i++){ printf("%d\n", Q[i]); }
        printf("\n");
        q--;
    }

    return 0;
}

Measured memory_bytes: 18324
#include <stdio.h>

int data[10][10];

/* prototype declaration */
int get_data();
void exec();

int main(int argc, const char *argv[])
{
  while(get_data()){
    exec();
  }
  return 0;
}

int get_data()
{
  int i, ch=getchar();
  if(ch == EOF) return 0;
  
  for(i=0; i<10; i++){
    while(ch < '0' || '9' < ch) ch = getchar();
    data[0][i] = ch-'0';
    ch = getchar();
  }
  return 1;
}

void exec()
{
  int i, j;
  for(i=1; i<10; i++){
    for(j=0; j<10-i; j++){
      data[i][j] = (data[i-1][j] + data[i-1][j+1])%10; 
    }
  }
  printf("%d\n", data[9][0]);
}

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

int main(){
  int N; cin >> N;
  set<string> box;
  string s;
  for(int i =0; i < N ; i++){
	cin >> s;
    box.insert(s);
  }
  cout << box.size() << endl;
  return 0; 
}

Measured memory_bytes: 19116
# include <bits/stdc++.h>
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define ll long long int
#include <tr1/unordered_map>
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define f(i,a,b)  for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#include <map>
using namespace std;



int main()
{



     flash;
     ///////////////////////////////////////////////////////////////////////////////////////

     

ll n;
cin>>n;
ll arr[n];
for(ll i=0;i<n;i++)
{
	cin>>arr[i];
}
ll mini=arr[0];
ll ans=1;
for(ll i=1;i<n;i++)
{
	if(arr[i]<mini)
	{
		ans++;
		mini=arr[i];
	}
}
cout<<ans;



    ///////////////////////////////////////////////////////////////////////////////////////

     return 0;

}


Measured memory_bytes: 1792
#include<stdio.h>
int gcd(int, int);
int main(){
  int a, b, r;
  scanf("%d%d",&a,&b);
  r = gcd(a, b);
  printf("%d\n",r);
  return 0;
}
int gcd(int x, int y){
  int r, a;
  if(x < y){
    a = x;
    x = y;
    y = a;
  }
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}



Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <algorithm>
#define F first
#define S second
using namespace std;

typedef long long ll;
#define PI pair<ll, ll>
ll n, m, mx, s, num, mn = 2e9;
PI a[100005];
int main()
{
	ll i;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		scanf ("%lld %lld", &a[i].S, &a[i].F);
		mx = max(mx, a[i].S);
	}
	sort(a, a + n);
	for (i = n; i >= 0; i--) {
		s += a[i].F;
		num = 0;
		if (m - s > 0) {
			num = (m - s) / mx;
			if ((m - s) % mx > 0) num++;
		}
		num += n - i;
		mn = min(mn, num);
	}
	cout << mn;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	string s;cin >> s;
	int cnt=0;
	rep(i,n) if(s.at(i)=='R') cnt++;
	if(cnt>n-cnt) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
    char buffer[11];
    char sub_value[4];
    int  diff, min_diff = 1000;
    if (fgets(buffer, 11, stdin) != NULL) {
        for (int i = 0; i < strlen(buffer)-2; i++) {
            for (int j = 0; j < 3; j++) {
                sub_value[j] = buffer[i+j];
            }
            diff = abs(753-atoi(sub_value));
            if (diff < min_diff) {
                min_diff = diff;
            }
        }
    }
    printf("%d",min_diff);
    return 0;
}

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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

// const long long MOD = 1000000007;

using LL = long long;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVLL = vector<VLL>;
using VVVLL = vector<VVLL>;

template <class T>
void add(T &a, const T &b, const T &mod = 1000000007)
{
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0)
    val += mod;
  a = val;
}

int main()
{
  IOS;

  string K;
  cin >> K;
  int D;
  cin >> D;

  int n = K.size();
  VVVLL dp(10001, VVLL(2, VLL(100)));
  dp[0][0][0] = 1;

  forn(i, 0, n) forn(s, 0, 2) forn(d, 0, D)
  {
    for (int x = 0; x <= (s ? 9 : K[i] - '0'); x++)
      add(dp[i + 1][s || x < K[i] - '0'][(d + x) % D], dp[i][s][d]);
  }
  LL res = dp[n][0][0] + dp[n][1][0];
  add(res, -1LL);
  cout << res << endl;

  return 0;
}


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

int main() {
  string S;
  int a, b;
  cin >> S;
  
  for (int i = 0; i < S.size(); i++) {
   if ( S.at(i) == 'A') {
     a = i;
     break;
   }
  }
  for (int i = S.size()-1; i >= 0; i--) {
   if ( S.at(i) == 'Z') {
     b = i;
     break;
   }
  }
  
  cout << b-a+1 << endl;
   
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define elif else if
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
typedef long long int ll;
#define vi vector<ll>
#define all(x) (x).begin(),(x).end()
#define trace(x) cerr<< #x<<":"<<" "<<x<<endl;
#define trace1(x,y) cerr<<#x<<","<<#y<<" "<<": "<<x<<" "<<y<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*ll n;
    cin>>n;
    deque<int> dq;
    ll query;
    cin>>query;
    rep(i,0,n){
        ll x;
        cin>>x;
        dq.push_back(x);
    }
    */
    string s;
    cin>>s;
    ll count=0;
    ll len=s.size();
    rep(i,0,len-1){
        if(s[i]==s[i+1]){
            count++;
        }
    }
    if(count){
        cout<<"Bad"<<'\n';
    }else{
        cout<<"Good"<<'\n';
    }
    return 0;
}

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

void solve()
{
  int ans=0;

  string s;
  cin >> s;

  for (int i=1; i<(int)(s.length()); i++) {
    if (s[i] != s[i-1]) ans++;
  }

  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <inttypes.h>

int main(void)
{
    size_t n;
    scanf("%zu", &n);
    uint_fast64_t p = 1;
    for (size_t i = 1; i <= n; ++i) {
        p = p * i % 1000000007;
    }
    printf("%" PRIuFAST64 "\n", p);
    return 0;
}


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

int main(){
    string S;

    cin >> S;
    for(int i=0;i<3;i++){
        if(S[i] == S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

public class Main{
  static int n;
  static long a, b;
  static long[] h;
  static final boolean DEBUG = false;

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

    n = sc.nextInt();
    a = sc.nextInt();
    b = sc.nextInt();
    h = new long[n];
    for(int i = 0; i < n; i++){
      h[i] = sc.nextInt();
    }

    long low = 0, high = Integer.MAX_VALUE / 2;
    while(high - low > 1){
      long mid = (low + high) / 2;
      if(f(mid)){
        high = mid;
      }
      else{
        low = mid;
      }
    }

    System.out.println(high);
  }

  private static boolean f(long c){
    long count = 0;
    for(int i = 0; i < n; i++){
      if(h[i] - c * b > 0){
        count += (long)Math.ceil((double)((h[i] - c * b)) / (a - b));
      }
    }
    if(DEBUG){
      System.out.println("count = " + count);
    }
    return count <= c;
  }
}


Measured memory_bytes: 50688
n = gets.chomp.to_i

# 
arr = Array.new(10).map{Array.new(10,0)}
(0..n).each do |i|
	s = i.to_s
	arr[s[0].to_i][s[-1].to_i] += 1
end

10.times do |i|
	arr[i][0] = 0
	arr[0][i] = 0
end

sum = 0
10.times do |i|
	10.times do |j|
		sum += arr[i][j] * arr[j][i]
	end
end

puts sum



Measured memory_bytes: 1788
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;


int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    ll SUM = 0;
    REP(i,n) {
        ll x;
        cin >> x;
        SUM += x-1;
    }
    cout << SUM << std::endl;
    return 0;
}

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

#define ll long long
#define vi vector<int> 
#define pb push_back
#define sz(s) (int)a.size()	

int n, a[1000001], cnt, cnt2;
 
int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] % 2 != 0){
			cnt += a[i];
		}
		else {
			cnt2 += a[i];
		}
	}
	if(cnt % 2 == 0 && cnt2 % 2 == 0){
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <functional>

using namespace std;

int main() {
    int n,a[200],ans = 0,i,flag = 0;

    cin >> n;

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

    while(1){
        for(i = 0;i < n;i++){
            if(a[i] % 2 == 1){
                flag = 1;
            }
            a[i] /= 2;
        }
        if(flag){
            break;
        }

        ans++;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin>>N>>K;

  vector<int> V(N);
  cin>>V;

  auto calc =[&](int l, int r, int m){
    vector<int> A;
    vector<int> used(N, 0);
    for(int i=0;i<min(N, l);i++) A.push_back(V[i]), used[i]++;
    for(int i=0;i<min(N, r);i++) if(used[N-1-i] == 0) A.push_back(V[N-1-i]);
    sort(A.begin(), A.end(), greater<int>());
    while(A.size() && A.back() < 0 && m!=0) A.pop_back(), m--;

    int sum = 0;
    for(int a:A) sum += a;
    return sum;
  };


  int ans = 0;
  for(int a=0;a<=K;a++)
    for(int b=0;b<=K;b++){
      if(a + b > K) continue;
      int c = K - a - b;
      Max(ans, calc(a, b, c));
    }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
    int K;
    cin >> K;
    int even = K / 2;
    int odd = (K + 1) / 2;
    cout << even * odd << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int ab(int a){
  if(a > 0){
    return 1;
  }
  return 0;
}
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",a - ab(a / (b + 1)));
  return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

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

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

struct edge{
	int a;int b;int cost;
};
bool comp(edge& a, edge& b){
	return a.cost < b.cost;
}

int n;
int par[100008],rk[100008];
int x[100008],y[100008];
edge eds[200008];
set<int> s;
vector<PII> xs,ys,XS,YS;

void init(int m){
	REP(i,m){
		par[i]=i;
		rk[i]=0;
	}
}

int find(int i){
	return par[i] == i ? i : par[i] = find(par[i]);
}
bool same(int x, int y){
	return  find(x) == find(y);
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x==y)return;
	if(rk[x]<rk[y]){
		par[y] = x;
	}else{
		par[x] = y;
		if(rk[x]==rk[y])rk[y]++;
	}
}

int main() {
	cin >> n;
	REP(i,n){
		cin >> x[i] >> y[i];
		xs.push_back(MP(x[i],i));
		ys.push_back(MP(y[i],i));
	}
	SORT(xs);SORT(ys);
//	reverse(ALL(xs));reverse(ALL(ys));
	int index=0;
	REP(i, n-1){
		eds[index++]=(edge){xs[i].second, xs[i+1].second, xs[i+1].first-xs[i].first};
		eds[index++]=(edge){ys[i].second, ys[i+1].second, ys[i+1].first-ys[i].first};
	}
	sort(eds, eds + index, comp);
	init(n);
	ll ans = 0;
	REP(i,index){
		edge ed = eds[i];
		if(!same(ed.a,ed.b)){
			ans += ed.cost;
			unite(ed.a, ed.b);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 5996
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll m1=in(),d1=in(),m2=in(),d2=in();
    cout<<(d2==1?1:0)<<endl;
}


Measured memory_bytes: 256
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

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

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int N, i, j, Ans, sub, judg, r,A[15];
int main()
{
	cin >> r >> N >> A[0];
	
	for (i = 0; i < 10; i++) {
		A[i + 1] = r * A[i] - N;
		cout << A[i + 1] << endl;
	}
	
}

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

using namespace std;

int main(){
  int X;
  int A;
  int B;
  int C;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> X;
  int count=0;
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
	if((X-500*i-100*j-50*k)==0) count +=1;
	}
    }
  }


  cout << count <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,i,count;
  double H,W,A[N],B[N];
  scanf("%d%f%f \n",&N,&H,&W);
for(i=0;i<N;i++){
  scanf("%f%f\n",&A[i],&B[i]);
}
for(i=0;i<N;i++){
for(A[i];A[i]>=H;A[i]-=H){
for(B[i];B[i]>=W;B[i]-=W){
  count+=1; A[i]-=H; B[i]-=W;}
   }
}
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int x[110],t,i,s=0;
    scanf("%d",&t);
    for(i=0;i<t;i++)
        scanf("%d",&x[i]);
    for(i=0;i<t-2;i++){
        if(x[i]>x[i+1] && x[i+1]>x[i+2])
            s++;
        else if(x[i]<x[i+1] && x[i+1]<x[i+2])
            s++;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriterSize(os.Stdout, 1000000)
)

func main() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	n := scanInt()
	h := scanInts(n)
	dp := make([]int, n)
	min := func(a, b int) int {
		if a > b {
			return b
		} else {
			return a
		}
	}
	for i := 1; i < n; i++ {
		dp[i] = math.MaxInt32
	}

	for i := 1; i < n; i++ {
		dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
		if i > 1 {
			dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
		}
	}

	fmt.Println(dp[n-1])
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func perm(n, r int) int {
	ret := 1
	for i := 0; i < r; i++ {
		ret *= n
		n--
	}
	return ret
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = a; i < min(b + 1, a + c); i++) {
		cout << i << endl;
	}
	for (int i = max(b-c+1, a + c) ;i<=b;i++) {
		cout << i << endl;
	}
}


Measured memory_bytes: 256
while True:
    try:
        string = input()
        for i in range(0, len(string)):
            if i % 2 == 0:
                if string[i] == 'L':
                    print('No')
                    break
            else:
                if string[i] == 'R':
                    print('No')
                    break
        else:
            print('Yes')
    except:
        break

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int aSum = 0;
		for (int i = 0; i < m; i++) {
			aSum += scan.nextInt();
		}
		if (n >= aSum) {
			System.out.println(n - aSum);
		} else {
			System.out.println(-1);
		}

	}
}

Measured memory_bytes: 46112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

int main()
{
    int R;
    cin >> R;
    const double PI = 3.14159265358979323846;
    cout << fixed << setprecision(30);
    cout << 2 * R * PI << endl;
}

Measured memory_bytes: 3788
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;
const int MOD=1000000007;

int n;
int samelim,difflim;
int col[MAXN],w[MAXN];

bool used[MAXN];
int mn[MAXN];
int mnc1,mnc2;
bool posfixed[MAXN];
bool colfixed[MAXN];
int cnt[MAXN];
int fac[MAXN+1],inv[MAXN+1],ifac[MAXN+1];


void run() {
	fac[0]=1; FORE(i,1,MAXN) fac[i]=(ll)fac[i-1]*i%MOD;
	inv[1]=1; FORE(i,2,MAXN) inv[i]=(ll)(MOD-MOD/i)*inv[MOD%i]%MOD;
	ifac[0]=1; FORE(i,1,MAXN) ifac[i]=(ll)ifac[i-1]*inv[i]%MOD;

	scanf("%d%d%d",&n,&samelim,&difflim);
	REP(i,n) scanf("%d%d",&col[i],&w[i]),--col[i];
	REP(i,n) used[i]=false;
	REP(i,n) { int c=col[i]; if(!used[c]) used[c]=true,mn[c]=w[i]; else if(w[i]<mn[c]) mn[c]=w[i]; }
	mnc1=mnc2=-1; REP(c,n) if(used[c]) { if(mnc1==-1||mn[c]<mn[mnc1]) mnc2=mnc1,mnc1=c; else if(mnc2==-1||mn[c]<mn[mnc2]) mnc2=c; }
	REP(i,n) { posfixed[i]=true; int c=col[i]; if(w[i]+mn[c]<=samelim) posfixed[i]=false; if(mnc1!=-1&&c!=mnc1&&w[i]+mn[mnc1]<=difflim) posfixed[i]=false; if(mnc2!=-1&&c!=mnc2&&w[i]+mn[mnc2]<=difflim) posfixed[i]=false; }
	REP(c,n) if(used[c]) { colfixed[c]=true; if(mnc1!=-1&&c!=mnc1&&mn[c]+mn[mnc1]<=difflim) colfixed[c]=false; if(mnc2!=-1&&c!=mnc2&&mn[c]+mn[mnc2]<=difflim) colfixed[c]=false; }
	REP(c,n) cnt[c]=0; REP(i,n) if(!posfixed[i]) ++cnt[col[i]];
	int ret=1,sum=0;
	REP(c,n) if(!colfixed[c]) { sum+=cnt[c]; ret=(ll)ret*fac[sum]%MOD*ifac[cnt[c]]%MOD*ifac[sum-cnt[c]]%MOD; }
	printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 6272
#include <iostream>
using namespace std;
int main()
{
    long long a, b;
    cin >> a >> b;
    long long cnt;
    if (a == 1 && b == 1)
    {
        cnt = 1;
    }
    else if (a == 2 || b == 2)
    {
        cnt = 0;
    }
    else if (a >= 3 && b >= 3)
    {
        cnt = (a - 2) * (b - 2);
    }
    else
    {
        cnt = a * b - 2;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target ("arch=sandybridge")
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
template <class T> ostream& operator<<(ostream &O, const deque<T>& v) {for (const T &e: v) O << e; return O;}



void _main() {
        int n; cin >> n;
        map<string,int> freq;
        while (n--) {
                string str; cin >> str;
                freq[str]++;
        }

        for (const string x: {"AC", "WA", "TLE", "RE"}) {
                cout << x << " x " << freq[x] << '\n';
        }
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3676
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
    {
        cout<<"Cloudy"<<endl;
    }else if (s=="Cloudy")
    {
        cout<<"Rainy"<<endl;
    }else if (s=="Rainy")
    {
        cout<<"Sunny"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
d = inl()
#d.insert(0,0)
if d[0]!=0:
    print(0)
    exit()
a = [0]*n
for i in range(n):
    a[d[i]] += 1
if a[0]>1:
    print(0)
    exit()

#ddprint(d)
#ddprint(a)

p = 1
t = -1
for i in range(1,n):
    if a[i]==0:
        t = i
        break
    p = (p * (a[i-1]**a[i])) % R
if t>=0:
  for i in range(t+1,n):
    if a[i]>0:
        print(0)
        exit()
print(p)


Measured memory_bytes: 53804
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
const int N=1e6+10;
int a,b;

int main(){
  cin>>a>>b;
  for(int i=1;i<=3;i++){
    if(i==a)
        continue;
        if(i==b)
        continue;
    cout<<i<<endl;
  }

return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n;
  scanf("%d",&n);
  char s[n];
  scanf("%s",s);
  int k=0,c=0;
  for(int i=1;i<n;i++){
    if(s[i] != s[k]){
      k = i;c++;
    }
  }
   printf("%d",c+1);
  
  return 0;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/dp/tasks/dp_i
#include <iostream>
using namespace std;

int N;
double p;
double dp[3005];

int main()
{
    cin >> N;
    dp[0] = 1.0;
    for (int i = 1; i <= N; ++i) {
        cin >> p;
        for (int j = i; j >= 0; --j) {
            double tmp = dp[i];
            dp[j] = p * dp[j] + (1 - p) * dp[j - 1];
        }
    }
    double res = 0.0;
    for (int i = 0; i < (N + 1) / 2; ++i){
        res += dp[i];
    }
    cout.precision(10);
    cout << res << endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF=INT_MAX;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
	int N;
	cin>>N;
	vector<char>d(N);
	REP(i,N){
		cin>>d[i];
	}
	vector<string>vs;
	set<int>st;
	REP(i,N){//?§????
		string str="";
		for(int j=0;i+j<N;j++){
			str+=d[i+j];
			//vs.PB(str);
			if(SZ(str)<6){
				st.insert(toInt(str));
			}
		}
	}
	REP(i,1000000)if(st.find(i)==st.end()){
		cout<<i<<endl;
		break;
	}
	return 0;
}

Measured memory_bytes: 1348
import java.util.*;

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

        int n = sc.nextInt();
        int k  = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int count = map.getOrDefault(a,0);
            map.put(a, ++count);
        }

        if (map.size() <= k) {
            System.out.println(0);
            return;
        }

        int diff = map.size() - k ;
        List<Map.Entry<Integer, Integer>> list = new ArrayList<>(map.entrySet());
        list.sort((e1, e2) -> (e1.getValue() - e2.getValue()));
        int count = 0;
        for (int i = 0; i < diff; i++) {
            count += list.get(i).getValue();
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 103160
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(a: [i32; 3]);
    let mut a = a;
    a.sort();
    a.dedup();
    puts!("{}\n", if a.len() == 2 { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
xy = input().split()
b = [int(a) for a in xy]

turu = 0
kame = 0

coeff = [[1, 1],[2,4]]
c = (coeff[0][0]*coeff[1][1]-coeff[0][1]*coeff[1][0])


inv_coeff = [[coeff[1][1]/c,-coeff[0][1]/c],[-coeff[1][0]/c,coeff[0][0]/c]]

turu = b[0]*inv_coeff[0][0]+b[1]*inv_coeff[0][1]
kame = b[0]*inv_coeff[1][0]+b[1]*inv_coeff[1][1]


if turu < 0 or kame < 0:
    print('No')
elif not turu.is_integer() or not kame.is_integer():
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9192
m,n=map(int,input().split())
ans=0
if m==1:
  ans+=300000
if m==2:
  ans+=200000
if m==3:
  ans+=100000
if n==1:
  ans+=300000
  if ans==600000:
    ans=1000000
if n==2:
  ans+=200000
if n==3:
  ans+=100000
print(ans)

Measured memory_bytes: 38384
#include <stdio.h>

int main() {
  long long int number_n, i, power = 1;
  scanf("%lld", &number_n);
  for(i = 1; i <= number_n; i++) {
    power = (power * i) % 1000000007;
  }
  printf("%lld\n", power);
  return 0;
}


Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize, usize); m],
    }

    let mut uf = UnionFind::new(n);

    for (a, b) in ab {
        uf.unite(a - 1, b - 1);
    }

    let ans = uf.sizes.iter().max().unwrap();

    println!("{}", ans);
}

pub struct UnionFind {
    pub parent: Vec<usize>,
    pub sizes: Vec<usize>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: (0..n).collect(),
            sizes: vec![1; n],
        }
    }

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

    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let mut x = self.find(x);
        let mut y = self.find(y);
        if x != y {
            if self.sizes[x] < self.sizes[y] {
                std::mem::swap(&mut x, &mut y);
            }
            self.parent[y] = x;
            self.sizes[x] += self.sizes[y];
            true
        } else {
            false
        }
    }

    pub fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }

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


Measured memory_bytes: 10780
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

using namespace std;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int main(void) {
    LL a,b,c,d;
    cin >> a >> b >> c >> d;

    LL max=-10e+17;

    if(a*c > max) max = a*c;
    if(a*d > max) max = a*d;
    if(b*c > max) max = b*c;
    if(b*d > max) max = b*d;

    cout << max << endl;
}

Measured memory_bytes: 3632
<?php
$count_answer = 0;
while ($word = rtrim(fgets(STDIN))){
    $count = 0;
    for ($i=0; $i < floor(strlen($word) / 2); $i++) { 
        if(substr($word,$i,1) == substr($word, - (1 + $i),1)){
            $count++;
        }
        // print substr($word, - (1 + $i),1);
        // print PHP_EOL;
    }
    // print $count . " " . floor(strlen($word) / 2);
    if ($count == floor(strlen($word) / 2)){
        $count_answer++;
    }
}
print $count_answer;
print PHP_EOL;

// print substr($word,0,1);
// print substr($word,-1);


Measured memory_bytes: 9232
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  int a, b, k;  cin >> a >> b >> k;
  for(int i=min(a, b); i>=1; i--){
    if(a%i!=0||b%i!=0)  continue;
    k--;
    if(k==0){
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define pb  push_back
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
ll n,a,b;
cin>>a>>b>>n;
if(n>=b)
{
	cout<<(a*(b-1)-((a*(b-1))%b))/b<<endl;
}
else
{
	cout<<(a*(n)-((a*(n))%b))/b<<endl;
}

return  0;
}




Measured memory_bytes: 3588
from sys import stdin
readline = stdin.buffer.readline
read = stdin.buffer.read
def i_input(): return int(input().rstrip())
def i_map(): return map(int, input().rstrip().split())
def i_list(): return list(i_map())

class UnionFind:
    def __init__(self, n):
        self.parents = [-1] * (n + 1)
        self.rank = [0] * (n + 1)

    def root(self, x):
        if(self.parents[x] < 0):
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def unite(self, x, y) -> bool:
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.rank[x] > self.rank[y]:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
        else:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
        return True

    def members(self, x):
        root = self.root(x)
        return [i for i in range(self.n) if self.root(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def is_same(self, x, y) -> bool:
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.parents[self.root(x)]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

def main():
    N, M = i_map()
    u = UnionFind(N)
    P = i_list()
    for _ in range(M):
        x, y = i_map()
        u.unite(x, y)
    ans = 0
    for i, p in enumerate(P, 1):
        if u.is_same(i, p):
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 86848
#include <bits/stdc++.h>
using namespace std;
const int maxn=112345;
int n,x[maxn],y[maxn],t[maxn];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i) scanf("%d%d%d",&t[i],&x[i],&y[i]);
    for (int i=1;i<=n;++i) {
        int dis=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        if (t[i]-t[i-1]>=dis&&(t[i]-t[i-1]-dis)%2==0) continue;
        return 0*puts("No");
    }
    return 0*puts("Yes");
}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
#define m 998244353
#define ll long long

using namespace std;
map<int, int> dis;
int D[100000];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> D[i];
	}
	if(D[0] != 0){
		cout << 0;
		return 0;
	}
	for(int i = 1; i < n; i++){
		if(D[i] == 0){
			cout << 0;
			return 0;
		}
	}
	ll res = 1;
	for(int i = 1; i < n; i++){
		dis[D[i]]++;
	}
	int prev = 0;
	int preCnt = 1;
	for(auto i : dis){
		if(i.first != prev + 1){
			cout << 0;
			return 0;
		}
		prev++;
		for(int j = 0; j < i.second; j++){
			res = (res * preCnt) % m;
		}
		preCnt = i.second;
	}
	cout << res;
}

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

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

    vector<int> W(N);

    for(int i = 0; i < N; i++)
    {
        cin >> W.at(i);
    }

    int preTsum = 0;
    int postTsum = 0;
    int T;
    int minD = pow(10,5);

    for(int i = 0; i < N-1; i++)
    {
        T = i;
        for(int j = 0; j < N; j++)
        {
            if(j <= T)
            {
                preTsum += W.at(j);
            }
            else
            {
                postTsum += W.at(j);
            }
            
        }
        minD = min(minD,abs(preTsum - postTsum));
        preTsum = 0;
        postTsum = 0;
    }

    cout << minD << endl;
    return 0;
}

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

int32_t main() {
    string n; cin>>n;
    int sum=0;
    for(int i=0 ; n[i] ; i++){
        sum += n[i]-'0';
    }
       sum%9 ? cout<<"No" : cout<<"Yes";
}

Measured memory_bytes: 3748