akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int gcd(int x,int y){
    if(y==0) return x;
    else if(x%y==0) return y;
    else return gcd(y,x%y);
}
int main(void){
    int n,i,max=0,tmp,a[100002],l[100002]={0},r[100002];
    scanf("%d",&n);
    r[n]=0;
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) l[i+1]=gcd(l[i],a[i]);
    for(i=n;i>0;i--) r[i-1]=gcd(r[i],a[i-1]);
    for(i=0;i<n;i++){
        tmp = gcd(l[i],r[i+1]);
        if(max<tmp) max=tmp;
    }
    printf("%d",max);
}

Measured memory_bytes: 1280
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

vi eratosthenes(const int &n) {
  vi v(n);
  iota(v.begin() + 2, v.end(), 2);
  for (int i = 2; i * i < n; i++) {
    if (v[i]) {
      for (int j = i * 2; j < n; j += i) {
        v[j] = false;
      }
    }
  }
  return v;
}

void solve() {
  vi primes = eratosthenes(50000);
  primes.erase(remove(all(primes), 0), primes.end());
  vi c(50001);
  rep(i, primes.size()) {
    for (int j = i; primes[i] + primes[j] <= 50000; j++) {
      c[primes[i] + primes[j]]++;
    }
  }
  int n;
  while (cin >> n, n) {
    cout << c[n] << endl;
  }
}

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

int main(){
    int i;
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << (double)sqrt(pow(x1-x2,2)+pow(y1-y2,2)) << endl;
    return 0;
}


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

long long int a[212345], pos[212345], resp;
int n;


int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]), pos[a[i]] = i;
    set < int > s;
    s.insert(0);
    s.insert(n+1);
    for(int i = 1; i <= n; i++){
        int l, r;
        s.insert(pos[i]);
        set<int>::iterator it = s.find(pos[i]);
        r = *(++it) - pos[i];
        --it;
        l = pos[i] - *(--it);
        resp += (long)i*r*l;
    }
    printf("%lld\n", resp);
    
    return 0;
}

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

int main ()
{
	int n;
	while(~scanf("%d",&n))
	{
		int a[2*n];
		for(int i=0;i<2*n;i++)
			cin>>a[i];
		sort(a,a+2*n);
		int sum=0;
		for(int i=0;i<2*n;i+=2)
			sum+=a[i];
		cout<<sum<<endl;		
		
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,t;
    cin>>n>>t;
    vector<ll> x(n);
    rep(i,n) cin>>x[i];
    ll ans=0;
    if(n==1){
      cout<<t<<endl;
      return 0;
    }
    rep(i,n-1){
      if(x[i+1]-x[i]<=t){
        ans+=x[i+1]-x[i];
      }else{
        ans+=t;
      }
    }
    ans+=t;
    cout<<ans<<endl;
}

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

using namespace std;
vector<bool> createPrime ( int num )	// 素数の配列を生成 ( num以下 )
{
	vector<int> vp;
	vector<bool> vb(num+1, true);
	vb[0] = vb[1] = false;
	for (int i = 2; i <= num; ++i) {
		if (!vb[i]) { continue; }
		vp.push_back(i);
		for (int j = i+i; j <= num; j+=i) { vb[j] = false; }
	}
	return vb;
}

int main( ){
	vector< bool > prime = createPrime(1299709);
	while(true) {
		int n;
		cin >> n;
		if(!n) {
			break;
		}

		int ans;
		if(prime[n]) {
			cout << 0 << endl;
		} else {
			int a, b;
			for(int i = n; i >= 0; i--) {
				if(prime[i]) {
					a = i;
					break;
				}
			}
			for(int i = n; i <= 1299709; i++) {
				if(prime[i]) {
					b = i;
					break;
				}
			}
			cout << b - a << endl;
		}

		
	}
}

Measured memory_bytes: 1752
S = set(input())
if 'N' in S and not 'S' in S:
    print('No')
elif 'S' in S and not 'N' in S:
    print('No')
elif 'W' in S and not 'E' in S:
    print('No')
elif 'E' in S and not 'W' in S:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using i64 = long long;

template <class T = long long int>
class Bit {
    private:
    T len;
    T *arr;

    public:
    Bit(T l, T initialValue = 0) : len(l) {
        arr = new T[l+1];
        for (T i = 0; i < l + 1; i++) {
            arr[i] = initialValue;
        }
    }
    ~Bit() {
        delete[] arr;
    }
    void update(T a, T newval) {
        for (T x = a; x <= len; x += x & -x) arr[x] = ((arr[x] > newval) ? arr[x] : newval);
    }
    T query(T a) const {
        T ret = 0;
        for (T x = a; x > 0; x -= x & -x) ret = ((arr[x] > ret) ? arr[x] : ret);
        return ret;
    }
};

int main() {
    int n;
    std::cin >> n;
    std::vector<int> h(n);
    std::vector<i64> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    Bit<> b(n + 10);
    i64 ret = 0;
    for (int i = 0; i < n; i++) {
        auto ss = b.query(h[i]);
        b.update(h[i], ss + a[i]);
        ret = std::max(ret, ss + a[i]);
    }
    std::cout << ret << std::endl;

    return 0;
}

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

int R,C,senbei[10000][10],f[10],num;

void rec(int);
int count();

int main()
{
  int i,j;
  while(cin>>R>>C,R|C){
    for(j=0;j<R;j++)for(i=0;i<C;i++)cin>>senbei[i][j];
    rec(0);
    cout<<num<<endl;
  }
}

void rec(int k)
{
  if(k==R){
    num=max(num,count());
    return;
  }
  f[k]=0;
  rec(k+1);
  f[k]=1;
  rec(k+1);
}

int count()
{
  int n=0,i,j;
  for(i=0;i<C;i++){
    int cnt=0;
    for(j=0;j<R;j++)cnt+=senbei[i][j]^f[j];
    n+=max(cnt,R-cnt);
  }
  return n;
}

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, k, q, a;
    cin >> n >> k >> q;
    vector<int> b(n, 0);
    for(int i = 0; i < q; i++){
        scanf("%d", &a);
        b[--a]++;
    }
    for(int i = 0; i < n; i++){
        if(k - (q - b[i]) > 0) puts("Yes");
        else                   puts("No");
    }
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var a = ReadInt();
            var b = ReadInt();
            var c = ReadInt();
            var d = ReadInt();

            var ans = a < b ? a : b;
            ans += c < d ? c : d;

            WriteAnswer(ans);
        }


        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 100;
