akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

int gcd(int a, int b) {
  if (a < b) { swap(a, b); }
  if (b == 0) { return a; }
  return gcd(b, a % b);
}

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll INF = 1e18;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

const int COM_MAX = 500010;
ll fac[COM_MAX], facinv[COM_MAX], inv[COM_MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  facinv[0] = facinv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < COM_MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    facinv[i] = facinv[i-1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD) * facinv[n-k] % MOD;
}

ll PERM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD);
}

const int MAXN = 200010;
const int MAXA = 200010;

vector<ll> G[MAXA];
ll dob[60][MAXA]; // dob[0][i]: distances from i. dob[k] is doubled by 2**k;

int main(int argc, char** argv) {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
    G[A[i]].push_back(i);
  }
  rep(a, MAXA) {
    int n = G[a].size();
    rep(j, n) {
      if (j == n - 1) {
        dob[0][G[a][j]] = (N + G[a][0]) - G[a][j] + 1;
      } else {
        dob[0][G[a][j]] = G[a][j + 1] - G[a][j] + 1;
      }
    }
  }

  rep(k, 59) {
    rep(i, N) {
      if (dob[k][i] == INF) {
        dob[k + 1][i] = INF;
      } else {
        ll tmp = dob[k][i] + dob[k][(i + dob[k][i]) % N];
        dob[k + 1][i] = min(tmp, INF);
      }
    }
  }

  ll t = 0;
  for (int k = 59; k >= 0; --k) {
    if (t + dob[k][t % N] <= N * K) {
      t = t + dob[k][t % N];
    }
  }

  if (t == N * K) { // No more characters.
    cout << endl;
    return 0;
  }

  t %= N;

  while (t < N) {
    if (t + dob[0][t] - 1 > N - 1) { // No more characters same with A[t].
      cout << A[t] << " ";
      ++t;
    } else {
      t = t + dob[0][t];
    }
  }

  return 0;
}


Measured memory_bytes: 109696
#include <bits/stdc++.h>
#define INF 1e+18
#define int long long
using namespace std;

struct edge{ int to,cost; };
typedef pair<int,int> P;

int n,m,q,ds[100010],dt[100010],bit[200010];
vector<edge> G[100010];

