akhauriyash/Code-Regression huggingface dataset:
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,m;
  while(cin>>n>>m){
    if(n==0 && m==0) return 0;
  
  vector<int> A(n+1);
  rep(i,n) cin>>A[i];
  A[n]=0;
  
  vector<int> B;
  B.push_back(0);
  rep(i,n+1){
    rep(j,n+1){
      if(A[i]+A[j]<=m) B.push_back(A[i]+A[j]);
    }
  }
  sort(ALL(B));
  B.erase(unique(ALL(B)),B.end());

  ll ans=0;
  rep(i,B.size()){
    auto itr=upper_bound(ALL(B),m-B[i])-B.begin();
    ll tmp=B[i]+B[itr-1];
    ans=max(ans,tmp);
  }
  
  cout<<ans<<endl;
  }
  
}


Measured memory_bytes: 10740
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int N;
    int[] D;
    bool input() {
        scanf("%d\n", &N);
        if (N == 0) return false;
        D = new int[N * (N - 1) / 2];
        foreach (i; 0 .. N * (N - 1) / 2) {
            scanf("%d", &D[i]);
        }
        return true;
    }
    void solve() {
        if (N == 2) {
            writeln(D[0]);
            writeln("-----");
            return;
        }

        int[int] L;
        foreach (i, d; D) {
            L[d]++;
        }
        //writeln("L: ", L);

        int[] splitL(in int[] X, int d) {
            int[] Ret;
            int s = 0, t = 0;
            foreach (i, x; X) {
                t += X[i];
                if (s < d && d < t) {
                    Ret ~= (d - s);
                    Ret ~= (t - d);
                } else {
                    Ret ~= t - s;
                }
                s = t;
            }
            //writeln("split: dir=", dir, ",", "d=", d, ",", X, " -> ", Ret);
            return Ret;
        }

        int[] splitR(in int[] X, int d) {
            auto Y = X.dup;
            reverse(Y);
            auto Ret = splitL(Y, d);
            reverse(Ret);
            return Ret;
        }

        int[][] Ans;
        void dfs(int[] X) {
            int[] s = new int[X.length + 1];
            s[0] = 0;
            foreach (j; 0 .. X.length) {
                s[j + 1] = s[j] + X[j];
            }
            //writeln("dfs(", X, ")");
            int[int] C;
            foreach (j; 0 .. X.length) {
                foreach (k; j + 1 .. X.length + 1) {
                    int p = s[k] - s[j];
                    //writeln([i, j, k]);
                    if (p !in L) return;
                    C[p]++;
                    if (C[p] > L[p]) {
                        return;
                    }
                }
            }

            if (X.length == N - 1) {
                //Ans ~= format("%(%s %)", X);
                Ans ~= X;
                return;
            }
            foreach (j, d; D) {
                if (d !in C || C[d] < L[d]) {
                    //writeln(d);
                    auto nX = splitR(X, d);
                    if (nX != X) dfs(nX);
                    nX = splitL(X, d);
                    if (nX != X) dfs(nX);
                    break;
                }
            }
        }

        dfs([D[0]]);
        if (!Ans.empty) {
            Ans.sort;
            Ans = Ans.uniq.array;
            foreach (A; Ans) {
                writefln("%(%s %)", A);
            }
        }
        writeln("-----");
    }
    while (input) solve;
}

Measured memory_bytes: 4388
fn main() {
    proconio::input! {
        n: usize,
        m: u64,
        k: usize,
    }
    let mut c=vec![0;n];
    c[0]=1;
    for i in 1..n {
        let mut x=i as u64;
        let mut y=1;
        let mut j=MOD-2;
        while j>0 {
            if j&1==1 {
                y=y*x%MOD;
            }
            x=x*x%MOD;
            j>>=1;
        }
        c[i]=c[i-1]*(n-i)as u64%MOD*y%MOD;
    }
    let mut p=vec![0;n];
    p[0]=m;
    for i in 1..n {
        p[i]=p[i-1]*(m-1)%MOD;
    }
    let mut t=0;
    for i in 0..=k {
        t = (t+c[i]*p[n-i-1]%MOD)%MOD;
    }
    println!("{}",t);
}
const MOD: u64=998244353;

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