const int mo = 1e9 + 7;

inline int fpm(int x, int y) {
    int res = 1;
    for(; y > 0; y >>= 1) {
        if(y & 1)
            res = (ll) res * x % mo;
        x = (ll) x * x % mo;
    }
    return res;
}

int n;
int a[N + 5], cnt;
int dp[N + 5][2];

inline void add(int &x, int y) {
    (x += y) >= mo ? x -= mo : 0;
}

pii solve(int l, int r, int base = 0) {
    if(l == r) {
        return mp(fpm(2, a[l] - base), 0);
    }

    int mn = oo;
    int u = ++ cnt;

    dp[u][0] = 1;
    for(int i = l; i <= r; ++i) { chkmin(mn, a[i]); }
    for(int i = l; i <= r; ++i) {
        if(a[i] > mn) {
            int j = i;
            while(j + 1 <= r && a[j + 1] > mn) { ++ j; }
            pii temp = solve(i, j, mn);

            if(i != l) {
                dp[u][1] = ((ll) dp[u][1] * (temp.snd + 2ll * temp.fst) % mo + 
                           (ll) dp[u][0] * (temp.snd + temp.fst) % mo) % mo;
                dp[u][0] = (ll) dp[u][0] * temp.fst % mo;
            } else {
                dp[u][1] = temp.snd;
                dp[u][0] = (ll) dp[u][0] * (2ll * temp.fst) % mo;
            }

            i = j;
        } else {
            if(i != l) {
                dp[u][1] = ((ll) dp[u][1] * 2 + dp[u][0]) % mo;
            } else {
                dp[u][0] = 2;
            }
        }
    }

    return mp((ll) dp[u][0] * fpm(2, mn - base - 1) % mo, dp[u][1]);
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n);
    for(int i = 1; i <= n; ++i) read(a[i]);

    pii ans = solve(1, n);
    printf("%d\n", (ans.fst + ans.snd) % mo);

    return 0;
}


Measured memory_bytes: 256
N = int(input())

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

H = []
H = list(map(int,input().split()))

