akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define repb(i,n) for(int i=1;i<=n-1;i++)
#define repa(i,n) for(int i=1;i<=n;i++)

int main(){
  int n,sum=0;
  cin >> n;
  vector<int> b(n+1);
  b[0] = b[n] = 1e6;
  repb(i,n) cin >> b[i];
  repa(i,n) sum += min(b[i-1],b[i]);
  cout << sum << endl;
  return 0;
}

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

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	cout << (n == m ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


int main(){
    
    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    m = 60 * h + m;

    long double rad1 = m * 2.0 * M_PI / 720.0;
    long double lx = a * cos(rad1);
    long double ly = a * sin(rad1);

    long double rad2 = m * 2.0 * M_PI / 60.0;
    long double sx = b * cos(rad2);
    long double sy = b * sin(rad2);

    long double dist = sqrt((lx-sx) * (lx-sx) + (ly-sy) * (ly-sy) );
    cout << setprecision(15) << dist << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
int md = 100000;
#define addm(X, Y) ((X) = ((X) + (Y) % md) % md)

int n;
int a[100000 + 5], sa[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        sa[i] = a[i];
    }
    sort(sa, sa + n);
    int ans = 0;
    rep(i, n) {
        int idx = lower_bound(sa, sa + n, a[i]) - sa;
        if (idx % 2 != i % 2) ans++;
    }
    cout << ans / 2 << endl;

}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N;
	cin>>N;
	
	map<pair<int,int>,long long> mp;
	
	for(int i=1;i<=N;i++){
		int a = i%10;
		
		int k = i;
		while(k>=10){
			k/=10;
		}
		
		int b = k;
		mp[make_pair(a,b)] ++;
	}
	
	long long ans = 0;
	
	for(auto a:mp){
		int x = a.first.first;
		int y = a.first.second;
		
		if(!mp.count(make_pair(y,x)))continue;
		
		ans += (long long)a.second * mp[make_pair(y,x)];
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

using namespace std;

int main(){
        int r, g, b;
        cin>>r>>g>>b;
        if((r*100+g*10+b)%4==0){
                cout<<"YES"<<endl;
        }
        else{
                cout<<"NO"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	d, n := iScan(), iScan()
	if n == 100 {
		n++
	}
	for i := 0; i < d; i++ {
		n *= 100
	}
	fmt.Println(n)
}


Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M, X; std::cin >> N >> M >> X;
  std::vector<ll> C(N);
  std::vector<std::vector<ll>> A(N, std::vector<ll>(M));
  rep(i,N) {
    std::cin >> C[i];
    rep(j,M) std::cin >> A[i][j];
  }

  ll ans = 1e9;
  for(int i=0; i<(1LL<<N); i++) {
    std::bitset<12> b(i);

    std::vector<ll> U(M,0);
    ll money = 0;
    rep(j,N) {
      if ( b[j] == 1 ) {
        rep(k,M) U[k] += A[j][k];
        money += C[j];
      }
    }

    bool check = true;
    rep(j,M) if ( U[j] < X ) check = false;

    if ( check ) ans = std::min(ans, money);
  }
  
  if ( ans == 1e9 ) std::cout << -1 << std::endl;
  else std::cout << ans << std::endl;

  return 0;
}



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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define repi(i,s,n) for(int i=(s);temp=(int)(n);i<temp;++i)
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

//#define double __float128

int main(void){
  int n,k;cin >> n >> k;
  double res=0;
  for(int i=1;i<=n;++i){
    int t=0;
    while(i*(pow(2,t))<k) t++;
    res+=((double)1/n)*(((double)1)/(pow(2,t)));
  }
  printf("%.10f\n",res);
  return 0;
}


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

import static java.lang.Long.parseLong;
import static java.lang.Integer.parseInt;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = parseInt(in.readLine());
      long[] seq = new long[n];

      for(int i=0; i<n; i++)
        seq[i] = parseLong(in.readLine());

      Arrays.parallelSort(seq);

      byte[] resU = new byte[n];  // /\/\Pattern
      byte[] resD = new byte[n];  // \/\/Pattern

      for(int i=0; i<n; i++) {
        if( i==0 ) {
          resU[i] = -1;
          resD[i] =  1;
        }
        else if( i==n-1 ) {
          resU[i] = (n&1) == 0 ? (byte)  1 : -1;
          resD[i] = (n&1) == 0 ? (byte) -1 :  1;
        }
        else {
          resU[i] = (i&1) == 1 ? (byte)  2 : -2;
          resD[i] = (i&1) == 1 ? (byte) -2 :  2; 
        }
      }
      Arrays.parallelSort(resU);
      Arrays.parallelSort(resD);

      long sumU=0,sumD=0;
      for(int i=0; i<n; i++) {
        sumU += seq[i] * resU[i];
        sumD += seq[i] * resD[i];
      }

      System.out.println(Math.max(sumU, sumD));
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

#define int long long
#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)

typedef complex<double> cmplx;
typedef vector<complex<double> > VC;
const double PI = acos(-1);
struct FFT {
    static void fft(VC &u, int sign) {
        int n = u.size();
        double theta = 2. * PI * sign / n;
        for (int m = n; m >= 2; m >>= 1, theta *= 2.) {
            cmplx w(1, 0), wDelta = polar(1., theta);
            for (int i = 0, mh = m >> 1; i < mh; i++) {
                for (int j = i; j < n; j += m) {
                    int k = j + mh;
                    cmplx temp = u[j] - u[k];
                    u[j] += u[k];
                    u[k] = w * temp;
                }
                w *= wDelta;
            }
        }
        for (int i = 1, j = 0; i < n; i++) {
            for (int k = n >> 1; k > (j ^= k); k >>= 1);
            if (j < i) {
                swap(u[i], u[j]);
            }
        }
    }

    static vector<int> mul(const vector<int> &a, const vector<int> &b) {
        int newSz = a.size() + b.size() - 1;
        int fftSz = 1;
        while (fftSz < newSz) {
            fftSz <<= 1;
        }
        VC aa(fftSz, 0.), bb(fftSz, 0.);
        for (int i = 0; i < a.size(); i++) {
            aa[i] = a[i];
        }
        for (int i = 0; i < b.size(); i++) {
            bb[i] = b[i];
        }
        fft(aa, 1);
        fft(bb, 1);
        for (int i = 0; i < fftSz; i++) {
            aa[i] *= bb[i];
        }
        fft(aa, -1);
        vector<int> res(newSz);
        for (int i = 0; i < newSz; i++) {
            res[i] = (int)(aa[i].real() / fftSz + 0.5);
        }
        return res;
    }
};

const int p = 200003;

int power(int x, int y) {
    if (y == 0) return 1;
    int res = 1;
    while (y) {
        if (y % 2) res = res * x % p;
        x = x * x % p;
        y >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    int pRoot = 2;
    vector<int> mp(p);
    vector<int> cnt(p);
    for (int i = 0; i < p - 1; i++) mp[power(pRoot, i)] = i;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 1; i <= n; i++) {
        int u; cin >> u;
        a[i - 1] = u;
        if (u == 0) continue;
        cnt[mp[u]]++;
    }
    vector<int> res = FFT::mul(cnt, cnt);
    long long ans = 0;
    for (int i = 0; i < res.size(); i++) ans += res[i] * power(pRoot, i);
    // cout << ans << endl;
    // for (int i = 0; i < res.size(); i++) {
    //     if (res[i] != 0) cout << res[i] << "*x^" << i << '+'; 
    // }
    // cout << endl;
    // for (int i = 0; i < cnt.size(); i++) ans -= cnt[i] * cnt[i] * power(pRoot, 2 * i);
    for (int e : a) {
        ans -= e * e % p;
    }
    ans /= 2;
    cout << ans;
    return 0;
}

/*
(1 + x)(1 + x) = 1 + 2x + x^2
1 + 2 * 2 + 4 = 9
9 - 1 - 4 = 4
4 / 2 = 3

*/


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

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	long long a,b,k;
	long long x,y;
	cin >> a >> b >> k;
	syc(a,0,1000000000000);
	syc(b,0,1000000000000);
	syc(k,0,1000000000000);
	
	x=a-k;
	y=b;
	if(x<0){
		y=y+x;
		x=0;
	}
	if(y<0){
		y=0;
	}
	cout << x << " " << y << endl;
	return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

a, b, c, d = map(int, input().split())
x2 = b // c
x1 = (a - 1) // c
y2 = b // d
y1 = (a - 1) // d
t = c * d // gcd(c, d)
z2 = b // t
z1 = (a - 1) // t
print(b - a + 1 - (x2 - x1) - (y2 - y1) + (z2 - z1))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll k,i,n,md=0,sum=0,d;
    cin>>k>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
      cin>>a[i];
      if(i>0)
      {
        d=a[i]-a[i-1];
        sum+=d;
        md=max(d,md);
      }
    }
    md=max(md,k-sum);
    cout<<k-md;
}

