akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <limits>

using namespace std;
typedef long long ll;

int main(){
    ll n, ma, mb;
    cin >> n >> ma >> mb;
    vector<array<ll, 3>> c(n);
    for(int i = 0; i < n; ++i){
        cin >> c.at(i).at(0) >> c.at(i).at(1) >> c.at(i).at(2);
    }

    vector<vector<ll>> price(
        n * 10 + 1, vector<ll>(n * 10 + 1, numeric_limits<ll>::max()));
    price.at(0).at(0) = 0;
    for(int i = 0; i < n; ++i){
        for(int a = price.size() - 1; a >= 0; --a){
            for(int b = price.at(a).size() - 1; b >= 0; --b){
                if(price.at(a).at(b) == numeric_limits<ll>::max()){
                    continue;
                }
                price.at(a + c.at(i).at(0)).at(b + c.at(i).at(1)) = min(
                    price.at(a + c.at(i).at(0)).at(b + c.at(i).at(1)),
                    price.at(a).at(b) + c.at(i).at(2)
                );
            }
        }
    }

    ll ans = -1;
    for(int i = 1; i < price.size(); ++i){
        for(int j = 1; j < price.at(i).size(); ++j){
            if(price.at(i).at(j) == numeric_limits<ll>::max()){
                continue;
            }
            if(i % ma == 0 && j % mb == 0 && i / ma == j / mb){
                if(ans == -1){
                    ans = price.at(i).at(j);
                }else{
                    ans = min(ans, price.at(i).at(j));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
int perm[333333];
int main() {
	int x;
	scanf("%d%d", &n, &x);
	n = 2*n-1;
	if(x == 1 || x == n) {
		printf("No\n");
		return 0;
	}
	set<int> all;
	REP(i, n) if(i+1 != x && i+1 != x-1 && i+1 !=x+1) all.insert(i+1);
	perm[n/2] = x;
	perm[n/2-1] = x-1;
	perm[n/2+1] = x+1;
	if(n > 3) {
		if(x > 2) {
			perm[n/2+2] = x-2;
			all.erase(x-2);
		} else {
			perm[n/2-2] = x+2;
			all.erase(x+2);
		}
	}
	REP(i, n) if(!perm[i]) {
		perm[i] = *all.begin();
		all.erase(all.begin());
	}
	printf("Yes\n");
	REP(i, n) printf("%d\n", perm[i]);
	

	/*
	REP(i, n) perm[i] = i+1;
	do {
		vector< vector<int> > V;
		V.pb(vector<int>(perm, perm+n));
		int csize = n;
		REP(i, n) printf("%d ", perm[i]);
		printf("\n");
		vector<int> last;
		int k = 0;
		while(csize > 1) {
			vector<int> curr;
			k++;
			REP(i, 2*k) printf(" ");
			for(int k = 1; k < csize-1; k++) {
				vector<int> X = {
					V.back()[k-1],
					V.back()[k],
					V.back()[k+1]
				};
				sort(X.begin(), X.end());
				curr.pb(X[1]);
				printf("%d ", X[1]);
			}
			printf("\n");
			V.pb(curr);
			csize -= 2;
			last = curr;
		}
		printf("\n\n");
	} while(next_permutation(perm, perm+n));
	*/
	return 0;
}


Measured memory_bytes: 11648
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class Val>
struct BinaryIndexedTree {
    int n;
    vector<Val> t;
    BinaryIndexedTree() {}
    BinaryIndexedTree(int _n) :n(_n + 1), t(_n + 1) {}
    void add(int k, Val val) {
        k++;
        while (k < n) {
            t[k] += val;
            k += (k&-k);
        }
    }
    void set(int k, Val val) {
        add(k, -sum(k, k + 1));
        add(k, val);
    }
    Val sum(int k) {
        Val r = 0;
        while (k > 0) {
            r += t[k];
            k -= (k&-k);
        }
        return r;
    }
    Val sum(int l, int r) {
        return sum(r) - sum(l);
    }
};

const int MAX_N = 100005;
int N, A[MAX_N], B[MAX_N];

// sm(C[i]), sorted
int S[MAX_N], T[MAX_N];

// 和のインデックス(BITで使う)
int g(int y) {
    return lower_bound(T, T + N + 1, y) - T;
};

ll f(int x) {
    // S[r]-S[l]>=0
    // を満たすようなS[l]の数
    BinaryIndexedTree<int> bit(N + 1);
    int b = B[x];

    rep(i, N) {
        int c = A[i] >= b ? 1 : -1;
        T[i + 1] = S[i + 1] = S[i] + c;
    }

    sort(T, T + N + 1);

    ll cnt = 0;
    bit.add(g(0), 1);
    rep(i, N) {
        int j = g(S[i + 1]);
        cnt += bit.sum(0, j + 1);
        bit.add(j, 1);
    }

    return cnt;
}

void solve() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        B[i] = A[i];
    }

    sort(B, B + N);
    int M = unique(B, B + N) - B;

    // ceil(H(N,2)/2)
    // = ceil(N*(N+1)/4)
    // オーバーフロー注意!!
    ll need = (N*(N + 1ll) + 3) / 4;

    int ok = 0, ng = M;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        if (f(mid) >= need) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << B[ok] << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}
 
void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

const int maxn = 5e5+10;
const int inf = 1e9;
const lf eps = 1e-8;

char s[maxn];
int sz[maxn],d1[maxn],d2[maxn],d3[maxn],d4[maxn],n,head[maxn],tot,f[maxn];
struct edge{int to,nxt;}e[maxn<<1];

void add(int u,int v) {e[++tot]=(edge){v,head[u]},head[u]=tot;}
void ins(int u,int v) {add(u,v),add(v,u);}

void dfs(int x,int fa) {
    sz[x]=s[x]-'0',f[x]=fa;d3[x]=1e9;
    for(int v,i=head[x];i;i=e[i].nxt)
        if((v=e[i].to)!=fa) {
            dfs(v,x),sz[x]+=sz[v];
            d1[x]=max(d1[x],d1[v]+1);
            if(sz[v]) d3[x]=min(d3[x],d1[e[i].to]+1);
        }
}

void dfs2(int x,int fa) {
    int fr=0,sc=0;if(fa) d4[x]=d2[x]-1;
    for(int v,i=head[x];i;i=e[i].nxt) {
        if((v=e[i].to)==fa) continue;
        if(d1[v]+1>=fr) sc=fr,fr=d1[v]+1;
        else if(d1[v]+1>sc) sc=d1[v]+1;
    }
    for(int v,i=head[x];i;i=e[i].nxt) {
        if((v=e[i].to)==fa) continue;
        if(d1[v]+1==fr) d2[v]=max(d2[x],sc)+1;
        else d2[v]=max(d2[x],fr)+1;
        dfs2(e[i].to,x);
    }
}

int main() {
    read(n);for(int i=1,x,y;i<n;i++) read(x),read(y),ins(x,y);
    scanf("%s",s+1);dfs(1,0),dfs2(1,0);
    ll ans=0;int mx,mn;
    // for(int i=1;i<=n;i++) write(d3[i]);
    for(int x=1;x<=n;x++) {
        mx=max(d1[x],d2[x])-1;//printf("debug :: %d\n",mx);
        if(s[x]=='0') mn=min(d3[x],sz[1]==sz[x]?(int)1e9:d2[x]);else mn=0;
        for(int i=head[x];i;i=e[i].nxt)
            if(e[i].to==f[x]) mx=min(mx,d1[x]+1);
            else mx=min(mx,d4[e[i].to]+1);
        // printf("%d %d %d\n",x,mn,mx);
        if(mx>=mn) ans+=(ll)mx-mn+1;
    }printf("%lld\n",ans+1ll);
    return 0;
}


Measured memory_bytes: 28416
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d; cin >> a >> b >> c >> d;
    if (b <= c || d <= a) { //離れてる
        cout << 0 << endl;
    } else if (a <= c && b <= d) { //一部かぶる
        cout << max(b, c) - min(b, c) << endl;
    } else if (c <= a && d <= b){
        cout << max(a, d) - min(a, d) << endl;
    } else { //完全被覆
        cout << min(b, d) - max(a, c) << endl;
    }
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,m; cin >> n >> m;
    vvl G(n);
    vl deg(n,0);//入次数
    vl dp(n+1,0);
    rep(i,m){
        int x,y; cin >> x >> y;
        x--;y--;
        G[x].push_back(y);
        deg[y]++;
    }
    queue<ll> que;
    rep(i,n) if(deg[i] == 0)que.push(i); //入次数が0のものをキューにいれる

    while(!que.empty()){
        int x = que.front();
        que.pop();
        for(auto nv:G[x]){
            deg[nv]--;
            if(deg[nv] == 0)que.push(nv);
            chmax(dp[nv],dp[x]+1);
        }
    }
    ll res = 0;
    rep(i,n)chmax(res,dp[i]);
    out(res);
}


Measured memory_bytes: 7296
#include <stdio.h>

int main() {
  int N, M, i, j, C, EXpoint = 0;
  int target[100];
  int finger[100][100];
  int point[100] = {0};
  scanf( "%d", &N );
  scanf( "%d", &M );
  for( i = 0; i < M; i++ ) {
    scanf( "%d", &target[i] );
  }
  for( i = 0; i < M; i++ ) {
    for( j = 0; j < N; j++ ) {
      scanf( "%d", &finger[i][j] );
    }
  }
  for( i = 0; i < M; i++ ) {
    for( j = 0; j < N; j++ ) {
      if( finger[i][j] == target[i] ) {
        point[j]++;
      } else {
        EXpoint++;
      }
    }
    C = target[i] - 1;
    point[C] +=  EXpoint;
    EXpoint = 0;
  }
  for( i = 0; i < N; i++ ) {
    printf( "%d\n", point[i] );
  }
  return 0;
}

Measured memory_bytes: 1064
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int N = Integer.parseInt(sc.next());
        char[] ch = sc.next().toCharArray();
        int x = 0;
        int max = 0;
        
        for (int i = 0; i < N; i++) {
            x = (ch[i] == 'I') ? ++x : --x;
            max = Math.max(x, max);
        }
        
        out.println(max);
        
        out.flush();
    }
}

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