min = 0
min_val = 0
for i in range(N):
    a = abs(T - H[i] * 0.006 - A)
    if min == 0 or min_val > a:
        min = i+1
        min_val = a

print(min)




Measured memory_bytes: 3060
import sys

X, N = list(map(int, input().split()))
p = list(map(int, input().strip().split()))

tmp1 = 201
tmp2 = 201

for i in range(0,100):
  if X-i not in p:
    tmp1 = X-i
  elif X+i not in p:
    tmp2 = X+i
  if tmp1 != 201 or tmp2 != 201:
    print(min(tmp1,tmp2))
    sys.exit()

Measured memory_bytes: 9192
a1=int(input())
a2=int(input())
a3=int(input())
a4=int(input())
a5=int(input())
a6=int(input())
a7=int(input())
a8=int(input())
a9=int(input())
a10=int(input())
s=[]
s=[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]
s.sort()
print(s[9])
print(s[8])
print(s[7])



Measured memory_bytes: 5592
N, M, X, Y = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

def check(Z):
    if not(X < Z and Z <= Y):
        return False

    for i in x:
        if not(i < Z):
            return False
    for i in y:
        if not(i >= Z):
            return False
    return True

ans = False
for i in range(-200, 200):
    ans = ans | check(i)

print ('No War' if ans else 'War')



Measured memory_bytes: 3064
#include<stdio.h>

struct Card{
  char suit;
  char value;
  int index;
};

/*

your codes

*/

void BubbleSort(struct Card* C, int lenght)
{
  int i, j;
  struct Card w;
  for(i = 1; i <= lenght; i++){
    for(j = lenght; i + 1 <= j; j--){
      if(C[j].value < C[j-1].value){
        w = C[j-1];
        C[j-1] = C[j];
        C[j] = w;
      }
    }
  }
  return;
}

void SelectionSort(struct Card* C, int lenght)
{
  int i, j, mini;
  struct Card w;
  for(i = 1; i <= lenght; i++){
    mini = i;
    for(j = i; j <= lenght; j++){
      if(C[j].value < C[mini].value){
        mini = j;
      }
    }
    w = C[i];
    C[i] = C[mini];
    C[mini] = w;
  }
  return;
}

