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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

const string YES_STR = "Yes";
const string NO_STR = "No";

long long ncr(int n, int r) {
	long long res = 1;
	rep(i, r) {
		res *= n - i;
		res /= i + 1;
	}
	return res;
}

bool solve() {
	int N;
	cin >> N;
	map<int, int> m;
	vector<int> v(1 << N);
	rep(i, 1 << N) {
		cin >> v[i];
		m[v[i]] = 1;
	}
	int cnt = 0;
	for (auto& p: m) {
		p.second = cnt++;
	}
	if (cnt < N + 1) {
		return false;
	}
	rep(i, 1 << N) {
		v[i] = m[v[i]];
	}
	vector<int> c(1 << 20);
	rep(i, 1 << N) {
		c[v[i]]++;
	}
	cnt = 0;
	int f = 0;
	int ma = *max_element(all(v));
	rep(i, N) {
		f = f + ncr(N, i);
		cnt += c[ma - i];
		if (cnt > f) return false;
	}
	rep(i, 1 << N) {
		if (c[i] > 1 << (N - 1)) return false;
	}
	return true;
}


signed main() {
	YES(solve());
}


Measured memory_bytes: 26880
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using pii = std::pair<int, int>;
using namespace std;

using graph = vec<vec<int>>;

constexpr int INF = numeric_limits<int>::max() / 3;
int n;
graph adj;

void bfs() {
  vec<int> d(n, INF);
  queue<int> q;
  d[0] = 0;
  q.emplace(0);

  while (!q.empty()) {
    const auto u = q.front();
    q.pop();
    for (auto&& v: adj[u]) {
      if (d[v] == INF) {
        d[v] = d[u] + 1;
        q.emplace(v);
      }
    }
  }
  REP(i, n) {
    cout << (i + 1) << " ";
    cout << (d[i] == INF ? -1 : d[i]) << endl;
  }
}

int main() {
  int u, v, k;
  cin >> n;
  adj.resize(n);
  REP(i, n) {
    cin >> u >> k;
    adj[i].resize(k);
    REP(j, k) {
      cin >> v;
      adj[i].emplace_back(v - 1);
    }
  }
  bfs();
  return 0;
}



Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
int main(){
    int W,ar,al,br,bl;
    cin >> W >> al >> bl;
    ar = al + W;
    br = bl + W;
    if(ar<bl) cout << bl-ar << endl;
    else if(al>br) cout << al-br << endl;
    else cout << "0" << endl;
    return 0;
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 100000;

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    int N,Q;
    cin >> N;
    vector<ll> t(N);
    vector<long double> a(N);
    vector<long double> bucket(500,1.00);
    Rep(i,N){
        cin >> t[i] >> a[i];
        a[i] = (10.0-a[i])/10.0;
        bucket[i/200] *= a[i];
    }
    cin >> Q;
    Rep(i,Q){
        ll l,r;
        double perf = 1e9;
        cin >> l >> r;
        int s = lower_bound(All(t),l)-t.begin();
        int e = lower_bound(All(t),r)-t.begin();
        e--;
        //cout << s << sp << e << endl;
        while((s % 200) != 0 && s <= e){
            perf *= a[s];
            s++;
        }
        while((e % 200) != 199 && e >= s){
            perf *= a[e];
            e--;
        }
        e++;
        s /= 200;
        e /= 200;
        for(int j = s;j < e;j++){
            perf *= bucket[j];
        }
        cout << fixed << setprecision(16) << perf << endl;
    }
    //cin >> N;
}


Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define mp make_pair
#define pb push_back
#define rep(i, begin, end) for(__typeof(end) i=begin; i<end; i++)
#define per(i, begin, end) for(__typeof(end) i=begin; i>=end; i--)
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;

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;		}

void solve(){
	int n, num = 0;
	cin>>n;
	num = n % 10;
	if(num == 0 || num == 1 || num == 6 || num == 8){
		cout<<"pon"<<endl;
	}else if(num == 3){
		cout<<"bon"<<endl;
	}else{
		cout<<"hon"<<endl;
	}
}

int main()
{
	fastio;
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}




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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}

const int MAX_T = 100005;
const int MAX_C = 30;
int a[MAX_T];
vector< pair<int,int> > v[MAX_C];

int main2() {
  memset(a, 0, sizeof(a));
  REP(i, MAX_C) v[i].clear();

  int N; cin >> N;
  int C; cin >> C;

  REP(i, N) {
    int s, t, c;
    cin >> s >> t >> c;
    v[c-1].push_back( make_pair(s, t) );
  }
  REP(c, C) {
    sort(ALL(v[c]));
    vector<pair<int,int>> t;
    for(auto p : v[c]) {
      if (t.size() > 0 && t.back().second == p.first) {
        t.back().second = p.second;
      } else {
        t.push_back(p);
      }
    }
    v[c] = t;
  }
  REP(c, C) {
    for (auto p : v[c]) {
      a[p.first - 1]++;
      a[p.second]--;
    }
  }
  REP(i, MAX_T - 1) {
    a[i+1] += a[i];
  }
  int ans = *max_element(a, a + MAX_T);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();  
  return 0;
}