Measured memory_bytes: 1792
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N = I()
    h = LI()
    dp = [IINF] * N
    dp[0] = 0

    for i in range(N-1):
        dp[i+1] = min(dp[i] + abs(h[i+1] - h[i]), dp[i+1])
        if i + 2 < N:
            dp[i+2] = min(dp[i] + abs(h[i+2] - h[i]), dp[i+2])

    print(dp[N-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 52588
#include <iostream>

using namespace std;
int n;
int main()
{
    cin>>n;
    long long x;
    long long ans=0;
    for(int i=0;i<n;++i)
    {
        cin>>x;
        while(x%2==0)
        {
            ans++;
            x/=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
        int n = int.Parse(Console.ReadLine());
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),i=>int.Parse(i));
        int[] b = Array.ConvertAll(Console.ReadLine().Split(' '),i=>int.Parse(i));
        
        long sum = 0;
        for(int i=0;i<n;i++){
            if(a[i]>=b[i]){
                sum += b[i];
            }else{
                sum += a[i];
                b[i] -= a[i];
                if(a[i+1]>=b[i]){
                    sum+=b[i];
                    a[i+1]-=b[i];
                }else{
                    sum+=a[i+1];
                    a[i+1] = 0;
                }
            }
        }
        Console.WriteLine(sum);

    }
}

Measured memory_bytes: 34908
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define int long long
#define vll vector<long long>
#define pii pair<long long ,long long >
#define vvi vector< vector<long long > >
#define vpii vector<pair<int,int>>
#define pll  pair<long long ,long long >
#define pb  push_back
#define ff  first
#define sec second
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend())
#define m_p make_pair
#define all(x) (x.begin(),x.end())
#define sz(v) ((int)(v.size()))
#define endl '\n'
typedef vector< long long > vi ;
const int MOD = 1e9 + 7 ;
int size = 10000000;


