akhauriyash/Code-Regression huggingface dataset:
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int tab[10005];
	for(int i = 0; i < 3; i++){
		cin >> tab[i];
	}
	
	sort(tab, tab+3);
	reverse(tab, tab+3);
	
	cout << tab[0] * 10 + tab[1] + tab[2] << endl;
	
	
	
	
	
	
	
						
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>();

    for (i, ch) in s.chars().enumerate() {
        if i % 2 == 0 && ch == 'L' {
            println!("No");
            return;
        }
        if i % 2 == 1 && ch == 'R' {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2092
#include<iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

// u に隣接する v を番号順に取得
int next(int u) {
  for ( int v = nt[u]; v < n; v++ ) {
    nt[u] = v + 1;
    if ( M[u][v] ) return v;
  }
  return -1;
}

// スタックを用いた深さ優先探索
void dfs_visit(int r) {
  for ( int i = 0; i < n; i++ ) nt[i] = 0;

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while ( !S.empty() ) {
    int u = S.top();
    int v = next(u);
    if ( v != -1 ) {
      if ( color[v] == WHITE ) {
        color[v] = GRAY;
        d[v] = ++tt;
        S.push(v);
      }
    } else {
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs() {
  // 初期化
  for ( int i = 0; i < n; i++ ) {
    color[i] = WHITE;
    nt[i] = 0;
  }
  tt = 0;

  // 未訪問の u を始点として深さ優先探索
  for ( int u = 0; u < n; u++ )
    if ( color[u] == WHITE ) dfs_visit(u);
  for ( int i = 0; i < n; i++ )
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
}

int main() {
  int u,  k, v;

  cin >> n;
  for ( int i = 0; i < n; i++ )
    for ( int j = 0; j < n; j++ ) M[i][j] = 0;

  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    u--;
    for ( int j = 0; j < k; j++ ) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 3120
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    vector<vector<int>> tree;
    vector<vector<ll>> dp;


    void input() {
        cin >> N;
        tree.resize(N);
        dp.resize(N, vector<ll>(2, -1));
        rep(i, 0, N - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            tree[a].push_back(b);
            tree[b].push_back(a);
        }

    }

    ll rec(int v, int c, int p = -1) {
        if (dp[v][c] != -1) return dp[v][c];
        if (tree[v].size() == 0 || (tree[v].size() == 1 && tree[v][0] == p)) {
            return dp[v][c] = 1ll;
        }
        if (c == 0) {
            //白黒試す
            ll ret = 1ll;
            for (auto nv : tree[v]) {
                if (nv == p) continue;
                //黒く塗る場合
                ll black = rec(nv, 1, v);
                //白く塗る場合
                ll white = rec(nv, 0, v);
                ret *= (black + white);
                ret %= MOD;
            }
            return dp[v][c] = ret;
        } else {
            //白くしか濡れない
            ll ret = 1ll;
            for (auto nv : tree[v]) {
                if (nv == p) continue;
                //白く塗る場合
                ll white = rec(nv, 0, v);
                ret *= white;
                ret %= MOD;
            }
            return dp[v][c] = ret;
        }
    }

    void solve() {
        input();

        ll tmp1 = rec(0, 0);
        ll tmp2 = rec(0, 1);
        ll ans = (tmp1 + tmp2) % MOD;

        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 19584
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
 
pub trait InputValue {
    fn parse(s: &str) -> Self;
}
 
pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}
 
pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}
 
pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}
 
macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, u32, u64, usize, String);
 
macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);
 
// ===
 
fn main() {
    let s: String = read();
    let c: Vec<u8> = s.into_bytes();
    let mut ans: u64 = 0;
    let mut black: u64 = 0;
    for ci in c {
        if ci == b'W' {
            ans += black;
        } else {
            black += 1;
        }
    }
    println!("{}", ans);
}

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

typedef long long ll;

const ll LLINF = 4e18;
const int INF = 1e9;
const ll SHIFT = 2.01e9;

const int MAXK = 1010;
int K;

const int MAXN = 2 * MAXK;
int N, M;
int S, T;

struct edge {
	int nxt, rev, cap; ll dist;
	edge() {}
	edge(int nxt_, int rev_, int cap_, ll dist_) : nxt(nxt_), rev(rev_), cap(cap_), dist(dist_) { }
};

vector<edge> adj[MAXN];

void add_edge(int a, int b, int c, ll d) {
	assert(d >= 0);
	adj[a].push_back(edge(b, int(adj[b].size()), c, d));
	adj[b].push_back(edge(a, int(adj[a].size()) - 1, 0, -d));
}

bool vis[MAXN];
ll dist[MAXN];
int ptr[MAXN];

bool reach() {
	vector<int> q;
	q.push_back(S);
	fill_n(dist, N, LLINF);
	fill_n(vis, N, false);
	dist[S] = 0;
	for (size_t i = 0; i < q.size(); i++) {
		int cur = q[i]; vis[cur] = false;
		for (size_t j = 0; j < adj[cur].size(); j++) {
			edge& e = adj[cur][j];
			if (!e.cap || dist[e.nxt] <= dist[cur] + e.dist) {
				continue;
			}
			dist[e.nxt] = dist[cur] + e.dist;
			if (!vis[e.nxt]) {
				vis[e.nxt] = true;
				q.push_back(e.nxt);
			}
		}
	}
	return dist[T] != LLINF;
}

int dfs(int cur, int rem) {
	if (cur == T) {
		return rem;
	}
	int tot = 0;
	vis[cur] = true;
	for (int& i = ptr[cur]; i < int(adj[cur].size()); i++) {
		edge& e = adj[cur][i];
		if (!e.cap || vis[e.nxt] || dist[e.nxt] != dist[cur] + e.dist) {
			continue;
		}
		ll d = dfs(e.nxt, min(rem - tot, e.cap));
		tot += d;
		e.cap -= d;
		adj[e.nxt][e.rev].cap += d;
		if (tot == rem) {
			vis[cur] = false;
			break;
		}
	}
	return tot;
}

ll mcf(int rem = INF) {
	int totflow = 0; ll totcost = 0;
	while (reach()) {
		fill_n(ptr, N, 0);
		int d = dfs(S, rem - totflow);
		totflow += d;
		totcost += d * dist[T];
	}
	assert(totflow == rem);
	return totcost;
}

int main() {
	scanf("%d", &K);
	S = 0, T = 1;
	N = 2 * K + 6;
	int tot = 0;
	for (int i = 0; i < K; i++) {
		ll x, y; int c; scanf("%lld %lld %d", &x, &y, &c);
		tot += c;
		add_edge(S, 6+i, c, 0);
		add_edge(6+i, 2, INF, -(x + y) + SHIFT);
		add_edge(6+i, 3, INF, -(x - y) + SHIFT);
		add_edge(6+i, 4, INF, -(-x + y) + SHIFT);
		add_edge(6+i, 5, INF, -(-x - y) + SHIFT);
	}
	for (int i = 0; i < K; i++) {
		ll x, y; int c; scanf("%lld %lld %d", &x, &y, &c);
		add_edge(6+K+i, T, c, 0);
		add_edge(2, 6+K+i, INF, -(-x - y) + SHIFT);
		add_edge(3, 6+K+i, INF, -(-x + y) + SHIFT);
		add_edge(4, 6+K+i, INF, -(x - y) + SHIFT);
		add_edge(5, 6+K+i, INF, -(x + y) + SHIFT);
	}

	cerr << "tot = " << tot << endl;

	ll ans = -mcf(tot) + 2 * tot * SHIFT;
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  long make, count = 0, a, b, three, five, seven, zero, flag;
  for(long i = 0; i < pow(4, 10); i++) {
    a = i;
    make = 0;
    three = 0, five = 0, seven = 0, zero = 0, flag = 0;
    for(long j = 0; j < 10; j++) {
      b = a % 4;
      a /= 4;
      if(b == 1) {
        if(zero != 0) flag = 1;
        make += 3 * pow(10, j);
        three++;
      } else if(b == 2) {
        if(zero != 0) flag = 1;
        make += 5 * pow(10, j);
        five++;
      } else if(b == 3) {
        if(zero != 0) flag = 1;
        make += 7 * pow(10, j);
        seven++;
      } else zero++;
      if(flag == 1)break;
    }
    if(flag == 1)continue;
    if(make > N) break;
    else if(three >= 1 && five >= 1 && seven >= 1) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N;
  string s[N];
  for (int i=0; i < N; i++){
    cin >> s[i];
  }  
  cin >> M;
  string t[M];
  for (int i=0; i < M; i++){
    cin >> t[i];
  }
  int max = -M;
  string str;
  for (int i=0; i < N; i++){
    str = s[i];
    int cnt = 0;
    for (int i=0; i < N; i++){
      if (str == s[i]) cnt++;
    }
    for (int i=0; i < M; i++){
      if (str == t[i]) cnt--;
    }
    if (cnt > max) max = cnt; 
  }
  if (max < 0) max = 0;
  cout << max << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (ans * 2 >= ans + k) {
			ans = ans + k;
		}
		else {
			ans = ans * 2;
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N+1];
        int[] C = new int[N];
        int count = 0;
        for (int i = 0; i < N; i++) A[i] = sc.nextInt();
        for (int i = 1; i <= N; i++) B[i] = sc.nextInt();
        for (int i = 1; i < N; i++) C[i] = sc.nextInt();
        
        for (int i = 0; i < N-1; i++) {
            count += B[A[i]];
            if (A[i+1] == A[i]+1) count += C[A[i]];
        }

        count += B[A[N-1]];
        System.out.println(count);
    }
}


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

int main()
{
    std::string s,t;
    std::cin>>s>>t;
    int n = s.size(),m = t.size();
    std::vector<std::vector<std::pair<int,int>>> dp(n+1,std::vector<std::pair<int,int>>(m+1)); //dp[i][j] sのi文字目までとtのj文字目までを使ってできる最長 / 0n方向: 1左下: 2m左方向
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1] != t[j-1]){
                if(dp[i-1][j].first >= dp[i][j-1].first){
                    dp[i][j].first = dp[i-1][j].first;
                    dp[i][j].second = 0;
                }else{
                    dp[i][j].first = dp[i][j-1].first;
                    dp[i][j].second = 2;
                }
            }else{
                dp[i][j].first = dp[i-1][j-1].first + 1;
                dp[i][j].second = 1;
            }
        }
    }
    std::pair<int,int> cur = {n,m};
    std::string ans;
    while(cur.first != 0 && cur.second != 0){
        if(dp[cur.first][cur.second].second == 1){
            cur.first--;
            cur.second--;
            ans.push_back(s[cur.first]);
        }else if(dp[cur.first][cur.second].second == 0){
            cur.first--;
        }else{
            cur.second--;
        }
    }
    std::reverse(ans.begin(),ans.end());
    std::cout<<ans<<std::endl;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  string T = "RGBRG";
  long ans = 0;
  for (int i = 0; i < N; i++) {
    int t = T.find(S.at(i));
    char a = T.at(t + 1);
    char b = T.at(t + 2);
    string s1 = S.substr(0, i);
    string s2 = S.substr(i + 1);
    int a1 = count(s1.begin(), s1.end(), a);
    int a2 = count(s2.begin(), s2.end(), a);
    int b1 = count(s1.begin(), s1.end(), b);
    int b2 = count(s2.begin(), s2.end(), b);
    reverse(s1.begin(), s1.end());
    int mi = min(s1.size(), s2.size());
    int ng = 0;
    for (int j = 0; j < mi; j++) {
      if (s1.at(j) == a && s2.at(j) == b || s1.at(j) == b && s2.at(j) == a) ng++;
    }
    ans += a1 * b2 + a2 * b1 - ng;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3636
S = input()
res = [0]*(len(S)+1)

# 左から探索
for i in range(len(S)):
  if S[i]=='<':
    res[i+1]=res[i]+1
    
for i in range(len(S)-1,-1,-1):
  if S[i]=='>':
    res[i]=max(res[i],res[i+1]+1)
    
print(sum(res))

Measured memory_bytes: 23336
#include<bits/stdc++.h>
#define basic using namespace std; int main()
basic{
	int n;
	string s;
	ios::sync_with_stdio(0);
	cin>>n>>s;
	for(int i=0;i<s.size();i++){
		s[i]+=n;
		if(s[i]>'Z') s[i]-=26; 
	}
	cout<<s<<"\n";
	return 0;
} 

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

int main(){
  int N;
  int l[1100];
  int r[1100];
  int x;
  cin >> N;
  for (int i=0; i<N; ++i){
  cin >>l[i] >>r[i];  
  }
  for (int i=0; i<N; ++i){
    x+= r[i]-l[i]+1;
      }
  cout << x<<endl;
}


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


def main():
    h, w, m = map(int, input().split())
    horizontal_counts = [0] * h
    vertical_counts = [0] * w
    bombs = set()
    for _ in range(m):
        y, x = map(int, input().split())
        y -= 1
        x -= 1
        vertical_counts[x] += 1
        horizontal_counts[y] += 1
        bombs.add((y, x))

    y_max = max(horizontal_counts)
    x_max = max(vertical_counts)
    y_candidates = [y for y, count in enumerate(horizontal_counts) if count == y_max]
    x_candidates = [x for x, count in enumerate(vertical_counts) if count == x_max]

    for y in y_candidates:
        for x in x_candidates:
            if (y, x) in bombs:
                continue
            else:
                print(y_max + x_max)
                return
    print(y_max + x_max - 1)
    return


if __name__ == "__main__":
    main()


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

int main() {
	// Get total number of subordinates provided
  	int n;
  	cin >> n;
  
  	// Store all subordinates in an array
  	int subordinates[n-1];
  	for(int i=0; i<n-1; i++){
    	cin >> subordinates[i];
    }
  
  	// Calculate no. of subordinate for each numbered boss
  	int bosses[n+1];	// we are not using index 0, hence n+1 instesad of n
  	memset(bosses, 0, sizeof(bosses));	// placing 0 at each position
  	for(int i=0; i<n-1; i++){	// iterating subordinates, hence n-1
    	bosses[subordinates[i]]++;
    }
  
  	// print subordinates at each boss-position from 1 to n
  	for(int i=1; i<n+1; i++){
    	cout << bosses[i] << "\n";
    }
  
  	return 0;
}

Measured memory_bytes: 5124
n = int(input())
renzoku = 0
for i in range(n):
	d = [int(each) for each in input().split()]
	if d[0] == d[1]:
		renzoku += 1
		if renzoku == 3:
			print('Yes')
			break
	else:
		renzoku = 0
else:
	print('No')

Measured memory_bytes: 9172
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#define PI 3.14159265358
using namespace std;
typedef long long ll;
typedef pair<double,double>P;
queue<P>S;
P s,t;
int N;
int main()
{
    scanf("%d",&N);
    S.push(make_pair(0,0));
    S.push(make_pair(100.0,0));
    for(;N--;)
    {
        s=S.front();S.pop();
        queue<P>T;
        do
        {
            t=S.front();S.pop();
            P s1=make_pair(s.first+(t.first-s.first)/3,s.second+(t.second-s.second)/3);
            P s2=make_pair(s.first+(t.first-s.first)/3*2,s.second+(t.second-s.second)/3*2);
             
            T.push(s);
            T.push(s1);
             
            T.push(make_pair(s1.first+(s2.first-s1.first)*cos(PI/3.0)-(s2.second-s1.second)*sin(PI/3.0),
                            s1.second+(s2.first-s1.first)*sin(PI/3.0)+(s2.second-s1.second)*cos(PI/3.0)));
            T.push(s2);
            s=t;
        }while(!S.empty());
        T.push(t);
        S=T;
    }
    for(;!S.empty();)
    {
        printf("%lf %lf\n",S.front().first,S.front().second);
        S.pop();
    }
    return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    vl b(n);rep(i,n)cin>>b[i];
    vl c(n);rep(i,n)cin>>c[i];
    sort(all(a));
    sort(all(c));
    ll ans=0;
    rep(i,n){
        ll canA=lower_bound(all(a),b[i])-a.begin();
        ll canC=c.end()-upper_bound(all(c),b[i]);
        ans+=canA*canC;
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 2560
s = input()
K =input()

list1=[]
for i in range(len(s)):
    if s[0:i].count(s[i])==0:
        list1.append(s[i])
        i +=1
    else:
        i+=1

i=0
for i in range(len(s)):
    if s[i:i+2] not in list1:
        list1.append(s[i:i+2])
    else:
        i+=1
i=0
for i in range(len(s)):
    if s[i:i+3] not in list1:
        list1.append(s[i:i+3])
    else:
        i+=1
i=0
for i in range(len(s)):
    if s[i:i+4] not in list1:
        list1.append(s[i:i+4])
    else:
        i+=1
i=0
for i in range(len(s)):
    if s[i:i+5] not in list1:
        list1.append(s[i:i+5])
    else:
        i+=1

list1=sorted(list1)
print(list1[int(K)-1])

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

int main() {
char c;
  cin >> c ;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int t,n,i,j,k,l;
    cin>>n;
    int dp[n+1];
    for(i=1;i<=n;i++) dp[i]=1;
    for(i=2;i<=n;i++)
    {
        for(j=i;j<=n;j+=i)
         dp[j]++;
    }
    l=0;
    for(i=1;i<n;i++)
    {
        l+=dp[i];
    }
    cout<<l;
}

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

int main(){
    string s1, s2;
    cin >> s1 >> s2;
    int x=0;
    rep(i, 3){
       if (s1[i]==s2[i]){
         x++;
       }
    }
    cout << x << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    int i;
 
    char m;

    string s, t;

    
    cin >> s;


    for( i = 0 ; i < s.size() ; i = i + 1 ){

         m = s.at(i);

         if( m != 'B' ) t.push_back(m);

         else if( m == 'B' && !t.empty() ) t.pop_back();

         }


    cout << t << endl;


    return 0;

}

Measured memory_bytes: 256
s = input()
alpha = [0, 0, 0]
for i in range(len(s)):
    if s[i] == 'a':
        alpha[0] += 1
    elif s[i] == 'b':
        alpha[1] += 1
    else:
        alpha[2] += 1
flag = 0
for i in range(3):
    if alpha[i] != 1:
        flag = 1
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod=1e7+7;
const int maxi=10000000;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r;cin>>r;
    cout<<3.14159*2*r<<endl;
    return 0;
}


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

string f(int v, int n){
  string ans = "";
  for (int i = 0; 0 < v; i++)
  {
    ans += to_string(v % n);
    v = v / n;
  }
  reverse(ans.begin(),ans.end());
  return ans;
}

int main() {

  int N, K;
  cin >> N >> K;

  string answer = f(N, K); 

  cout << answer.size() << endl;

  return 0;

}

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

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


void solve() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	int n = a + b + c;
	vector<pair<int, int>> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i].first;
		int t = 3;
		if (i < a) t = 1;
		else if (i < a + b) t = 2;
		v[i].second = t;
	}

	sort(range(v), greater<pair<int, int>>());

	int rCnt = 0, gCnt = 0, tCnt = 0;
	int tot = 0;
	for (int i = 0; i < n; i++) {
		if (rCnt + gCnt + tCnt == x + y) break;
		int val = v[i].first;
		int c = v[i].second;
		if (c == 1 and rCnt == x) continue;
		if (c == 2 and gCnt == y) continue;

		tot += val;
		if (c == 1) rCnt++;
		else if (c == 2) gCnt++;
		else tCnt++;
	}

	cout << tot << endl;

}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