Measured memory_bytes: 1920
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn get_line() -> String {
    let stdin = stdin();
    let mut line = String::new();
    stdin.lock().read_line(&mut line).expect("io error.");
    line.trim().to_string()
}

#[allow(dead_code)]
fn cast<T: FromStr>(s: &str) -> T {
    s.parse().ok().expect("parse error.")
}

#[allow(dead_code)]
fn get_word<T: FromStr>() -> T {
    cast(&get_line())
}

#[allow(dead_code)]
fn get_vec<T: FromStr>() -> Vec<T> {
    (&get_line()).split(' ').map(cast::<T>).collect()
}



/* ---------- ここまでテンプレ ---------- */


fn main() {
    let v: Vec<usize> = get_vec();
    let (h, w) = (v[0], v[1]);

    let mut av: Vec<Vec<usize>> = Vec::new();
    for i in 0..h {
        av.push(get_vec());
    }

    let mut route: Vec<(usize, usize)> = Vec::new();
    for i in 0..h {
        if i % 2 == 0 {
            for j in 0..w {
                route.push((i, j));
            }
        } else {
            for j in (0..w).rev() {
                route.push((i, j));
            }
        }
    }

    // println!("{:?}", route);

    let mut ans: Vec<((usize, usize), (usize, usize))> = Vec::new();
    for i in 0..(h * w - 1) {
        let (x, y) = route[i];
        if av[x][y] % 2 == 1 {
            ans.push((route[i], route[i + 1]));

            let (nx, ny) = route[i + 1];
            av[x][y] -= 1;
            av[nx][ny] += 1;
        }
    }

    println!("{}", ans.len());
    for p in ans {
        println!("{} {} {} {}",
            (p.0).0 + 1, (p.0).1 + 1,
            (p.1).0 + 1, (p.1).1 + 1);
    }
}


Measured memory_bytes: 17396
#include<stdio.h>

int main(int argc, char const *argv[])
{
	/* code */
int A[1000],N,B[1000],n=0;

scanf("%d", &N);
for (int i = 0; i < N; ++i)scanf("%d", A+i);

for (int i = 0; i < N; ++i)
{
	/* code */
	if(A[i]%2==0){
		B[n]=A[i];
		n++;	
	}
}
N=0;
for (int i = 0; i <n; ++i)
{
	/* code */
	if(B[i]%3==0 || B[i]%5==0) 
		N++;
//	printf("B=%d N=%d n=%d\n",B[i],N,n);
}
if (N==n)
	printf("APPROVED\n");
	else
printf("DENIED\n");
	return 0;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int a=nextInt();
		System.out.println(a+(a*a)+(a*a*a));
		out.flush();
	}
	static boolean isOK(int index,int key,ArrayList<Integer>a){
		if (a.get(index) >= key) return true;
	    else return false;
	}
	static int binary_search(int key,ArrayList<Integer> a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;

	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}


Measured memory_bytes: 32604
import sys
from bisect import bisect_left
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *XY = map(int, read().split())

    X = set()
    Y = set()
    for i, (x, y) in enumerate(zip(*[iter(XY)] * 2)):
        X.add(x - 1)
        Y.add(y - 1)

    X = sorted(X)
    Y = sorted(Y)

    P, Q = len(X), len(Y)

    G = [[0] * Q for _ in range(P)]
    for x, y in zip(*[iter(XY)] * 2):
        G[bisect_left(X, x - 1)][bisect_left(Y, y - 1)] = 1

    csum = [[0] * (Q + 1) for _ in range(P + 1)]
    for i in range(P):
        for j in range(Q):
            csum[i + 1][j + 1] = csum[i + 1][j] + csum[i][j + 1] - csum[i][j] + G[i][j]

    ans = -1
    for x1 in range(P):
        for x2 in range(x1, P + 1):
            for y1 in range(Q):
                for y2 in range(y1, Q + 1):
                    if csum[x2][y2] - csum[x1][y2] - csum[x2][y1] + csum[x1][y1] >= K:
                        if ans > (X[x2 - 1] - X[x1]) * (Y[y2 - 1] - Y[y1]) or ans == -1:
                            ans = (X[x2 - 1] - X[x1]) * (Y[y2 - 1] - Y[y1])

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9348
#include <iostream>
#include <stack>
#include <vector>
#include <string>

using namespace std;