int main()
{
ll n ;
cin >> n ;
vector<ll> p(n);
vector<ll> ind(n+1);
rep(i, n){
  cin >> p[i];
  ind[p[i]]=i;
}
set<ll> s;
s.insert(-1);
s.insert(n);
rep(i,n){
  auto itr=s.insert(ind[n-i]);
  auto itr0=itr.first;
  auto itr1=itr.first;
  auto itr2=itr.first;
  itr1--;itr2++;
  if(*itr1!=-1){
    auto itr3=itr1;
    itr3--;
    ans+=(*itr1-*itr3)*(*itr2-*itr0)*(n-i);
  }
    if(*itr2!=n){
    auto itr4=itr2;
    itr4++;
    ans+=(*itr4-*itr2)*(*itr0-*itr1)*(n-i);
  }
}


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


Measured memory_bytes: 6528
s=input()
kouho=["AKIHABARA","KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA","AKIHABR","AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA"]
if s in kouho:print("YES")
else:print("NO")

Measured memory_bytes: 2940
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp::{max, min};
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        N: i64,
        A: [i64; N],
    }
    let mut C: HashMap<i64, i64> = HashMap::new();
    for a in A.iter() {
        if C.contains_key(&a) {
            if let Some(time) = C.get_mut(&a) {
                *time+=1;
            }
        } else {
            C.insert(a.clone(), 1);
        }
        /*
        if let Some(time) = C.get_mut(&a) {
            *time+=1;
        } else {
            C.insert(a.clone(), 1);
        }
        */
    }
    let mut time = 0;
    for c in C.into_iter() {
        if c.0 < c.1 {
            time += c.1 - c.0;
        } else if c.0 > c.1 {
            time += c.1;
        }
    }
    println!("{}", time);
}

Measured memory_bytes: 14588
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

ll power(ll a,ll n,ll m=M){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a;
        a=a*a;
        n=n>>1;
        ans=ans%m;
        a=a%m;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll A[n];
	rep(i,0,n)	cin>>A[i];
	unordered_map<int,int> m1;
	Vpll v[n];
	rep(i,0,n){
		int a=A[i];
		unordered_map<int,int> m;
		for(int j=2;j*j<=a;j++){
			if(a%j==0){
				int cnt=0;
				while(a%j==0){
					a=a/j;
					cnt++;
				}
				m[j]=cnt;	
			}
		}
		if(a!=1)	m[a]++;
		for(auto j:m){
			v[i].pb({j.ft, j.sd});
			m1[j.ft] = max(m1[j.ft], j.sd);
		}
	}
	ll ans=0;
	ll cur=1;
	for(auto i:m1){
		cur = (cur*power(i.ft, i.sd))%M;
	}
	rep(i,0,n){
		ll cnt=cur;
		for(auto j:v[i]){
			cnt = (cnt*power(power(j.ft, j.sd), M-2))%M;
		}
		ans += cnt;
	}
	ans %= M;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main(void){
    long long l, i=0, min=1000000, max=-1000000, sum=0;
    cin >> l;
    while(cin>>l){
        if(l<min)
            min=l;
        if(l>max)
            max=l;
        sum=sum+l;
        i++;
    }
    cout << min << " " << max << " " << sum << endl;
}


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

int main(){
  string s;
  int K;
  cin >>s>>K;
  set<string> sub;
  int l=s.size();
  for(int i=0;i<l;i++){
    string p="";
    int c=0;
    while(i+c<l && c<K){
      p += s[i+c];
      sub.insert(p);
      c++;
    }
  }
  string ans;
  auto itr=sub.begin();
  for(int i=1;i<K;i++){
    itr++;
  }
  ans=*itr;
  cout<<ans<<endl;
}
    

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

int main() {
	int N;
	vector<int> a;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x; cin >> x; a.push_back(x);
	}

	int minsum = INT_MAX;
	for (int x = -100; x <= 100; x++) {

		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += (a[i] - x)*(a[i] - x);
		}
		if (sum < minsum) minsum = sum;
	}
	cout << minsum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,C; cin >> A >> B >> C;
    int K; cin >> K;
    int cnt=0;
    while(B<=A) B*=2,++cnt;
    while(C<=B) C*=2,++cnt;
    cout << (cnt<=K?"Yes":"No") << '\n';
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    
    vector<int> a(n,-1);//要素数　値の順番
    
    while(m--){
        int s,c;
        cin >> s >> c;
        s--;
        
            if(a[s]!=-1 and a[s]!= c){
                cout << -1 << endl;
                return 0;
            }
            else{
                a[s] = c;
            }
        
    }
        if(n == 1){
		a[0] = max(0, a[0]);
        }
        else {
		if(a[0] == 0){//複数桁で一桁めがゼロの数は存在しない
			cout << -1 << endl;
			return 0;
		}
		else if(a[0] == -1){//一桁目の入力がない時は1で初期化
			a[0] = 1;
		}
		REP1(i,n){
			a[i] = max(0, a[i]);
		}
	
	}
            
    
    int ans = 0;
	REP(i,n){
		ans *= 10;
		ans += a[i];
	}
	cout << ans << endl;
	return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n;
    cin>>n;
    string s[n];
    rep(i,n) cin>>s[i];
    rep(i,n) sort(s[i].begin(),s[i].end());
    ll ans=0;
    map<string,ll> B;
    rep(i,n) ans+=B[s[i]],B[s[i]]++;
    cout<<ans;
}