Measured memory_bytes: 7956
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int t = 1e9+7;
int a[10000],cnt[10000];
main(){
    int n,k;cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i<j&&a[i]>a[j])
                ans++;
            if(a[j]<a[i])
                cnt[i]++;
        }
    }
    //cout<<ans<<endl;
    ans*=k;
    ans%=t;
    for(int i=1;i<=n;i++){
        int c=cnt[i];
        // (k-1)*cnt[i], (k-2)*cnt[i];
        int tt=(k*(k-1)/2)%t;
        ans+=(c*tt)%t;
        ans%=t;
    }
    cout<<ans;
}


Measured memory_bytes: 256
N = int(input())
XYH = [tuple(map(int,input().split())) for i in range(N)]

cands = []
for cx in range(101):
    for cy in range(101):
        ch = None
        for x,y,h in XYH:
            if h==0: continue
            d = abs(cx-x) + abs(cy-y)
            if ch is None:
                ch = h + d
            else:
                if h + d != ch:
                    break
        else:
            cands.append((cx,cy,ch))

for cx,cy,ch in cands:
    for x,y,h in XYH:
        d = abs(cx-x) + abs(cy-y)
        if h != max(ch - d, 0):
            break
    else:
        print(cx,cy,ch)
        exit()

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()
 
//vector<vector<ll>> G(N,vector<ll>(0));
void no_cost_graphmake(ll E,vector<set<ll>> &G){
  rep(i,E){
    ll a,b;
    cin >> a >> b;
    G.at(a-1).insert(b-1);
  }
}