int main() {
    stack<int> S1;
    vector< pair<int, int> > S2;
    char ch;
    int sum = 0;
    for (int i = 0; cin >> ch; i++) {
        if (ch == '\\') {
            S1.push(i);
        }
        else if (ch == '/' && S1.size() > 0) {
            int j = S1.top();
            S1.pop();
            
            int area = i - j;
            sum += area;
            
            while (S2.size() > 0 && (*(S2.end()-1)).first > j) {
                area += (*(S2.end()-1)).second;
                S2.pop_back();
            }
            
            S2.push_back(make_pair(j, area));
        }
    }
    
    cout << sum << endl;
    cout << S2.size();
    
    for (vector<pair<int, int> >::iterator i = S2.begin(); i != S2.end(); i++) {
        cout << " ";
        cout << (*i).second;
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 3188
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	long long int N, c = 0,ans = 0; cin >> N;
	while (N > 0) {
		N = N / 2;
		ans +=pow(2,(double)c);
		c++;
     }
	cout << ans<< endl;

	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define Rep(i,a) for(int i = 0; i < a; i++)
using namespace std;
const int N = 2e5 + 10;

struct edge{ int to, pre; } e[N << 1]; int l = 0, u[N];
void ins(int a, int b) { e[++l] = (edge){b, u[a]}, u[a] = l; }
#define v e[i].to
#define reg(i,a) for(int i = u[a]; i; i = e[i].pre)

int n, X, Y, a[N], b[N], dep[N], fa[N];

void dfs(int x, int f) {
	reg(i,x) if (v != f) dep[v] = dep[x] + 1, fa[v] = x, dfs(v, x);
}

bool jump(int a, int b) {
	if (dep[a] < dep[b]) swap(a, b);
	if (fa[a] == b || fa[fa[a]] == b || fa[a] == fa[b]) return false;
	else return true;
}

vector<int> adj[N];
#define pb(a) push_back(a)

bool inf = false, win[N];
int ans = 0;
void chk(int x, int f, int d) {
	if (d >= dep[x]) return; else ans = max(ans, dep[x]);
	inf |= win[x]; int l = adj[x].size();
	Rep(j,l) if (adj[x][j] != f) chk(adj[x][j], x, d + 1);
}

int main() {
	scanf("%d%d%d",&n,&X,&Y);
	rep(i,1,n - 1) scanf("%d%d",a + i,b + i);
	rep(i,1,n - 1) {
		int a, b; scanf("%d%d",&a,&b);
		ins(a, b), ins(b, a);
	}
	dfs(Y, 0);
	rep(i,1,n - 1) 
		if (!jump(a[i], b[i])) 
			adj[a[i]].pb(b[i]), adj[b[i]].pb(a[i]);
		else win[a[i]] = win[b[i]] = true;
	chk(X, 0, 0);
	if (inf) printf("-1\n");
	else printf("%d\n",ans * 2);
	return 0;
}

Measured memory_bytes: 26240
import math

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

y = x / a

if y <= a * b / 2:
  h = y * 2 / b
  t = math.degrees(math.atan(h / b))
  res = 90 - t
else:
  r = a * b - y
  h = r * 2 / a
  res = math.degrees(math.atan(h / a))

print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> P;
#define MAX 11451
vector<P> G[MAX];
vector<int> E[MAX];
map<int,int> M[MAX];
int ans[MAX];
int idx;
int dfs(int v,int p){
  int res=0;
  E[v].resize(G[v].size());
  for(int i=0;i<(int)G[v].size();i++){
    P e=G[v][i];
    int u=e.first,c=e.second;
    if(u==p) continue;
    int tmp=dfs(u,v)+c;
    E[v][i]=tmp;
    M[v][tmp]++;
    res=max(res,tmp);
  }
  return res;
}
void dfs2(int v,int p,int d){
  int res=d;
  M[v][d]++;
  for(int i=0;i<(int)G[v].size();i++){
    P e=G[v][i];
    int u=e.first,c=e.second;
    if(u==p) continue;
    res=max(res,E[v][i]);
    M[v][E[v][i]]--;
    if(M[v][E[v][i]]==0)
      M[v].erase(M[v].find(E[v][i]));
    int tmp=(--M[v].end())->first;
    dfs2(u,v,tmp+c);
    M[v][E[v][i]]++;
  }
  ans[v]=res;
}
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n-1;i++){
    int s,t,w;
    //cin>>s>>t>>w;
    scanf("%d %d %d",&s,&t,&w);
    G[s].push_back(P(t,w));
    G[t].push_back(P(s,w));
  }
  dfs(0,-1);
  dfs2(0,-1,0);
  for(int i=0;i<n;i++) cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 7364
import java.util.*;
import java.math.*;
class Main {
	static Scanner sc = new Scanner(System.in);

	void solve() {
		try {
			int num = sc.nextInt();
			if (num == 1)
				System.out.println(0);
			else
				System.out.println(1);
		} catch (Exception e) {
			return;
		}
	}
	public static void main(String[] args) {
		Main ob = new Main();
		ob.solve();
	}
}

Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
#define N 16
#define ll long long
const ll mod=1e9+7;

int n,m,x,y;
int s[N][1<<N],ok[1<<N];
ll g[N][1<<N],f[1<<N],p[N];

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) {
		scanf("%d%d",&x,&y); x--; y--;
		s[x][1<<y]=1;
	}
	for (int i=0;i<n;i++)
		for (int j=0;j<(1<<n);j++) {
			int k=j&(-j);
			g[i][j]=g[i][j-k]+s[i][k];
		}
	for (int i=0;i<(1<<n);i++) if ((i&1)==((i&2)>>1)) ok[i]=1;
	p[0]=1; for (int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
	
	f[0]=1;
	for (int i=1;i<(1<<n);i++) if (ok[i]) {
		f[i]=1;
		for (int j=(i-1)&i;j;j=(j-1)&i) if (ok[j]) {
			ll tmp=f[i-j];
			for (int k=0;k<n;k++)
				if (j>>k&1) tmp=tmp*p[g[k][i-j]]%mod; else
				if ((i-j)>>k&1) tmp=tmp*(p[g[k][j]]-1+mod)%mod;
			f[i]=(f[i]+tmp)%mod;
		}
	}
	ll ans=1; for (int i=1;i<=m;i++) ans=ans*2%mod;
	printf("%lld\n",(ans-f[(1<<n)-1]+mod)%mod);
	return 0;
}

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