int main() {
	int n;
	cin >> n;
	vector<vector<int>> cnt(10,vector<int>(10));
	for(int i=1;i<=n;i++) {
		string s;
		s = to_string(i);
		if (s[0] != '0' && s[s.size() - 1] != '0') {
			cnt[s[0] - '0'][s[s.size() - 1] - '0']++;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ans += cnt[i][j] * cnt[j][i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if 0 > self.parents[x]:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if 0 > x]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
	
N, M = MAP()
bridge = [LIST() for _ in range(M)][::-1]
tree = UnionFind(N)

ans = []
A = N*(N-1)//2
for x, y in bridge:
	ans.append(max(A, 0))
	#print([tree.size(r) for r in tree.roots()])
	if not tree.same(x-1, y-1):
		A -= tree.size(x-1)*tree.size(y-1)
	tree.union(x-1, y-1)

print(*ans[::-1], sep="\n")

Measured memory_bytes: 36756
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,ff;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>m>>x>>y;
		if(m<x+y)ff=1;
		if((m-x-y)%2==1) ff=1;
	}
	if(ff==1) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

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

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a; cin >> b; cin >> k;

    int ct = 0;
    int x = min(a,b);
    for(int i = x; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
            ct++;
        }
        if(ct == k) {
            cout << i << "\n";
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>

using namespace std;


int main(){
    long long int n, m = 1000000007;
    cin >> n;
    vector <long long int> t(n), a(n);
    for (int i = 0; i < n; ++i){
        cin >> t[i];
    }
    long long int ans = 1;
    for (int i = 0; i < n; ++i){
        cin >> a[i];
    }
    if (t[n-1] != a[0]){
        cout << "0";
        return 0;
    }
    for (int i = 1; i < n-1; ++i){
        if (t[i]<=t[i-1] && a[i]<= a[i+1]){
            ans = (ans*min(a[i],t[i]))%m;
        }
        else if ((t[i]>t[i-1] && a[i]<t[i]) || (a[i]>a[i+1] && a[i]>t[i])){
            cout << "0";
            return 0;
        }
    }
    cout << ans;
   return 0;
}

Measured memory_bytes: 1792
use proconio::{input, marker::Usize1};

fn chmax(a: &mut i32, b: i32) { *a = (*a).max(b); }
fn rotate(x: &mut usize, y: &mut usize, z: &mut usize) {
    let w = *x;
    *x = *y;
    *y = *z;
    *z = w;
}

struct DP {
    l12: Vec<Vec<i32>>,
    l1_max: Vec<i32>,
    l2_max: Vec<i32>,
    max: i32,
    n: usize,
}

impl DP {
    fn new(n: usize) -> DP {
        DP {
            l12: vec![vec![i32::min_value(); n + 1]; n + 1],
            l1_max: vec![i32::min_value(); n],
            l2_max: vec![i32::min_value(); n],
            max: i32::min_value(),
            n: n,
        }
    }
    fn set(&mut self, l1: usize, l2: usize, v: i32) {
        if l2 != self.n {
            chmax(&mut self.l12[l1][l2], v);
            chmax(&mut self.l12[l2][l1], v);
            chmax(&mut self.l1_max[l2], v);
            chmax(&mut self.l2_max[l2], v);
        }
        chmax(&mut self.l1_max[l1], v);
        chmax(&mut self.l2_max[l1], v);
        chmax(&mut self.max, v);
    }
}

fn main() {
    input! {
        n: usize,
        a: [Usize1; n * 3],
    }

    let mut dp = DP::new(n);
    dp.set(a[0], a[1], 0);
    let mut mc = 0;
    for i in 1..n {
        let (mut x, mut y, mut z) = (a[i * 3 - 1], a[i * 3], a[i * 3 + 1]);
        if x == y && x == z {
            mc += 1;
        } else {
            let mut h = std::collections::HashMap::new();
//            let mut q = vec![];
            for _ in 0..3 {
                for l in 0..n {
                    let mut v = dp.l1_max[l];
                    if y == z {
                        v = v.max(dp.l12[y][l] + 1);
                    }
//                    q.push((x, l, v));
                    let hv = h.entry((x, l)).or_insert(v);
                    chmax(hv, v);
                }
                let mut v = dp.max;
                if y == z {
                    v = v.max(dp.l1_max[y] + 1);
                }
//                q.push((x, n, v));
                let hv = h.entry((x, n)).or_insert(v);
                chmax(hv, v);

                let v = dp.max.max(dp.l12[z][z] + 1);
//                q.push((x, y, v));
                let hv = h.entry((x, y)).or_insert(v);
                chmax(hv, v);
                rotate(&mut x, &mut y, &mut z);
            }
//            for (x, y, v) in q {
            for ((x, y), v) in h {
                dp.set(x, y, v);
            }
        }
    }
    let l = a[3 * n - 1];
    let v = dp.max.max(dp.l12[l][l] + 1);
    println!("{}", v + mc);
}


Measured memory_bytes: 18284
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 2501;
const int N2 = 55;
VE<pair<ll, P<ll>>> e[N];
P<ll> rate[N2];
ll zero = 0;
void dijkstra(int s, VVL& dp) {
	priority_queue <pair<ll, P<ll>>, VE<pair<ll, P<ll>>>, greater<pair<ll, P<ll>>>> pq;
	pq.push(make_pair(zero, make_pair(s, zero)));
	while (!pq.empty()) {
		ll t = pq.top().first;
		ll m = pq.top().second.first;
		ll v = pq.top().second.second;
		pq.pop();
		if (dp[v][m] < t) continue;
		ll nm = min(m + rate[v].first, (ll)2500);
		if (chmin(dp[v][nm], dp[v][m] + rate[v].second)) {
			pq.push(make_pair(t + rate[v].second, make_pair(nm, v)));
		}
		for (auto c : e[v]) {
			ll nv = c.first;
			ll cost = c.second.first;
			ll time = c.second.second;
			if (m - cost < 0) continue;
			if (chmin(dp[nv][m - cost], dp[v][m] + time)) {
				pq.push(make_pair(t + time, make_pair(m - cost, nv)));
			}
		}
	}
}
int main() { // うまく状態を減らさないとTLEしそう
	int n, m, s;
	cin >> n >> m >> s;
	chmin(s, N - 1);
	VVL dp(n, VL(N, UPPER));
	dp[0][s] = 0;
	rep(i, m) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--, b--;
		e[a].push_back(make_pair(b, make_pair(c, d)));
		e[b].push_back(make_pair(a, make_pair(c, d)));
	}
	rep(i, n) {
		cin >> rate[i].first >> rate[i].second;
	}
	dijkstra(s, dp);
	rep1(i, n - 1) {
		ll ans = UPPER;
		rep(j, N) chmin(ans, dp[i][j]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 7264
N = int(input())
H = list(map(int, input().split()))
q = 0
s = [0]
for i in range(N-1):
  if H[i] >= H[i+1]:
    p = q + 1
    s.append(p)
    q = q + 1
  else:
    s.append(0)
    q = 0

s.sort()
ans = s[-1]
print(ans)

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

N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0]*(K+2) for _ in range(N+1)]
dp[0][0] = 1
MOD = 10**9+7

for i in range(N):
    for j in range(K+1):
        dp[i+1][j] += dp[i][j]
        dp[i+1][min(K, j+a[i])+1] -= dp[i][j]
        
    dp[i+1][0] %= MOD
    
    for j in range(1, K+2):
        dp[i+1][j] += dp[i+1][j-1]
        dp[i+1][j] %= MOD
    
print(dp[N][K])

Measured memory_bytes: 118640
#include<stdio.h>
 
int main(){
    int cards[4][14];
    int n, i,j,c;
    char m, d;
    for(i=0; i < 4; i++){
        for(j=0; j < 14; j++){
            cards[i][j]=0;
        }
    }
    scanf("%d", &c);
    for(i = 0; i < c; i++){
        scanf("%c", &d);
        scanf("%c %d", &m, &n);
        if(m == 'S'){
            cards[0][n] = 1;
        }
        else if(m == 'H'){
            cards[1][n] = 1;
        }
        else if(m == 'C'){
            cards[2][n] = 1;
        }
        else if(m == 'D'){
            cards[3][n] = 1;
        }
    }
    for(j=1; j < 14; j++){
        if(cards[0][j] != 1){
            printf("S %d\n", j);
        }
    }
 
    for(j=1; j < 14; j++){
        if(cards[1][j] != 1){
            printf("H %d\n", j);
        }
    }
 
    for(j=1; j < 14; j++){
        if(cards[2][j] != 1){
            printf("C %d\n", j);
        }
    }
 
    for(j=1; j < 14; j++){
        if(cards[3][j] != 1){
            printf("D %d\n", j);
        }
    }
 return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    string s;
    cin>>s;
    int l=s.length();
    int j=l-1;
    int c=0;
    l=l/2;
    for(int i=0;i<l;i++)
    {
       if(s[i]!=s[j])
       {
           c++;
       }
       j--;
    }
    printf("%d",c);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>
#include <type_traits>
#include <map>
#include <cstdio>
#include <string>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

// 最大公約数算出
int calc_gcd(const vector<int> vec){
	int gcd = *min_element(vec.begin(), vec.end());
	for (const int ele: vec){
		gcd = gcd_euclid(gcd,ele);
	}
	return gcd;
}

// 最小公倍数
int calc_lcm(const vector<int> vec) {
	int tmp = 1;
	for (const int ele: vec){
		tmp *= ele;
	}
	int gcd = calc_gcd(vec);
	return tmp/gcd;
}

std::string join(const std::vector<std::string>& v, const char* delim = 0) {
  std::string s;
  if (!v.empty()) {
    s += v[0];
    for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += v[i];
    }
  }
  return s;
}

// nが奇数、偶数の場合の場合分け
// n & 1 ? odd : even

// distinctはsortしてunique + erase
// https://qiita.com/ysk24ok/items/30ae72f4f1060b088588
//sort(vec.begin(), vec.end());
//vec.erase(unique(vec.begin(), vec.end()), vec.end());


void run() {
	int n, a, b; get n; get a >> b;
	vector<int> l;
	vector<int> m;
	vector<int> h;

	rep(i, 0, n) {
		int p; get p;
		if (p <= a) l.emplace_back(p);
		if (a+1 <= p && p <= b) m.emplace_back(p);
		if (b+1 <= p) h.emplace_back(p);
	}

	int ll = l.size();
	int mm = m.size();
	int hh = h.size();
	put min({ll, mm, hh});
}

int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
import java.util.*;
import java.util.regex.Pattern;
public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int [] pasta = new int[3];
		int [] juice = new int[2];
		for(int i = 0; i < 3; i++){
			pasta[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++){
			juice[i] = sc.nextInt();
		}
		int ans = 1 << 24;
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 2; j++){
				int value = pasta[i] + juice[j] - 50;
				ans = Math.min(ans, value);
			}
		}
		System.out.println(ans);
	}

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

Measured memory_bytes: 12000
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

a, b = map(int, input().split())

ans = 0

if (a >= 13):
    ans = b
elif(a >= 6 and a <= 12):
    ans = b // 2
else:
    pass
print(ans)



Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	LL a[n];
	map<LL,LL> l,r;
	LL ans = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		ans += r[i+a[i]];
		ans += l[i-a[i]];
		l[i+a[i]]++;
		r[i-a[i]]++;
	}
	// syutsuryoku
	cout << ans << endl;
}

