akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

using namespace std;

int main(){
    int n;cin >> n;
    string s;cin >> s;
    int left=0;
    int right = 0;
    int countl = 0;
    int countr = 0;
    for(int i=0;i<n;i++){
        if(s[i] == '('){
            right ++;
        }
        else{
            if(right>0){
                right --;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(s[n-1-i] == ')'){
            left ++;
        }
        else{
            if(left >0){
                left --;
            }
        }
    }
    for(int i=0;i<left;i++){
        s = '(' + s;
    }
    for(int i=0;i<right;i++){
        s = s + ')';
    }
    cout << s << endl;
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
   string S[3]={};
   for(int i=0;i<3;i++){
       cin>>S[i];
       reverse(S[i].begin(),S[i].end());
   }
   int turn=0;
   int temp;
   while (1){
       if(S[turn].size()==0){
           cout<<(char)('A'+turn)<<endl;
           break;
           
       }
       else {
           temp=S[turn].back()-'a';
           S[turn].pop_back();
           turn=temp;
       }
   }
   
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


void solve(){
    
    int n;
    cin>>n;
    vi likes(n+1,-1);
    int cnt=0;
    for(int i=1;i<=n;i++){
        cin>>likes[i];
        if(likes[likes[i]]==i){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}





int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

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

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

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

  int sum = 1;
  int maxv = 0;
  for (int i = 0; i < N-1; i++) {
    if (S[i] == S.at(i+1)) {
      sum++;
    } else {
      sum = 1;
    }

    if (maxv < sum) {
      ANS.clear();
      ANS.push_back(S[i]);
      maxv = sum;
    } else if (maxv == sum) {
      ANS.push_back(S[i]);
    }

    if (i == N-2 && sum == 1) {
      ANS.push_back(S[i+1]);
    }
  }

  for (int i = 0; i < ANS.size(); i++) {
    cout << ANS[i] << endl;
  }
}


Measured memory_bytes: 15984
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

void dfs1(int from, vector< vector<int> >& edges, vector<int>& group, int group_idx) {
    if(group[from] > 0) return;
    group[from] = group_idx;

    for(int next: edges[from]) {
        dfs1(next, edges, group, group_idx);
    }

    return;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> p(N), group(N);
    vector<bool> visited(N);
    vector< vector<int> > edges(N, vector<int>());
    vector< set<int> >reachable(N, set<int>());
    REP(i, N) {
        cin >> p[i];
        p[i]--;
    }
    REP(i, M) {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        edges[tmp1-1].push_back(tmp2-1);
        edges[tmp2-1].push_back(tmp1-1);
    }

    int group_idx = 1;
    REP(i, N) {
        if(group[i] == 0) {
            dfs1(i, edges, group, group_idx);
            group_idx++;
        }
    }

    int ans = 0;
    REP(i, N) {
        if(group[i] == group[p[i]]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14208
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main(void) {

    int K, A, B; cin >> K >> A >> B;
    bool flag = false;
    for (int i = A; i <= B; ++i) {
        if (i % K == 0) {
            flag = true;
        }
    }
    if (flag) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
    

    return 0;
}











Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        List<string> list = new List<string>();

        int[] pos = new int[] { 8, 6, 4, 0 };
        for (int i = 0; i < Math.Pow(2, 4); i++)
        {
            string str = "AKIHABARA";
            for (int j = 0; j < 4; j++)
            {
                if ((1 & (i >> j)) == 1)
                {
                    // bitが立っている際のチェック処理
                    str = str.Remove(pos[j], 1);
                }
            }
            list.Add(str);
        }

        string answer = list.Contains(s) ? "YES" : "NO";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 26496
def solve(h, str)
  pics = []
  h.times do |i|
    pics << str[i]
    pics << str[i]
  end
  pics
end

if $PROGRAM_NAME == __FILE__
  str = []
  h, w = gets.chomp.split(' ').map(&:to_i)
  h.times { str << gets.chomp }
  pictures = solve(h * 2, str)
  pictures.each { |picture| puts picture }
end

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

long long kruskal(const vector<vector<pair<int, long long>>> &G) {
    using Edge = pair<long long, pair<int, int>>;
    struct UnionFind {
        vector<int> data; int sz;
        UnionFind(int sz) : data(sz, -1), sz(sz) { }
        bool unite(int x, int y) {
            if ((x = root(x)) == (y = root(y))) { return false; }
            if (data[x] > data[y]) { swap(x, y); }
            data[x] += data[y]; data[y] = x; sz--; return true;
        }
        int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
        int size() { return sz; }
    };
    int N = G.size(); long long sum = 0;
    vector<Edge> edges;
    UnionFind uf(N);
    for (int u = 0; u < N; u++) for (auto v : G[u]) {
        edges.emplace_back(v.second, make_pair(u, v.first));
    }
    sort(edges.begin(), edges.end());
    for (auto e : edges) {
        int from, to; long long cost = e.first; tie(from, to) = e.second;
        if (uf.unite(from, to)) { sum += cost; }
        if (uf.size() == 1) break;
    }
    return sum;
}


int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<pair<int, long long>>> G(V);
    for (int i = 0; i < E; i++) {
        int u, v;
        long long cost;
        cin >> u >> v >> cost;
        G[u].emplace_back(v, cost);
        G[v].emplace_back(u, cost);
    }
    
    long long sum = kruskal(G);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 12436
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=105;
int tab1[MAX];
int tab2[MAX];
int pref[MAX],suf[MAX];
int ans=0;
int32_t main()
{
  BOOST;
  int n;
  cin>>n;
  for (int i=1;i<=n;i++)cin>>tab1[i],pref[i]=pref[i-1]+tab1[i];
  for (int i=1;i<=n;i++)cin>>tab2[i];
  for (int i=n;i>=1;i--)suf[i]=suf[i+1]+tab2[i];
  for (int i=1;i<=n;i++)ans=max(ans,pref[i]+suf[i]);
  cout<<ans;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  string s; cin >> s;
  int n = s.size();

  reverse(all(s));
  //cout << s << endl;

  int i = 0;
  while(i < n){
    if(s.substr(i,5) == "maerd") i += 5;
    else if(s.substr(i,7) == "remaerd") i += 7;
    else if(s.substr(i,5) == "esare") i += 5;
    else if(s.substr(i,6) == "resare") i += 6;
    else break;
  }

  //cout << i << endl;
  if(i == n) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
// #define DEBUG 10

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7, maxn = 500050;
const double PI = acos(-1);
vector<ll> seg(4*maxn, 0);

inline int to_int(char a){
    return int(a - 'a');
}

void update(int i, int l, int r, int pos, ll car){
    if (l == r) {
        seg[i] = 0;
        seg[i] += (1 << car);
        return;
    }

    int mid = (l+r)/2;
    
    if (pos <= mid) update(2*i, l, mid, pos, car);
    else update(2*i+1, mid+1, r, pos, car);

    seg[i] = (seg[2*i] | seg[2*i+1]);
}

ll query(int i, int l, int r, int ql, int qr){
    if (r < ql || l > qr) return 0;
    if (ql <= l and r <= qr) return seg[i];

    ll mid = (l+r)/2, ans = 0LL;
    ans |= query(2*i, l, mid, ql, qr);
    ans |= query(2*i+1, mid+1, r, ql, qr);

    return ans;
}
int main (){
    ios_base::sync_with_stdio(false);
    int n, q, tq, l, r, pos;
    char c;
    string s;

    cin >> n >> s >> q;

    for (int i=0; i<n; i++){
        update(1, 1, n, i+1, to_int(s[i]));
    }

    for (int i=0; i<q; i++){
        cin >> tq;

        if (tq == 1){
            cin >> pos >> c;
            update(1, 1, n, pos, to_int(c));
        }
        else {
            cin >> l >> r;
            ll ans = query(1, 1, n, l, r), cnt = 0;
            while (ans) cnt += (ans%2), ans/=2;
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 16788
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args){
		solve();
	}

	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		boolean flag = false;
		for(int i=0;i<=n;i++){
			for(int j=0;j<=m;j++){
				if(i*m + j*n - 2*i*j == k){
					flag = true;
					break;
				}
			}
			if(flag){
				break;
			}
		}
		if(flag){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 21844
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := float64(nextInt())
	b := float64(nextInt())
	x := float64(nextInt())

	var tan float64
	if x > a*a*b/2 {
		tan = 2 * (a*a*b - x) / (a * a * a)
	} else {
		tan = a * b * b / (2 * x)
	}
	theta := math.Atan(tan)
	c := theta * 180 / math.Pi
	fmt.Println(c)
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
using namespace std;
double a, b, c, d, e, f;
short int solve() {
	double dis = sqrt((a - d)*(a - d)+(b - e)*(b - e));
	if (dis > c + f)return 0;
	else if (dis < c - f)return 2;
	else if (dis < f - c)return -2;
	else return 1;
}
int main() {
	size_t n; cin >> n;
	for (size_t i = 0; i < n; i++){
		cin >> a >> b >> c >> d >> e >> f;
		cout << solve() << endl;
	}
}

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

N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for bit in range(1 << 3):
    dp = [-float('inf')] * (M+1)
    dp[0] = 0
    for i in range(N):
        for j in range(M)[::-1]:
            if dp[j] != -float('inf'):
                score = 0
                for k in range(3):
                    score += xyz[i][k] * (-1)**((bit >> k) & 1)
                dp[j+1] = max(dp[j+1], dp[j] + score)
    ans = max(ans, dp[M])
print(ans)


Measured memory_bytes: 48092
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int n; cin >> n;
    map<LL, int> a;
    vector<LL> buf(n+1);
    for(int i = 1; i <= n; ++i) {
        cin >> buf[i];
        a[i+buf[i]]++;
    }
    LL ans = 0;
    for(int i = 1; i <= n; ++i)
        ans += a[i-buf[i]];
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 27436
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  string s; cin >> s;

  ll ans = 0;
  rep(i, s.size()){
    if (s[i] == '0') ans++;
    else ans--;
  }
  cout << s.size() - abs(ans) << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

long long  mod=1e9+9;
const int N=1e6+2;
int t,j,cs=0,n,a,b,i;
string s;

int main()
{
    for(i=0;i<5;i++){
        cin>>a;
        if(!a) b=i+1;
    }
    cout<<b<<endl;
}



Measured memory_bytes: 3636
#include <iostream>

int main(int argc, char **argv)
{
	int a, b;
	int n;
	int acards[10000],bcards[10000];
	while(true){
		a = 0;
		b = 0;
		std::cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			std::cin >> acards[i] >> bcards[i];
			if(acards[i] < bcards[i]){
				b += bcards[i] + acards[i];
			}
			if(acards[i] > bcards[i]){
				a += bcards[i] + acards[i];
			}
			if(acards[i] == bcards[i]){
				a += acards[i];
				b += bcards[i];
			}
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
int n,m;
string s[505];
int sy,sx,ey,ex;
struct edge{
    int to,cap,rev;
};
vector<edge> adj[505];
int level[505],iter[505];
void bfs(int s){
    memset(level, -1,sizeof(level));
    queue<int> q; q.push(s); level[s]=0;
    while(!q.empty()){
        int here = q.front(); q.pop();
        for(int i=0;i<adj[here].size();i++){
            edge &e =adj[here][i];
            if(e.cap > 0){
                if(level[e.to] == -1){
                    level[e.to] = level[here]+1;
                    q.push(e.to);
                }
            }
        }
    }
}
int dfs(int t,int here,int f){
    if(t == here)return f;
    for(int &i=iter[here];i<adj[here].size();i++){
        edge & e=adj[here][i];
        if(e.cap > 0 && level[e.to] > level[here]){
            int d =dfs(t,e.to,min(f,e.cap));
            if(d>0){
                e.cap-=d; adj[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int maxFlow(int source,int sink){
    int f=0;
    while(true){
        bfs(source);
        if(level[sink]==-1)return f;
        int r=1;
        memset(iter,0,sizeof(iter));
        while(r){
            r = dfs(sink,source,1e9);
            f+=r;
        }
    }
}
void addEdge(int from,int to,int cap){
    adj[from].push_back({to,cap,(int)adj[to].size()});
    adj[to].push_back({from,cap,(int)adj[from].size()-1});
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int source = n+m+5; int sink=source+1;
    for(int i=0;i<n;i++)for(int j=0;j<m;j++){
        if(s[i][j] == 'S'){
            addEdge(source,i,1e9);
            addEdge(source,j+n,1e9);
        }
        else if(s[i][j]=='T'){
            addEdge(i,sink,1e9);
            addEdge(j+n,sink,1e9);
        }
        else if(s[i][j]=='o'){
            addEdge(i,j+n,1);
        }
    }
    int min_cut = maxFlow(source,sink);
    if(min_cut>=1e9)min_cut=-1;
    cout<<min_cut;
    return 0;
}

Measured memory_bytes: 640
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a
 
show_flg=False
show_flg=True
 
ans=0

n=len(input())

for i in range(n):
    print('x',end='')
print()

Measured memory_bytes: 39404
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i=6;i>=0;i--)
    {
        if(pow(2,i)<=n)
        {
            cout<<pow(2,i)<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	int d=a/b;
	printf("%d",  d);
	int r=a%b;
	printf(" %d", r);
	double f=(double)a/b;
	printf(" %lf", f);
	return 0;
}


Measured memory_bytes: 2108
//此程序使用了qt专属名称，请勿模仿。侵权必究！！！
//我真是太菜了…… 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=20,P=1e9+7;
ll n,m,ans=1,a[1<<N]={1};
inline ll read()
{
	ll sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
inline ll pow(ll x,ll y)
{
	ll k=1;
	while(y)
	{
		if(y&1)
		{
			k*=x;
			k%=P;
		}
		y>>=1;
		x*=x;
		x%=P;
	}
	return k;
}
int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read();
	m=read();
	for(int i=1;i<=1<<(N-1);++i)
	{
		a[i]=a[i-1]*i%P;
	}
	for(ll i=2;i*i<=m;++i)
	{
		if(!(m%i))
		{
			ll k=0;
			while(!(m%i))
			{
				++k;
				m/=i;
			}
			ans*=a[n+k-1]%P*pow(a[n-1],P-2)%P*pow(a[k],P-2)%P;
			ans%=P;
		}
	}
	if(m>1)
	{
		ans*=n;
		ans%=P;
	}
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

vector<ll> s;

bool search(int i, int j, ll n){
    int k = (i+j)/2;
    if(s[k] == n){
        return true;
    } else if(s[k] < n){
        if(k == j) return false;
        return search(k+1,j,n);
    } else {
        if(k == i) return false;
        return search(i,k-1,n);
    }
}

int main(){
    int n,q;
    cin >> n;
    for(int i = 0; i < n; i++){
        int ss;
        cin >> ss;
        s.push_back(ss);
    }
    sort(s.begin(), s.end());

    cin >> q;
    vector<ll> t(q);
    for(int i = 0; i < q; i++){
        cin >> t[i];
    }

    int c = 0;
    for(int i = 0; i < q; i++){
        if(search(0,n,t[i]) == true) c++;
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 4076
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

N = I()
def dfs(s, n):
    if int(s) > n:
        return 0
    count = 0
    if '7' in s and '5' in s and '3' in s:
        count += 1
    return count + dfs(s+'7', n) + dfs(s+'5', n) + dfs(s+'3', n)
print(dfs('0', N))


Measured memory_bytes: 69988
#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

int n,h[100005],dp[100005];


signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin >> n;
    for(int i=1;i<=n;i++) cin >> h[i];
    dp[2]=abs(h[2]-h[1]);
    dp[1]=0;
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];
}

Measured memory_bytes: 1792
import std.stdio;
import std.string;
import std.conv;
import std.bigint;

int main()
{
	int n = readln.chomp.to!int;
	foreach(int i;0..n)
	{
		BigInt value = readln.chomp.to!BigInt;
		BigInt value_2 = readln.chomp.to!BigInt;

		BigInt sum = value + value_2;
		if(sum.to!string.length > 80)
		{
			writeln("overflow");
		}
		else
		{
			writeln(sum);
		}
	}
	return 0;
}

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

int main(){
    int n,i=0;
    cin >> n;
    unsigned long long ans=1,tmp=1;
    bool ok=true,zero=false;
    while(true){
        if(i==n)break;
        unsigned long long a;
        cin >> a;
        if(a==0)zero=true;
        if(zero)break;
        tmp *= a;
        if(tmp>1000000000000000000){
            ok=false;ans=0;
            }
        if(tmp/a==ans){
            ans=tmp;
        }
        else{
            ok=false;tmp=0;ans=0;
        }
        //if(ans<0){ok=false;ans=0;}
        i++;
    }
    if(zero)cout << 0 << endl;
    else{
        if(ok)cout << ans << endl;
        else cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; ++i)
            x[i] = scanner.nextInt();
        boolean find = false;
        for (int i = 0; i < n && !find; ++i) {
            for (int j = i; j < n && !find; ++j) {
                int t = x[i];
                x[i] = x[j];
                x[j] = t;
                boolean valid = true;
                for (int k = 0; k < n - 1; ++k)
                    if (x[k] > x[k + 1]) {
                        valid = false;
                        break;
                    }
                find = valid;
                t = x[i];
                x[i] = x[j];
                x[j] = t;
            }
        }
        writer.println(find ? "YES" : "NO");
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, p; cin >> n >> p;
    int even, odd;
    vi a(n); for(auto& e : a){ cin >> e, e %= 2; if(e == 0) even++; }
    odd = n - even;

    if(odd == 0 and p == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    ll res = (1LL << even);
    if(odd >= 1){
        res *= (1LL << (odd - 1));
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int max(int x, int y)
{
	return x>y ? x : y;
}

int main()
{
	std::string strq; getline(std::cin, strq);
	int q = std::stoi(strq);
	
	for (int i=0; i<q; i++) {
		std::string X; getline(std::cin, X);
		std::string Y; getline(std::cin, Y);
		
		int n = X.size();
		int m = Y.size();
		
		int** DP = new int*[n+1];
		for (int i=0; i<n+1; i++) DP[i] = new int[m+1];
	
		for (int i=0; i<n+1; i++) DP[i][0] = 0;
		for (int j=1; j<m+1; j++) DP[0][j] = 0;
	
		for (int i=1; i<n+1; i++) {
			for (int j=1; j<m+1; j++) {
				if (X[i-1] == Y[j-1]) DP[i][j] = DP[i-1][j-1] + 1;
				else DP[i][j] = max(DP[i][j-1], DP[i-1][j]);
			}
		}
		
		std::cout << DP[n][m] << std::endl;

		for (int i=0; i<n+1; i++) delete[] DP[i];
		delete[] DP;
	}
	
	return 0;
}



Measured memory_bytes: 6804
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	void solve() {
		IOS;
		ll x;
		cin >> x;
		ll n = 100;
		ll res = 0;
		for (ll n = 100; n < x;) {
			ll t = n / 100;
			n += t;
			res++;
		}
		put(res);

	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


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

int main()
{int s = -1, t = -1, u = -1;
 int N,Y; cin >> N >> Y;
 int Z = Y / 1000;
 for(int a = 0; a <= N ; a++)
  {for(int b = 0; b <= N; b++)
   { int c = N - a - b;
    if(c >= 0 && 10*a + 5*b + c == Z)
    { s = a, t = b, u = c;}}}
 
 cout << s << ' ' << t << ' ' << u << endl;
  
 return 0;
}

Measured memory_bytes: 256
// AOJ 2298: Starting Line
// 2017.11.2 bal4u@uu

#include <stdio.h>

int d[10002]; 

int main()
{
	int n, k, t, u, v, l, i;
	int pos, up, keep;
	double ans;

	scanf("%d%d%d%d%d%d", &n, &k, &t, &u, &v, &l);
	while (n--) scanf("%d", &i), d[i]++;
	ans = 0, up = keep = 0;
	for (pos = 1; pos <= l; pos++) {
		if (up) up--, ans += 1.0/v;
		else          ans += 1.0/u;

		if (keep && up == 0) keep--, up = v*t;

		if (d[pos]) {
			if (up == 0) d[pos]--, up = v*t;
			if (keep + d[pos] > k) d[pos]--, up = v*t, keep = k;
			else keep += d[pos];
		}
	}
	printf("%.9lf\n", ans);
	return 0;
}

Measured memory_bytes: 1824
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int loop,a[2000001];

void maxHeapify(int i){
  int l, r, largest,tmp;
  l = 2 * i;
  r = 2 * i + 1;
  if (l <=loop && a[l] > a[i]){
    largest = l;
  }
  else {
    largest = i;
  }
  if (r <= loop && a[r] > a[largest]){
    largest = r;
  }
  if (largest != i){
    tmp = a[i];
    a[i] = a[largest];
    a[largest] = tmp;
    maxHeapify(largest) ;// ?????°??????????????????
  }
}

void buildMaxHeap(){
  int i;
  for (i = loop/2; i>= 1; i--){
    maxHeapify(i);
  }
}

int main(){
  scanf("%d",&loop);
  int i;
  for (i = 1;i<=loop; i++){
    scanf("%d",&a[i]);
  }
  buildMaxHeap();
  for (i = 1; i<= loop; i++){
    printf(" %d",a[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2556
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int x; cin >> x;
	for(int i = 1; ; i++){
		if(i >= x){
			cout << i << endl;
			return 0;
		}
		x -= i;
	}
	
	
	return 0;
}

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

int64_t gcd(int64_t a,int64_t b){
  if(b==0) return a;
  else gcd(b, a%b);
}

int main() {
  int64_t A,B,C,D;
  cin >> A >> B >> C >> D;
  A--;
  //cout << C*D/gcd(D, C);
  cout << B-B/C-B/D+B/(C*D/gcd(D, C)) - (A-A/C-A/D+A/(C*D/gcd(D, C)));
  

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll K,A,B;
    cin>>K>>A>>B;
    for(int i=A;i<=B;i++){
        if(i%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


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

// TwoEdgeConnectedComponents + LowLink
struct TwoEdgeConnectedComponents {
  int n;
  vector<vector<int>> g;
  vector<int> ord, low, articulation;
  vector<bool> used;
  using P = pair<int, int>;
  vector<P> bridge;
  TwoEdgeConnectedComponents(int _n = 1) : n(_n), g(n) {}
  TwoEdgeConnectedComponents(vector<vector<int>> &_g) : n(_g.size()), g(_g) {
    build();
  }

  bool add(int from, int to) {
    g[from].push_back(to);
    g[to].push_back(from);
    return 1;
  }

  void build() {
    ord.assign(n, -1);
    low.assign(n, -1);
    int k = 0;
    for (int i = 0; i < n; ++i)
      if (ord[i] < 0) lowlinkdfs(i, -1, k);
  }
  void lowlinkdfs(int now, int par, int &k) {
    ord[now] = low[now] = k++;
    bool ch = 0;  // articulation
    int cnt = 0;
    for (auto &to : g[now])
      if (ord[to] < 0) {
        ++cnt;
        lowlinkdfs(to, now, k);
        low[now] = min(low[now], low[to]);
        ch |= ~par && low[to] >= ord[now];  // articulation
        if (ord[now] < low[to])
          bridge.emplace_back(min(now, to), max(now, to));  // bridge
      } else if (to != par)
        low[now] = min(low[now], ord[to]);
    ch |= par == -1 && cnt > 1;           // articulation
    if (ch) articulation.push_back(now);  // articulation
  }
};

long long n, m;
TwoEdgeConnectedComponents lowlink;
vector<vector<int>> g;

int main() {
  cin >> n >> m;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  lowlink = TwoEdgeConnectedComponents(g);
  using P = pair<int, int>;

  vector<P> res = lowlink.bridge;
  sort(res.begin(), res.end());
  for (auto p : res) cout << p.first << " " << p.second << endl;
  return 0;
}



Measured memory_bytes: 4884
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll N;
  cin >> N;
  ll ans = LINF;
  for(ll a = 1ll;a*a <= N;a++) {
    if(N%a != 0) continue;
    ll b = N / a;
    ans = min(ans,a+b-2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        //int[] nums = new int[n];
        for (int i = 0; i < n; i ++){
            int t = scan.nextInt();
            if (t % 2 == 0 && t % 3 != 0 && t % 5 != 0) {
                System.out.println("DENIED");
                return;
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 23124
#include<stdio.h>
int main(void){
  int i, j, tmp, n, k, p[1010], s=0;
  scanf("%d%d", &n, &k);
  for(i=0;i<n;i++){
    scanf("%d", &p[i]);
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(p[i]>p[j]){
        tmp=p[i];
        p[i]=p[j];
        p[j]=tmp;
      }
    }
  }
  for(i=0;i<k;i++){
    s+=p[i];
  }
  printf("%d", s);
  return 0;
 }

Measured memory_bytes: 1740
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<cmath>
#include<tuple>
#include<utility>
#include<vector>
namespace pcl{template<typename T>constexpr T gcd(T a,T b){return b==0?a:gcd(b,a%b);}template<typename T>constexpr T lcm(T a,T b){return a/gcd(a,b)*b;}template<typename T>constexpr std::tuple<T,T,T>extgcd(T a,T b){if(b==0){return std::make_tuple(a,1,0);}else{T gcd,xd,yd;std::tie(gcd,xd,yd)=extgcd(b,a%b);return std::make_tuple(gcd,yd,xd-(a/b)*yd);}}template<typename T>std::vector<T>sieve(T N){std::vector<T>res;std::vector<bool>is_not_prime(N);for(T i=2;i<=N;i++){if(is_not_prime[i])continue;res.push_back(i);for(T j=i+i;j<=N;j+=i)is_not_prime[j]=true;}return res;}template<typename T>constexpr T pow(T x,int n){T res=1;while(n>0){if(n&1)res*=x;x*=x;n>>=1;}return res;}template<typename T>constexpr bool is_prime(T val){for(T i=2;i<val;i++){if(val%i==0)return false;}return true;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int N;cin>>N;vector<ll>A(N);cin>>A;vector<ll>lgcd(N),rgcd(N);lgcd[0]=A[0];rgcd[N-1]=A[N-1];for(int i=1;i<N;i++)lgcd[i]=gcd(A[i],lgcd[i-1]);for(int i=N-2;i>=0;i--)rgcd[i]=gcd(A[i],rgcd[i+1]);ll ma=max(lgcd[N-2],rgcd[1]);for(int i=1;i<N-1;i++)updmax(ma,gcd(lgcd[i-1],rgcd[i+1]));cout<<ma<<endl;}


Measured memory_bytes: 2560