int main(void){
    string S;
    cin >> S;
    int lenS=S.size();

    long long ans=0;
    for(int i=0; i<pow(2,lenS-1); i++){
        string str="";
        for(int j=0; j<lenS-1; j++){
            str += S[j];
            if(i&(1<<(lenS-2-j))) str += '+';
        }
        str += S[lenS-1]; //strは与えられた数値のなかに＋が混ざった式になっている
        //cout << str << endl;
        // 式strを評価してansに加える
        int k=0;
        string tmp[lenS];
        for(int l=0; l<str.size(); l++){
            if(str[l]!='+') tmp[k]+=str[l];
            else k++;
        }
        for(int m=0; m<=k; m++) ans+=std::stoll(tmp[m]);
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int main(){

  int i,j;
  int num,u,k,v;
  int Matrix[N][N];

  

  scanf("%d",&num);

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      Matrix[i][j]=0;
    }
  }

  for(i=0;i<num;i++){
    scanf("%d",&u);
    scanf("%d",&k);
  
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      Matrix[u][v]=1;
    }
  }

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      if(j>0){
	printf(" ");
      }
      printf("%d",Matrix[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2052
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		for(int i = 1;; ++i){
			int x = sc.nextInt();
			if(x == 0) break;
			System.out.printf("Case %d: %d\n", i, x);
		}
	}
}