Measured memory_bytes: 50680
#include<bits/stdc++.h>
#define ll  long long
#define pp pair<int,int>
#define ppn pair<pp,int>
#define F first
#define S second
#define N 1000005
#define mod 1000000007
#define pi 3.14159265358979323846

using namespace std;
vector<int>graph[N];
int vis[N];
void dfs(int s)
{
    vis[s]=1;
    for(int i=0; i<graph[s].size(); i++)
    {
        if(!vis[graph[s][i]])
        {
            dfs(graph[s][i]);
        }
    }
}


int main()
{


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

    int n, m, u, v;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        if(!vis[i])
        {
            dfs(i);
            ans++;
        }
    }
    cout<<ans-1<<endl;

}


Measured memory_bytes: 31088
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int k = sc.nextInt();
      int x = (int) k/2;
      int y = x*2;
	  if(y == k)System.out.println(k*k/4);
      else System.out.println((k-1)*(k+1)/4);
      sc.close();
    }
}


Measured memory_bytes: 21844
N=int(input())
ans=0
A=0
BA=0
B=0
for i in range(N):
    S=list(input())
    for j in range(1,len(S)):
        if S[j-1]=="A" and S[j]=="B":
            ans+=1
    if S[0]=="B" and S[len(S)-1]=="A":
        BA+=1
    elif S[0]=="B":
        B+=1
    elif S[len(S)-1]=="A":
        A+=1