void dijk(int s,int *d){
	for(int i = 0;i < n;i++) d[i] = INF;
	d[s] = 0;
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(edge e : G[v]){
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

void add(int i,int x){
	while(i < 200010){
		bit[i] += x;
		i += i & -i;
	}
}

int get(int i){
	int s = 0;
	while(i){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

signed main(){
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int a,b,c;
		cin >> a >> b >> c;
		G[a].push_back({b,c});
		G[b].push_back({a,c});
	}
	dijk(0,ds);
	dijk(n - 1,dt);
	vector<int> d;
	for(int i = 0;i < n;i++) d.push_back(ds[i]);
	sort(d.begin(),d.end());
	d.erase(unique(d.begin(),d.end()),d.end());
	int fs[100010],fg[100010],ans[100010];
	vector<P> query,vec;
	for(int i = 0;i < n;i++) vec.push_back(P(dt[i],lower_bound(d.begin(),d.end(),ds[i]) - d.begin()));
	sort(vec.begin(),vec.end(),greater<P>());
	cin >> q;
	for(int i = 0;i < q;i++){
		cin >> fs[i] >> fg[i];
		query.push_back(P(fg[i],i));
	}
	sort(query.begin(),query.end(),greater<P>());
	int num = 0;
	for(int i = 0;i < q;i++){
		int v = query[i].second,ind = upper_bound(d.begin(),d.end(),fs[v]) - d.begin();
		while(num < n && vec[num].first >= fg[v]) add(vec[num++].second + 1,1);
		ans[v] = get(ind);
	}
	for(int i = 0;i < q;i++) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 19004
n = int(input())
a = list(map(int, input().split()))

count_minus = 0
b = []
for i in range(n):
    if a[i] < 0:
        count_minus += 1
        b.append(-1 * a[i])
    else:
        b.append(a[i])

if count_minus % 2 == 0:
    print(sum(b))
if count_minus % 2 == 1:
    print(sum(b) - 2 * min(b))


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

int main(){
int n,k,d,a;

cin >> n >> k;
set<int> A;
for(int i =0;i < k;++i){
cin >> d;
for(int j=0;j < d;++j){
    cin >>a;
    A.insert(a);
}
}

cout << n-A.size() << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int p[300000];
int main(){
  p[0]=p[1]=1;
  for(int i=2;i*i<300000;++i){
    if(!p[i]){
      for(int j=i+i;j<300000;j+=i) p[j]=1;
    }
  }
  int n;
  while(cin>>n,n){
    int cnt=0;
    for(int i=n+1;i<=2*n;++i)
      if(!p[i]) cnt++;
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 4252
/*ITP1_3_C.c*/
#include<stdio.h>
int main(void){
   int a[3000],b[3000],i,j,k;
   for(i=1;i>=1;i++){
      scanf("%d %d",&a[i],&b[i]);
      if(a[i]==0 && b[i]==0){
         break;
      }
   }
   for(j=2;j<=i;j++){
      if(a[j-1]<b[j-1]){
         printf("%d %d\n",a[j-1],b[j-1]);
      }
      else{
         printf("%d %d\n",b[j-1],a[j-1]);
      }
   }
   return 0;
}

Measured memory_bytes: 1808
use proconio::input;

fn main() {
    input! { n: usize }
    let mut a = vec![];
    let mut ac = vec![0; 1000_000 + 1];
    let mut ma = 0;
    for _ in 0..n {
        input! { ai: usize }
        a.push(ai);
        ac[ai] += 1;
        ma = ma.max(ai);
    }

    let mut pc = true;
    for i in 2..=ma {
        let mut c = 0;
        for j in (i..=ma).step_by(i) {
            c += ac[j];
        }
        if c > 1 {
            pc = false;
            break;
        }
    }

    println!("{} coprime", if pc {
        "pairwise"
    } else {
        let mut v = a[0];
        for i in 1..n {
            v = num_integer::gcd(v, a[i]);
        }
        if v == 1 {
            "setwise"
        } else {
            "not"
        }
    });
}


Measured memory_bytes: 20556
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int n, m;
    while (cin >> n >> m, n || m) {
        vector<ll> k(n);
        for (int i = 0; i < n; ++i) {
            cin >> k[i];
            k[i] %= m;
        }

        vector<ll> sum(n + 1);
        for (int i = 0; i < n; ++i) {
            sum[i + 1] = (sum[i] + k[i]) % m;
        }

        ll ans = 0;
        set<ll> s;
        s.insert(0);
        for (int i = 1; i <= n; ++i) {
            auto it = s.lower_bound(sum[i] + 1);
            if (it != s.end()) {
                ans = max(ans, (sum[i] - (*it) + m) % m);
            } else {
                ans = max(ans, sum[i]);
            }

            s.insert(sum[i]);
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 4552
#include <bits/stdc++.h>
using namespace std;
void rotate(vector<pair<int, int>> &L){
  int m = L.size();
  for (int i = 0; i < m; i++){
    int x = L[i].first;
    int y = L[i].second;
    L[i] = make_pair(y, -x);
  }
}
void standardize(vector<pair<int, int>> &L){
  int m = L.size();
  if (L[0].first == L[1].first && L[0].second > L[1].second){
    rotate(L);
  }
  if (L[0].first > L[1].first && L[0].second == L[1].second){
    rotate(L);
  }
  if (L[0].first == L[1].first && L[0].second < L[1].second){
    rotate(L);
  }
  int x = L[0].first;
  int y = L[0].second;
  for (int i = 0; i < m; i++){
    L[i].first -= x;
    L[i].second -= y;
  }
}
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<vector<pair<int, int>>> L(n + 1);
    for (int i = 0; i <= n; i++){
      int m;
      cin >> m;
      L[i] = vector<pair<int, int>>(m);
      for (int j = 0; j < m; j++){
        int x, y;
        cin >> x >> y;
        L[i][j] = make_pair(x, y);
      }
    }
    for (int i = 0; i <= n; i++){
      standardize(L[i]);
    }
    vector<bool> same(n, false);
    for (int i = 1; i <= n; i++){
      if (L[0] == L[i]){
        same[i - 1] = true;
      }
    }
    reverse(L[0].begin(), L[0].end());
    standardize(L[0]);
    for (int i = 1; i <= n; i++){
      if (L[0] == L[i]){
        same[i - 1] = true;
      }
    }
    for (int i = 0; i < n; i++){
      if (same[i]){
        cout << i + 1 << endl;
      }
    }
    cout << "+++++" << endl;
  }
}


Measured memory_bytes: 3112
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    const RES: i32 = 7;
    for bit in 0..(1 << 3) {
        let mut res = String::with_capacity(7);
        let mut r: i32 = 0;
        for (i, (d, c)) in s
            .iter()
            .map(|x| (x.to_digit(10).unwrap() as i32, x.clone()))
            .enumerate()
        {
            if i == 0 {
                r += d;
                res.push(c);
                continue;
            }
            if bit & 1 << (i - 1) != 0 {
                r += d;
                res.push('+');
            } else {
                r -= d;
                res.push('-');
            }
            res.push(c);
        }
        if r == RES {
            println!("{}={}", res, RES);
            break;
        }
    }
}

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

int main()
{
   
   char c;
   cin>>c;
   if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
       cout<<"vowel"<<endl;
   }
   else{
       cout<<"consonant"<<endl;
   }
   
   return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    while(n > 0){
        cnt++;
        n = n / k;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

pll change(string s) {
    pll p = make_pair(0, 0);
    for(ll i = 0; i < s.size(); i++) {
        if(s[i] == '(') p.first++;
        else if(p.first > 0) p.first--;
        else p.second++;
    }
    return p;
}

bool comp_pl(pll& a, pll& b) {
    return a.second < b.second;
}

bool comp_pr(pll& a, pll& b) {
    return a.first > b.first;
}

void solve() {
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    vpll pl, pr;
    rep(i, n) {
        pll p = change(s[i]);
        if(p.first >= p.second) pl.push_back(p);
        else pr.push_back(p);
    }
    sort(pl.begin(), pl.end(), comp_pl);
    sort(pr.begin(), pr.end(), comp_pr);
    for(auto& p : pr) pl.push_back(p);
//    rep(i, n) cout << p[i].first << ' ' << p[i].second << endl;
    pll p2 = make_pair(0, 0);
    bool ans = true;
    rep(i, n) {
        p2.first -= pl[i].second;
        if(p2.first < 0) ans = false;
        p2.first += pl[i].first;
        if(!ans) break;
    }
    if(ans && p2.first != 0) ans = false;
    cout << (ans ? "Yes" : "No") << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 58740
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 

const long long int mod=1000000007;
const long long int INF=99999999999999999;



long long int N,M,K;
int main() {
	cout << fixed << setprecision(18);
	cin>>N>>M>>K;
    IFYes((N==M&&N!=K)||(K==M&&M!=N)||(N==K&&N!=M));
} 


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <queue>

using namespace std;

#define pb push_back
#define pbk pop_back
#define fs first
#define sc second
#define sz(s) ((int) (s).size())
#define all(x) (x).begin(), (x).end()
#define mt make_tuple
#define mp make_pair
#define next hunext
#define prev huprev

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int inf = 1e9;
const double pi = 4 * atan(1.0);
const double eps = 1e-9;
const int N = 2020;
const int MOD = int(1e9) + 7;

int n, k;
int dp[N][N], f[N * N];

inline int calc(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b % 2 != 0) {
            res = (1LL * res * a) % MOD;
        }
        a = (1LL * a * a) % MOD;
        b /= 2;
    }
    return res;
}

inline int solve() {
    if (k == 1) {
        return 1;
    }
    f[k - 2] = 1;
    for (int i = k - 1; i <= n * k; ++i) {
        f[i] = (1LL * f[i - 1] * i) % MOD;
        f[i] = (1LL * f[i] * calc(i - (k - 2), MOD - 2)) % MOD;
    }
    dp[n][n] = 1;
    for (int zero = n; zero >= 0; --zero) {
        for (int active = zero; active >= 0; --active) {
            if (zero > 0 && zero - 1 >= active) {
                dp[zero - 1][active] = (dp[zero - 1][active] + dp[zero][active]) % MOD;
            }
            if (active > 0) {
                int cur = (1LL * dp[zero][active] * (n - active + 1)) % MOD;
                int ind = (n - active + 1) * (k - 1) + (n - zero) - 1;
                assert(ind >= k - 2 && ind <= n * k);
                cur = (1LL * cur * f[ind]) % MOD;
                dp[zero][active - 1] = (dp[zero][active - 1] + cur) % MOD;
            }
        }
    }
    return dp[0][0];
}

int main() {
#ifdef LOCAL42
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k;
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 29696
bool_zeroone = True
count = 0
sl = list(input())
for c in sl:
    if bool_zeroone and c == '0':
        count += 1
    elif not bool_zeroone and c == '1':
        count += 1
    bool_zeroone = not bool_zeroone

answer = min(count, len(sl) - count)
print(answer)


Measured memory_bytes: 3956
def main():
    a, b = map(int, input().split())
    str = input()

    array = []

    for i in range(len(str)):
        if (i+1 == b):
            array.append(str[i].lower())
        else:
            array.append(str[i])

    str2 = ''.join(array)
    print(str2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
while True:
  N = int(input())
  if N==0:
    break
  W,H = map(int,input().split())
  data = [[0 for i in range(W)] for j in range(H)]
  for i in range(N):
    x,y = map(int,input().split())
    data[y-1][x-1] = 1
  S,T = map(int,input().split())
  ans = 0
  for h in range(H-T+1):
    for w in range(W-S+1):
      #
      a = 0
      for x in range(T):
        for y in range(S):
          if data[h+x][w+y]==1:
            a+=1
      ans = max(ans,a)
  print(ans)


Measured memory_bytes: 5788
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }

        int base = (int) Math.pow(3, N);

        int even = (int) IntStream.of(A).filter(a -> a % 2 == 0).count();
        System.out.println(base - (int) Math.pow(2, even));
    }
}


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

inline int dis(int x1, int y1, int x2, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}

int main() {
	int N, M;
	vector<int> a, b, c, d;

	cin >> N >> M;

	for (int i = 0; i < N; i++)
	{
		int tmpa, tmpb;
		cin >> tmpa >> tmpb;
		a.push_back(tmpa);
		b.push_back(tmpb);
	}

	for (int i = 0; i < M; i++)
	{
		int tmpc, tmpd;
		cin >> tmpc >> tmpd;
		c.push_back(tmpc);
		d.push_back(tmpd);
	}

	for (int i = 0; i < N; i++)
	{
		int min = 0;
		for (int j = 1; j < M; j++)
		{
			//cout << a[i] << " " << b[i] << " " << c[j] << " "<< d[j] << endl;
			if (dis(a[i], b[i], c[j], d[j])<dis(a[i], b[i], c[min], d[min])) {
				min = j;
			}
		}
		cout << min + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	string s;
	int w;
	cin >> s >> w;
	for (int i=0;i<s.size();i+=w)
	{
		cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <functional>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
	int n;
  string k;
  map<string, int> m;
  vector<string> v;
	cin >> n;
  int max = 1;
  rep(i,n) {
    cin >> k;
    decltype(m)::iterator it = m.find(k);
    if (it != m.end()) {
      int num = it->second + 1;
      m[k] = num;
      if (num == max) {
        v.push_back(k);
      } else if (num > max) {
        max = num;
        v.clear();
        v.push_back(k);
      }
    } else {
      m.insert(make_pair(k, 1));
      if (max == 1) {
        v.push_back(k);
      }
    }
  }
  sor(v);
  for (string ki: v) {
    cout << ki << endl;
  }
  return 0;
}

Measured memory_bytes: 26736
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int a[2][20];
    
    int i;
    for(i = 0; i < N; i++){
        cin >> a[0][i];
    }
    for(i = 0; i < N; i++){
        cin >> a[1][i];
    }
    
    int sum =0;
    for(i = 0; i < N; i++){
        if(a[0][i] - a[1][i] > 0) sum += a[0][i] - a[1][i];
    }
    
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// Logging
//#define DEBUG
#if defined(DEBUG)
#define debug(x) print(x)
#define sdebug(x) sprint(x)
#else
#define debug(x) \
    {}
#define sdebug(x) \
    {}
#endif

#define print(x) std::cout << x << "\n";
#define sprint(x) std::cout << x;
#define FOR(i, x, y) for (size_t i = x; i < (y); i++)
#define PB push_back

#define ll int64_t
#define vi vector<int>

using namespace std;
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vt) {
    if (vt.empty())
        return os;
    for (size_t i = 0; i + 1 < vt.size(); i++) {
        os << vt[i] << " ";
    }
    os << vt.back();
    return os;
}

struct Timer {
    std::chrono::system_clock::time_point start;
    Timer() {
        start = std::chrono::system_clock::now();
    }

    ~Timer() {
        auto now = std::chrono::system_clock::now();
        std::chrono::system_clock::duration duration = now - start;
        auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
        std::string str;
        str = str + "Runtime: " + std::to_string(ms.count()) + " ms";
        debug(str);
    }
};

void solve();
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    Timer time;

    while (t--) {
        solve();
    }
}

// To compute x^y under modulo m
ll power(ll x, ll y, ll m) {
    if (y == 0)
        return 1;
    ll p = power(x, y / 2, m) % m;
    p = (p * p) % m;

    return (y % 2 == 0) ? p : (x * p) % m;
}

ll inv_mod(ll x, ll m) {
    ll g = gcd(x, m);
    if (g != 1) {
        cout << "Inverse doesn't exist";
        return g;
    } else {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
        return power(x, m - 2, m);
    }
}

ll mod(ll x, ll y) {
    ll ans = x % y;
    if (ans < 0)
        ans += y;
    return ans;
}

void solve() {
    int n;
    cin >> n;
    vector<double> probs(n);
    for (int i = 0; i < n; i++) {
        cin >> probs[i];
    }
    vector<double> dp(2 * n + 1);
    dp[n + 1] = probs[0];
    dp[n - 1] = 1 - probs[0];
    for (int i = 1; i < n; i++) {
        vector<double> newdp(dp.size() + 2);
        for (int j = -i; j <= i; j++) {
            newdp[n + j + 1] += dp[n + j] * probs[i];
            newdp[n + j - 1] += dp[n + j] - dp[n + j] * probs[i];
        }
        dp = move(newdp);
    }
    double ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += dp[n + i];
    }
    printf("%.10f",ans);
}

Measured memory_bytes: 3428
const input = require("fs").readFileSync("/dev/stdin", "utf8")

const lines = input.split('\n')
const X = lines[0] - 0

let five = [0, 1]

const max = X * X
for (let i = 2; five[five.length - 1] < max; i++) {
    five.push(Math.pow(i, 5))
}

;(() => {
    for (let i = 0; i < five.length; i++) {
        for (let j = 0; j < five.length; j++) {
            if (five[i] - five[j] === X) {
                console.log(i, j)
                return
            } else if (five[i] + five[j] === X) {
                console.log(i, -j)
                return
            }
        }
    }
})()

Measured memory_bytes: 33208
#include <stdio.h>

int main(void)
{
    int n, x, t, count = 1;
    scanf("%d %d %d", &n, &x, &t);

    while (n > x)
    {
        count++;
        n -= x;
    }
    

    printf("%d", count * t);

    return 0;
}

Measured memory_bytes: 1732
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(new InputStreamReader(System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(b-a==c-b){
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}


Measured memory_bytes: 21972
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b = LI()
    if a+b == 15:
        return '+'
    if a*b==15:
        return '*'

    return 'x'



print(main())


Measured memory_bytes: 8136
s=input()
t=input()
s_rm = s
ans=0
for i in t:
    if i in s_rm:
        index = s_rm.index(i)
        s_rm = s_rm[index+1:]
        ans += index+1
    elif i in s:
        index = s.index(i)
        ans += len(s_rm) + index +1
        s_rm = s[index+1:]
    else:
        ans=-1
        break
print(ans)

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 998244353;
int main()
{
    int N;
    cin >> N;
    vector<lint> count(N, 0);
    REP(i, N) {
        lint D;
        cin >> D;
        if(i == 0 && D != 0) {
            cout << 0 << endl;
            return 0;
        } else if(i != 0 && D == 0) {
            cout << 0 << endl;
            return 0;
        }
        count[D]++;
    }
    int max = -1;
    IREP(i, N) {
        if(max == -1 && count[i] > 0) {
            max = i;
        } else if(max != -1 && count[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    lint ans = 1;
    lint last = 1;
    REP(i, max+1) {
        REP(j, count[i]) {
            ans = (ans * last) % MOD;
        }
        last = count[i];
    }
    cout << ans << endl;
}

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

using namespace std;


int main(){
cin.tie(0);
string n;
int k;
cin >> k;
cin >> n;

if(n.size()<=k)cout << n;
else{
   string n2;
 for(int i=0;i<k;i++){
 
   n2.push_back(n[i]);

 }
     n2+="...";
   cout << n2;
}
return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define log(i,n) log(n)/log(i);
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n,a, b, c, d;
	cin >> n;
	d = n % 10;
	n /= 10;
	c = n % 10;
	n /= 10;
	b = n % 10;
	n /= 10;
	a = n % 10;
	if (a + b + c + d == 7)return cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl,0;
	else if (a + b + c - d == 7)return cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl,0;
	else if (a + b - c + d == 7)return cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl,0;
	else if (a - b + c + d == 7)return cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl,0;
	else if (a - b - c + d == 7)return cout << a << "-" << b << "-" << c << "+" << d << "=7"  <<endl,0;
	else if (a + b - c - d == 7)return cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl,0;
	else if (a - b + c - d == 7)return cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl,0;
	else if (a - b - c - d == 7)return cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl,0;
}


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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		int x = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		System.out.println((x*y)+" "+(2*(x+y)));
	}

}

Measured memory_bytes: 24304
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
//这里是简单循环，特别的还是手写吧，或者有的循环用的全局变量也要手写
#define fup(i,a,b) for(int i=a; i<=b; ++i)
#define fwn(i,a,b) for(int i=b; i>=a; --i)

string jnvi("ABCDEF");

int main()
{
    string s1, s2;
    cin>>s1>>s2;
    int ans1 = jnvi.find(s1),
        ans2 = jnvi.find(s2);
    if(ans1==ans2)
        printf("=\n");
    if(ans1<ans2)
        printf("<\n");
    if(ans1>ans2)
        printf(">\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <queue>
#include <vector>
#include <functional>

using namespace std;

int N;
long long int a[300005];
long long int L[300005], R[300005];

priority_queue<long long int, vector<long long int>, greater<long long int > > PQ;
priority_queue<long long int> PQ2;

long long int max_val, min_val;

int main(void) {

	cin >> N;

	long long int tmp;
	for (int i = 1; i <= 3*N; i++) {
		cin >> tmp; a[i] = tmp;
	}

	//===========L==============
	for (int i = 1; i <= N; i++) {
		L[N] += a[i]; PQ.push(a[i]);
	}

	
	for (int K = N + 1; K <= 2 * N; K++) {
		min_val = PQ.top(); //cout << min_val << endl;
		//cout << a[K] << "   " << min_val << endl;
		if (a[K] <= min_val) { L[K] = L[K-1]; }
		else { L[K] = L[K - 1] - min_val + a[K]; PQ.pop(); PQ.push(a[K]);}
	}
	

	//===========R===============
	for (int i = 3 * N; i >= 2 * N+1; i--) {
		R[2 * N+1] += a[i];  PQ2.push(a[i]);
	}

	
	for (int K = 2 * N; K >= N + 1; K--) {
		max_val = PQ2.top();  //cout << "max_val= " << max_val << endl;
		if (a[K] >= max_val) { R[K] = R[K + 1]; }
		else { R[K] = R[K + 1] - max_val + a[K]; PQ2.pop(); PQ2.push(a[K]); }
	}


//===========================
	
	

	
	/*for (int K = N; K <= 2 * N; K++) {
		cout << "L[" << K << "]= " <<L[K] << endl;
	}
	for (int K = N+1; K <= 2 * N+1; K++) {
		cout << "R[" << K << "]= " << R[K] << endl;
	}*/

	long long int ans = -1000000000000005;
	for (int K = N; K <= 2 * N; K++) {
		ans = max(ans, L[K] - R[K + 1]);
		//cout << ans << endl;
	}
	
	cout << ans << endl;
	//system("pause");
	return 0;
}

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    
    h[0]--;
    for (int i = 0; i + 1 < n; i++){
        if (h[i] + 1 <= h[i+1]) h[i+1]--;
        else if (h[i] == h[i+1]) continue;
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
}


Measured memory_bytes: 3784
#include<bitset>
#include<iostream>
using namespace std;
int a[2009];
int main(){
  ios::sync_with_stdio(0);cin.tie(0);
  int n;cin>>n;
  int sum=0;
  for(int i=1;i<=n;++i){cin>>a[i];sum+=a[i];}
  //now do that bitset  thing
  bitset<4000004>dp={};
  dp.reset();
  dp[0]=1;
    //for(int i=0;i<=sum;++i)cout<<dp[i]<<" &&\n";
  for(int i=1;i<=n;++i){
    dp=dp|(dp<<a[i]);
    // for(int j=sum;j>=a[i];--j){
    //   if(dp[j-a[i]]==1)dp[j]=1;
    // }
  }
  //now find the smallest one greater than sum/2
//  for(int i=0;i<=sum;++i)cout<<dp[i]<<" **\n";
  for(int j=(sum+1)/2;j<=sum;++j)if(dp[j]==1){cout<<j<<"\n";return 0;}
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int i, j, n;
    string s, r, cmd;
    cin >> s;
    cin >> n;
    while (n--) {
        cin >> cmd >> i >> j;
        if (cmd == "print") cout << s.substr(i, (j - i + 1)) << "\n";
        else if (cmd == "reverse") reverse(s.begin() + i, s.begin() + j + 1);
        else {
            cin >> r;
            s.replace(i, (j - i + 1), r);
        }
    }
    
    return 0;
}



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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	cout << W*H/2 << " ";
	if(x == W/2 && y == H/2) cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int r;
    cin >> r;
    double pi = acos(-1);
    cout << fixed << setprecision(12);
    cout << 2*pi*r << '\n';
}

Measured memory_bytes: 3780
#include<iostream>
using namespace std;
int main()
{
  int a;
 
  int c5=0,c7=0;
  int i=1;
  for(i=1;i<=3;i++)
  {
    std::cin>>a;
    if(a==5)
      c5+=1;
    else if(a==7)
      c7+=1;
  }
  std::cout<<endl;
  if(c7==1&&c5==2)
    std::cout<<"YES";
  else
    std::cout<<"NO";
  return 0;
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int N = 5e5 + 100;
const int SZ = 30;

int n, jump[N][SZ];
string s;

int d[N], f[N], t;
vi adj[N];
void dfs(int u, int p) {
    d[u] = t++;
    for (int v : adj[u]) if (v != p) dfs(v,u);
    f[u] = t;
}

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

    cin >> s; n = si(s);
    for (char &c : s) c -= 'a';

    forn(c,27) {
        jump[n+1][c] = n+1;
        jump[n][c] = n+1;
    }

    dforsn(i,0,n) {
        forn(c,27) {
            if (c < s[i]) jump[i][c] = n+1;
            else if (c == s[i]) jump[i][c] = i+1;
            else jump[i][c] = jump[jump[i][c-1]][c-1];
        }
        if (jump[i][26] < n+1) {
            forn(c,27) jump[i][c] = min(jump[i][c], jump[jump[i][26]][c]);
        }
    }

    //forn(i,n+1) cerr << i << ' ' << jump[i][26] << endl;

    forn(i,n+1) adj[jump[i][26]].pb(i);
    dfs(n+1,-1);

    int q; cin >> q;
    while (q--) {
        int l,r; cin >> l >> r;
        l--;
        bool ans = (d[r] <= d[l] && f[l] <= f[r]);
        cout << (ans ? "Yes\n" : "No\n");
    }

    return 0;
}


Measured memory_bytes: 102684
#include <bits/stdc++.h>
using namespace std;
signed main(){
    long long n , p , ans=1 , i=2 , tem , m;
    cin >> n >> p;
    
    if(n == 1){
        ans = p;
    } else {
        while(i*i <= p){
            if(p%i == 0){
                tem = p , m = 0;
                while(tem%i == 0 && tem > 0){
                    tem = tem / i;
                    m++;
                }
                if(m >= n){
                    ans = max(i , ans);
                }
            }
            i++;
        }
    }
    
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

bool ok(int mask)
{
    for (int i = 0; i < 20; ++i)
        if ((mask & (1 << i)) > 0 && (mask & (1 << (i + 1))) > 0)
            return false;
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m, k;
    cin >> n >> m >> k;
    if (m == 1)
    {
        cout << "1";
        return 0;
    }
    vector< vector<ll> > dp(n, vector<ll>(m, 0));
    for (int mask = 0; mask < (1 << (m - 1)); ++mask)
    {
        if (ok(mask))
        {
            if ((mask & (1 << 0)) > 0)
                ++dp[0][1];
            else
                ++dp[0][0];
        }
    }
    for (int i = 0; i < n - 1; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            for (int mask = 0; mask < (1 << (m - 1)); ++mask)
            {
                if (ok(mask))
                {
                    if (j - 1 >= 0 && (mask & (1 << (j - 1))) > 0)
                        dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j]) % MOD;
                    else
                    {
                        if (j < m - 1 && (mask & (1 << j)) > 0)
                            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
                        else
                            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
                    }
                }
            }
        }
    }
    cout << dp[n - 1][k - 1];
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN
 main() {
int a,b;
cin>> a >>b;
if(1<=a&&9>=a&&1<=b&&9>=b){
  cout << a *b <<endl;
}
else{
  cout <<  -1 << endl;
}
 }

Measured memory_bytes: 256
using System;
using System.Linq;


class A
{
    public static void Main() {
        int n = int.Parse(Console.ReadLine());
        int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        CountingSort(ref A, n);
    }
    public static void CountingSort(ref int[] A, int n) {
        int k = 10000;
        int[] B = new int[n];
        int[] C = new int[k + 1];
        for (int i = 0; i < n; i++) {
            C[A[i]]++;
        }
        for (int j = 1; j <= k; j++) {
            C[j] = C[j] + C[j - 1];
        }
        for (int i = n - 1; i >= 0; i--) {
            B[C[A[i]] - 1] = A[i];
            C[A[i]]--;
        }
        Console.WriteLine(string.Join(" ", Array.ConvertAll(B, b => b.ToString())));
    }
}



Measured memory_bytes: 265344
N,M = map(int,input().split())
P = list(map(int,input().split()))
XY = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]
uf = UnionFind(N)

for x,y in XY:
    x,y = x-1,y-1
    if not uf.is_same(x,y):
        uf.unite(x,y)
ans = 0
for i,p in enumerate(P):
    if uf.is_same(i,p-1):
        ans += 1
print(ans)

Measured memory_bytes: 25176
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG N; cin >> N;
    LLONG ans = 0;
    for (LLONG i = 1; i <= N; ++i)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct fraction{
    ll num,dom;
    fraction(){}
    fraction(ll num,ll dom):num(num),dom(dom){
        //assert(dom!=0);    
        if(dom<0) num*=-1,dom*=-1;  
        //いりそうならここでGCDとる  
    }
    fraction operator+(const fraction a) const{
        return fraction(num*a.dom+a.num*dom,dom*a.dom);
    }
    fraction operator-(const fraction a) const{
        return fraction(num*a.dom-a.num*dom,dom*a.dom);
    }
    fraction operator*(const fraction a) const{
        return fraction(num*a.num,dom*a.dom);
    }
    fraction operator/(const fraction a){
        return fraction(num*a.dom,dom*a.num);
    }
    fraction operator*(ll k) const{return fraction(num*k,dom);}
    fraction operator/(ll k) const{return fraction(num,dom*k);}
    bool operator<(const fraction a)const{
        return num*a.dom<a.num*dom;
    }
    bool operator>(const fraction a)const{
        return num*a.dom>a.num*dom;
    }
    bool operator==(const fraction a)const{
        return num*a.dom==a.num*dom;
    }
    bool operator!=(const fraction a)const{
        return num*a.dom!=a.num*dom;
    }
    bool operator<=(const fraction a)const{
        return num*a.dom<=a.num*dom;
    }
    bool operator>=(const fraction a)const{
        return num*a.dom>=a.num*dom;
    }
};   
int main(){
    int h,w;
    cin>>h>>w;
    string s[h+1];
    rep(i,h){
        cin>>s[i+1];
        s[i+1]+='.';
    }
    rep(i,w+1)s[0]+='.';
    vector<pair<fraction,fraction> > v;
    rep(i,h)rep(j,w){
        if(s[i+1][j]=='#'&&s[i][j]=='.'){
            v.push_back({{h-i,j+1},{h-i,j}});
        }
        if(s[i+1][j]=='#'&&s[i+1][j+1]=='.'){
            v.push_back({{h-i-1,j+1},{h-i,j+1}});
        }
    }
    sort(v.begin(),v.end());
    priority_queue<fraction,vector<fraction>,greater<fraction> > que;
    int ans=0;
    for(auto p : v){
        while(que.size()&&que.top()<=p.first)que.pop();
        que.push(p.second);
        ans=max(ans,(int)que.size());
    }
    cout<<ans+1<<endl;
    return 0;
}   


Measured memory_bytes: 11824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int boss=1e4;
int n,a[boss+10],b[boss+10],c[boss+10];ll cnt1,cnt2;
int main()
{
int i;
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%d",&a[i]);
for (i=1;i<=n;i++) scanf("%d",&b[i]);
for (i=1;i<=n;i++) c[i]=a[i]-b[i];
for (i=1;i<=n;i++) if (c[i]>0) cnt1+=c[i];else cnt2-=c[i]/2;
puts(cnt1<=cnt2?"Yes":"No");
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int A,B,K;cin>>A>>B>>K;
    vector<int>ans;
    for(int i=100;i>0;i--){
        if(A%i==0&&B%i==0)
            ans.push_back(i);
    }
    cout << ans[K-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
int N;
int counter_2 = 0;

cin >> N;
for(int i = 1; i <= N; i = i+2){
    int counter_1 = 0;
    for(int j = 1; j <= i; j++){
        if(i % j == 0){
            counter_1++;
        }
    }
    if(counter_1 == 8){
        counter_2++;   
    }
}
cout << counter_2 << endl;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3 4" ].parse.expand.solve == 6 );
	assert( [ "2 2" ].parse.expand.solve == 1 );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	return tuple( nm[ 0 ], nm[ 1 ] );
}

auto solve( long n, long m )
{
	return ( n - 1 ) * ( m - 1 );
}


Measured memory_bytes: 256