Measured memory_bytes: 60960
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < k; i++){
        vector<int> b(n,0);
        for(int j = 0; j < n; j++){
            b[max(j-a[j],0)]++;
            if(j+a[j]+1 < n) b[min(n-1,j+a[j]+1)]--;
        }
        int now = 0;
        for(int j = 0; j < n; j++){
            now += b[j];
            a[j] = now;
        }
        bool flag = true;
        for(int j = 0; j < n; j++){
            if(a[j] != n){
                flag = false;
                break;
            }
        }
        if(flag){
            for(int j = 0; j < n; j++){
                cout << n << " ";
            }
            return 0;
        }
    }
    for(int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 4932
//I solved it before. If I had enough time I wouldn't have submitted old codes.
//If you forbid I won't do this in the upcoming contests
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
#include <limits.h>
#include <bits/stdc++.h>
#define fw(x) freopen("x.txt","w",stdout)
#define For(i,a,b,c) for(int i = a;i < b;i+=c)
#define REP(i,n) for(int i = 0;i < n;++i)
#define REP1(i,n) for(int i = 1; i<=n;i++)
#define mem(a,s) memset(a,s,sizeof a)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define pf printf
#define sc scanf
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define vii vector<int>
#define vll vector<ll>
#define vss vector<string>
#define debug(x)  cout<<#x"="<<(x)<<endl
#define pb push_back


using namespace std;


// moves

//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/


//big_mod

//ll bigmod(ll a,ll b,ll m)
//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}
//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}
//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
string s, t;
int c[3001][3001];
int b[3001][3001];
void lcs(int i, int j){
    if(i<=0 || j<=0) return;
    if(b[i][j] != 0) return;
    if(s[i]==t[j]){
        lcs(i-1, j-1);
        c[i][j] = 1 + c[i-1][j-1];
        b[i][j] = 3;
    }
    else {
        lcs(i-1, j);
        lcs(i, j-1);
        if(c[i-1][j] > c[i][j-1]){
            c[i][j] = c[i-1][j];
            b[i][j] = 1;
        }
        else{
            c[i][j] = c[i][j-1];
            b[i][j] = 2;
        }
    }
}
int main()
{
    fast;
    cin>>s>>t;
    s = 'd' + s;
    t = 'x' + t;
    int sz1 = s.size()-1;
    int sz2 = t.size()-1;
    REP1(i, sz1) c[0][i] = 0;
    REP1(i, sz2) c[i][0] = 0;
    c[0][0] = 0;
    lcs(sz1, sz2);
    string ans = "";
    while(sz1>0&&sz2>0){
        if(b[sz1][sz2]==3){
            ans = s[sz1] + ans;
            sz1--;
            sz2--;
        }
        else if(b[sz1][sz2]==1){
            sz1--;
        }
        else sz2--;
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 74476
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    int sum = 0;

    for (int i = 0; i < 2 ; i++ ) {
      if(a > b) {
        sum += a;
        a--;
      } else if (b > a) {
        sum += b;
        b--;
      } else {
        sum += a;
        a--;
      }
    }

    System.out.println(sum);
  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template <typename T>
vector<T> dijkstra(Int s,vector<vector<pair<Int, T> > > & G){  
  const T INF = numeric_limits<T>::max();    
  using P = pair<T, Int>;
  Int n=G.size();
  vector<T> d(n,INF);
  vector<Int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      Int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
        d[u]=d[v]+c;
        b[u]=v;
        q.emplace(d[u],u);
      }
    }
  }
  return d;
}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  char s,t;
  cin>>h>>w>>s>>t;
  vector<string> st(h);
  for(Int i=0;i<h;i++){
    cin>>st[i];
    st[i]='.'+st[i]+'.';
  }
  
  st.emplace(st.begin(),string(w+2,'.'));
  st.emplace_back(string(w+2,'.'));

  h=st.size();w=st[0].size();
    
  using P = pair<Int, Int>;
  
  vector<vector<P> > G(26);

  Int dy[]={0,0,1,-1};
  Int dx[]={1,-1,0,0};
  char dc[]={'-','-','|','|'};
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(!isupper(st[i][j])) continue;
      //cout<<st[i][j]<<endl;
      for(Int k=0;k<4;k++){
        Int ni=i+dy[k]*2,nj=j+dx[k]*2;
        if(st[ni][nj]=='.') continue;
        if(st[ni][nj]=='o') continue;
        if(st[ni][nj]!=dc[k]) continue;
        while(!isupper(st[ni][nj])) ni+=dy[k],nj+=dx[k];
        G[st[i][j]-'A'].emplace_back(st[ni][nj]-'A',1);

        //cout<<st[i][j]<<" "<<st[ni][nj]<<endl;
      }            
    }        
  }
  
  cout<<dijkstra(s-'A',G)[t-'A']<<endl;
  return 0;
}



Measured memory_bytes: 3224
S = input()
ans = 0
while len(S)>=2:
    if S[0]==S[-1]:
        S = S[1:-1]
    elif S[0]=='x':
        ans += 1
        S = S[1:]
    elif S[-1]=='x':
        ans += 1
        S = S[:-1]
    else:
        ans = -1
        break
print(ans)

Measured memory_bytes: 9256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(ll i =(l);(i)<(r);(i)++)
using namespace std;
int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> alp(26,0);
    rep(i,0,n)alp[s[i]-'A']++;
    ll ans=alp['R'-'A']*alp['G'-'A']*alp['B'-'A'];
    rep(i,0,n-1){
        rep(j,i+1,n){
            ll k=2*j-i;
            if(k<n&&(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]))ans--;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  
  if (b-a+1>=2*k){
    rep(i,k) cout << a+i << endl;
    for (int i=k-1;i>=0;--i) cout << b-i << endl;
  }
  else {
    for (int i=a;i<=b;++i) cout << i << endl;
  }
}


Measured memory_bytes: 256
import sys

n = int(input())

numlist = []

for i in range(n):
  numlist.append(int(input()))

index = 0
count = 1
while numlist[index] != 2:
  if numlist[index] == -1:
    print(-1)
    sys.exit()

  numlist[index], index = -1, numlist[index] - 1
  count += 1

print(count)



Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else if(s == "ARC") cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int n;
  cin >> n;
  ll a[n];
  ll sum=0,esum=0,ans;
  rep(i,n){
     cin>>a[i];
     sum+=a[i];
     if(i%2)esum+=a[i]*2; 
  }
  ans=sum-esum;
  rep(i,n){
    cout<<ans<<" ";
    ans=(a[i]-ans/2)*2;
  }
  return 0;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}