#print(ans,A,B,BA)
if A>=1 or B>=1:
    print(ans+BA+min(A,B))
elif BA>=1:
    print(ans+BA-1)
else:
    print(ans)


Measured memory_bytes: 50408
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    map<string, int> M;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        sort(S.begin(), S.end());
        M[S]++;
    }
    long long ans = 0;
    for (auto &m : M) {
        ans += (long long)m.second*(m.second-1)/2;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 11264
/* 入力：1～12の整数x、y	出力：Yes・No
	xとyは同じグループに属しているのかを調べるプログラム*/


#include <stdio.h>

//整数を入力すると所属グループ番号を出力する
int group(int num)
{
	switch (num)
	{
		case 2: num = 1;
				break;
		case 4:
		case 6:
		case 9:
		case 11:num = 2;
				break;
		default:num = 3;
				break;
	}
	return num;
}
int main (void)
{
	//変数宣言
	int x,y;//入力
	char str[8]; //標準入力読み取り用
	
	//標準入力読み込み
	fgets(str,8,stdin);
	sscanf(str,"%d %d",&x,&y);
	
	//グループチェック
	x = group(x);
	y = group(y);
	
	//出力
	if(x == y)
	{
		puts("Yes");
	}else
	{
		puts("No");
	}
	
	return 0;
}


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



int main(){
  string S,T;
  cin>>S>>T;
  int sum=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!=T.at(i)) sum++;
  }
  cout<<sum<<endl;
  
    
    
}
  