void solve() {

  int n; cin >> n;
  int sum = 0;
  for ( int i = 1; i <= n ; i++ ) {

    if (i % 3 != 0 && i % 5 != 0) sum += i;
  }


  cout << sum << endl;
}


int32_t main() {
  fast;
  /*  #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif */

  int T = 1; //cin>>T;
  while (T--) {
    solve();
  }

  return 0;
}



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

int main() {
    
  int N;
  cin>>N;
  
  int C0=0;
  int C1=0;
  int C2=0;
  int C3=0;
  
  for(int i=0; i<N; i++){
    string S;
    cin>>S;
    
    if(S=="AC"){
        C0++;
    }
    if(S=="WA"){
        C1++;
    }
    if(S=="TLE"){
        C2++;
    }
    if(S=="RE"){
        C3++;
    }
}
    
  cout<<"AC x "<<C0<<endl;
  cout<<"WA x "<<C1<<endl;
  cout<<"TLE x "<<C2<<endl;
  cout<<"RE x "<<C3<<endl;
    
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int test[12345678];
signed main() {
	int n, a, res = 0, ok = 0; cin >> n;
    vector<vector<int>> kariG(n + 1), cost(123456), ans(123456);
    vector<int> G(n + 1), kari(n + 1); for (int h = 2; h <= n; h++) {
        cin >> a; G[h] = a; kari[a]++; kariG[a].push_back(h);
	} queue<int> QUE; queue<int> CNT;
    for (int i = 0; i < kariG[1].size(); i++) {
        QUE.push(kariG[1][i]); CNT.push(2); 
        if (kariG[kariG[1][i]].size() == 0) {
            cost[2].push_back(kariG[1][i]);
        } res = max(res, (long long)2);
    }
    while (QUE.size()) {
        for (int i = 0; i < kariG[QUE.front()].size(); i++) {
            QUE.push(kariG[QUE.front()][i]); CNT.push(CNT.front() + 1);
            if (kariG[kariG[QUE.front()][i]].size() == 0) {
                cost[CNT.front() + 1].push_back(kariG[QUE.front()][i]);
            } res = max(res, CNT.front() + 1);
        } QUE.pop(); CNT.pop();
    }
    for (int h = res; h >= 0; h--) {
        for (int i = 0; i < cost[h].size(); i++) { ans[cost[h][i]].push_back(0); }
    }
    for (int h = res; h >= 0; h--) {
        for (int i = 0; i < cost[h].size(); i++) {
            int z = 0; if (cost[h][i] != 1) {
                sort(ans[cost[h][i]].begin(), ans[cost[h][i]].end());
                for (int j = 0; j < ans[cost[h][i]].size(); j++) {
                    ans[cost[h][i]][j] += ans[cost[h][i]].size() - 1 - j;
                    z = max(z, ans[cost[h][i]][j]);
                }
                if (test[G[cost[h][i]]] == 0) { cost[h - 1].push_back(G[cost[h][i]]); }
                test[G[cost[h][i]]]++; ans[G[cost[h][i]]].push_back(z + 1);
            }
        }
    } sort(ans[1].begin(), ans[1].end());
    for (int h = 0; h < ans[1].size(); h++) {
        ans[1][h] += ans[1].size() - h - 1; ok = max(ok, ans[1][h]);
    }
    cout << ok << endl; return 0;
}

Measured memory_bytes: 20096
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int pri=998244353;

signed main(){
	double A,B,H,M; cin>>A>>B>>H>>M;
	double rad=2.0*3.1415926535897932384626*abs((H+M/60.0)/12.0-M/60.0);

	double ans=sqrt(A*A+B*B-2.0*A*B*cos(rad));
	cout<<fixed<<setprecision(16)<<ans<<endl;
}

Measured memory_bytes: 4192
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18
ll gcd(ll a,ll b){
	while(b!=0){
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}
int main(){
	ll a,b;
	cin>>a>>b;
	cout<<a/gcd(a,b)*b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char str[800100];
int n,k;
void solve(){
	int p=1,dr=1;
	while(p>0&&p<=n){
		if(str[p]=='A'){
			str[p]='B';
			dr=-dr;
			p+=dr;
		}
		else{
			str[p]='A';
			p+=dr;
		}
	}
}
int main(){
//	freopen("D.in","r",stdin);
	scanf("%d%d",&n,&k);
	scanf("%s",str+1);
	for(int i=n+1;i<=n*4;i++)
		str[i]='A'+((i-n)&1);
	if(k<=n*2){
		int res=0,p=1,cnt=0;
		for(int i=1;i<=k;i++){
			if(str[p]-'A'==((res+(cnt&1))&1))
				res^=1;
			else{
				cnt++,p++;
				res=0;
			}
		}
		for(int j=1;j<=n;j++){
			if(cnt&1) str[j]='A'+'B'-str[j+cnt];
			else str[j]=str[j+cnt];
		}
		if(res) solve();
	}
	else{
		int res=0,p=1,cnt=0;
		for(int i=1;i<=n*2;i++){
			if(str[p]-'A'==((res+(cnt&1))&1))
				res^=1;
			else{
				cnt++,p++;
				res=0;
			}
		}
		for(int j=1;j<=n;j++){
			if(cnt&1) str[j]='A'+'B'-str[j+cnt];
			else str[j]=str[j+cnt];
		}
		if(res) solve();
		k-=n*2;
		if((n&1)&&(k&1))
			str[1]='A'+'B'-str[1];
	}
	for(int i=1;i<=n;i++)
		printf("%c",str[i]);
	printf("\n");
	return 0;
}


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

#define loop(i,n) for(int i=1;i<=n;i++)
long long x;

int main(){
    cin>>x;
    long long res=0;
    res+=(x/11)*2;
    x%=11;
    if(1<=x)res++;
    if(7<=x)res++;
    cout<<res<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _ % MOD
#define __ %= MOD

#define each(it, s) for (auto it = s.begin(); it != s.end(); ++it)
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.begin(), v.end(), greater<auto>())
#define fill(a) memset(a, 0, sizeof(a))

#define swap(a, b) \
	{              \
		a = a + b; \
		b = a - b; \
		a = a - b; \
	}
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repA(i, a, n) for (ll i = a; i <= (n); ++i)
#define repD(i, a, n) for (ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) << endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)                                 \
	{                                         \
		rep(i, a.size()) cout << a[i] << " "; \
		cout << endl;                         \
	}
#define mark(v) cout << "Here--" << v << endl;

const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}
ll binpow(ll a, ll b, ll m)
{
	a %= m;
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}

ll f[MAXN + 1] = {0};

ll InverseEuler(ll n, ll MOD)
{
	return binpow(n, MOD - 2, MOD);
}

ll C(ll n, ll r, ll MOD)
{
	return (f[n] * ((InverseEuler(f[r], MOD) * InverseEuler(f[n - r], MOD)) % MOD)) % MOD;
}
int main()
{
	ios_base::sync_with_stdio(false); // don't use printf and scanf
	cin.tie(NULL);					  // cout<<fixed<<setprecision
	ll s;
	cin >> s;
	ll maxdigits = s / 3;
	ll mindigits = 1;
	f[0] = 1;
	for (ll i = 1; i <= MAXN; i++)
	{
		f[i] = f[i - 1] * i % MOD;
	}
	ll ans = 0;
	for (ll i = mindigits; i <= maxdigits; i++)
	{
		ll starter = 3 * i;
		ll dif = s - starter;
		ans = (ans + C(dif + i - 1, i - 1, MOD)) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11456
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){ 
	string o,e;
	cin>>o>>e;
	for(int i=0;i<o.size()+e.size();i++){
		if(i%2==1){
			cout<<e[(i-1)/2];
		}
		else{
			cout<<o[i/2];
		}
	}
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<vector>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,N) for(int i=0;i<N;i++)

using namespace std;

int main(void){
    int p,m,c;
    cin>>p>>m>>c;
    cout<<p+m+c<<endl;
}




Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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


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

  int n,a,b,x,y;
  vector<int> s(5);
  cin >> s[0] >>s[1] >>s[2]>>s[3]>>s[4];

  b=0;
  x=100;
  y=10;
  REP(i,5){
    if(s[i]%10==0){
      b+=s[i];
    }else{
      if(s[i]%10<x){
        x=s[i]%10;
        y=s[i];
      }
      b+= (s[i]/10+1)*10;
    }
  }
  if(y!=10){
  cout <<b-(10-y%10)<<endl;
  }else{
    cout <<b<<endl;
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int A[N];
  cin >> A[0];
  int ans = A[0];
  for(int i=1;i<N;i++){
    cin >> A[i];
    ans = __gcd(ans, A[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }  // O( log(a) )
bool isPrime(ll n) {                                  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) flag = false;
  }
  return flag;
}
vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int n;
  cin >> n;
  vector<ll> a;
  for (int i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  // for (int i = 0; i < n - 1; i++) {
  //   if (a.at(i) == a.at(i + 1)) cout << a.at(i) << endl;
  // }

  ll ans = 0;
  ll currNum = a.front();
  int cnt_currNum = 0;
  int cnt_prevNums = 0;
  int cnt_ans = 0;
  for (int i = 0; i < n; i++) {
    if (a.at(i) != currNum || i == n - 1) {
      int times;
      if (cnt_currNum <= cnt_prevNums)
        times = 2 * cnt_currNum;
      else
        times = 2 * cnt_prevNums + (cnt_currNum - cnt_prevNums) +
                (cnt_currNum - cnt_prevNums);
      if (ans == 0) times--;
      for (int j = 0; j < times; j++) {
        ans += currNum;
        cnt_ans++;
        if (cnt_ans == n - 1) break;
      }
      if (cnt_ans == n - 1) break;

      currNum = a.at(i);
      cnt_currNum = 0;
      cnt_prevNums = i;
    }

    cnt_currNum++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 5312
program beginning
  implicit none
  integer :: n(4), x(0:9) = 0, i
  read(*,*) n
  do i = 1, 4
    x(n(i)) = x(n(i))+1
  end do
  if (x(1) == 1 .and. x(4) == 1 .and. x(7) == 1 .and. x(9) == 1) then
    write(*,'(a)') "YES"
  else
    write(*,'(a)') "NO"
  end if
end program beginning

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a+b+c>=22){
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
  }
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

vector<int> g[100005];
int vis[100005];
int n,m;

void solve(int u) {
  for(int i=0;i<g[u].size();i++){
    int v = g[u][i];
    if(!vis[v]){
      vis[v]=1;
      solve(v);
    }
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x,y,z;cin>>x>>y>>z;x--,y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  int res=0;
  for(int i=0;i<n;i++){
    if(!vis[i]){
      vis[i]=1;
      solve(i);
      res++;
    }
  }

  cout<<res<<endl;

  return 0;
}


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


int main() {
    vector<int> vec(5);
    for (int i = 0; i < 5; i++) {
        cin >> vec.at(i);
    }

    int min_num = 10;
    int index = 0;
    for (int i = 0; i < 5; i++) {
        int num = vec.at(i) % 10;
        if (num != 0 && num < min_num) {
            min_num = num;
            index = i;
        }
    }

    int sum = 0;
    for (int i = 0; i < 5; i++) {
        if (i == index) continue;
        sum += vec.at(i);
        if (sum % 10 != 0) sum += 10 - (sum % 10);
    }
    sum += vec.at(index);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def is_prime(x):
  if x == 1:
    return False
  for i in range(2,int(x**0.5)+1):
    if x % i == 0:
      return False
  return True

N = int(input())

ans = []
i = 2
while (len(ans) < N):
  a = i*5+1
  if is_prime(a):
    ans.append(a)
  i += 1
print(*ans)


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int a,b,c,d;
string s="-+",e;

main() {
    cin >> e;
    a=e[0]-'0';
    b=e[1]-'0';
    c=e[2]-'0';
    d=e[3]-'0';
    rep(i,2) rep(j,2) rep(k,2) {
        int tmp;
        if (i) tmp=a+b;
        else tmp=a-b;
        if (j) tmp+=c;
        else tmp-=c;
        if (k) tmp+=d;
        else tmp-=d;
        if (tmp==7) {
            cout << a << s[i] << b << s[j] << c << s[k] << d << "=7" << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define UGOKE_EI_EI_EI_YAAAAAAAAAA2 int main() { int k, x; std::cin >> k >> x; for (int i = x-k+1; i <= x+k-1; i++) { std::cout << i; if (i == x+k-1) { std::cout << std::endl; } else { std::cout << " "; } } return 0; }

UGOKE_EI_EI_EI_YAAAAAAAAAA2 

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

P_NUM = 1000000007


def solv(n, m, a):
    comb =  [1] * (n+1)
    for i in a:
        comb[i] = 0

    for i in range(2, n+1):
        comb[i] *= (comb[i-1] + comb[i-2]) % P_NUM

    return comb[-1]


if __name__ == '__main__':

    n, m = map(int, input().split())
    if m:
        a = map(int, sys.stdin)
    else:
        a = []

    ans = solv(n, m, a)

    print(ans)

Measured memory_bytes: 6976
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    ll n, q;
    cin >> n >> q;
    ll x_free = n, y_free = n;
    vector<ll> b_x(n, n - 2), b_y(n, n - 2);
    ll cur_x = n - 2, cur_y = n - 2;
    ll ans = (n - 2) * (n - 2);

    REP(_, 0, q)
    {
        ll a, b;
        cin >> a >> b;

        if (a == 1)
        {
            if (b < x_free)
            {
                REP(i, b + 1, x_free)
                b_x[i] = cur_x;
                x_free = b;
                cur_y = b - 2;
                ans -= cur_x;
            }
            else
            {
                ans -= b_x[b];
            }
        }
        else
        {
            if (b < y_free)
            {
                REP(i, b + 1, y_free)
                b_y[i] = cur_y;
                y_free = b;
                cur_x = b - 2;
                ans -= cur_y;
            }
            else
            {
                ans -= b_y[b];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6360
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
using ll = long long int;
const int MAX_NUM = 2 * 1e5 + 10;
vector<int> a(MAX_NUM, 0);
vector<int> b(MAX_NUM, 0);
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    priority_queue<pair<int, int>, vector<pair<int,int>>, less<pair<int,int>>> pq;
    int n; cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i]; 
    }
    for(int i=0; i<n; i++){
        cin >> b[i]; 
        if(b[i] != a[i]){
            pq.push(pair<int, int>{b[i], i});
        }
    }
 
    ll ans = 0;
    while(!pq.empty()){
        pair<int, int> maxp = pq.top(); pq.pop();
        int val = maxp.first; int id = maxp.second;
        int l = b[(id + n - 1) % n];
        int r = b[(id + 1) % n];
        int div = ceil((val - max(max(l, r), a[id])) / double(l + r));
        val -= div * (l + r);
        ans += div;
        b[id] = val;
        // for(int i=0; i<n; i++){
        //     cout << b[i] << " ";
        // }
        // cout << endl;
        if(val == a[id]){continue;}
        else if(div <= 0){cout << -1 << endl; return 0;}
        else{
            pq.push(pair<int, int>{b[id], id});
        }
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3956
S = input()
ans = ""
for i in range(2**(len(S)-1)):
    total = int(S[0])
    for j in range(1, len(S)):
        if (i >> j-1) & 1:
            total += int(S[j])
        else:
            total -= int(S[j])
    if total == 7:
        for j in range(len(S)-1):
            ans += S[j]
            if i >> j & 1:
                ans += "+"
            else:
                ans += "-"
        ans += S[-1]
        break
print(ans + "=7")


Measured memory_bytes: 9052
import java.util.Scanner;

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

		for(int i=0; i<S.length(); i++) {
			for(int j=0; j<S.length(); j++) {
				if(i==j)continue;
				else {
					if(S.charAt(i)==S.charAt(j)) {
						int k=0;
						int l=0;
						while(k==i | k==j) {
							k++;
						}
						while(l==i | l==j | l==k) {
							l++;
						}
						if(S.charAt(k)==S.charAt(l) && S.charAt(i)!=S.charAt(k)){
							System.out.println("Yes");
							return;
						}
					}
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 22996
import collections
N=int(input())
S =input()
def countchar(s1,s2):
  ret=0
  table=collections.defaultdict(int)
  for x in s1:
    table[x]+=1
  for x in s2:
    if x in table and table[x]>0:
      ret+=1
      table[x]=0
  return(ret)
ans=0
for i in range(1,N):
  X=S[:i]
  Y=S[i:]
  ans=max(ans,countchar(X,Y))
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=2e5+5;

int n;
int a[N], ans[N];

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int  finans=1;
	for(int i=1;i<=n;i++)
	{
		int cur=a[i];
		ans[cur]=max(ans[cur], ans[cur-1]+1);
		finans=max(finans, ans[cur]);
	}
	cout<<n-finans;
	return 0;
}

Measured memory_bytes: 3328
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def main():
    n = int(sys.stdin.readline())
    a = sorted(map(int, sys.stdin.readline().split()), reverse=True)
    s = [[], []]
    for i, b in enumerate(a):
        s[i % 2].append(b)
    print(sum(s[0]) - sum(s[1]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int value = 0;
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;
  value = max(a * c, b * d);
  value = max(value, a * d);
  value = max(value, b * c);
  cout << value << endl;
  return 0;}

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

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int monster = scan.nextInt();
		int waza = scan.nextInt();
		long[] hp = new long[monster];

		for(int i=0;i<monster;i++) {

			hp[i] = scan.nextInt();
		}

		long sum = 0;

		Arrays.sort(hp);

		for(int i=0;i<monster-waza;i++) {

			sum += hp[i];
		}

		   System.out.println(sum);

		scan.close();
	}

}


Measured memory_bytes: 90384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	string s;
	while(1)
	{
		getline(cin,s);
		if(s==".")break;
		stack<string> st;
		int len=s.size();
		for(int i=0;i<len;i++)
		{
			string tmp;
			tmp+=s[i];
			if(s[i]=='('||s[i]=='[')st.push(tmp);
			if(s[i]==')')
			{
				if(st.empty())
				{
					cout << "no" << endl;
					goto end;
				}
				string p=st.top();
				st.pop();
				if(p!="(")
				{
					cout << "no" << endl;
					goto end;
				}
			}
			if(s[i]==']')
			{
				if(st.empty())
				{
					cout << "no" << endl;
					goto end;
				}
				string p=st.top();
				st.pop();
				if(p!="[")
				{
					cout << "no" << endl;
					goto end;
				}
			}
		}
		if(!st.empty())
		{
			cout << "no" << endl;
			goto end;
		}
		cout << "yes" << endl;
		end:;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

void solve() {
    ll N, M; cin >> N >> M;
    vector<ll> a(M), b(M);
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    UnionFind uf(N);
    vector<ll> res;
    ll cur = N*(N-1)/2;
    rep(i, M) {
        ll ai = a[M-1-i], bi = b[M-1-i];
        res.emplace_back(cur);

        if (uf.issame(ai, bi)) continue;

        cur -= uf.size(ai) * uf.size(bi);
        uf.merge(ai, bi);
    }

    reverse(res);
    rep(i, M) outl(res[i]);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 4596
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;
int main()
{
    int N, M, k, hw = 0;
    cin >> N >> M;

    for (int i = 0; i < M; i++)
    {
        cin >> k;
        hw = hw + k;
    }
    if (N < hw)
        cout << "-1" << endl;
    else
        cout << (N - hw) << endl;

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll cnt[N+1] = {};
    ll A[N];
    rep(i, N){
        int a; cin >> a;
        A[i] = a;
        cnt[a]++;
    }
    ll base = 0;
    rep(i, N+1) base += cnt[i]*(cnt[i]-1)/2;
    rep(i, N){
        if(cnt[A[i]] >= 2) cout << base-(cnt[A[i]]-1) << "\n";
        else cout << base << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    vector<int> parity(2, 0);
    for(auto& val: arr) {
        parity[val%2] += 1;
    }
    if (parity[1] % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3688
# solution
import io
from scipy.misc import comb

data = int(input())
inti = input()


def check(ans):
    for i in range(1, data - 1):
        if (ans[i] == 0) == (inti[i] == 'o'):
            ans += [ans[i - 1]]
        else:
            ans += [1 - ans[i - 1]]
    if ((inti[0] == 'o') == (ans[0] == 0)) != (ans[1] == ans[-1]):
        return
    if ((inti[-1] == 'o') == (ans[-1] == 0)) != (ans[-2] == ans[0]):
        return
    print(*['W' if _ else 'S' for _ in ans], sep='')
    exit()


check([0, 0])
check([0, 1])
check([1, 0])
check([1, 1])
print(-1)

Measured memory_bytes: 22964
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl

bool sosuu(const int x)
{
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}
int gcd(int a, int b)
{
	if (a % b == 0) { return b; }
	else { return gcd(b, a % b); }
}
int ketawa(int a)
{
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

bool kaibun(std::string s)
{
	
	for(int i=0;i< sz(s);i++)
	{
		if (s[i] != s[sz(s) - i - 1])
			return false;
	}
	return true;
}

typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

ll a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	cin >> n; map<ll, ll>x; vector<ll>a(n);
	ll sum = 0;
	rep(i,n)
	{
		cin >> a[i];
		x[a[i]]++;
	}
	for (auto i = x.begin(); i != x.end(); i++)
		sum += i->second * (i->second-1) / 2;
	rep(i, n)
		cout << sum + (x[a[i]] - 1) * (x[a[i]] - 2) / 2 - x[a[i]] * (x[a[i]] - 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 11008
package main

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

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (int, int, []int) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines

	n, k := scanInt(sc), scanInt(sc)
	as := []int{}
	sum := 0
	for i := 0; i < n; i++ {
		as = append(as, scanInt(sc))
		sum += as[i]
	}
	return sum, k, as
}

func resolve(sum, k int, as []int) int {
	divs := enumDivisors(sum)
	sort.Sort(sort.Reverse(sort.IntSlice(divs)))
	for _, d := range divs {
		rests := make([]int, len(as))
		for i, a := range as {
			rests[i] = a % d
		}
		sort.Sort(sort.IntSlice(rests))
		mSums, pSums := make([]int, len(rests)), make([]int, len(rests))
		mSums[0] = rests[0]
		pSums[0] = d - rests[0]
		for i := 1; i < len(rests); i++ {
			mSums[i] = mSums[i-1] + rests[i]
			pSums[i] = pSums[i-1] + d - rests[i]
		}
		for i := 0; i < len(rests); i++ {
			if mSums[i] == pSums[len(rests)-1]-pSums[i] && mSums[i] <= k {
				return d
			}
		}
	}
	return 1
}

func pow(n, i int) (res int) {
	res = 1
	for i > 0 {
		if i&1 == 1 {
			res *= n
		}
		i >>= 1
		n *= n
	}
	return res
}

func enumDivisors(n int) (r []int) {
	max := int(math.Sqrt(float64(n))) + 1
	for i := 1; i < max; i++ {
		if n%i == 0 {
			r = append(r, i)
			if n/i != i {
				r = append(r, n/i)
			}
		}
	}
	sort.Sort(sort.IntSlice(r))
	return r
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 6528