int main(void){
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  REP(i, n) cin >> h[i];
  vector<int> a(m), b(m);
  REP(i, m){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<int> visit(n, -1);
  vector<bool> flag(n, true);
  REP(i, m){
    if (h[a[i]] < h[b[i]]) flag[a[i]] = false;
    else if (h[a[i]] == h[b[i]]){
      flag[a[i]] = false;
      flag[b[i]] = false;
    }
    else flag[b[i]] = false;
  }
  int ans = 0;
  REP(i, n){
    if (flag[i]) ans++;
  }
  cout << ans << endl;
  return 0;

}



Measured memory_bytes: 4844
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<vector<pair<int, bool>>> edge(n);
  vector<int> color(n, -1);
  rep(i, n-1){
  	int u, v, w;cin>>u>>v>>w;u--;v--;
    edge[u].push_back(make_pair(v, bool(w&1)));
    edge[v].push_back(make_pair(u, bool(w&1)));
  }
  queue<pair<int, bool>> que;
  que.push(make_pair(0, false));
  while(!que.empty()){
    pair<int, bool> v=que.front();que.pop();
    // cout<<v.first<<endl;
    color[v.first]=v.second;
    for(auto &e: edge[v.first]){
      if(color[e.first]!=-1)continue;
      que.push(make_pair(e.first, v.second^e.second));
    }
  }
  for(auto &e: color)cout<<e<<endl;
  return 0;
}


Measured memory_bytes: 6784
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        for(int i = 0; i < n; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            sum += r-l+1;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 24116
#include <stdio.h>

#define NUM 100000010

//int table[NUM]={};
//void sieve() {
//    table[0] = table[1] = 1;
//    int i,j;
//    for(i = 2; i*i < NUM; i++) {
//        for(j = i*2; j < NUM; j+=i) {
//            table[j] = 1;
//        }
//    }
//}難易度表

int check(int x) {
    int i;
    if(x<2)return 0;
    for(i = 2; i*i <= x; i++){
        if(x % i == 0)return 0;
    }
    return 1;
}

int main() {
    int n;
    scanf("%d",&n);

    int cou=0;
    int i;
    for(i=0;i<n;i++) {
        int x;
        scanf("%d",&x);
        if(check(x)) cou++;
    }

    printf("%d\n",cou);

    return 0;
}




Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
#define MOD1 1000000007
#define MOD2 1000000009
#define ll long long int
#define li long int
#define fi first
#define se second
#define ffl fflush(stdout);
#define all(x) (x).begin,(x).end()
#define whT int t; cin>>t; while(t--)
typedef pair<long long, long long> pi;
int main() 
{
	#ifndef ONLINE_JUDGE
	freopen("G:/coding/CPP/input.txt", "r", stdin);
	freopen("G:/coding/CPP/output.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	#endif
	int a;
	cin>>a;
	ll ans = (a)+(a*a)+(a*a*a);
	cout<<ans<<endl;

}


Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, AB: "List[[int, int]]"):
    AB = sorted(AB)
    ans = 0
    bought_drink = 0
    for ab in AB:
        if M - bought_drink > ab[1]:
            ans += ab[0] * ab[1]
            bought_drink += ab[1]
        else:
            ans += ab[0] * (M - bought_drink)
            bought_drink = M
            break
    print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, M = map(int, input().split())
    AB = []
    for n in range(N):
        AB.append(list(map(int, input().split())))
    solve(N, M, AB)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28648
#include<stdio.h>
int main(void)
{
	int  x, y;
	while (1)
	{
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)
			return 0;
		if (x > y)
		{
			printf("%d %d\n", y, x);
		}
		else
		{
			printf("%d %d\n", x, y);
		}
	}
	return 0;
}


Measured memory_bytes: 2036
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
string s;
ll MAX_VALUE = 500000;