Measured memory_bytes: 18176
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//templete
int main() {
	ll N,Q;
	cin>>N>>Q;
	vll A;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	ll tes[SIZE]={},ket[SIZE]={};	//累積和、右から偶数番目の累積和
	for(int i=0;i<N;i++){
		if((N-i)%2)
			ket[i]+=A[i];
		tes[i]+=A[i];
	}
	for(int i=1;i<N;i++){
		tes[i]+=tes[i-1];
		ket[i]+=ket[i-1];
	}
	while(Q--){
		ll x;
		cin>>x;
		ll ans=0;
		//青木くんが最初にとるカードより右のカードで、青木くんが取るものと高橋くんが取るものの境界を求める
		int aoki=0,takahashi=N;
		while(takahashi-aoki>1){
			ll idx=(aoki+takahashi)/2;
			if(A[idx]<x){
				aoki=idx;
				continue;
			}
			//高橋くんは、idx番目のカードをN-idx番目に取る
			//青木くんは、idx番目のカードをord番目に取る
			ll ord=upper_bound(A.begin(),A.end(),A[idx])-lower_bound(A.begin(),A.end(),x-(A[idx]-x));
			if(ord<N-idx)
				aoki=idx;
			else
				takahashi=idx;
		}
		ans+=tes[N-1]-tes[aoki];
		//aokiくんはaoki-(N-takahashi)番目まで取る
		ll und=aoki-(N-takahashi);
		if(und>=0)
			ans+=ket[und];
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 5748
class Queue:
    def __init__(self, data=[]):
        self.data = data

    def enqueue(self, x):
        self.data.append(x)

    def dequeue(self):
        if self.is_empty is True:
            return None
        else:
            return self.data.pop(0)

    def is_empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False

    def is_full(self):
        pass


n, q = map(int, input().split())

queue = Queue()
for i in range(n):
    name, time = input().split()
    time = int(time)
    queue.enqueue({'name': name, 'time': time})

time = 0
while queue.is_empty() is False:
    next_process = queue.dequeue()

    if next_process['time'] > q:
        time += q
        next_process['time'] -= q
        queue.enqueue(next_process)
    else:
        time += next_process['time']
        print(next_process['name'], time)



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

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;
    vector<int> A(N);
    map<int, int> c;
    rep(i, N) {
        int v; cin >> v;
        A[i] = v;
        if (c.count(v)) {
            c[v] += 1;
        } else {
            c[v] = 1;
        }
    }
    ll all_sum = 0;
    for (auto x: c) {
        all_sum += ll(x.second) * (x.second - 1) / 2;
    }

    rep(i, N) {
        if (c[A[i]] == 1) {
            cout << all_sum << endl;
        } else if (c[A[i]] == 2) {
            cout << all_sum - 1 << endl;
        } else {
            cout << all_sum - c[A[i]] + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 9472
/* HARDWORK IS THE KEY TO SUCCESS.
       RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/
    #include <bits/stdc++.h>
    #define pragma
    using namespace std;
    #define ll long long
    #define ld long double
    #define T ll t = 1; cin>>t; while(t--)
    #define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
    #define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
    #define ain ll n,k,i; cin>>n; ll a[n + 1]; for( i=1; i<=n; i++) cin>>a[i]
    #define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
    #define matin ll m,n; cin >> n; ll a[n + 1][n + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++) cin>>a[i][j];
    #define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
    #define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
    #define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
    #define F first
    #define S second
    #define I insert
    #define pb push_back
    #define ppb pop_back
    #define AISORT sort(a,a+n)
    #define ADSORT sort(a,a+n,greater<ll>())
    #define VISORT sort(x.begin(),x.end())
    #define VDSORT sort(x.begin(),x.end(),greater<ll>())

    const ll maxs = 1e5+3;
    const ll maxs1 = 1e3+4;
    const ll mod = 1e9 + 7;

    //MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

    //POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

    //MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}

//     ll n;
//     ll a[maxs];
//     ll tree[maxs];
    bool vis[maxs];
    vector<ll>graph[maxs];
    //ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN
    //ALWAYS RETURN WHEN ST == ED CONDITION IN SEGMENT TREES
    


    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        ll n;
        cin >> n;
        ll i;
        vector<ll>X;
        for(i = 1;i <= n;++i)
        {
        if(i % 3 == 0 && i % 5 == 0)
        {}      
    else if(i % 3 == 0 )
    {}      
   else if(i % 5 == 0)
   {}
   else
        X.pb(i);
            }
        ll sum = 0;
        for(int e : X)
            sum += e;
    cout << sum;
    }

Measured memory_bytes: 13896
#include<stdio.h>
int main(void)
{
    int i,count=0;
    char s[4],t[4];
    scanf("%s",s);
    scanf("%s",t);
    for(i=0;i<3;i++)
    {
        if(s[i]==t[i])
            count++;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
while True:
  H,W = map(int, input().split())
  if W==0 and H==0:
   break
  for i in range(H):
    for j in range(W):
      if (i+j)%2==0:
        print('#', end="")
      else: 
        print('.',end="")
    print()
  print()


Measured memory_bytes: 7000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

typedef long long ll;
#define fi first
#define se second

const ll mod = 1000000007;
//              123456789

using namespace std;

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

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


int a[112345];
int N;
bool flag[112345];

ll ans = 0;
int fact[112345]; //階乗を入れておく
int inv[112345];  //逆元を入れておく


void setC( int n )//nCrのnの最大値までの配列準備
{
  int i;
  int j;
  ll num = 1;
  ll w;
  
  fact[0] = 1;
  inv[0] = 1;
  
  for( i = 1; i <= n; i++ ){
    num *= (ll)i;
    num %= mod;
    fact[i] = num;
  }
  
  int jdg;
  
  for( i = 1; i <= n; i++ ){
    w = 1;
    num = fact[i];
    jdg = mod-2;
    
    while( jdg ){
      if( jdg % 2 ){
        w *= num;
        w %= mod;
      }
      
      jdg >>= 1;
      num *= num;
      num %= mod;
    }
    
    inv[i] = w;
  
  }
}

int  combination( int n, int r )//mod付きnCr(コンビネーション)
{
  ll a;
  int b;
  
  a = ( (ll)fact[n] * (ll)inv[n-r] ) % mod;
  a *= (ll)inv[r];
  a %= (ll)mod;
  
  b = a;
  
  return b;
    
}

int main(){
  
  cin>>N;
  int i;
  int key;
  int idx1;
  int idx2;
  int num;
  int rum;
  
  fill( flag, flag+N+1, 0 );
  
  for( i = 0; i <= N; i++ ){
  	scanf("%d", a+i);
  	if( flag[a[i]] ){
  		 key = a[i];
  		 idx2 = i;
  	}
  	flag[a[i]] = 1;
  }
  
  for( i = 0; i <= N; i++ ){
  	if( key == a[i] ){
  	  idx1 = i;
  	  break;
  	 }
  }
  
  setC( N+10 );
  
  //cout<<idx1<<" "<<idx2<<endl;
  
  for( i = 1; i <= N+1; i++ ){
  	ans = combination( N+1, i );
  	if( i == 1 ){
  		ans--;
  		if( ans < 0 ) ans += mod;
  	}	
  	else{
  		num = idx1 + N - idx2;
  		rum = i-1;
  		if( num >= rum ){
  			ans -= combination( num, rum );
  			if( ans < 0 ) ans += mod;
  		}
  		//cout<<num<<" "<<rum<<endl;
  		/*
  		if( num >= rum ){
  			ans -= combination( num, rum );
  			if( ans < 0 ) ans += mod;
  		}
  		//cout<<num<<" "<<rum<<endl;
  		*/
  	}
  	printf("%d\n", ans);
  }
    
  return 0;
}

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

using namespace std;



int main(){
    int a, b;
    int res = 0;
    cin >> a;
    b = INT_MAX;
    while(a--){
        int temp;
        cin >> temp;
        if(temp < b){
            b = temp;
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

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

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    String str=reader.readLine();
	    String s[]=str.split(" ");
	    int a=Integer.parseInt(s[0]);
	    int b=Integer.parseInt(s[1]);
	    int c=(a+b)/2;
	    System.out.println(c);
	    
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}



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

int gcd(int p,int q){
    if(p%q == 0){
        return q;
    }
        return gcd(q,p%q);
}

int main(){
    int x; cin >> x;
    vector<int> p(0);

    for(int i=1;i<=sqrt(x);i++){
        if(x%i == 0){
            p.push_back(i);
        }
    }

    int A,B;
    bool f = false;

    rep(i,p.size()){
        int P = p[i];

        for(int a = -200;a <= 200;a++){
            int a5 = a*a*a*a*a,b5 = (a-P)*(a-P)*(a-P)*(a-P)*(a-P);

            if(a5-b5 == x){
                A = a; B = a-P;
                f= true;
                break;
            }

            b5 = (a+P)*(a+P)*(a+P)*(a+P)*(a+P);

            if(a5-b5 == x){
                A = a; B = a+P;
                f= true;
                break;
            }
        }
        if(f){
            break;
        }
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 3724
/*
	ARIJIT SUR 
	@duke_knight
	@surcode
    @comeback
	IIT ISM 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define maxelem(a) *max_element(all(a))
#define minelem(a) *min_element(all(a))
#define pb push_back
#define pi pair<int,int>
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i1=0;i1<a.size();i1++) cin>>a[i1];}
#define display(a) {for(int i1=0;i1<a.size();i1++) cout<<a[i1]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
int changes(string a, string b){
    int ans = 0;
    for(int i=0;i<b.size();i++) if(a[i]!=b[i])ans += 1;
        return ans;
}
void solve(){
   string s,t;
        cin>>s>>t;
        int l=s.length();
        int len=t.length();
        int ans=len;
        for(int i=0;i<=l-len;i++)
        {
            ans = min(ans,changes(t,s.substr(i,len)));
        }
        printf("%d\n",ans );
    }
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3704
#include <stdio.h>
int main(void){
  long long n, m, a[99999] = {0}, p = 0, pre1[3000] = {0}, pre2[3000] = {0}, now[3000] = {0};
  scanf("%lld %lld", &n, &m);getchar();
  for(int i = 0; i < m; i++){
    scanf("%lld", &a[i]);getchar();
  }
  for(int i = 1; i <= n; i++){
    if(i == 1){
      now[0] = 1;
    }else if(i == 2){
      if(a[p - 1] == 1){
        now[0] = 1;
      }else{
        now[0] = 2;
      }
    }else{
      for(int j = 0; j < 3000; j++){
      	now[j] = pre1[j] + pre2[j];
      }
    }
    if(a[p] == i){
      for(int j = 0; j < 3000; j++){
      	now[j] = 0;
      }
      p++;
    }
    for(int j = 0; j < 2999; j++){
      if(now[j] >= 1000000000){
        now[j + 1]++;
        now[j] %= 1000000000;
      }
    }
    for(int j = 0; j < 3000; j++){
    	pre2[j] = pre1[j];
    	pre1[j] = now[j];
    }
  }

  for(int i = 2999; i >= 0; i--){
    now[i] %= 1000000007;
    if(i == 0){break;}
    now[i - 1] += now[i] * 1000000000;
  }
  printf("%lld\n", now[0]);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
char b;

int main(){
	cin >> b;
	if(b == 'A'){cout << 'T' << endl;}
	if(b == 'T'){cout << 'A' << endl;}
	if(b == 'G'){cout << 'C' << endl;}
	if(b == 'C'){cout << 'G' << endl;}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  string s;
  cin >> s;
  int size = s.size();
  int n = size;
  n--;
  size /= 2;
  int ans = 0;
  rep(i,size) {
    if(s[i] != s[n-i]) ans++;
  }
  cout << ans;
  hinata;
}

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

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

int n, m;

void solve() {
  map<string,int> il;

  rep(i,n) {
    string name; int price; cin>>name>>price;
    il.insert(mp(name, price));
  }
  
  map<string,vector<string> > al;
  cin>>m;
  rep(i,m) {
    string name; int tn; cin>>name>>tn;
    vector<string> t_vec(tn);
    rep(j,tn) {
      cin>>t_vec[j];
    }
    al.insert(mp(name, t_vec));
  }
  
  map<string,int> al_p;
  
  
  string item; cin>>item;
  /*
  {
    cout<<"item list"<<endl;
    map<string,int>::iterator it = il.begin();
    while (it != il.end()) {
      cout<<it->first<<"|"<<it->second<<endl;
      it++;
    }
  }
  {
    cout<<"alchem item list"<<endl;
    map<string,vector<string> >::iterator it = al.begin();
    while (it != al.end()) {
      cout<<it->first<<"|";
      rep(i,it->second.size()) cout<<it->second.at(i)<<" ";
      cout<<endl;
      it++;
    }
  }*/
    
  // BàXg©çBàliXgÉliðo^·é
  while (true) {
    if (al.size() == al_p.size()) break;
    map<string,vector<string> >::iterator it = al.begin();
    while (it != al.end()) {
      if (al_p.count(it->first)) {it++;continue;}
      // efÞÌvÌliðvZ·é
      // tOð§ÄÄ¨«AêÂÅàvZÅ«È¢fÞª¶Ý·éêÍ[vðñ·
      int sum_price = 0;
      bool flag = true;
      rep(i,it->second.size()) {
        // BàfÞÌACeªACeXgAÜ½ÍBàXgÉ é©
        string material = it->second.at(i);
        // BàXgÉ èABàliXgÉ³¢êÍcontinue;
        if (il.count(material) && al.count(material)) {
          if (al_p.count(material)) {
            sum_price += min(il[material], al_p[material]);
          } else {
            flag = false;
          }
        }
        // BàXgÉµ©³¢ê
        else if (!il.count(material) && al.count(material)) {
          if (al_p.count(material)) {
            sum_price += al_p[material];
          } else {
            flag = false;
          }
        }
        // ACeXgÉµ©³¢ê
        else if (il.count(material) && !al.count(material)) {
          sum_price += il[material];
        }
      }
      // SÄÌfÞÌliðvZÅ«½
      if (flag) {
        //cout<<"insert "<<it->first<<endl;
        al_p.insert(mp(it->first, sum_price));
      }
      it++;
    }
  }
  
  /*
  {
    cout<<"alchem item price list"<<endl;
    map<string,int>::iterator it = al_p.begin();
    while(it != al_p.end()) {
      cout<<it->first<<"|"<<it->second<<endl;
      it++;
    }
  }*/
  int res;
  if (il.count(item) && al_p.count(item)) {
    res = min(il[item], al_p[item]);
  } else if (!il.count(item) && al_p.count(item)) {
    res = al_p[item];
  } else {
    res = il[item];
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> pii;
int main() {
    int n;cin >> n;
    vector<double> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    double sum = 0;
    rep(i, n){
        sum += (1/a.at(i));
    }
    sum = 1 / sum;
    printf("%.6lf", sum);
    return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main(){
    IOS;
    ll x,k,d;
    cin>>x>>k>>d;
    ll m=abs(x)/d;
    ll ans=x;
    if(m<=k){
        if(x<0){
            ans=x+d*(abs(x)/d);
        }
        else ans=x-d*(abs(x)/d);
        k-=m;
    }
    else {
        if(x<0)ans=ans+d*k;
        else ans=x-d*k;
        k=0;
    }
    if(ans>0&&k>0){
        if(abs(ans-d)<ans){
            ans=ans-d;
            k--;
        }
    }
    if(ans<0&&k>0){
        if(abs(ans+d)<ans){
            ans=ans+d;
            k--;
        }
    }
    if(k>0){
        if(k%2==0){
            cout<<abs(ans)<<endl;
        }
        else {
            if(ans<0)ans+=d;
            else ans-=d;
            cout<<abs(ans)<<endl;
        }
    }
    else cout<<abs(ans)<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	int d;cin>>d;
	
	int ans=0;
	rep(i,n){
		int x,y;
		cin>>x>>y;
		if(d*d>=x*x+y*y) ans++;
	}
	cout<<ans<<endl;

	return 0;
}



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

using namespace std;

int main() {
  int N;
  bool ans = true;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int A;
    
    cin >> A;
    
    if (A % 2 == 0) {
      ans = (A % 3 == 0 || A % 5 == 0) ? true : false;
      
      if (!ans) {
        break;
      }
    }
  }
  
  cout << (ans ? "APPROVED" : "DENIED") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

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

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
const ll MAX_X = 1e10;

ll calc(ll x, ll ss, ll tt) {
    if(ss == 0 || ss == MAX_X+1 || tt == 0 || tt == MAX_X+1) return LLONG_MAX;
    if((x<ss)^(x<tt)) {
        if(abs(ss-x) < abs(tt-x)) {
            return 2*abs(ss-x) + abs(tt-x);
        } else {
            return 2*abs(tt-x) + abs(ss-x);
        }
    }
    return max(abs(ss-x), abs(tt-x));
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int A,B,Q;
    cin >> A >> B >> Q;
    vector<ll> s(A+2), t(B+2);
    s[0] = 0; s[A+1] = MAX_X+1;
    t[0] = 0; t[B+1] = MAX_X+1;
    for(int i=1;i<=A;++i) cin >> s[i];
    for(int i=1;i<=B;++i) cin >> t[i];

    ll x;
    for(int i=0;i<Q;++i) {
        cin >> x;
        int si = distance(s.begin(), lower_bound(all(s), x));
        int ti = distance(t.begin(), lower_bound(all(t), x));
        ll ans = LLONG_MAX;
        for(int j=0;j<2;++j) for(int k=0;k<2;++k) {
            ans = min(ans, calc(x, s[si-j], t[ti-k]));
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;



int main(){
    int n;
    cin >> n;
    vector<int>a(n+1),b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    ll cnt = 0;
    rep(i,n){
        cnt+=min(a[i],b[i]);
        if(a[i]<b[i]){
            cnt+=min(a[i+1],b[i]-a[i]);
            a[i+1] = a[i+1] - min(a[i+1],b[i]-a[i]);
        }
    }
    cout << cnt <<endl;
}


Measured memory_bytes: 4000
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n,k; cin >> n >> k;
    string s; cin >> s;

    int b=0,e=0;

    int count = 0;
    if(s.at(0) == '1') count --;
    while(count < k){
        e ++;
        if(e == n){
            cout << n << endl;
            return 0;
        }
        if(s.at(e-1) == '1' && s.at(e) == '0') count ++;

    }

    int ans = e - b;

    for(;;){
        for(;;){
            b ++;
            if(s.at(b-1) == '0' && s.at(b) == '1') break;
        }

        for(;;){
            e ++;
            if(e == n) break;
            if(s.at(e-1) == '1' && s.at(e) == '0')break;
        }

        ans = max(ans,e-b);
        if(e == n) break;
    }

    cout << ans << endl;

}

Measured memory_bytes: 512
import time
from random import randint
import copy
d = int(input())
c = list(map(int,input().split()))
starttime = time.time()
timelimit = 1.8
ans = []
fin = [1]*d
pen = [0]*26
sattemp = 0
sat = 0
sl = [list(map(int,input().split())) for i in range(d)]
for i in range(d):
    s = sl[i]
    sp = sum(pen)
    temp = -(10**9)
    for j in range(26):
        if s[j]-(sp-pen[j]) > temp:
            temp = s[j]-(sp-pen[j])
            tempans = j+1
    ans += [tempans]
    sat += s[tempans-1]-sp+pen[tempans-1]
    for j in range(26):
        pen[j] += c[j]
        pen[tempans-1] = 0
fin = ans
ans = []
pen = [0]*26
while time.time() - starttime <= timelimit:
    ans = fin.copy()
    d1 = randint(0,d-1)
    d2 = randint(d1,min(d-1,d1+15))
    if randint(0,1):
        ans[d1],ans[d2] = ans[d2],ans[d1]
        # print(1)
    else:
        ans[d1] = randint(1,26)
        # print(0)
    pen = [0]*26
    sattemp = 0
    for i in range(d):
        # print(i,fin,fin[i])
        s = sl[i]
        sp = sum(pen)
        tempans = ans[i]
        sattemp += s[tempans-1]-sp+pen[tempans-1]
        for j in range(26):
            pen[j] += c[j]
            pen[tempans-1] = 0
        # print(sattemp)
    if sattemp > sat:
        fin = ans
        sat = sattemp
for i in fin:
    print(i)



Measured memory_bytes: 93136
import numpy as np


a = int(input())

def f(a):
    count = np.zeros(1000000, dtype=int)
    loop_i = 1
    while True:
        count[a-1] += 1
        if count[a-1] == 2:
            return loop_i
        a = a // 2 if a % 2 == 0 else 3 * a + 1
        loop_i += 1

out = f(a)
print(out)

Measured memory_bytes: 18844
class UnionFind():
 def __init__(self, n):
  self.n = n
  self.parents = [-1] * n

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

 def union(self, x, y):
  x = self.find(x)
  y = self.find(y)

  if x == y:
   return

  if self.parents[x] > self.parents[y]:
   x, y = y, x

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

 def size(self, x):
  return -self.parents[self.find(x)]
 def same(self, x, y):
  return self.find(x) == self.find(y)
import sys
input = sys.stdin.readline
N,M,K = map(int,input().split())
uf = UnionFind(N)
lst=[0]*(N)
for i in range(M):
 A,B=map(int,input().split())
 uf.union(A-1,B-1)
 lst[A-1]-=1
 lst[B-1]-=1
for i in range(K):
 A,B=map(int,input().split())
 if uf.same(A-1,B-1):
  lst[A-1]-=1
  lst[B-1]-=1
lst=[lst[i]+uf.size(i)-1 for i in range(N)]
L=[str(a) for a in lst]
L=' '.join(L)
print(L)


Measured memory_bytes: 17820
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int A, B, M;
	int sum = 0;
	vector<int> a, b;
	
	
	cin>>A>>B>>M;
	
	a.resize(A);
	b.resize(B);
	
	for(int i = 0; i < A; i++){
		cin>>a[i];
		sum += a[i];
	}
	
	for(int j = 0; j < B; j++){
		cin>>b[j];
		sum += b[j];
	}
	
	int maximum = 0;
	
	int minimum = INF;
	
	for(int i = 0; i < M; i++){
		int x, y, c;
		
		cin>>x>>y>>c;
		x--, y--;
		maximum = max(maximum, c);
		minimum = min(minimum, a[x] + b[y] - c);
	}
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	
	minimum = min(minimum, a[0] + b[0]);
	
	sum -= maximum;
	
	// cout<<sum<<endl;
	cout<<minimum<<endl;
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 5e5 + 10;
int F[N], G[N];
int p[N], c[N];
bool visit[N];

int64 power_mod(int64 a, int n) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
  }
  return ret;
}

int64 comb(int n, int m) {
  if (m > n || n < 0 || m < 0) return 0;
  return (int64)F[n] * G[m] % MOD * G[n - m] % MOD;
}

int64 c2(int m) {
  return (int64)m * (m - 1) / 2 % MOD;
}

void add(int x, int n) {
  for (; x <= n; x += x & -x) {
    c[x]++;
  }
}

int query(int x) {
  int ret = 0;
  for (; x; x -= x & -x) {
    ret += c[x];
  }
  return ret;
}

int main() {
  F[0] = G[0] = 1;
  for (int i = 1; i < N; ++i) {
    F[i] = (int64)F[i - 1] * i % MOD;
    G[i] = power_mod(F[i], MOD - 2);
  }
  int n, m;
  vector<int> zero;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    if (p[i]) visit[p[i]] = true;
  }
  for (int i = 1; i <= n; ++i) {
    if (!visit[i]) zero.push_back(i);
  }
  m = zero.size();
  int ret = 0, cnt = 0;
  int64 sum2 = 0, cnt2 = 0;
  for (auto& it : zero) sum2 = (sum2 + it - 1) % MOD;
  // trace(sum2);
  for (int i = 0; i < n; ++i) {
    if (p[i] == 0) {
      int64 sum = (int64)(sum2 + MOD - cnt2) * F[m - 1] % MOD;
      sum = (sum + MOD -
             c2(m) * comb(m - 2, cnt - 1) % MOD *
             F[m - 1 - cnt] % MOD * F[cnt] % MOD) % MOD;
      ret += sum * F[n - 1 - i] % MOD;
      ret %= MOD;
      ++cnt;
    } else {
      int L = lower_bound(zero.begin(), zero.end(), p[i]) - zero.begin();
      int64 sum = (int64)F[m] * (p[i] - 1 - query(p[i])) % MOD;
      sum = (sum + MOD -
             (int64)L * comb(m - 1, cnt - 1) % MOD *
             F[m - cnt] % MOD * F[cnt] % MOD) % MOD;
      // trace(L, cnt, sum);
      ret += sum * F[n - 1 - i] % MOD;
      ret %= MOD;
      add(p[i], n);
      cnt2 = (cnt2 + m - L) % MOD;
    }
    // trace(i, ret);
  }
  ret = (ret + F[m]) % MOD;
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 10352
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	bool flag = false;
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			bool flagi = true;
			rep(k, m) {
				rep(l, m) {
					if (a[i + k][j + l] != b[k][l]) flagi = false;
				}
			}
			if (flagi) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(){
   int N;
   cin >> N;
   vector<int> vec(N+2);
  
  //0;0
  //1~N;そのまま
  //N+1;0
  
  vec[0]  =0;
  vec[N+1]=0;
  //とりあえず総和を求める
  int sigma=0;
  for (int i=1;i<N+1;i++){
    cin >> vec[i];
    sigma += abs(vec[i]-vec[i-1]);}
  sigma += abs(vec[N]);
  
  //iを取り除いた時は？
  for (int i=1;i<N+1;i++){
    int ans;
    ans =sigma- (abs(vec[i]-vec[i-1])+abs(vec[i+1]-vec[i]));
    ans += abs(vec[i+1]-vec[i-1]);
    cout << ans <<"\n";}
  
  
}
  
  
  


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

int x,y,z;

int main()
{
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int128, x)
parseFloat(x) = parse(BigFloat, x)
#parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
  N,X,T = parseMap(split(readline()))
  if div(N,X) == N/X
    ans = T*div(N,X)
  else
    ans = T*(div(N,X)+1)
  end
  println(Int128(ans))
end
main()


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

bool dfs(int tefuda1, int tefuda2, int l, int r) {	
 	if (tefuda2 == 0) { return false; }
 	
 	if ((l == 0 || (tefuda1 >> (l - 1)) % 2 == 0) && (r == 12 || (tefuda1 >> (r + 1)) % 2 == 0)) {
 		return !dfs(tefuda2, tefuda1, l, r);	//??????
 	}
 	
 	if (l > 0 && (tefuda1 >> (l - 1)) % 2 == 1) {
 		if (!dfs(tefuda2, tefuda1 - (1 << (l - 1)), l - 1, r)) { return true; }
 	}
 	if (r < 12 && (tefuda1 >> (r + 1)) % 2 == 1) {
 		if (!dfs(tefuda2, tefuda1 - (1 << (r + 1)), l, r + 1)) { return true; }
 	}
 	return false;
}

int n;
int f[6];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 6; j++) { cin >> f[j]; f[j]--; }
		
		int tefuda1 = 0;
		for (int j = 0; j < 6; j++) { tefuda1 += (1 << f[j]); }
		int tefuda2 = (1 << 13) - 1 - tefuda1 - (1 << 6);
		
		if (dfs(tefuda1, tefuda2, 6, 6)) { cout << "yes" << endl; }
		else { cout << "no" << endl; }
	}
	return 0;
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define int long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
int power(int base, int exp)
{
    if (exp == 0)
       return 1;
    else if (exp == 1)
       return base;
    else
    {
       int calc;
       if (exp % 2 == 0)
       {
         calc = power(base, exp/2);
         calc =(calc* calc)%mod;
       }
       else
       {
         calc = (base*power(base, exp-1))%mod;
       }
       return calc%mod;
    }
}
    int32_t main()
    {
        std::ios::sync_with_stdio(false);
       int x;
       double y;
       cin>>x>>y;
      int lb = y*100+0.5;
    cout << (x*lb)/100 << endl;
        return 0;
    }


Measured memory_bytes: 3696