void IsStable(struct Card* C, int lenght)
{
  int stable = 0;
  int i;
  for(i = 1; i < lenght; i++){
    if((C[i].value == C[i+1].value) && (C[i].index > C[i+1].index)){
      stable = 1;
      break;
    }
  }
  if(stable == 0){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  return;
}

void d(struct Card* C, int lenght)
{
  int i;
  for(i = 1; i < lenght; i++){
    printf("%c%c ", C[i].suit, C[i].value);
  }
  printf("%c%c\n", C[i].suit, C[i].value);
  return;
}

int main(){
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

  scanf("%d%c", &n, &ch);
  for ( i = 1; i <= n; i++ ){
    scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
    C1[i].index = i;
    C2[i] = C1[i];
  }

  /*

  your codes

  */
  BubbleSort(C1, n);
  d(C1, n);
  IsStable(C1, n);

  SelectionSort(C2, n);
  d(C2, n);
  IsStable(C2, n);

  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define fiin        freopen("input.txt", "r", stdin); 
#define fiout       freopen("output.txt", "w", stdout);
#define pi          2 * acos(0.00)
#define ll          long long
#define ull         unsigned long long
#define fastio      ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl          '\n'
#define nll         '\0'
#define pb          push_back
#define bdyptb      return 0;
#define testcase    ll t,tt; cin>>tt; for(t=1;t<=tt;t++)
   
#define mx 1000007

using namespace std;

int main()
{
    fastio;
    
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;

    bdyptb;
}

Measured memory_bytes: 3608
#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;


int main(){
    string S;
    cin >> S;
    ll sum = 0;
    rep(i,S.size()){
        sum += S[i] - '0';
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3732
k = int(input())
nums = set()


def rec(past: int, num: int):
    nums.add(num)
    if num > 10**10:
        return
    if past > 0:
        rec(past - 1, num * 10 + past - 1)
    rec(past, num * 10 + past)
    if past < 9:
        rec(past + 1, num * 10 + past + 1)


for i in range(1, 10):
    rec(i, i)
ans = sorted(nums)
print(ans[k - 1])

Measured memory_bytes: 56000
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);


  string S;
  cin>>S;
  int N=S.size();
  bool OK=true;
  for(int i=0;i<(N-1)/2-1;i++){
    if(S[i]==S[(N-1)/2-1-i]){
      continue;
    }
    OK=false;  
  }
 // vreverse(S);
    for(int i=(N+3)/2-1;i<N;i++){
    if(S[i]==S[N-1-i]){
      continue;
    }
    OK=false;  
  }
  if(OK){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
}



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

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

int N;
vector<ll> A;

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

  sort(A.begin(), A.end(), greater<ll>());
  ll res = 0;
  for (int i = 1; i < N; i++) {
    res += A[i / 2];
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 4816
#include <cstdio>

bool isPrime(int n);

int main(){
	int n, m, count = 0; scanf("%d", &n);
	
	for(int i = 0; i < n; i++){
		scanf("%d", &m);
		if(isPrime(m)) count++;
	}
	
	printf("%d\n", count);
	
	return 0;
}

bool isPrime(int n){
	if(n <= 1) return false;
	bool judge = true;
	for(int i = 2; i * i <= n; i++){
		if(n % i == 0){
			judge = false;
			break;
		}
	}
	return judge;
}

Measured memory_bytes: 1028
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;
#[allow(dead_code)]
const N_PRIME : i64 = 1000000007;

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

fn main(){
    let xs = read_charvec();
    for i in 0..xs.len()-1{
        if xs[i] == xs[i+1]{
            println!("Bad");
            return;
        }
    }
    println!("Good");
}

Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.InputMismatchException;

public class Main{
	public static void main(String[] args){
		try{
			Scanner scanner = new Scanner(System.in);
			String input = scanner.nextLine();
			String[] nums = input.split(" ", 0);
			
			long N = Long.parseLong(nums[0]);
			long sum = 0;
			if(N<1 || 1_000_000_000_000l < N){
				return;
			}
			
			long mStart = ((long)Math.sqrt(1+4*N) - 1)/2;
			
			for(long a=1; a<=mStart; a++){
				long m = N/a - 1;
				if(N/m == N%m){
					sum += m;
				}
			}
			
			System.out.println(sum);
		} catch(IndexOutOfBoundsException e){
			e.printStackTrace();
		} catch(NumberFormatException e){
			e.printStackTrace();
		} catch(InputMismatchException e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 23380
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int A, B;
        A = cin.nextInt();
        B = cin.nextInt();
        int ans = A + B;
        if (ans >= 10) Console.WriteLine("error");
        else Console.WriteLine(ans);
        
    }
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();

        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <math.h>
#include <string>

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define vb vector<bool>
#define vvb vector<vb>
#define vstr vector<string>
#define pll pair<ll, ll>
#define pb pair<bool, bool>
#define vpll vector<pll>
#define vpb vector<pb>

using namespace std;

bool is_prime(ll n)
{
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
vpll calc(ll n)
{
	vpll ans;

	for (ll i = 2; i*i <= n; i++)
	{
		if (n % i == 0)
		{
			ans.push_back({ i, 1 });
			//ll x = n / i;
			n /= i;
			while (n % i == 0)
			{
				ans[ans.size() - 1].second++;
				n /= i;
			}
		}
	}
	/*
	if (ans.size() == 0)
	{
		ans.push_back({ n, 1 });
	}*/
	if (n != 1)
	{
		ans.push_back({ n, 1 });
	}
	return ans;
}


int main()
{
	ll n;
	cin >> n;
	if (n == 1)
	{
		cout << "0" << endl;
		return 0;
	}
	if (is_prime(n) == true)
	{
		cout << "1" << endl;
		return 0;
	}
	vpll primes = calc(n);
	/*
	cout << "primes: " << endl;
	for (ll i = 0; i < primes.size(); i++)
	{
		cout << primes[i].first << " ";
	}
	cout << endl;*/
	ll ans = 0;
	for (ll i = 0; i < primes.size(); i++)
	{
		for (ll j = 1; primes[i].second - j >= 0; j++)
		{
			ans++;
			primes[i].second -= j;
		}
	}
	cout << ans << endl;
	return 0;
}

/*
714530981539

*/



Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long int ll;
int main(){
  ll n,k;
  cin >>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++) cin>>a[i];
  if((n-1)%(k-1)==0) cout <<(n-1)/(k-1)<<endl;
  else cout <<(n-1)/(k-1)+1<<endl;
}


Measured memory_bytes: 1024
x=int(input())
m=int(x%100)
n=int(x/100)
c=0
if n<m:
  for i in range(n+1):
    for j in range(n+1-i):
      for k in range(n+1-i-j):
        for s in range(n+1-i-j-k):
          if 1*i+2*j+3*k+4*s+5*(n-i-j-k-s)==m:
            c=1
            break
          
else:
   c=1
    
if c==1:
  print(1)
else:
  print(0)


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

int main(){
  
  string S;
  cin >> S;
  if (S.at(0) == 'S') cout << "Cloudy";
  else if (S.at(0) == 'C') cout << "Rainy";
  else cout << "Sunny";
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
vector<int> G[2001];
int cnt,ng;
int dist[2001];
int a[2001],b[2001];
int res;
bool flag;

void dfs(int v,int d){
	dist[v]=d;
	cnt++;
	if(d==k/2)return;
	for(int i=0;i<G[v].size();i++){
		if(dist[G[v][i]]==-1){
			dfs(G[v][i],d+1);
		}
	}
}

void func(int v){
	memset(dist,-1,sizeof(dist));
	dist[v]=0;
	cnt=0;
	for(int i=0;i<G[v].size();i++){
		dfs(G[v][i],1);
	}
	res=min(res,n-cnt-1);
}

void func2(int v1,int v2){
	memset(dist,-1,sizeof(dist));
	dist[v1]=0;
	dist[v2]=0;
	cnt=0;
	if(k>0){
		for(int i=0;i<G[v1].size();i++){
			if(G[v1][i]!=v2)dfs(G[v1][i],1);
		}
		for(int i=0;i<G[v2].size();i++){
			if(G[v2][i]!=v1)dfs(G[v2][i],1);
		}
	}
	res=min(res,n-cnt-2);
}


int main(void){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n-1;i++){
		scanf("%d%d",&a[i],&b[i]);
		a[i]--;
		b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	res=n-1;
	if(k%2==0){
		for(int i=0;i<n;i++){
			func(i);
		}
	}else{
		k--;
		for(int i=0;i<n-1;i++){
			func2(a[i],b[i]);
		}
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class Z> V<Z> divisor(Z n) {
  V<Z> res;
  Z i;
  for (i = 1; i * i < n; ++i) if (n % i == 0) res.push_back(i), res.push_back(n / i);
  if (i * i == n) res.push_back(i);
  sort(begin(res), end(res));
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  V<> c(1e5 + 2);
  for (int m = 2; m <= 1e5; ++m) {
    auto ds = divisor(m);
    ds.pop_back();
    lint p = 1;
    for (int d : ds) {
      p *= d;
      if (p >= 2 * m) break;
    }
    if (p >= 2 * m) ++c[m];
  }
  for (int i = 0; i <= 1e5; ++i) c[i + 1] += c[i];
  int q; cin >> q;
  while (q--) {
    int n; cin >> n;
    cout << c[n] << '\n';
  }
}


Measured memory_bytes: 3244
/* Fairy dandy tickling the fancy of his lady friend */

#include <iostream>

#include <vector>

#include <algorithm>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)

#define rep(i,a,b) for(int i=int(a); i<int(b); i++)

#define rip(i,a,b) for(int i=(int)a; i>=(int)b; i--)

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

#define sz(x) int(x.size())

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

#define trace(x) cerr << #x << ": " << x <<endl;



using namespace std;



typedef long long int lli;

typedef pair<lli, lli> ii;

typedef vector<int> vi;

typedef vector<ii> vii;


const int N = 1e5+5;


int main(){

    fastio;

	int n; cin>>n;
	lli M[N], A[N];
	lli ans=0;
	rep(i,0,n+1) cin>>M[i];
	rep(i,0,n) cin>>A[i];
	lli cur;
	rep(i,0,n){
		rep(j,i,i+2){
			cur = min(A[i], M[j]);
			A[i]-=cur;
			M[j]-=cur;
			ans+=cur;
		}
	}
	cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200050;
typedef long long ll;

ll a[maxn];
int main()
{
    ll n;
    cin>>n;

    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
        a[i] = a[i] - (i+1);
    }
    sort(a,a+n);


    ll total = a[n/2];
    //ll t2 = a[n/2 + 1];
    //ll t3 = a[n/2 - 1];
    ll ans = 0,ans2 = 0,ans3 = 0;
    for(ll i=0; i<n; i++)
    {
        ans += abs(a[i]-total);
        //ans2 += abs(a[i]- t2);
        //ans3 += abs(a[i]- t3);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1792
let m, cs, c, d = Scanf.scanf "%d %d" @@ fun n m -> m, Array.make n (0, 0), ref 0, ref 0
let _ = for _ = 1 to m do Scanf.scanf " %d %s" @@ fun p s -> let a, w = cs.(p - 1) in if s = "AC" then (if a = 0 then (d := !d + w; cs.(p - 1) <- 1, w; incr c)) else if a = 0 then cs.(p - 1) <- a, w + 1 done; Printf.printf "%d %d\n" !c !d

Measured memory_bytes: 6528
#include <stdio.h>

int Z[300000]={0};

int main(){
  int x, n, i, tmp;
  scanf("%d", &n);
  for (i=0; i<n; i++){
    scanf("%d", &Z[i]);
  }

  tmp=1;
  for (i=0; i<n; i++){
    if (Z[i]==tmp) tmp++;
  }

  if (tmp==1) printf("-1\n");
  else printf("%d\n", n-(tmp-1));

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 998244353
//#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 222222;
int l[N], r[N], stree[N << 2];
int n, k;

int update(int i, int v, int cl, int cr, int pos) {
    if(cl > i || cr < i) {
        return stree[pos];
    } else if(cl == i && cr == i) {
        stree[pos] += v % MOD;
        stree[pos] %= MOD;
        return stree[pos];
    }
    int m = cl + cr >> 1;
    int x = update(i, v, cl, m, pos * 2 + 1);
    int y = update(i, v, m + 1, cr, pos * 2 + 2);
    stree[pos] = (x + y) % MOD;
    return stree[pos];
}

int query(int l, int r, int cl, int cr, int pos) {
    if(cl > r || cr < l) {
        return 0;
    } else if(cl >= l && cr <= r) {
        return stree[pos];
    }
    int m = cl + cr >> 1;
    int x = query(l, r, cl, m, pos * 2 + 1);
    int y = query(l, r, m + 1, cr, pos * 2 + 2);
    return (x + y) % MOD;
}

int solve() {
    cin >> n >> k;
    rep(i, 1, k) {
        cin >> l[i] >> r[i];
    }
    update(1, 1, 1, n, 0);
    rep(i, 2, n) {
        rep(j, 1, k) {
            int from = i - r[j], to = i - l[j];
            if(to < 1) continue;
            from = max(1LL, from);
            int x = query(from, to, 1, n, 0);
            update(i, x, 1, n, 0);
            x = query(i, i, 1, n, 0);
        }
    }
    int ans = query(n, n, 1, n, 0);
    cout << ans << endl;
    return 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


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

int main() {

	char a; cin >> a;
	string ans;
	if (a - 'a' < 26 &&  0 <= a - 'a')  {
		ans = "a";
	}
	else {
		ans = "A";
	}		
	cout << ans << endl;
	return 0;
}

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

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

    int u = abs(b - d);
    int r = abs(a - c);
    for (int i = 0; i < u; i++) cout << "U";

    for (int i = 0; i < r; i++) cout << "R";

    for (int i = 0; i < u; i++) cout << "D";

    for (int i = 0; i < r; i++) cout << "L";

    cout << "L";

    for (int i = 0; i < u + 1; i++) cout << "U";

    for (int i = 0; i < r + 1; i++) cout << "R";

    cout << "D" << "R";

    for (int i = 0; i < u + 1; i++) cout << "D";

    for (int i = 0; i < r + 1; i++) cout << "L";

    cout << "U" << endl;


    
}

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

using Edge = pair<int, int>; //エッジ(本問題では使わない))
using Graph = vector<vector<int>>;	//グラフ

int N, Q;
Graph G;

// res は答え
vector<int> res;

// 深さ優先探索(再帰)
// 根を持つ木であり，親子関係を利用したい場合はこちら
// v:現在のノード p:親ノード
void dfs_recursive(int v, int p) {
	for (auto e : G[v]) {
		if (e == p) continue;	//親ノードにさかのぼらない
		res[e] += res[v];		//親の答えを子に足し合わせる
		dfs_recursive(e, v);				//vから下流に進む，このときvが親ノードになる
	}
}

int main(void){
  cin >> N >> Q;
  G.assign(N, vector<int>());
  for (int i = 0; i < N - 1; i++) {
    	int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
  }
  
  res.assign(N, 0);
  
  for (int i = 0; i < Q; i++) {
    	int p,x; cin >> p >> x;
    	res[p-1] += x;
  }
  
  dfs_recursive(0,-1);
  
  for (int i = 0; i < N; i++) cout << res[i] << "\n";
  
}

Measured memory_bytes: 23424
#include <stdio.h>
void swap(int *pfrom,int *pto);
int main(){
  int x,y,r,ans;
  scanf("%d %d",&x,&y);
  if(x==y){
    printf("%d\n",x);
  } else {
    for(;;){
      if(y==0){
        ans=x;
        break;
      }
      if(x<y){
        swap(&x,&y);
      }
      r=x%y;
      x=y;
      y=r;
    }
    printf("%d\n",ans);
  }
  return 0;
}
void swap(int*pfrom,int *pto){
  int t;
  t=*pfrom;
  *pfrom=*pto;
  *pto=t;
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
  int n;
  double avg = 0, count = 0;
  cin >> n;
  std::vector<int> v(n), x(n), y(n);
  REP(i,n){
    v.at(i) = i;
    cin >> x.at(i) >> y.at(i);
  }

  do {
    REP(i,n-1){
      avg += sqrt(pow(x[v[i]]-x[v[i+1]],2) + pow(y[v[i]]-y[v[i+1]],2));
    }
    count += 1;
  } while (std::next_permutation(v.begin(), v.end()));
  cout << fixed << setprecision(10) << avg / count;

  return 0;

}



Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    ll n,m,k;cin >> n >> m >> k;
    vl a(n), b(m);
    cin >> a;
    cin >> b;

    rep(i,n-1) a[i+1] += a[i];
    rep(i,m-1) b[i+1] += b[i];
    //cout << a << "\n";
    //cout << b << "\n";
    ll ans = 0;
    // 0
    if(a[0] <= k) chmax(ans, upper_bound(all(a), k) - a.begin());
    if(b[0] <= k) chmax(ans, upper_bound(all(b), k) - b.begin());

    for(int i=0;a[i] < k && i<n;++i){
        if(k - a[i] < b[0]){
            chmax(ans, i+1);
            continue;
        }
        int bi = upper_bound(all(b), k - a[i]) - b.begin();
        --bi;
        // call(a[i]);
        // call(k-a[i]);
        // call(bi);
        // call(b[bi]);
        chmax(ans, i+1 + bi+1);
        // cerr << "\n";
    }
    for(int i=0;b[i] < k && i<m;++i){
        if(k - b[i] < a[0]){
            chmax(ans, i+1);
            continue;
        }
        int ai = upper_bound(all(a), k - b[i]) - a.begin();
        --ai;
        // call(b[i]);
        // call(k-b[i]);
        // call(ai);
        // call(a[ai]);
        chmax(ans, i+1 + ai+1);
        // cerr << "\n";
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6428
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

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

    vvl x(3, vl(3));
    x[0][0] = a;
    x[0][1] = b;
    x[0][2] = -a - b + 3*c;
    x[1][0] = -2*a - b + 4*c;
    x[1][1] = c;
    x[1][2] = 2*a + b - 2*c;
    x[2][0] = a + b - c;
    x[2][1] = -b + 2*c;
    x[2][2] = -a + 2*c;

    rep(i, 3) {
        rep(j, 3) {
            cout << x[i][j];
            if(j < 2) {
                cout << " ";
            }
        }
        cout << "\n";
    }

    re0;
}

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

int main() {

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

  // ll t; cin>>t; 
   {
       ll k;
       cin>>k;

    string s;
    cin>>s;

    ll n=s.length();

    if(n<=k)
    cout<<s;

    else
    {
        for(int i=0;i<k;i++)
        cout<<s[i];
        
        cout<<"...";
    }
   }

  


    return 0;
}

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

int main(){
  ll n,k,q;
  cin>>n>>k>>q;
  vector<int> v(n,-q);
  vector<int> v2(q);
  rep(i,q){
    cin>>v2.at(i);
  }
  
  rep(i,q){
    v.at(v2.at(i)-1) ++;
  }
  rep(i,n){
    if (v.at(i) + k >0){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        update_list = []
        while self.parent_or_size[a] >= 0:
            update_list.append(a)
            a = self.parent_or_size[a]

        for i in update_list:
            self.parent_or_size[i] = a

        return a

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = DSU(n)
res = []
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        res.append(int(uf.same(u, v)))
    else:
        uf.merge(u, v)
print("\n".join(map(str, res)))


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

using namespace std;

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchArray(v) for(auto i : v) cout << i << " "; cout << endl;
#define all(v) (v).begin(), (v).end()

#define endl '\n'
#define MAX 100000
#define MOD int(1e9 + 7)
#define INF numeric_limits<int>::max()
#define INFLL numeric_limits<long long int>::max()

typedef long long int lli;
typedef long double ld;

vector<vector<int>> v;
int l, c;

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

  cin >> l >> c;
  v.resize(l);
  for(int i = 0; i < l; i++) {
    string str;
    cin >> str;
    for(auto c : str) {
      if(c == '.') v[i].push_back(0);
      else v[i].push_back(-1);
    }
  }

  for(int i = 0; i < l; i++) {
    if(v[i][0] != -1) v[i][0] = 1;
    else break;
  }

  for(int i = 0; i < c; i++) {
    if(v[0][i] != -1) v[0][i] = 1;
    else break;
  }

  for(int i = 1; i < l; i++) {
    for(int j = 1; j < c; j++) {
      if(v[i][j] == -1) continue;

      if(v[i-1][j] == -1 and v[i][j-1] == -1) v[i][j] = 0;
      else if(v[i-1][j] == -1) v[i][j] = v[i][j-1];
      else if(v[i][j-1] == -1) v[i][j] = v[i-1][j];
      else v[i][j] = (v[i-1][j] + v[i][j-1]) % MOD;
    }
  }

  cout << v[l-1][c-1] << endl;

  return 0;
}


Measured memory_bytes: 4352
/*{{{*/
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif

#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()

using namespace std;
using ll = long long;
using ld = long double;
template < typename t >
using V = vector< t >;

template< typename t > 
int size(const t& c)
{return c.size();}

void print()
{cout << '\n';}

template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}

template< typename a, typename b >
inline ostream& operator<<(ostream& os, const pair< a, b > p)
{return os << '(' << p.st << ", " << p.nd << ')';}

template< typename t >
void print_range(t a, const t& b)
{while (a != b) cout << (*a++) << ' '; cout << '\n';}

#define flag() __LINE__"| "__PRETTY_FUNCTION__
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cout<<#__VA_ARGS__": ";print_range(__VA_ARGS__))
/*}}}*/



int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, h, w;
    cin >> n >> h >> w;
    int a = n - h + 1;
    int b = n - w + 1;

    print(max(0, a * b));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < 2*n; i += 2) {
        if (s[i] == 'B') s[i] = 'W';
        else s[i] = 'B';
    }
    int w = 0;
    ll ans = 1;
    rep(i, 2*n) {
        if (s[i] == 'W') w++;
        else {
            if (w == 0) {
                puts("0");
                return 0;
            }
            ans *= w;
            ans %= MOD;
            w--;
        }
    }
    if (w != 0) {
        puts("0");
        return 0;
    }
    srep(i, n+1, 1) {
        ans *= i;
        ans %= MOD;
    }

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

Measured memory_bytes: 640
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>

using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

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


    if(a==b && b== c){
        cout <<"No";
    }else if(a==b){
       cout <<"Yes";
    } else if (b==c){
        cout <<"Yes";
    } else if (c==a){
        cout <<"Yes";
    }else {
        cout<<"No";
    }

    return 0;
}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin >> s;
    int a,z;
    a = z;
    for(int i = s.size() - 1; i >= 0; i--) a = (s[i] == 'A')? i : a;
    for(int i = 0; i < s.size() ; i++) z = (s[i] == 'Z')? i : z;
    cout << (( a < z) ? z - a + 1 : 0) << "\n";
    return 0;
}


Measured memory_bytes: 720