int main() {
  cin >> s;
  ll n = s.length()+1;
  vector<ll> val(n);
  vector<int> pal(n);
  ll j = 0;
  ll c = 1;
  for(ll i = 0; i < n-2; i++){
    if(s[i] == s[i+1]){
      c++;
    }else{
      val[j] = c;
      if(s[i] == '<'){
        pal[j] = 1;
      }else{
        pal[j] = -1;
      }
      j++;
      c = 1;
    }
  }
  val[j] = c;
  if(s[n-2] == '<'){
    pal[j] = 1;
  }else{
    pal[j] = -1;
  }
  ll k = 0;
  ll sum = 0;
  for(ll k=0; k<n; k++){
    if(pal[k] != 0){
      //cout << val[k] << " " << pal[k] << endl;
      if(pal[k] == 1 && pal[k+1] == -1){
        if(val[k] >= val[k+1]){
          val[k+1] = val[k+1] -1;
        }else{
          val[k] = val[k] -1;
        }
      }
    }
  }
  for(ll kk = 0; kk<n; kk++){
    if(pal[kk] != 0){
      //cout << val[kk] << endl;
      sum += val[kk] * (val[kk] + 1)/2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int nax=1e5+5;
vector<int> g[100005];
int vis[100005];
int dist[100005];
int in[100005];
void dfs(int a){
	if(!vis[a]){
      	vis[a]=true;
    	for(int b:g[a]){
        	dist[b]=max(dist[b],dist[a]+1);
          	in[b]--;
          if(in[b]==0) dfs(b);
        }
    }
}

int main(){
	int n,m;
  	scanf("%d%d",&n,&m);
  	while(m--){
    int a,b;
  	scanf("%d%d",&a,&b);
    g[a].push_back(b);
    in[b]++;
    }
	for(int i = 1; i <= n; ++i) {
        if(!vis[i] && in[i] == 0) {
            dfs(i);
        }
    }
    int answer = 0;
    for(int i = 1; i <= n; ++i) {
        answer = max(answer, dist[i]);
    }
    printf("%d\n", answer);      
}

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

using namespace std;
typedef long long ll;

const int N = 500000, C = 30;
int bit[C][N], n, q;
char s[N];

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

ll sum(int c, int x) {
    ll sum = 0;
    for (; x > 0; x -= x & -x)
        sum += bit[c][x];
    return sum;
}

int main() {
    scanf("%d", &n);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) add(s[i] - 'a', i, 1);
    scanf("%d", &q);
    int t, i, l, r;
    char c;
    while (q--) {
        scanf("%d", &t);
        if (t == 1) {
            scanf("%d %c", &i, &c);
            if (s[i] == c) continue;
            add(s[i] - 'a', i, -1);
            s[i] = c;
            add(s[i] - 'a', i, 1);
        } else {
            scanf("%d%d", &l, &r);
            int ans = 0;
            for (int j = 0; j < C; j++) {
                if (sum(j, r) - sum(j, l - 1)) ans++;
            }
            printf("%d\n", ans);
        }
    }
}


Measured memory_bytes: 55096
N = input()
list_X =  list(map(float,input().split()))

mean_dai = int(sum(list_X)/len(list_X)//1 +1)
mean_syo = int(sum(list_X)/len(list_X)//1)

l_dai = [(list_X[i] - mean_dai)**2 for i in range(len(list_X)) ]
l_syo = [(list_X[i] - mean_syo)**2 for i in range(len(list_X)) ]

ans = int(min(sum(l_dai),sum(l_syo)))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    long long cnt = 0;
    for (long long x = 1; x <= N; ++x) {
        long long Y = floor<int>(N / x);
        cnt += x * (Y + 1) * Y / 2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;
 
int main(){
 
    int r, g, b;

    cin >> r >> g >> b;

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

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

const int N = 100005;

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

int used[N];

int main() {
  scanf("%d", &n);
  
  long long sumA = 0, sumB = 0;
  for (int i=0; i<n; i++) {
    scanf("%d %d", a + i, b + i);
    
    sumA += a[i];
    sumB += b[i];
  }
  
  long long ans = min(sumA, sumB);
  
  vector<pair<long long, int>> v;
  for (int i=0; i<n; i++) {
    v.push_back({a[i], i});
    v.push_back({b[i], i});
  }
  sort(v.begin(), v.end());
  
  long long mini = 0;
  for (int i=0; i<n; i++) {
    ++used[v[i].second];
    mini += v[i].first;
  }
  
  for (int i=0; i<n; i++) {
    if (used[i] == 0) ans = min(ans, mini);
    else if (used[i] == 1) {
      if (v[n].second == i) ans = min(ans, mini - min(a[i], b[i]) + v[n+1].first);
      else ans = min(ans, mini - min(a[i], b[i]) + v[n].first);
    } else {
      ans = min(ans, mini - a[i] - b[i] + v[n].first + v[n+1].first);
    }
  }
  
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 7280
#include <iostream>
#include <list>
#include <stack>
#include <limits.h>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <memory>
#include <regex>
#include <functional>
using namespace std;

int input[7][7];
int main() {
    int sum = 0;
    for (size_t i = 0; i < 3; i++)
    {
        for (size_t j = 0; j < 3; j++)
        {
            cin >> input[i][j];
            sum += input[i][j];
        }
    }
    // consider a1 = 0 since we are just want to vaidate
    int a1 = 0;
    int b1 = input[0][0];
    int b2 = input[0][1];
    int b3 = input[0][2];
    int a2 = input[1][0] - b1;
    int a3 = input[2][0] - b1;

    if (input[1][1] != a2 + b2 || input[1][2] != a2 + b3 || input[2][1] != a3 + b2 || input[2][2] != a3 + b3)
    {
        cout << "No" << endl;
        return 0;
    }   
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define LLINF (1<<30)
#define MOD 1000000007
# define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int n, i;
    cin >> n >> i;
    cout << n - i + 1;
    return 0;
}


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

using namespace std;

int main()
{
	int n, m, min, count = 0;
	scanf("%d", &n);
	
	vector<int> v;
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		v.push_back(m);
	}
	
	for(int i = 0; i < v.size()-1; i++)
	{
		min = i;
		
		for(int j = i; j <= v.size()-1; j++)
			if(v[j] < v[min])
				min = j;
		if(v[min] < v[i])
		{
			swap(v[i], v[min]);
			count++;
		}
	}
	
	int i;
	
	for(i = 0; i < v.size()-1; i++)
		printf("%d ", v[i]);
	printf("%d\n%d\n", v[i], count);
	
	return 0;
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main()
{ FAST
    ll n, b, r; cin >> n >> b >> r;
    ll ans = (n/(b+r))*b + min(b, n%(b + r));
    cout << ans << endl;
    return 0;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


void solve(){
    int H, A;
    cin >> H >> A;
    cout << (H+A-1)/A << endl;
}

signed main(){
    cout << fixed << setprecision(18) << endl;
    cerr << fixed << setprecision(18) << endl;
    solve();
}


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

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

  // ここにプログラムを追記
  for(int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if(S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if(i + 1 == N){
      cout << "Three" << endl;
      break;
    }
    else{
    }
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MAX(type)   std::numeric_limits<type>::max()
#define MIN(type) std::numeric_limits<type>::min()
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
ll inf = 1e18;
ll dp[100090];
vector<ll> v[100090];
ll dfs(ll curr){
	ll &ref = dp[curr];
	if(ref!=-1){
		return ref;
	}
	ref = 0;
	ll mx = 0;
	for(auto x:v[curr]){
		//cout<<"\n"<<curr<<"call "<<x;
		mx = max(mx,dfs(x)+1);
	}
	//cout<<"\nc"<<curr<<" "<<mx<<endl; 
	return ref=mx;
}
int main(){
	fast;
	memset(dp,-1,sizeof(dp));
	ll ver,e;cin>>ver>>e;
	map<ll,ll> id;
	for(ll i=0;i<e;++i){
		ll x,y;cin>>x>>y;
		v[x].push_back(y);
		++id[y];
		id[x] = id[x]==0?-1:id[x];
	}
	ll mx = MIN(ll);
	for(auto x:id){
		if(x.second==-1){
			//cout<<"_"<<x.first<<"_\n";
			mx = max(mx,dfs(x.first));
		}
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 17408
n,m = map(int,input().split())
MAX = 10 ** 5
MIN = 0
for i in range(m):
    l,r = map(int,input().split())
    if MAX >= r:
        MAX = r
    if MIN <= l:
        MIN = l
ans = MAX - MIN + 1
if ans >= 0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N;
  string S;
  cin >> N >> S;
  priority_queue<int> ans;
  for (int i = 1; i <= N-1; i++) {
    int count = 0;
    for (int f = 'a'; f <= 'z'; f++) {
      bool check_l = false;
      bool check_r = false;
      for (int j = 0; j < i; j++) {
        if (S[j] == f) {
          check_l = true;
        }
      }
      for (int j = i; j < N; j++) {
        if (S[j] == f) {
          check_r = true;
        }
      }
      if (check_l && check_r) {
        count++;
      }
    }
    ans.push(count);
  }
  cout << ans.top() << endl;
}


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

#define N 1000010
#define Mod 998244353

int fac[N],inv[N];

int C(int n,int m){return 1LL*fac[n]*inv[m]%Mod*inv[n-m]%Mod;}

int Power(int b,int p){
	int res=1;
	for(;p;p>>=1,b=1LL*b*b%Mod)
		if(p&1)
			res=1LL*res*b%Mod;
	return res;
}

int Inv(int x){return Power(x,Mod-2);}

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if(n<m)
		std::swap(n,m);
	for(int i=*fac=1;i<=n+m;i++)
		fac[i]=1LL*fac[i-1]*i%Mod;
	inv[n+m]=Power(fac[n+m],Mod-2);
	for(int i=n+m-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(i+1)%Mod;
	int ans=0;
	for(int i=1;i<=m;i++)
		ans=(ans+1LL*C(i+i,i)*C(n+m-i-i,n-i)%Mod)%Mod;
	ans=1LL*ans*Inv(2)%Mod*Inv(C(n+m,n))%Mod;
	ans=(ans+n)%Mod;
	printf("%d\n",ans);
}


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

using namespace std;
#define int long long
const int INF = 200000000007;


 
signed main(){
    string s;
    cin>>s;
    if(s[0]==s[1]){
        if(s[0]!=s[2]&&s[2]==s[3])cout<<"Yes";
        else cout<<"No";
    }else{
        if((s[0]==s[2]&&s[1]==s[3])||(s[0]==s[3]&&s[1]==s[2]))cout<<"Yes";
        else cout<<"No";
        }
    
  
    
    return 0;
}

Measured memory_bytes: 256