Measured memory_bytes: 3808
// ~zaletaet~

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
struct chash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + RANDOM);
  }
};

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int32_t main() {
  fre("");
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
  int x, y;
  cin >> x >> y;

  for (int i = 0; i <= x; i++) {
    if (i * 2 + (x - i) * 4 == y) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";

  return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation
// gp_hash_table<T, U, chash> -> fast unordered_map
// m.count(x) <-> (m.find(x) != m.end())


Measured memory_bytes: 3640
#pragma GCC optimize(3)
#pragma GCC optimize(s)
#include <iostream>
#include <cstdio>
using namespace std;
#define LL long long

LL n,a,b,c,d;

inline void read(LL& sum)
{
    char ch; sum=0;
    ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9')
        sum=(sum<<3)+(sum<<1)+ch-'0',ch=getchar();
}

int main()
{
	read(a),read(b),read(c),read(d);
	read(n);
	LL min1=min(a*4,min(b*2,c));
	LL min2=min(min(a*8,b*4),min(c*2,d));
	LL ans=(n%2?(n-1)*min2/2+min1:n*min2/2);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan =new Scanner(System.in);
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		int c=Integer.parseInt(scan.next());
    		

    		if(a==b && b==c) {
    			System.out.print(1);
    		}else if (a==b || a==c||b==c) {
    			System.out.print(2);
    		}else {
    			System.out.print(3);
    		}
    		
    }
     
    }

Measured memory_bytes: 21844
import numpy as np

a,b,c,d = map(int,input().split())

cdlcm = np.lcm(c,d)

a_c = (a-1) // c
b_c = b // c
a_d = (a-1) // d
b_d = b // d
a_cd = (a-1) // (cdlcm)
b_cd = b // (cdlcm)

ans = (b-(a-1)) - (b_c - a_c) - (b_d - a_d) + (b_cd - a_cd)

print(ans)

Measured memory_bytes: 27144
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a[3][3];
    bool vis[3][3];
    forn(i,3){
        forn(j,3)   cin>>a[i][j], vis[i][j]=false;
    }
    int n;
    cin>>n;
    forn(i,n){
        int b;
        cin>>b;
        forn(j,3){
            forn(k,3){
                if(a[j][k]==b)
                    vis[j][k] = true;
            }
        }
    }
    bool flag1 = false;
    forn(i,3){
        if(vis[i][0] && vis[i][1] && vis[i][2]){
            flag1 = true;
            break;
        }
    }
    bool flag2 = false;
    forn(i,3){
        if(vis[0][i] && vis[1][i] && vis[2][i]){
            flag2 = true;
            break;
        }
    }
    bool flag3 = false;
    if(vis[0][0] && vis[1][1] && vis[2][2] )    flag3 = true;
    
    bool flag4 = false;
    if(vis[0][2] && vis[1][1] && vis[2][0])     flag4 = true;

    if(flag1 || flag2 || flag3 || flag4){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}



Measured memory_bytes: 256
N = int(input())
num = [0 for i in range(7*N)]

for x in range(1, int(N**0.5)+1):
  for y in range(1, int(N**0.5)+1):
    for z in range(1, int(N**0.5)+1):
      f_N = x**2 + y**2 + z**2 + x*y + y*z + z*x
      num[f_N] += 1

for i in range(N):
  print(num[i+1])

Measured memory_bytes: 9956
// Problem : C - Back and Forth
// Contest : AtCoder -  AtCoder Beginner Contest 051
// URL : https://atcoder.jp/contests/abc051/tasks/abc051_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x2 -=x1;
	y2 -=y1;
    x1 = 0;
	y1 = 0;
	for(int i = 0; i < y2; i++){
	    cout << 'U';
	}
	for(int i = 0; i < x2; i++){
	    cout << 'R';
	}
	for(int i = 0; i < y2; i++){
	    cout << 'D';
	}
	for(int i = 0; i < x2; i++){
	    cout << 'L';
	}
	cout << 'L';
	for(int i = 0; i <= y2; i++){
	    cout << 'U';
	}
	for(int i = 0; i <= x2; i++){
	    cout << 'R';
	}
	cout << 'D';
	cout << 'R';
	for(int i = 0; i <= y2; i++){
	    cout << 'D';
	}
	for(int i = 0; i <= x2; i++){
	    cout << 'L';
	}
	cout << 'U';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long sum = 0;
        for (int i = 0; i <= n; i++) {
            if(i%3 != 0 && i%5!=0){
                sum+=i;
            }
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 35776
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;
vector<ll> A(100100, 0);

int main() {
    cin >> n;
    for(int i = 0; i <= n; ++i) cin >> A.at(i);

    vector<ll> sumleft(n+2, 0);
    vector<ll> sumright(n+2, 0);
    for(int i = n; i >= 0; --i) {
        if(i == n) {
            sumleft.at(n) = A.at(n);
            sumright.at(n) = A.at(n);
        }else {
            sumleft.at(i) = (sumleft.at(i+1)+1)/2 + A.at(i);
            sumright.at(i) = sumright.at(i+1) + A.at(i);
        }
    }

    if(sumright.at(0) >= 1 && sumleft.at(0) <= 1) {
        ll ans = 0;
        ll limit = 1;
        for(int i = 0; i <= n; ++i) {
            if(i == 0) {
                ans += 1;
                limit *= 2;
            }else {
                ll cnt = min(limit, sumright.at(i));
                ans += cnt;
                cnt -= A.at(i);
                limit = cnt*2;
            }
            // cout << "i ans " << i << " " << ans << endl;
            // cout << "limi " << limit << endl;
        }
        cout << ans << endl;
    }else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 5584
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int d;
    cin >> d;

    while(--d >= 0){
        string s;
        cin >> s;
        int n = s.size();

        int a = 0;
        bool ret = false;
        for(int i=0; i<n; ++i){
            a = a * 10 + (s[i] - '0');
            while(a > 9){
                a = a / 10 + a % 10;
                ret = !ret;
            }
        }

        if(!ret)
            cout << "Audrey wins." << endl;
        else
            cout << "Fabre wins." << endl;
    }

    return 0;
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;

stack<tuple<int, int, int> > area;
stack<int> res;
stack<int> downs;

int integrate(int i, int j){
    int value = j-i;
    while(!area.empty() && get<1>(area.top()) >= i && get<2>(area.top()) <= j){
        value += get<0>(area.top());
        area.pop();
    }
    return value;
}

int main() {
    string str;
    int total = 0;
    int temp = 0;
    cin >> str;
    int n = str.length();
    REP(i, n){
        string query = str.substr(i, 1);
        if(query == "\\"){
            downs.push(i);
        } else if(query == "/" && !downs.empty()){
            area.push(make_tuple(integrate(downs.top(), i), downs.top(), i));
            downs.pop();
        }
    }

    while(!area.empty()){
        res.push(get<0>(area.top()));
        total += get<0>(area.top());
        area.pop();
    }
    cout << total << endl << res.size();
    while(!res.empty()){
        cout << " " << res.top();
        res.pop();
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
int b[maxn];
int main()
{
     int n;
     double t,a;
     cin>>n>>t>>a;
     double dis = inf;
     int ans = -1;
     for(int i = 1; i <= n; ++i)
     {
         double x;
         cin>>x;
         double now = t - x*0.006;
         if(abs(now - a) < dis)ans = i,dis = abs(now - a);
     }
     cout<<ans<<endl;
}












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

int main() {
    double a, b, C, S, L, h;
    std::cin >> a >> b >> C;
    S = 0.5 * a * b * std::sin(C / 180 * M_PI);
    L = a + b + std::pow(a * a + b * b - 2 * a * b * std::cos(C / 180 * M_PI), 0.5);
    h = b * std::sin(C / 180 * M_PI);
    std::cout << std::fixed << std::setprecision(8) << S << std::endl << L << std::endl << h << std::endl; 
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(abs(A-C) <= D || ( abs(A - B) <= D && abs(B-C) <= D)) 
    cout << "Yes" << endl; 
  else
    cout << "No" << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
    {
        if(a==c)
            printf("No\n");
        else
            printf("Yes\n");
    }
    else
    {
        if(a==c)
            printf("Yes\n");
        else if(b==c)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static long frac[] = new long[100020];
	public static final int ZYY = 1000000007;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		if (Math.abs(x - y) > 1) {
			System.out.println('0');
			return;
		}
		frac[0] = 1;
		for (int i = 1; i <= 100000; i++)
			frac[i] = frac[i - 1] * i % ZYY;
		long ans = frac[x] * frac[y] % ZYY;
		if (x == y) ans = ans * 2 % ZYY;
		System.out.println(ans);
		return;
	}
}

Measured memory_bytes: 23380
#include<stdio.h>
#include<math.h>
int N,P[51][2],i,c,s;
int main()
{
	for(c=1;scanf("%d",&N),N;c++)
	{
		scanf("%d%d",&P[0][0],&P[0][1]);
		for(i=0,s=0;i<N;i++)
		{
			if(i<N-1)scanf("%d%d",&P[i+1][0],&P[i+1][1]);
			s+=P[i][0]*P[(i+1)%N][1]-P[(i+1)%N][0]*P[i][1];
		}
		printf("%d %.1f\n",c,abs(s)/2.0);
	}
	return 0;
}

Measured memory_bytes: 636
using System;

namespace _vscode
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var d = int.Parse(Console.ReadLine());
            var e = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());
            if (e-a > k)
            {
                System.Console.WriteLine(":(");
            }else{
                System.Console.WriteLine("Yay!");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define ll long long
#define MOD 1000000007
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
ll f[200010],finv[200010],meth[200010];
ll qpow(ll a,ll b){
	ll re=1;
	while(b){
		if(b&1) re=(re*a)%MOD;
		a=a*a%MOD;b>>=1;
	}
	return re;
}
void init(){
	ll i,len=200000;
	f[0]=f[1]=finv[0]=finv[1]=1;
	for(i=2;i<=len;i++) f[i]=f[i-1]*i%MOD;
	finv[len]=qpow(f[len],MOD-2);
	for(i=len;i>2;i--) finv[i-1]=finv[i]*i%MOD;
}
int n,a[200010],vis[200010],cir[200010],cntcir=0,in[200010],bst[200010],siz[200010];
ll ans=1;
vector<int>s;
vector<int>nd[200010];
bool cmp(int l,int r){
	return siz[l]<siz[r];
}
ll C(ll x,ll y){
	return f[x]*finv[y]%MOD*finv[x-y]%MOD;
}
int main(){
	n=read();int i,j;ll tmp,c,cc;
	init();
	meth[0]=1;
	for(i=1;i<=n;i++) meth[i]=C(i*2,i)*f[i]%MOD*qpow(qpow(2,MOD-2),i)%MOD;

	for(i=1;i<=n;i++) a[i]=read(),in[a[i]]++;
	for(i=1;i<=n;i++){//取出环
		j=i;
		while(!vis[j]) vis[j]=i,j=a[j];
		if(vis[j]^i) continue;
		cntcir++;
		while(!cir[j]){
			cir[j]=cntcir,nd[cntcir].push_back(j),siz[cntcir]++,j=a[j];
		}
	}
	memset(vis,0,sizeof(vis));
	for(i=1;i<=n;i++){//判断环套树，以及外挂树是不是都是链
		if(in[i]) continue;
		j=i;
		while(!cir[j]&&!vis[j]) j=a[j];
		if(vis[j]){
			puts("0");return 0;
		}
		bst[cir[j]]=1;tmp=cir[j];
		j=i;c=0;
		while(!cir[j]) cir[j]=tmp,c++,vis[j]=1,j=a[j];
		vis[j]=c;
	}
	for(i=1;i<=cntcir;i++){//环套树处理
		if(!bst[i]){s.push_back(i);continue;}
		for(j=0;j<nd[i].size();j++) if(vis[nd[i][j]]) break;
		tmp=j;
		do{
			c=j;cc=1;
			j--;
			(j+=(int)nd[i].size());
			j%=(int)nd[i].size();
			for(;!vis[nd[i][j]];j--,j=((j<0)?j+nd[i].size():j)) cc++;
			if(vis[nd[i][c]]>cc){
				puts("0");return 0;
			}
			if(vis[nd[i][c]]<cc) (ans*=2)%=MOD;
		}while(tmp!=j);
	}
	sort(s.begin(),s.end(),cmp);
	for(i=0;i<s.size();i+=c){
		j=i;tmp=0;
		while(siz[s[j]]==siz[s[i]]&&j<s.size()) j++;
		c=j-i;
		for(j=0;j<=c/2;j++){
			(tmp+=C(c,2*j)*meth[j]%MOD*qpow(siz[s[i]],j)%MOD*qpow(2,(c-2*j)*(siz[s[i]]!=1)*(siz[s[i]]&1))%MOD)%=MOD;
		}
		ans=ans*tmp%MOD;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 18044
s=input()
t=input()
l=len(s)
c=[chr(i) for i in range(97,97+26)]
for i in range(26):
    f=0
    for j in range(l):
        if c[i]==s[j]:
            if f==0:
                k=t[j]
                f+=1
            elif f==1 and t[j]!=k:
                f+=1
                print("No")
                break
    if f==2:
        break
else:
    for i in range(26):
        f=0
        for j in range(l):
            if c[i]==t[j]:
                if f==0:
                    k=s[j]
                    f+=1
                elif f==1 and s[j]!=k:
                    f+=1
                    print("No")
                    break
        if f==2:
            break
    else:
        print("Yes")


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()

#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	int n; cin>>n;
	n %= 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
		cout<<"hon";
	}
	else if(n == 3){
		cout<<"bon";
	}
	else cout<<"pon";
}


Measured memory_bytes: 3624