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


long long int arr[100005];
int main(){
    long long int n,k,q,s=0;
    cin>>n>>k>>q;

    while(q--){
        int a;
        cin>>a;
         arr[a]++;
        s++;

    }

    for(int i=1;i<=n;i++){
        int z=s-arr[i];
        if(k-z<=0)
            cout<<"No"<<endl;

        else
            cout<<"Yes"<<endl;
    }



}


Measured memory_bytes: 1408
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j;
  int M[MAX][MAX],u,k,v,c;
  int key[MAX],vis[MAX],pi[MAX],minv;
  
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  for(i=0; i<n; i++){
    key[i]=INFTY;
    vis[i]=0;
    pi[i]=-1;
  }
  
  key[0]=0;
  
  while(1){
    u=-1;
    minv=INFTY;
    
    for(i=0; i<n; i++){
      if(key[i] < minv && !vis[i]){
	u=i;
	minv=key[i];
      }
    }
    
    if(u==-1)
      break;
    
    vis[u]=1;
    for(i=0; i<n; i++){
      if(key[i] >=M[u][i]+key[u] && !vis[i]){
	pi[i]=u;
	key[i]=M[u][i]+key[u];
      }
    }
  }
  
  
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (key[i]==INFTY?-1:key[i]));
  }
  
  return 0;
}

Measured memory_bytes: 804
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}

int main(){
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	puts(a<=c&&c<=b?"Yes":"No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
using VLL = vector <LL>;
#define ALL(a) (a).begin(), (a).end()

template<typename T>
istream& operator >> ( istream& is, vector<T>& vec ) {
    for( T& x: vec ) {
        is >> x;
    }
    return is;
}

int main() {
    LL n;
    cin >> n;
    
    VLL s(n);
    cin >> s;
    
    LL q;
    cin >> q;
    
    VLL t(q);
    cin >> t;
    
    auto is_in_s = [&]( LL x ){ return find( ALL(s), x ) != s.end(); };
    cout << count_if( ALL(t), is_in_s ) << endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n; //if(n==1) {cout<<1<<endl; return 0;}
    vector <int> a(n);
    vector <int>  data(100010) ;
    for(int i=0;i<n;i++){
    cin>>a[i];
    data[a[i]]++;
    }
    int ans = 0;
    for(int i=1;i<100000;i++){
        ans = max(ans, data[i]+ data[i-1] + data[i+1]);
    }
    cout<<ans<<endl;
}

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

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k;i--)
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define mp make_pair

const int mod = 1000000007;
const ld pi = acos(-1);
const int maxn = 200006;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int32_t main(){
    int n;  cin>>n;
    vector<int> A(n); fr(i,0,n) cin>>A[i];
    double ans = 0;
    fr(i,0,n)
      ans += 1/(double)A[i];
    double res = 1/ans;
    cout<<fixed<<setprecision(8)<<res<<endl;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B){
    vector<vector<int>> edges(N+1);
    rep(i,0,M) {
        edges[A[i]].emplace_back(B[i]);
        edges[B[i]].emplace_back(A[i]);
    }
    int answer = 0;
    rep(i,1,N+1) {
        bool isGood = true;
        for (const auto next : edges[i]) {
            if (H[next] >= H[i]) {
                isGood = false;
                break;
            }
        }
        if (isGood) answer++;
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N+1);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i+1]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(H), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 10676
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    sort_g(A);
    cout << A.at(0) - A.at(A.size() - 1) << endl;
}

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

void output(vector<vector<int>>& x){
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 10; ++j){
            cout << " " << x[i][j];
        }
        cout << endl;
    }
}

void print_delimiter(){
    for(int i = 0; i < 20; ++i){
        cout << '#';
    }
    puts("");
}

int main(){

    int n;
    cin >> n;
    vector<vector<int>> A(3, vector<int>(10));  // A棟
    vector<vector<int>> B(3, vector<int>(10));  // B棟
    vector<vector<int>> C(3, vector<int>(10));  // C棟
    vector<vector<int>> D(3, vector<int>(10));  // D棟

    for(int i = 0; i < n; ++i){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        --f; --r; // 0インデックスのため1引く
        if(b == 1){
            // A棟
            A[f][r] += v;
        }
        else if(b == 2){
            // B棟
            B[f][r] += v;
        }
        else if(b == 3){
            // C棟
            C[f][r] += v;
        }
        else{
            // D棟
            D[f][r] += v;
        }
    }

    output(A);
    print_delimiter();
    output(B);
    print_delimiter();
    output(C);
    print_delimiter();
    output(D);

    return 0;
}


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