int main(){
  ll N;
  cin >> N;
  vector<ll> S((ll)pow(2,N));
  rep(i,(ll)pow(2,N)) cin >> S.at(i);
  sort(all(S));
  vector<ll> s;
  rep(i,(ll)pow(2,N)){
    ll k=1,x=S.at((ll)pow(2,N)-1-i);
    while(k+i<(ll)pow(2,N)&&x==S.at((ll)pow(2,N)-1-i-k)){
      k++;
    }
    i+=k-1;
    s.push_back(k);
  }
  vector<vector<ll>> x((ll)s.size()+1,vector<ll>(N+1,0));
  x.at(0).at(N)=1;
  rep(i,(ll)s.size()){
    ll t=0;
    rep(j,N+1){
      t+=x.at(i).at(j);
    }
    if(s.at(i)>t){
      cout << "No" << endl;
      return 0;
    }
    ll y=N;
    rep(j,s.at(i)){
      while(x.at(i).at(y)==0){
        y--;
      }
      x.at(i).at(y)--;
      rep(k,y){
        x.at(i+1).at(k)++;
      }
    }
    rep(j,N){
      x.at(i+1).at(j)+=x.at(i).at(j);
    }
  }
  cout << "Yes" << endl;
  
}

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

using namespace std;

template <class T> inline bool chmin(T &a, T b) { /* {{{ */
  if (a > b) {
    a = b;
    return true;
  }
  return false;
} /* }}} */

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i > 0) A[i] += A[i - 1];
  }
  long long ans = 1e15;
  for (int i = 0; i < N - 1; i++) {
    chmin(ans, abs(A[i] - (A[N - 1] - A[i])));
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INFL (1LL<<60)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



class UnionFind{
	vector<int> par;
	vector<int> rank;
public:
	UnionFind(int max_n) :par(max_n), rank(max_n){}
	void init(int n){
		for (int i = 0; i<n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x){
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if (x==y)return;
		if (rank[x]<rank[y]){
			par[x] = y;
		}
		else{
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
};


long long dist[300][300];
int a[300][300];

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

	int n;
	cin>>n;
	UnionFind uf(n);
	uf.init(n);
	vector<tuple<int,int,int>> v;
	rep(i,n){
		rep(j,n){
			dist[i][j] = INFL;
			cin>>a[i][j];

			if (i<j)v.emplace_back(a[i][j],i,j);
		}
	}
	rep(i, n)dist[i][i]=0;
	long long ans=0;
	sort(all(v));
	for (auto t:v){
		int c,u,v;
		tie(c,u,v) = t;
		if (!uf.same(u,v) || c < dist[u][v]){
			uf.unite(u,v);
			ans+=c;
			dist[u][v] = dist[v][u]=c;
			rep(i,n)rep(j,n){
				dist[i][j] = dist[j][i] 
					= min(dist[i][j],dist[i][u]+c+dist[v][j]);
			}
		}
	}
	rep(i,n){
		rep(j,n){
			if (a[i][j] != dist[i][j]){
				ans = -1;
				break;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 2040
#include<stdio.h>
int main() {
	int a, b;;
	scanf("%d %d",&a,&b);
	if (a >= 1 && b >= 1 && a + b <= 16) {
		if (a <= 8 && b <= 8) {
			printf("Yay!\n");
		}
		else {
			printf(":(\n");
		}
	}
	else {
		printf(":(\n");
	}

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(m, 0);
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    while (k--) {
      int a;
      cin >> a;
      ++vec[a-1];
    }
  }

  int ans = 0;
  for (auto &v : vec)
    ans += v == n;

  cout << ans << endl;
}


Measured memory_bytes: 3548
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=2000;
int n,k;
vector<int> lnk[N+5];
vector< pair<int,int> > edg;
void DFS(int u,int pre,int dep,int &del_tot) {
	if(dep>k/2) del_tot++;
	for(int i=0; i<lnk[u].size(); i++) {
		int v=lnk[u][i];
		if(v==pre) continue;
		DFS(v,u,dep+1,del_tot);
	}
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1; i<n; i++) {
		int u,v;
		scanf("%d%d",&u,&v);
		lnk[u].push_back(v);
		lnk[v].push_back(u);
		edg.push_back(make_pair(u,v));
	}
	int ans=(1<<30);
	if(k%2) {
		k--;
		for(int i=0; i<edg.size(); i++) {
			int u=edg[i].first,v=edg[i].second;
			int resu=0,resv=0;
			DFS(u,v,0,resu);
			DFS(v,u,0,resv);
			ans=min(ans,resu+resv);
		}
	} else {
		for(int i=1; i<=n; i++) {
			int res=0;
			DFS(i,0,0,res);
			ans=min(ans,res);
		}
	}
	printf("%d\n",ans);
	return 0;
}
/*
6 3
1 2
2 3
2 4
1 5
5 6
*/

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

int main(void){
    int n;
    cin >> n;
    
    int a[4][14] = {{0}};
    char suit;
    
    int r;
    
    while(!cin.eof()){
        cin >> suit >> r;
        switch(suit){
            case 'S': a[0][r] = 1; break;
            case 'H': a[1][r] = 1; break;
            case 'C': a[2][r] = 1; break;
            case 'D': a[3][r] = 1; break;
            default: break;
        }
    }
    int i;
    for(i = 1; i <= 13; i++)
        if(!a[0][i]) cout << "S " << i << endl;
        
    for(i = 1; i <= 13; i++)
        if(!a[1][i]) cout << "H " << i << endl;
        
    for(i = 1; i <= 13; i++)
        if(!a[2][i]) cout << "C " << i << endl;
        
    for(i = 1; i <= 13; i++)
        if(!a[3][i]) cout << "D " << i << endl;

    return 0;
    
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(x);
    LL ans = x / 500 * 1000 + x % 500 / 5 * 5;
    co(ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

#define NUM_DIVISOR 75

vector<int> getPrime(int n)
{
	if(n < 2)
		return vector<int>();

	vector<bool> v(n+1, false);
	v[2] = true;
	for(int i=3; i<=n; i+=2)
		v[i] = true;

	for(int i=2; i*i<=n; i++){
		if(v[i] == false)
			continue;

		for(int j=2*i; j<=n; j+=i)
			v[j] = false;
	}

	vector<int> prime;
	for(int i=2; i<=n; i++)
		if(v[i] == true)
			prime.push_back(i);

	return prime;
}

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

	vector<int> prime = getPrime(N);
	
	long long multi = 1;
	vector<int> cnt(prime.size(), 0);
	for(int i=2; i<=N; i++){
		multi *= i;
		for(int j=0; j<prime.size(); j++){
			while(multi%prime[j] == 0){
				cnt[j]++;
				multi /= prime[j];
			}
		}
	}
	
	vector<vector<long long>> dp(prime.size()+1, vector<long long>(NUM_DIVISOR+1, 0));
	dp[0][1] = 1;
	for(int i=0; i<prime.size(); i++){
		for(int j=0; j<=cnt[i]; j++){
			for(int k=0; k<=NUM_DIVISOR; k++){
				int index = k * (j + 1);
				if(index > NUM_DIVISOR)
					break;

				dp[i+1][index] += dp[i][k];
			}
		}
	}

	cout << dp[prime.size()][75] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <ctime>
#include <climits>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    while (cin >> n && n) {
        vector<vector<int>> mat(n+1, vector<int>(n+1, 0));
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                cin >> mat[i][j];
                mat[n][j] += mat[i][j];
                mat[i][n] += mat[i][j];
                mat[n][n] += mat[i][j];
            }
        }
        for (int i=0; i<n+1; ++i) {
            for (int j=0; j<n+1; ++j) {
                cout << setw(5) << mat[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<vector>

using namespace std;
int main(){
 int n,m; cin>>n>>m;
 vector<int> vec = vector<int>(n,0);
 for(int i=0;i<m;i++){
 int a,b; cin>>a>>b;
 vec[a-1] += 1;
 vec[b-1] += 1;
}
for(auto a : vec){ cout<<a<<endl;}
 return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int X = N;
  for(; X > -1; X--){
    if((int)(X * 1.08) == N) break;
  }
  
  if(X == -1) cout << ":(" << endl;
  else cout << X << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

// 文字列から数値へ変換して key を生成する
long long getKey(char str[]) {
  long long sum =0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); // 文字列を数値に変換
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) %M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); // 文字列を数値に変換
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str); // より高速なscanfを使用
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 16048
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int N,M;
const int MN=3005;
int fac[MN],inv[MN],pw[9000005];
int Mul(int x,int y){return (1ll*x*y)%M;}
int Add(int x,int y){return (x+y)%M;}
int C(int x,int y){return Mul(fac[x],Mul(inv[y],inv[x-y]));}
int f[MN][MN],g[MN],ans;
int main()
{
	N=read();M=read();
	reg int i,j;
	for(pw[0]=i=1;i<=N*N;++i) pw[i]=Mul(2,pw[i-1]);
	for(fac[0]=i=1;i<=N;++i)fac[i]=Mul(fac[i-1],i);
	for(inv[0]=inv[1]=1,i=2;i<=N;++i)inv[i]=Mul(inv[M%i],(M-M/i));
	for(i=2;i<=N;++i)inv[i]=Mul(inv[i-1],inv[i]);
	f[0][0]=1;
	for(i=1;i<=N;++i)for(f[i][0]=1,j=1;j<=i;++j)
		f[i][j]=Add(f[i-1][j],Add(f[i-1][j-1],Mul(f[i-1][j],j)));
	reg int tmp=2;
	for(i=N;~i;--i,tmp=Mul(tmp,tmp))for(j=0;j<=i;++j)
		g[i]=Add(g[i],Mul(f[i][j],Mul(tmp,pw[(N-i)*j])));
	for(i=0;i<=N;++i)
		ans=Add(ans,Mul((i&1?M-1:1),Mul(C(N,i),g[i])));
	return 0*printf("%d\n",ans);
}

Measured memory_bytes: 69376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    long A,B,C,K;
    cin >> A >> B >> C >> K;
    long MaxSum=0;
    long tempLong=K;
    
    if(A<K){
        MaxSum+=A;
        tempLong-=A;
    }else{
        MaxSum+=K;
        tempLong-=A;
    }
    tempLong-=B;
    if(tempLong>0){
        MaxSum-=tempLong;
    }
    
    cout << MaxSum << endl;
    
    return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    int N; cin>>N;
    f64 T,A; cin>>T>>A;
    f64 H[N]; REP(i,N) cin>>H[i];
    f64 ans = 0, tmp = INF;
    REP(i,N) {
        if (abs(T-0.006*H[i]-A)<tmp) {
            ans = i+1;
            tmp = abs(T-0.006*H[i]-A);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline

def main():
    K = int(input())
    A = list(map(int,input().split()))
    
    L = [1]
    for i in range(K):
        if L[-1] != A[-i-1]:
            L.append(A[-i-1])
    
    L.pop(0)
    L_long = len(L)
    ans = [2,2]
    for i in range(L_long):
        s,t = ans[0],ans[1]
        ans[0] = -(-s//L[i])*L[i]
        ans[1] = (t//L[i] + 1)*L[i] - 1
        if ans[1] < ans[0]:
            print(-1)
            exit()
    
    print(ans[0],ans[1])
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 12852
#include<iostream>
using namespace std;
int main(){
int h,ans;
while(cin>>h,h){
ans=0;
int t[200][5]={{0},{0}};
for(int i=0;i<h;i++)for(int j=0;j<5;j++)cin>>t[i][j];
while(1){
bool f=1;
for(int i=0;i<h;i++){
int c=0,fi=-1;
for(int j=0;j<3;j++){
if(t[i][j]==t[i][j+1]&&t[i][j]==t[i][j+2]&&t[i][j]!=0){
c++;
if(fi==-1)fi=j;
}
}
if(c!=0)ans+=t[i][fi]*(2+c),f=0;
if(c!=0)for(int j=0;j<2+c;j++)t[i][fi+j]=0;
}
if(f)break;
for(int i=h-2;i>=0;i--){
for(int j=0;j<5;j++){
int ti=i;
while(true){
if(ti==h-1||t[ti+1][j]!=0)break;
t[ti+1][j]=t[ti][j];
t[ti][j]=0;
ti++;
}
}
}
}
cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 1164
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def inmap?(i,j,h=$H,w=$W);
  0 <= i && i < h && 0 <= j && j < w
end

h, w  = gets.split.map(&:to_i)
s = Array.new(h){ gets.chomp }

$H = h
$W = w

h.times do |i|
  w.times do |j|
    
    if '#' == s[i][j]
      ok = false
      4.times do |k|
        nx = i + dx[k]
        ny = j + dy[k]
        ok = true if inmap?(nx,ny) && "#" == s[nx][ny]
      end
      if !ok
        puts "No"
        exit
      end
    end
  end
end

puts "Yes"
    

Measured memory_bytes: 1788
#include<iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    // 整数の入力
    int a, b, x;
    cin >> a >> b >> x;
    
    // A+B<X or A>X ga dame
    if(a + b < x || a > x){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
from functools import *
from itertools import *

N = int(input())
As = list(map(int, input().split()))

def gcd(a, b):
    if a == 0 or b == 0:
        return max(a, b)
    a , b = (a, b) if a > b else (b, a)
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
        pass
    return b

def gcd_acc(acc, x):
    if len(acc) == 0:
        acc.append(x)
        return acc
    last = acc[-1]
    acc.append(gcd(last, x))
    return acc

def candidates(As):
    length = len(As)
    L = iter(reduce(gcd_acc, As, deque()))
    R = reversed(reduce(gcd_acc, reversed(As), deque()))
    next(R)

    yield next(R)

    if length == 1:
        return

    for _ in range(length-2):
        yield gcd(next(L), next(R))
        pass
    yield next(L)
    pass

print(max(candidates(As)))



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

int h, w, s;
int lower;
int sum[33][33];
int u[32][32];
int memoCnt[32][32][32][32];
int memoMinNeed[32][32][32][32];

int getNeed(int a, int b, int c, int d){
    return sum[c + 1][d + 1] - sum[c + 1][b] - sum[a][d + 1] + sum[a][b];
}

pair<int, int> func(int a, int b, int c, int d){

    //cout << a << " " << b << " " << c << " " << d << endl;

    int temp = memoCnt[a][b][c][d];
    if(temp != -1){
        return make_pair(temp, memoMinNeed[a][b][c][d]);
    }

    if(a == c && b == d){
        int cnt, minNeed;
        if(u[a][b] >= lower){
            cnt = 1;
            minNeed = u[a][b];
        }
        else{
            cnt = 0;
            minNeed = u[a][b];
        }

        memoCnt[a][b][c][d] = cnt;
        memoMinNeed[a][b][c][d] = minNeed;
        return make_pair(cnt, minNeed);
    }

    int tempSum = getNeed(a, b, c, d);
    if(tempSum < lower){
        memoCnt[a][b][c][d] = 0;
        memoMinNeed[a][b][c][d] = tempSum;
        return make_pair(0, tempSum);
    }

    pair<int, int> tempPair = make_pair(1, tempSum);
    for(int i = a; i < c; i++){
        auto temp1 = func(a, b, i, d);
        auto temp2 = func(i + 1, b, c, d);
        auto temp3 = make_pair(temp1.first + temp2.first, min(temp1.second, temp2.second));
        if(temp3 > tempPair){
            tempPair = temp3;
        }
    }
    for(int i = b; i < d; i++){
        auto temp1 = func(a, b, c, i);
        auto temp2 = func(a, i + 1, c, d);
        auto temp3 = make_pair(temp1.first + temp2.first, min(temp1.second, temp2.second));
        if(temp3 > tempPair){
            tempPair = temp3;
        }
    }

    memoCnt[a][b][c][d] = tempPair.first;
    memoMinNeed[a][b][c][d] = tempPair.second;
    return tempPair;
}

int main(){

    while(true){
        cin >> h >> w >> s;
        if(h == 0){
            break;
        }

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> u[i][j];
            }
        }

        memset(sum, 0, sizeof(sum));
        memset(memoCnt, -1, sizeof(memoCnt));
        memset(memoMinNeed, -1, sizeof(memoMinNeed));
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + u[i - 1][j - 1];
            }
        }

        lower = sum[h][w] - s;

        pair<int, int> ans = func(0, 0, h - 1, w - 1);

        cout << ans.first << " " << ans.second - lower << endl;
    }
    return 0;
}


Measured memory_bytes: 11216
N, A, B, C = list(map(int, input().split()))
d = {'A': A, 'B': B, 'C': C}
res = []
SN = [input() for i in range(N)]
for i in range(N):
    s = SN[i]
    s0 = s[0]
    s1 = s[1]

    if d[s0] == d[s1] == 0:
        print('No')
        exit()
    elif d[s0] == 0:
        d[s0] += 1
        d[s1] -= 1
        res.append(s0)
    elif d[s1] == 0:
        d[s0] -= 1
        d[s1] += 1
        res.append(s1)
    elif i == N-1:
        res.append(s0)
    elif s0 in SN[i+1]:
        d[s0] += 1
        d[s1] -= 1
        res.append(s0)
    else:
        d[s0] -= 1
        d[s1] += 1
        res.append(s1)

print('Yes')
for r in res:
    print(r)


Measured memory_bytes: 86924
N=int(input())
p=list(map(int, input().split()))
i = 1
res = 0
while i<N:
    if i==p[i-1] and i+1==p[i]:
        res += 1
        i += 2
    elif i==p[i-1]:
        res += 1
        i += 1
    else:
        i += 1
if i==N and i==p[i-1]:
    res += 1
print(res)


Measured memory_bytes: 14008
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N, sum = 0;
    cin >> N;

    vector<int> A(N);
    vector<int> B(N-1);

    for (int i = 0; i < N-1; i++){
        cin >> B[i];
    }

    for (int i = 0; i < N; i++){
        if (i == 0){
            A[i] = B[i];
        }
        else if (i == N-1){
            A[i] = B[i-1];
        } else {
            A[i] = min(B[i-1], B[i]);
        }
    }

    for (int i = 0; i < N; i++){
        sum += A[i];
    }

    cout << sum <<endl;

    return 0;
}


Measured memory_bytes: 256