int main(){
  while(true){
    int n,m,ans=0;
    cin>>n>>m;
    if(n+m==0)break;
    vector<int>v(n);
    rep(i,n)cin>>v[i];
    rep(i,n){
      for(int j=i+1;j<n;j++){
        if(v[j]+v[i]>ans&&m>=v[j]+v[i])ans=v[j]+v[i];
      }
    }
    if(ans)cout<<ans<<endl;
    else cout<<"NONE"<<endl;
  }
}



Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	int a,b,c,d;
	cin >> a;
	vector<ll int> v,res;
	for(ll int i=0;i<a;i++)
	{
		cin >> b;
		v.push_back(b);
	}
	res.assign(a,0);
	res[1]=abs(v[1]-v[0]);
	for(ll int i=2;i<a;i++)
	{
		res[i]=min(res[i-1]+abs(v[i]-v[i-1]),res[i-2]+abs(v[i]-v[i-2]));
	}
	cout << res[a-1];
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    // A-B
    // (B+C) - (A+C) -> (B - A)
    // ((A+C)+(A+B)) - ((B+C)+(B+A)) -> A - B
    cout << (K%2 == 0 ? (A - B) : (B - A)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 3000000007;
const double INFD = 1e100;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  S = '#' + S;
  vector<int> f;
  f.push_back(0);
  for(int i=1; i<N; i++){
    if(S[i] != S[i+1]){
      f.push_back(i);
    }
  }
  f.push_back(N);
  int m=0;
  for(int i=0; i<(int)f.size()-1; i++){
    int res;
    if(S[f[i]+1] == '0'){
      res = f[min(2*K+i,(int)f.size()-1)] - f[i];
    }else{
      res = f[min(2*K+i+1,(int)f.size()-1)] - f[i];
    }
    chmax(m,res);
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 1016
k, n = map(int, input().split())
a_ls = list(map(int, input().split()))
deg_ls = []
for i in range(n-1):
    deg_ls.append(a_ls[i+1] - a_ls[i])
deg_ls.append(a_ls[0] + k- a_ls[-1])
deg_ls.sort()
print(k-deg_ls[-1])


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

using namespace std;

int main() {
  int x, n;
  cin >> x >> n;
  if(n == 0) {
    cout << x << endl;
    return 0;
  }
  vector<int> vec(n);
  vector<int> a(300);
  for(int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  for(int i = 0; i < 301; i++) {
    a[i] = i - 100;
  }
  for(int i = 0; i < n; i++) {
    int m = vec[i];
    a.erase(a.begin() + m + 100 - i);
  }
  int ans = 200;
  int q = a.size();
  for(int i = 0; i < q; i++) {
    ans = min(ans, abs(a[i] - x));
  }
  for(int i = 0; i < n; i++) {
    if(x - ans == vec[i]) {
      cout << x + ans << endl;
      return 0;
    }
  }
  cout << x - ans << endl;
  return 0;
}


Measured memory_bytes: 3636
/*
2020-05-05
atcoder ABC
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int K;
    string S;
    cin >> K >> S;
    if(S.size() > K){
        cout << S.substr(0,K) + "..." << endl;
    } else {
        cout << S << endl;
    }
    
    return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  cout << C << " " << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    
    int n,m,x,y;
  	cin >> n >> m >> x >> y;
  	int a[n],b[m];
  	bool flag = true;
  	
  	rep(i,0,n){
      cin >> a[i];
    }
  
  	rep(i,0,m){
      cin >> b[i];
    }
  
  	rep(i,x+1,y+1){
      flag = true;
      rep(j,0,n){
        if(a[j] >= i){
          flag = false;
        }
      }
      rep(j,0,m){
        if(b[j] < i){
          flag = false;
        }
      }
      
      if(flag){
        cout << "No War" << endl;
      	return 0;
      }
    }
  
  	cout << "War" << endl;
  
  	
  
  return 0;
  
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

x1,y1,x2,y2 = map(int, input().split())

X = x2 - x1
Y = y2 - y1

print(str(x2 - Y) + ' ' + str(y2 + X) + ' ' + str(x1 - Y) + ' ' + str(y1 + X))

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

int gcd(int x, int y) {
	if (y == 0)return x;
	else return gcd(y, x%y);
}

int main() {
	int a, b;
	while (cin >> a >> b) {
		int c = gcd(a, b);
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
import java.util.*;

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

        Set<Integer> P = makePrimes(100000);
        int[] S = new int[100001];
        int c = 0;
        for (int n = 1; n < 100001; n++) {
            if (P.contains(n) && P.contains((n + 1) / 2)) {
                c++;
            }
            S[n] = c;
        }

        int Q = in.nextInt();
        for (int q = 0; q < Q; q++) {
            int L = in.nextInt();
            int R = in.nextInt();
            System.out.println(S[R] - S[L - 1]);
        }
    }

    static HashSet<Integer> makePrimes(int n) {
        HashSet<Integer> P = new HashSet<>();
        boolean[] F = new boolean[n + 1];
        Arrays.fill(F, true);
        for (int i = 2; i < n + 1; i++) {
            if (!F[i]) {
                continue;
            }

            P.add(i);
            for (int j = i; j < n + 1; j += i) {
                F[j] = false;
            }
        }

        return P;
    }
}



Measured memory_bytes: 63708
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int x=0;
    string S;
    cin >> N >> S;
    for(int i=0; i<10; i++){ //1桁目
        for(int j=0; j<10; j++){  //2桁目
            for(int k=0; k<10; k++){ //3桁目
                int count = 0;
                int Secure[] = {i,j,k};
                for(int t=0; t<N; t++){ //作成可能かどうか
                    if(count == 3) break;
                    if(S[t] - '0' == Secure[count]) count++;
                }
                if(count == 3) x++;
            }
        }
    }
    cout << x << endl;
}

Measured memory_bytes: 384
/+ dub.sdl:
    name "A"
    dependency "dcomp" version=">=0.0.2"
+/

import std.algorithm, std.range, std.stdio, std.math, std.conv, core.bitop;

// import dcomp.scanner;
// import dcomp.algorithm;

int n;
struct Edge {
    int to;
    long dist;
}
Edge[][] g;
long md;

T[N] toS(T, int N)(T[N] data){ return data; }

long[2][][] memo;
long[2][] dfs(int p) {
    if (g[p].empty) {
        return [[0L, 0L]];
    }
    Edge le = g[p][0], re = g[p][1];
    auto lt = dfs(le.to);
    auto rt = dfs(re.to);
    if (lt.length > rt.length) {
        swap(le, re);
        swap(lt, rt);
    }
    long ld = le.dist, rd = re.dist;
    auto buf = Appender!(long[2][])(memo[p]);
    buf.clear();
    foreach (co; lt) {
        //co[1] + ld + rd + rco[0] <= md
        int idx = binSearch!((i){return co[1]+ld+rd+rt[i][0] > md;})(-1L, rt.length).to!int-1;
        if (idx == -1) continue;
        buf.put([co[0]+ld, rt[idx][1]+rd].toS);
        buf.put([rt[idx][1]+rd, co[0]+ld].toS);
    }
    memo[p] = buf.data;
    sort(memo[p]);
    if (memo[p].empty) return memo[p];
    long ma = 10L^^15;
    int co = 0;
    foreach (e; memo[p]) {
        if (ma <= e[1]) continue;
        ma = min(ma, e[1]);
        memo[p][co] = e;
        co++;
    }
    return memo[p][0..co];
}

//md以下にできるか？
bool solve(long _md) {
    md = _md;
    return !dfs(0).empty;
}

int main() {
    auto sc = new Scanner();
    int n;
    sc.read(n);
    g = new Edge[][](n);
    memo = new long[2][][](n);
    foreach (i; 1..n) {
        int a; long b;
        sc.read(a, b); a--;
        g[a] ~= Edge(i, b);
    }

    writeln(binSearch!solve(-1L, 10L^^12));
    return 0;
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

class Scanner {
    import std.stdio : File, readln, stdin;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeString, isDynamicArray;
    import std.algorithm : map;
    File f;
    this(File f = stdin) {
        this.f = f;
    }
    string[] buf;
    bool succ() {
        while (!buf.length) {
            if (f.eof) return false;
            buf = readln.split;
        }
        return true;
    }
    int read(Args...)(auto ref Args args) {
        foreach (i, ref v; args) {
            if (!succ()) return i;
            alias VT = typeof(v);
            static if (!isSomeString!VT && isDynamicArray!VT) {
                v = buf.map!(to!(ElementType!VT)).array;
                buf.length = 0;
            } else {
                v = buf.front.to!VT;
                buf.popFront();
            }
        }
        return args.length;
    }
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/algorithm.d */
// module dcomp.algorithm;

//[0,0,0,...,1,1,1]で、初めて1となる場所を探す。pred(l) == 0, pred(r) == 1と仮定
T binSearch(alias pred, T)(T l, T r) {
    while (r-l > 1) {
        T md = (l+r)/2;
        if (!pred(md)) l = md;
        else r = md;
    }
    return r;
}


Measured memory_bytes: 93308
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <iostream>
using namespace std;

const double EPS=1e-10;
const double INF=1e10;

struct Point {
    double x, y;
    Point(double x=0, double y=0) : x(x), y(y) {}

    Point operator-(const Point &o) const {
        return Point(x-o.x, y-o.y);
    }

    Point operator+(const Point &o) const {
        return Point(x+o.x, y+o.y);
    }

    Point operator*(const double m) const {
        return Point(x*m, y*m);
    }

    double dot(const Point &o) const {
        return x * o.x + y * o.y;
    }
    
    double cross(const Point &o) const {
        return x * o.y - y * o.x;
    }

    double norm() const {
        return dot(*this);
    }
};

int ccw(Point a, Point b, Point c) {
    b = b - a, c = c - a;
    if (b.cross(c) > EPS) return +1;
    if (b.cross(c) < -EPS) return -1;
    if (b.dot(c) < 0) return +2;
    if (b.norm() < c.norm()) return -2;
    return 0;
}

int main() {
    Point a, b, c, d;
    string s;
    while (getline(cin, s)) {
        for (int k = s.find(','); k != string::npos; k = s.find(',')) {
            s[k] = ' ';
        }
        istringstream ss(s);
        ss >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y;
        if (ccw(a, b, c) == ccw(b, c, d) && ccw(b, c, d) == ccw(c, d, a) && ccw(c, d, a) == ccw(d, a, b)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
def main():
  N, M = list(map(lambda a: int(a), input().split(" ")))

  if N >= M:
    print(0)
    return 0
  
  X = list(map(lambda x: int(x), input().split(" ")))
  X.sort()
  D = [X[i+1] - X[i] for i in range(len(X) - 1)]
  D.sort()
  print(sum(D[:M-N]))

main()

Measured memory_bytes: 20552
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(i,l,r) for (int i=l;i<=r;++i) 
#define mp(x,y) make_pair(x,y)
#define ft first
#define sd second 
#include <map>
#include <string>
#include <iostream>
#define GG return printf("-1"),0;
using namespace std;
const int N=1e5+5;
void read(int &x)
{
	x=0;
	char ch=getchar();int f=1;
	while (ch<'0'||ch>'9') ch=='-'?f=-1:0,ch=getchar();
	while ('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x*=f;return ;
}

int n,a[N],b[N],c[N],d[N];
int tmp,cnt;
int zzk;
int check(int x)
{
	return (upper_bound(d+1,d+1+n,x)-d)-(lower_bound(d+1,d+1+n,x)-d)>0;
}

struct xx
{
	int V,next;
}B[N<<2];
int head[N],bel[N],G;
void add(int x,int y)
{
	B[++G]=(xx){y,head[x]};
	head[x]=G;
}

#define F(x) for (int i=head[x];i;i=B[i].next)
#define v B[i].V
int dfn[N],low[N],T,In[N],st[N];
void dfs(int x)
{
	low[x]=dfn[x]=++T;
	st[++st[0]]=x;In[x]=1;
	F(x) if (!dfn[v]) dfs(v),low[x]=min(low[x],low[v]);
	else if (In[v]) low[x]=min(low[x],dfn[v]);
	#define now st[st[0]]
	if (dfn[x]==low[x])
	{
		for (++cnt;now^x;--st[0]) In[now]=0,bel[now]=cnt;
		bel[x]=cnt,--st[0],In[x]=0;
	}
	return ;
}
int ans;
int gg;
map <int,int>ma,mb;
int main()
{	
	read(n);
	rep(i,1,n) read(a[i]),++ma[a[i]],tmp^=a[i],c[i]=a[i];
	c[n+1]=a[n+1]=tmp;sort(c+1,c+1+n+1);
	tmp=0;
	rep(i,1,n) read(b[i]),++mb[b[i]],tmp^=b[i],d[i]=b[i];
	b[n+1]=d[n+1]=tmp;sort(d+1,d+1+n+1);
	rep(i,1,n+1) if (c[i]^d[i]) GG;
	zzk=unique(c+1,c+1+n+1)-c;
	tmp=lower_bound(c+1,c+zzk,tmp)-c;
	rep(i,1,n+1) a[i]=lower_bound(c+1,c+zzk,a[i])-c;
	rep(i,1,n) b[i]=lower_bound(c+1,c+zzk,b[i])-c;
	rep(i,1,n) if (a[i]!=b[i]) add(a[i],b[i]);
	if (!G) return printf("0"),0;
	cnt=0;
	for (int i=1;i<zzk;++i)
	  if (head[i]&&!bel[i]) 
	    dfs(i);
	ans=cnt;
	rep(i,1,n) if (a[i]!=b[i]&&bel[a[i]]==bel[b[i]]) 
	  ++ans;
	return printf("%d",ans-(bel[a[n+1]]?1:0)),0;
}

Measured memory_bytes: 19712
n,m = map(int,input().split())
XYZ = [list(map(int,input().split())) for _ in range(m)]


def search(UF,loc):
    if UF[loc] == loc:
        return UF[loc]
    else:
        UF[loc] = search(UF,UF[loc])
        return UF[loc]
    
dic = [0]*(n+1)
A = [0]*(n+1)
UF = [_ for _ in range(n+1)]
for x,y,z in XYZ:
    UF[x] = search(UF,x)
    UF[y] = search(UF,y)
    if UF[x] != UF[y]:
        UF[max(UF[x],UF[y])] = min(UF[x],UF[y])


for i in range(1,n+1):
    temp = search(UF,i)
    dic[temp] = 1
print(sum(dic))

Measured memory_bytes: 35052
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(); int k = sc.nextInt();
        if (k >= (1 << m)) {
            System.out.println(-1);
        } else if (m == 0) {
            System.out.println(0 + " " + 0);
        } else if (m == 1) {
            if (k == 0) {
                System.out.println(0 + " " + 0 + " " + 1 + " " + 1);
            } else System.out.println(-1);
        } else {
            ArrayList<Integer> ans = new ArrayList<>();
            for (int i = 0; i < (1 << m); i++) if (i != k) ans.add(i);
            ans.add(k);
            for (int i = (1 << m) - 1; i >= 0; i--) if (i != k) ans.add(i);
            ans.add(k);
            for (int i = 0; i < ans.size(); i++) System.out.print(ans.get(i) + " ");
        }
    }


}

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

int main() {
  int N, K;
  cin >> N >> K;
  int j=0;

  // ここにプログラムを追記
  int M = K/2;
  for (int i=0; i<N; ++i){
    int A;
    cin >> A;
    if (A <= M) {
      j += 2*A;
    }else{
      j += 2*(K-A);
    }
  }
  cout << j << endl;
}


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

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

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

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

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

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N = lread();
    long x = 1;
    while (x * 2 <= N)
    {
        x *= 2;
    }
    writeln(x);
}


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

int main(){
	int h, w, n;
	cin >> h >> w >> n;
	int val = max(h, w);
	cout << ((n / val) + (bool)(n % val)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcnt(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 1005

int n, m, a[maxn][maxn], num[maxn];
bool flag[maxn];

int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	ios::sync_with_stdio(0);
	cin.tie(0);

	ms(flag, 0);
	cin >> n >> m;
	For(i, 1, n) For(j, 1, m) cin >> a[i][j];

	int res = inf;
	For(run, 0, m - 1){
//		cout << run << endl;
		ms(num, 0);
		For(i, 1, n){
			int id = -1;
			For(j, 1, m) if(!flag[a[i][j]]){
				id = a[i][j];
				break;
			}
			num[id]++;
		}

		int id = -1;
		For(j, 1, m) if(!flag[j]){
			id = j;
			break;
		}
		For(i, 1, m) if(!flag[i] && num[i] > num[id]){
			id = i;
		}
//		cout << id << " " << num[id] << endl;
		res = min(res, num[id]);
		flag[id] = 1;
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val as = Vector.fill(n / 2)((sc.nextInt, sc.nextInt))

  val odd = mutable.Map[Int, Int]()
  val even = mutable.Map[Int, Int]()

  as.foreach { case (o, e) =>
    odd.put(o, odd.getOrElse(o, n / 2) - 1)
    even.put(e, even.getOrElse(e, n / 2) - 1)
  }

  val oo = odd.toSeq.sortBy(a => a._2)
  val ee = even.toSeq.sortBy(a => a._2)

  val res = (oo, ee) match {
    case _ if oo.head._1 != ee.head._1 => oo.head._2 + ee.head._2
    case (o1 +: o2 +: _, e1 +: e2 +: _) => (o1._2 + e2._2) min (o2._2 + e1._2)
    case (o1 +: _, _ +: e2 +: _) => o1._2 + e2._2
    case (_ +: o2 +: _, e1 +: _) => e1._2 + o2._2
    case _ => n / 2
  }

  println(res)
}


Measured memory_bytes: 79036
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 9
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
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 II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    xp9, xm9, xf9, yp9, ym9, yf9 = [-INF] * 6
    xp0, xm0, xf0, yp0, ym0, yf0 = [INF] * 6
    for _ in range(N):
        x, y, d = LS()
        x = int(x)
        y = int(y)
        if d == 'R':
            xp9 = max(xp9, x)
            xp0 = min(xp0, x)
            yf9 = max(yf9, y)
            yf0 = min(yf0, y)
        elif d == 'L':
            xm9 = max(xm9, x)
            xm0 = min(xm0, x)
            yf9 = max(yf9, y)
            yf0 = min(yf0, y)
        elif d == 'U':
            xf9 = max(xf9, x)
            xf0 = min(xf0, x)
            yp9 = max(yp9, y)
            yp0 = min(yp0, y)
        elif d == 'D':
            xf9 = max(xf9, x)
            xf0 = min(xf0, x)
            ym9 = max(ym9, y)
            ym0 = min(ym0, y)
    ts = [0]
    ts += [xf0 - xp0, xf9 - xp0, xf0 - xp9, xf9 - xp9]
    ts += [(xm0 - xp0) * 0.5, (xm9 - xp0) * 0.5, (xm0 - xp9) * 0.5, (xm9 - xp9) * 0.5]
    ts += [xm0 - xf0, xm9 - xf0, xm0 - xf9, xm9 - xf9]
    ts += [yf0 - yp0, yf9 - yp0, yf0 - yp9, yf9 - yp9]
    ts += [(ym0 - yp0) * 0.5, (ym9 - yp0) * 0.5, (ym0 - yp9) * 0.5, (ym9 - yp9) * 0.5]
    ts += [ym0 - yf0, ym9 - yf0, ym0 - yf9, ym9 - yf9]
    ts = [t for t in ts if t >= 0]
    ans = 10 ** 18
    for t in ts:
        xmax = max(xf9, xm9 - t, xp9 + t)
        xmin = min(xf0, xm0 - t, xp0 + t)
        ymax = max(yf9, ym9 - t, yp9 + t)
        ymin = min(yf0, ym0 - t, yp0 + t)
        tmp = (xmax - xmin) * (ymax - ymin)
        ans = min(ans, tmp)

    return ans

print(main())

Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int n;
    scanf("%d",&n);
    char s[102],t[102];
    scanf("%s %s",s,t);
    int i=0, a=0;
    char m[202];
    
    while(t[i] != '\0'){
        m[a] = s[i];
        a++;
        m[a] = t[i];
        a++;
        i++;
    }
    m[a] = '\0';
    printf("%s\n",m);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long n,a[100005],m=1000000000000000000;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int f=1;
	long long ans=1,c=0;
	sort(a,a+n);
	while(c<n)
	{
		if(m/ans>=a[c])
		{
			ans=ans*a[c];
			c++;
		}
		else
		{
			f=-1;
			break;
		}
		if(ans==0)
		{
			break;
		}
	}
	if(f==1)cout<<ans<<endl;
	else cout<<-1<<endl;
	return 0;
}



Measured memory_bytes: 3960
n=int(input())
C=[int(i) for i in input().split()]
mod=10**9+7
C.sort()
P=[0]*(2*n+1)
P[0]=1
for i in range(1,2*n+1):
  P[i]=(P[i-1]*2)%mod

ans=0
for i in range(n):
  ans=(ans+(n-i+1)*P[2*n-2]*C[i])%mod
print(ans)


Measured memory_bytes: 30700
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;
ll n,q;
ll arr[N];
int main()
{  fast
ll sum=0;
cin>>n;
for(int i=0;i<n;i++){
	ll x;
	cin>>x;
	arr[x]++;
	sum+=x;
}
cin>>q;
while(q--){
	ll x,y;
	cin>>x>>y;
	ll z=arr[x]*(y-x);
	arr[y]+=arr[x];arr[x]=0;
	sum+=z;
	cout<<sum<<endl;
}

}

Measured memory_bytes: 4408
n = int(input())
L_list = [int(i) for i in input().split()]
count = 0
for i in range(len(L_list)):
    for j in range(i,len(L_list)):
        for k in range(j,len(L_list)):
            if L_list[i]!=L_list[j] and L_list[j]!=L_list[k] and L_list[k]!=L_list[i]:
                list = [L_list[i],L_list[j],L_list[k]]
                list.sort()
                if list[0]+list[1] > list[2]:
                    count += 1
print(count)


Measured memory_bytes: 9192
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==5  && b==5 && c<=7)
  {
    printf("YES\n");
  }
  else if(a==5  && b==7 && c<=5)
  {
    printf("YES\n");
  }
  else if(a==7  && b==5 && c<=5)
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
}


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

int main() {
  int n;
  cin >> n;
  unordered_set<string> st;
  rep(i,n) {
    string si;
    cin >> si;
    st.insert(si);
  }

  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 17692
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

constexpr int INF = LIM( int )::max() / 2;

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

	int N;
	cin >> N;

	VS lines( N );
	cin.ignore();
	FOR( line, lines )
	{
		getline( cin, line );
		line.resize( SZ( line ) - 1 );
	}

	map< string, int > labels;
	REP( i, N )
	{
		if ( lines[i].find( "goto " ) != 0 )
		{
			labels[ lines[i] ] = i;
		}
	}

	VI distances( N + 1, INF );
	distances[0] = 0;

	deque< int > que;
	que.PB( 0 );

	while ( !que.empty() && que.front() != N )
	{
		const int u = que.front();
		que.pop_front();

		if ( lines[u].find( "goto " ) == 0 )
		{
			const int v = labels[ lines[u].substr( 5 ) ];
			if ( distances[u] < distances[v] )
			{
				distances[v] = distances[u];
				que.push_front( v );
			}
			if ( u < N && distances[u] + 1 < distances[ u + 1 ] )
			{
				distances[ u + 1 ] = distances[u] + 1;
				que.PB( u + 1 );
			}
		}
		else if ( u < N && distances[u] < distances[ u + 1 ] )
		{
			distances[ u + 1 ] = distances[u];
			que.push_front( u +  1 );
		}
	}

	cout << distances[N] << endl;

	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i, N) cin >> p.at(i);

  double tmp = 0.0;
  rep(i, K) {
    tmp += p.at(i);
  }
  double x = tmp;
  for (int i = K; i < N; i++) {
    tmp += p.at(i);
    tmp -= p.at(i - K);
    x = max(x, tmp);
  }

  cout << fixed << setprecision(12) << (x + K) / 2 << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 2019;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main() {
    cout << fixed << setprecision(10);
    
    string S; cin >> S;

    ll ans = 0;

    vector<int> c(2019, 0);
    c[0] += 1;

    reverse(S.begin(), S.end());

    // cout << "a" << endl;
    mint p = 0;
    rep(i, S.size()) {
        // cout << "b" << endl;
        mint pp = 10;
        // cout << "d" << endl;
        pp = pp.pow(i);
        // cout << "c" << endl;
        p += pp * (S[i] - '0');
        // cout << p.x << endl;
        ans += c[p.x];
        c[p.x] += 1;
    }

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

Measured memory_bytes: 3756
#C
k, n = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = []
for i in range(len(a)):
    if i == 0:
        b.append(k - a[len(a) - 1] + a[0])
    else:
        b.append(a[i] - a[i - 1])
print(k - max(b))

Measured memory_bytes: 26436
#include <iostream>
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589
using namespace std;

double x[3],y[3],rx,ry,r;

int trgin() {
	int i,k;
	double a,b,c,d=0;
	for (i=0; i<3; i++) {
	 k=(i+1) % 3;
	 a=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k]));
	 b=sqrt((x[i]-rx)*(x[i]-rx)+(y[i]-ry)*(y[i]-ry));
	 c=sqrt((x[k]-rx)*(x[k]-rx)+(y[k]-ry)*(y[k]-ry));
     d=d+acos((b*b+c*c-a*a)/(2*b*c));
	}
	if ((d-PI*2)<0.000001 && (d-PI*2)>-0.000001) return 1;
	return 0;
}
int line(double x1,double y1,double x2,double y2) {
    double x,y,m,d;
	if (y1==y2) { x=rx;y=y1;} else if (x1==x2) { x=x1;y=ry;}
	else {
    m=(y2-y1)/(x2-x1);
	x=(ry-y1+m*x1+rx/m)/(m+1/m);
	y=y1+m*(x-x1);
	}
	if (((x>=x1 && x<=x2) || (x>=x2 && x<=x1)) && ((y>=y1 && y<=y2) || (y>=y2 && y<=y1))){
	d=(rx-x)*(rx-x)+(ry-y)*(ry-y);
    if (d==r*r) return 1; else if (d<r*r) return 2;
	}
	return 0;
}
int main() {
	int i,j,k,f;
	while(true) {
		for (i=0;i<3;i++) {
		cin >> x[i] >> y[i];
		if (x[i]==0) break;
	}
    if (i!=3) break;
	cin >> rx >> ry >> r;
	for (i=0,f=0;i<3;i++) if ((x[i]-rx)*(x[i]-rx)+(y[i]-ry)*(y[i]-ry)<=r*r) f++;
	if (f==3) { cout << 'b' << endl; continue;} else if (f>0) { cout << 'c' << endl; continue;} 
	for (i=0,f=0,k=0;i<3;i++) {
		j=line(x[i],y[i],x[(i+1) % 3],y[(i+1) % 3]); k+=j;
		if (j>1) break;
	}
	if (i==3) if (trgin()==1) { cout << 'a' << endl; continue;} else if (k==0) {cout << 'd' << endl; continue;}
	cout << 'c' << endl;
	}
return 0;
 }

Measured memory_bytes: 1272
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            (long N, long x) = Slice2<long>();
            var ai = Slist();
            ai.Insert(0, 0);
            var ans = 0L;
            for (var i = 1; i < ai.Count; ++i)
            {
                var t = ai[i] + ai[i - 1];
                if (t <= x) continue;
                ans += t - x;
                ai[i] -= t - x;
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 40588
#include <iostream>
using namespace std;
 
int main() {
	long long int a,b,c,i,j,s=0;
	cin >> a;
	cin >> b >> c;
	for(i=b;i<=c;i++)
	{
		if(i%a==0)
		{
			s=1;
			break;
		}
	}
	if(s==1)
	{
		cout << "OK" << endl;
	}
	else{
		cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
# prime factorization
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

n = int(input())
ans = factorization(n)
cnt = 0
if n == 1:
    print("0")
    exit()
for i in ans:
    num = i[1]
    j = 1
    while num - j >= 0:
        num = num - j
        j +=1
        cnt +=1
print(cnt)

Measured memory_bytes: 9436
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
using namespace std;
typedef pair<int, int> P;

int main() {
	int n, k;
	cin >> n >> k;
	if (1 + 2*(k-1) <= n) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
int N;
char ei[2][222];

signed main(){
    cin>>N;
    rep(i,2)cin>>ei[i];

    int cur,ans;
    bool beet;
    if(ei[0][0]==ei[1][0]){
        ans=3;
        cur=1;
        beet=true;
    }
    else{
        ans=6;
        cur=2;
        beet=false;
    }

    while(cur<N){
        if(ei[0][cur]==ei[1][cur]){
            if(beet){
                ans=ans*2%mod;
            }
            else{

            }
            beet=true;
            cur++;
        }
        else{
            if(beet){
                ans=ans*2%mod;
            }
            else{
                ans=ans*3%mod;
            }
            beet=false;
            cur+=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 1; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if ( 2 * b < a) {
        int ans = a - 2 * b;
        cout << ans << endl;
    } else if (2 * b >= a) cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N,A,B; cin >> N >> A >> B;
	if(__builtin_popcount(A^B)%2 == 0){
		cout << "NO" << endl;
		return 0;
	}
	auto Gray = [&](int mask){
		show(mask);
		int p = __builtin_popcount(mask);
		V<int> f;
		rep(i,N) if(mask&1<<i) f.pb(i);
		V<int> res(1<<p);
		rep(i,1<<p){
			int v = i^(i>>1);
			rep(j,p) if(v&1<<j) res[i] |= 1<<f[j];
		}
		return res;
	};
	int mask = (1<<N)-1;
	V<int> ans;
	rep(_,N){
		int d = 0;
		rep(i,N) if((A^B)&1<<i) d = i;
		assert(mask&1<<d);
		auto f = Gray(mask^(1<<d));
		for(int x: f) ans.pb(A^x);
		A = ans.back() ^ (1<<d);
		mask ^= 1<<d;
	}
	ans.pb(B);
	cout << "YES" << endl;
	for(int v: ans) cout << v << " ";
	cout << endl;
}


Measured memory_bytes: 1652
A, B, C, K = map(int, input().split())
# 1:A枚, 0:B枚, -1:C枚, K枚を選ぶ
A = min(A, K)
B = min(K - A, B)
C = min(K - A - B, C)
assert A + B + C >= K
#print(A, B, C)
print(A - C)

Measured memory_bytes: 9000
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    int n,m;
    cin >> n >> m;

    vector<int> arr[n+1];
    for (int i=0;i<=m-1;i++)
    {   
        int a,b;
        cin >> a >> b;
        arr[a].push_back(b);
        arr[b].push_back(a);
    }

    queue<int> temp;
    vector<int> ans(n+1,0);
    int visited_count=0;
    temp.push(1);

    while (visited_count<n)
    {
        int node=temp.front();
        temp.pop();

        for (auto it=arr[node].begin();it!=arr[node].end();it++)
        {
            if (ans[*it]==0)
            {
                visited_count++;
                ans[*it]=node;
                temp.push(*it);
            }
        }
    }

    int flag=0;
    for (int i=2;i<=n;i++)
    {
        if (ans[i]!=0)
        {
            flag++;
        }
    }

    if (flag==n-1)
    {
        cout << "Yes" << endl;
        for (int i=2;i<=n;i++)
        {
            cout << ans[i] << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<int> a(n+1);
        for(int i=1; i<=n; ++i) {
            cin >> a[i];
            a[i] %= m;
            (a[i] += a[i-1]) %= m;
        }
        int res = 0;
        set<int> s;
        for(int i=1; i<=n; ++i) {
        	 set<int>::iterator it= s.upper_bound(a[i]);
            res = max(res, a[i]);
            if(it != s.end()) {
                res = max(res, (a[i] - *it + m) % m);
            }
            s.insert(a[i]);
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 4156