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

using namespace std;

char three[3][3] = {
    {'a','a','.'},
    {'.','.','b'},
    {'.','.','b'},
};

char four[4][4] = {
    {'a','a', 'b', 'c'},
    {'e','e', 'b', 'c'},
    {'d','f', 'g', 'g'},
    {'d','f', 'h', 'h'}
};

string five[5] = {
    "aabee",
    ".cbff",
    "dch..",
    "d.h.z",
    "ffxxz"
};

string six[6] = {
    "aab.ee",
    ".cb.ff",
    "dcgg..",
    "dehh..",
    "fe...z",
    "f..xxz"
};

string seven[7] = {
    "aab..ee",
    ".cb..ff",
    ".cggk..",
    "d.hhk..",
    "de.jj..",
    "fe....z",
    "f...xxz"
};

const int N = 1024; 
char a[N][N];

void p3(int x) {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            a[x+i][x+j] = three[i][j];
        }
    }
}
void p4(int x) {
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            a[x+i][x+j] = four[i][j];
        }
    }
}
void p5(int x) {
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            a[x+i][x+j] = five[i][j];
        }
    }
}
void p6(int x) {
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 6; j++) {
            a[x+i][x+j] = six[i][j];
        }
    }
}
void p7(int x) {
    for (int i = 0; i < 7; i++) {
        for (int j = 0; j < 7; j++) {
            a[x+i][x+j] = seven[i][j];
        }
    }
}

void solve() {
    int n; cin >> n;
    if (n==2) {
        cout << -1; return;
    }

    memset(a, '.', sizeof a);
    if (n%5==0) {
        for (int i = 0; i < n; i+=5) {
            p5(i);
        }
    } else if (n%3 == 0) {
        for (int i = 0; i < n; i+=3) {
            p3(i);
        }
    } else if (n%2==0){
        int i = 0;
        while (n-i > 6) {
            p4(i); i+=4;
        }
        assert(n-i==4||n-i==6);
        if (n-i==4) {
            p4(i);
        }else p6(i);
    } else {
        int i = 0;
        p7(i); i+=7;
        while (n-i > 6) {
            p4(i); i+=4;
        }
        if (n-i>0) {
            if (n-i==4) p4(i);
            else p6(i);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << a[i][j];
        }cout << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long h,w;
  cin >> h >> w;
  char s[h+1][w+1],red[h+1][w+1],blue[h+1][w+1];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i%2==0){
        if(j==0){
          red[i][j]='#';
          blue[i][j]='.';
        }else{
          red[i][j]='.';
          blue[i][j]='#';
        }
      }else{
        if(j==w-1){
          red[i][j]='.';
          blue[i][j]='#';
        }else{
          red[i][j]='#';
          blue[i][j]='.';
        }
      }
      if(s[i][j]=='#'){
        red[i][j]='#';
        blue[i][j]='#';
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << red[i][j];
    }
    cout << endl;
  }
  cout << endl;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << blue[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int c = (a*b)/2;
  if (2*c==a*b){
    cout << "Even" <<endl;
  }
  else{
    cout << "Odd" << endl;
  }
  return 0;
}
  


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

#define MAXN 100005
#define int long long
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

using namespace std;

int N, M;
vector<int> g[MAXN];
int par[MAXN];
int dp[MAXN][2];

void dfs(int u, int p) {
    par[u] = p;
    dp[u][1] = 1 % M;
    dp[u][0] = 1 % M;
    for (int v: g[u]) {
        if (v == p) continue;
        dfs(v, u);
        dp[u][1] = dp[u][1] * dp[v][0] % M;
        dp[u][0] = dp[u][0] * ((dp[v][0] + dp[v][1]) % M) % M;
    }
}

signed main() {
    fastio;
    cin >> N;
    M = 1e9+7;
    for (int i = 1; i <= N-1; i++) {
        int u, v;
        cin >> u >> v ;
        g[u].push_back(v), g[v].push_back(u);
    }
    dfs(1, 0);
    cout << (dp[1][0] + dp[1][1]) % M << endl;
    return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string str;
int main() {
  cin >> str;
  cout << "ABC" << str <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    intl mi = INF;
    string s0 = s;
    sort(all(s0));
    if(s0[0] == s0[s0.length()-1]){
        cout << 0 << endl;
        return 0;
    }
    for(char c = 'a'; c <= 'z'; c++){
        string t = s;
        intl cnt = 0;
        while(true){
            string u = t;
            string v = "";
            intl len = u.length();
            rep(i,len - 1){
                if(u[i] == c)v += u[i];
                else if(u[i + 1] == c)v += u[i + 1];
                else v += u[i];
                //debug(t);
            }
            //v += u[len - 1];
            t = v;
            cnt++;
            bool f = true;
            rep(i,v.length())if(v[i] != c)f = false;
            if(f)break;
            //debug(v);
            //debug(u);
        }
        //debug(t);
        if(t.length() > 0)mi = min(mi,cnt);
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 3616
Q = int(input())

import math
def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)
    for serial in range(3, num, 2):
        if serial >= sqrt:
            return input_list
        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

primes = sieve_of_erastosthenes(10**5)
likes = []
for i in range(3, 10**5, 2):
    if primes[i] and primes[(i+1)//2]:
        likes.append(i)

from bisect import bisect_left, bisect_right

for _ in range(Q):
    l, r = map(int, input().split())
    print(bisect_right(likes, r) - bisect_left(likes, l))

Measured memory_bytes: 79328
import bisect
from itertools import accumulate
n = int(input())
A = sorted(map(int,input().split()))
B = sorted(map(int,input().split()))
C = sorted(map(int,input().split()))
D = [0]*(n+1)
for i in range(n):
    D[i+1] = n-bisect.bisect_right(C,B[i])
D = tuple(accumulate(D))
ans = 0
for i in range(n):
    j = bisect.bisect_right(B,A[i])
    ans += D[-1]-D[j]
print(ans)

Measured memory_bytes: 25156
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int a, b, c, d, e, k;
    std::cin >> a >> b >> c >> d >> e >> k;
    std::cout << (e - a > k ? ":(" : "Yay!") << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_V 1000
#define INF 1<<29
using namespace std;
struct edge{int to,cap,rev;};
vector<edge>G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}
void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int>q;
  level[s]=0;
  q.push(s);
  while(!q.empty()){
    int v=q.front();q.pop();
    for(int i=0;i<G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[e.to]<0){
        level[e.to]=level[v]+1;
        q.push(e.to);
      }
    }
  }
}
int dfs(int v,int t,int f){
  if(v==t)return f;
  for(int &i=iter[v];i<G[v].size();i++){
    edge &e=G[v][i];
    if(e.cap>0&&level[v]<level[e.to]){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}
int max_flow(int s,int t){
  int flow=0;
  while(1){
    bfs(s);
    if(level[t]<0)return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f=dfs(s,t,INF))>0){
      flow+=f;
    }
  }
}
int main(){
  int n,m;
  cin>>n>>n>>m;
  for(int i=1;i<101;i++)add_edge(0,i,1);
  for(int i=101;i<201;i++)add_edge(i,300,1);
  while(m--){
    int a,b;
    cin>>a>>b;
    a++;
    b+=101;
    add_edge(a,b,1);
  }
  cout<<max_flow(0,300)<<endl;
}

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

int main(void)
{
	int m;
	int p_taro = 0, p_hanako = 0;
	string taro, hanako;


	cin >> m;

	for(int i = 0; i < m; i++) {
		cin >> taro >> hanako;
		if(taro > hanako)			p_taro += 3;
		else if(taro < hanako)		p_hanako += 3;
		else {
			p_taro += 1;
			p_hanako += 1;
		}
	}

	cout << p_taro << " " << p_hanako << endl;

	return 0;
}

Measured memory_bytes: 1208
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"8 3
" => r"2.6666666667",

r"99 1
" => r"99.0000000000",

r"1 100
" => r"0.0100000000"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        t: f64,
        x: f64
    }

    (t / x).to_string()
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    long long x,y;
    cin >> x >> y;
    long long ans=0;
    if(abs(x)<abs(y)){
        ans+=abs(abs(y)-abs(x));
        if(x<0){
            ans++;
        }
        if(y<0){
            ans++;
        }
    }else if(abs(x)==abs(y)){
        if(x*y>=0){
            ans=0;
        }else{
            ans++;
        }
    }else{
        if(y<=0){
            ans+=abs(abs(x)-abs(y));
            if(x>0){
                ans++;
            }
        }else{
            ans+=abs(abs(x)-abs(y));
            if(x<0){
                ans++;
            }else{
                ans = ans+2;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    let s = getline();
    println!("{}", s.match_indices("+").count() as i32 * 2 - 4);
}



#[allow(dead_code)]
fn getline() -> String {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().to_string()
}

#[allow(dead_code)]
fn read<T>() -> T where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn reads<T>() -> Vec<T> where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	bool flag = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '7') {
			flag = 1;
			break;
		}
	}
	if (flag) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;

const ll MAX = 600005;
const ll mod = 998244353LL;

ll sq(ll a) { return a*a; }

ll modpow(ll b, ll p) 
{
    if(p == 0)  
        return 1; 
    if(p % 2 == 0) 
        return sq(modpow(b, p/2)) % mod; 
    else 
        return b * modpow(b, p-1) % mod; 
}

ll fa[MAX], fi[MAX]; // fa: factorial, fi: inverse factorial

void init()
{
    fa[0] = fi[0] = 1;
    for(int i = 1; i < MAX; i++)
    {
        fa[i] = fa[i-1] * i % mod;
        fi[i] = modpow(fa[i], mod - 2);
    }
}

ll comb(ll n, ll k) { return fa[n] * fi[k] % mod * fi[n-k] % mod; }

iii egcd(ll a, ll b) 
{ 
    if(!b) return {a,{1,0}};
    iii p = egcd(b, a%b);  
    ll x = p.second.first, y = p.second.second;
    return {p.first, {y, x - (a/b)*y}};
}

ll solve(ll n, ll a, ll b, ll c)
{
    iii ans = egcd(a,b); 
    ll x = ans.second.first, y = ans.second.second, d = ans.first;
    if(c % d != 0) return 0; 
    ll t1 = ceil(-c*x/b), t2 = floor(c*y/a);
    ll sum = 0;
    for(ll t = t1; t <= t2; t++)
    {
        ll x1 = (x*c/d) + (b/d) * t, y1 = (y*c/d) - (a/d)*t;
        if(x1 >= 0 && y1 >= 0 && x1 <= n && y1 <= n)
            sum = (sum + comb(n,x1) * comb(n,y1) % mod) % mod;
    }
    return sum;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    init();
    ll n,a,b,c;
    while(cin >> n >> a >> b >> c)
        cout << solve(n,a,b,c) << '\n';
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main()
{
	long long x;
	cin >> x;
	
	long long ans = 0;
	int a = x % 11;
	ans = 2 * (x / 11);
	
	if(a == 0)
	{
		;
	}
	else if(a > 6)
	{
		ans += 2;
	}
	else
	{
		ans++;
	}
	
	cout << ans << endl;
}

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

struct UnionFind
{
	int N;
	vector<int> parent;
	vector<int> size_r;
	int num_of_sets;

	UnionFind(int N) :  N(N), parent(N), size_r(N, 1), num_of_sets(N) {
		for (int i = 0; i < N; ++i) parent[i] = i;
	}

	int root(int x) {
		if (parent[x] == x) return x;
		return parent[x] = root(parent[x]);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (size_r[x] < size_r[y]) swap(x, y);
		parent[y] = x;
		size_r[x] += size_r[y];
		size_r[y] = 0;
		num_of_sets--;
		return true;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	int size(int x) {
		return size_r[root(x)];
	}
};

struct Edge
{
	int a, b;
	long long cost;
};

struct Kruskal
{
	int V, E;
	vector<Edge> edges;
	vector<Edge> min_span_tree;
	long long min_span_cost;

	Kruskal(int V, const vector<Edge> &edges) : V(V), E(edges.size()), edges(edges) {}

	void calc() {
		auto edge_comp = [&](Edge e1, Edge e2) -> bool {
			return e1.cost < e2.cost;
		};
		sort(edges.begin(), edges.end(), edge_comp);
		UnionFind uf(V);
		min_span_cost = 0;
		for (Edge e : edges) {
			if (uf.same(e.a, e.b)) continue;
			min_span_tree.push_back(e);
			uf.merge(e.a, e.b);
			min_span_cost += e.cost;
		}
	}
};

struct P
{
	long long val;
	int idx;
};

bool compP(P a, P b) {
	return a.val < b.val;
}

int main() {
	int n;
	cin >> n;
	vector<P> x(n), y(n);
	for (int i = 0; i < n; i++) {
		long long xi, yi;
		cin >> xi >> yi;
		x[i] = {xi, i};
		y[i] = {yi, i};
	}
	sort(x.begin(), x.end(), compP);
	sort(y.begin(), y.end(), compP);
	vector<Edge> es;
	for (int i = 0; i < n-1; i++) {
		es.push_back({x[i].idx, x[i+1].idx, x[i+1].val - x[i].val});
		es.push_back({y[i].idx, y[i+1].idx, y[i+1].val - y[i].val});
	}
	Kruskal K(n, es);
	K.calc();
	long long ans = K.min_span_cost;
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define mset(a,x) memset(a,x,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define mp make_pair

int main() {
    int n;
    cin >> n;
    vi a(n);
    for(int& i : a) cin >> i;

    int ans = 114514810;
    FOR(y, -100, 101) {
        int cost = 0;
        for(auto& i : a) cost += (i - y) * (i - y);
        ans = min(ans, cost);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const array = input.split(' ').map(n => Number(n));
  const startTime = array[0] + array[1];
  if(startTime >= 24) {
    console.log(startTime - 24);
  } else {
    console.log(startTime);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i = 0;i < N;i++){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  p.at(0) /= 2;
  int sum = 0;
  for(int i = 0;i < N;i++){
    sum += p.at(i);
  }
  cout << sum;
}


Measured memory_bytes: 256
import sys
from collections import deque
N,M=map(int,input().split())
s=input()
table=[]
for i in range(M):
    x,y=map(int,input().split())
    table.append((x-1,y-1))
A=[0]*N
B=[0]*N
edge=[[] for i in range(N)]
S=[False]*N
L=deque()
for x,y in table:
    if x==y:
        #edge[x].append(y)
        if s[x]=='A':
            A[x]+=1
        else:
            B[x]+=1
        continue
    edge[x].append(y)
    edge[y].append(x)
    if s[x]=='A':
        A[y]+=1
    else:
        B[y]+=1
    if s[y]=='A':
        A[x]+=1
    else:
        B[x]+=1 
        
for i in range(N):
    if A[i]*B[i]==0:
        L.append(i)
        S[i]=True

while L:
    x=L.pop()
    t=s[x]
    for y in edge[x]:
        if S[y]:
            continue
        if t=='A':
            A[y]-=1
        else:
            B[y]-=1
        if A[y]*B[y]==0:
            L.append(y)
            S[y]=True
if sum(S)!=N:
    print('Yes')
else:
    print('No')


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

int main(){
  cout << fixed << setprecision(15);
  int n; cin >> n;
  vector<int> k(n);
  rep(i, n) cin >> k[i];

  int ans = 0;
  rep(i, n){
    rep(j, n){
      if (i == j) continue;
      else ans += k[i] * k[j];
    }
  }

  cout << ans / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, a[100005], b;
ll ans;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n;

    for (int i = 0; i < n+1; i++)
        cin >> a[i];

    for (int i = 0; i < n; i++) {
        cin >> b;
        int tmp = min(a[i], b);
        a[i] -= tmp;
        b -= tmp;
        ans += tmp;

        tmp = min(a[i+1], b);
        a[i+1] -= tmp;
        b -= tmp;
        ans += tmp;
    }

    cout << ans << '\n';

    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int a,b;
  char op;
  while(1){
    cin >> a >> op >> b;
    if(op=='+')cout << a+b << endl;
    else if(op=='-')cout << a-b << endl;
    else if(op=='*')cout << a*b << endl;
    else if(op=='/')cout << a/b << endl;
    else break;
  }
}



Measured memory_bytes: 3116
//  Created by conan1024hao on 2019/11/26.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //------------------------------
    ll n,X;
    cin>>n>>X;
    vector<ll>x;
    x.clear();
    x.push_back((ll)X);
    ll nn;
    for(int i=0;i<n;i++){
        ll t;
        cin>>t;
        x.pb(t);
        nn=t;
    }
    sort(all(x));
    vector<ll>ch;
    for(int i=0;i<n;i++)
        ch.pb(x[i+1]-x[i]);
    //cout<<ch[0]<<endl;
    ll ans=INF;
        for(int j=0;j<n-1;j++){
            chmin(ans,GCD(ch[j],ch[j+1]));
        }
    if(n==1)
        cout<<abs(X-nn)<<endl;
    else
            cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 2548
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cout<<a[i]<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const ll p = 78294349;

int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    vector<int> a(5);
    int t;
    for (int i = 0; i<6; i++)
    {
        cin>>t; a[t]++;
    }
    int counter = 0;
    for (int i = 0; i<=4; i++) if (a[i]%2==1) counter++;
    if (counter>=3) cout<<"NO";
    else cout<<"YES";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main(){
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;

  int mae = 0; //0のとき一つ前が縦
  int now = 0;
  int ans = 1;
  if( S[0] == T[0] ){ //縦ドミノ
    ans = 3;
    now++;
  }else{
    ans = 6;
    now += 2;
    mae = 1;
  }

  while( now < N ){
    if( S[now] == T[now] ){
      if( mae == 0 ) ans*= 2;
      ans %= MOD;
      now++;
      mae = 0;
    }else{
      if( mae == 0 ) ans *= 2;
      else ans *= 3;
      ans %= MOD;
      mae = 1;
      now += 2;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 998244353;
const long long int INF = 1e18;

long long int N,X,Y,res=0;
string S[55];
int main()
{
    cout << fixed << setprecision(18);
    cin>>X>>N;
    if(N==100){N++;}
    for(long long int i = 0; i < X; i++){
        N*=100;
    }
    cout<<N<<endl;
}


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

vector<int> answer;

void count (int i, int countR, int countL) {
  // 中央
  int center = i - countL;
  // RとLの差
  int diff = abs(countR - countL);
  if (diff % 2 == 0) {
    // RとLの差が偶数だったら同じ値
    answer[center] = (countR + countL) / 2;
    answer[center + 1] = (countR + countL) / 2;
  } else {
    // RとLの差が奇数だったら大きい方に+1
    answer[center] = (countR + countL) / 2;
    answer[center + 1] = (countR + countL) / 2;
    // RとLの差が奇数だったら大きい方の数が偶数の場合は、
    if (countR < countL) {
      if (countL % 2 == 0) {
        answer[center]++;
      } else {
        answer[center + 1]++;
      }
    } else {
      if (countR % 2 == 0) {
        answer[center + 1]++;
      } else {
        answer[center]++;
      }
    }
  }
}

int main() {

  string S;
  cin >> S;

  answer.resize(S.size());

  // RとLが何個続くかを数える
  int countR = 0;
  int countL = 0;
  for (int i = 0; i < S.size(); i++) {
    if (i == S.size() - 1) {
      countL++;
      count (i, countR, countL);
    } else if (S[i] == 'R' && countL != 0) {
      count (i - 1, countR, countL);
      countR = 1;
      countL = 0;
    } else if (S[i] == 'R' && countL == 0) {
      countR++;
    } else {
      countL++;
    }
  }

  for (int i = 0; i < answer.size(); i++) {
    cout << answer[i];
    if (i != answer.size() - 1) {
      cout << " ";
    }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		
		while( true ) {
			int height	= sc.nextInt();
			int width	= sc.nextInt();
			
			if (		height	== 0
					&&	width	== 0	) {
				break;
			}
			
			for (int i = 0; i < height; i++ ) {
				for ( int j = 0; j < width; j++ ) {
					System.out.print("#");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
			
		}
	}
}

Measured memory_bytes: 31664
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define lint long long
#define mod 1000000007
#define ull unsigned lint
#define db long double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gc getchar()
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int cnt[100];char s[100010];
int main()
{
	int n=inn(),ans=1;
	scanf("%s",s+1);
	rep(i,1,n) cnt[s[i]-'a'+1]++;
	rep(i,1,26) ans=ans*(cnt[i]+1ll)%mod;
	ans--;if(ans<0) ans+=mod;
	return !printf("%d\n",ans);
}

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

using namespace std;

int main() {
  int min = 1e9, max = 0;
  int N, K;
  cin >> N >> K;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
    if (max < v[i]) {
      max = v[i];
    }
  }
  if (max < K) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  auto find_min = [&v, &min] {
    bool flag = false;
    for (int x : v) {
      if (min > x) {
        min = x;
        flag = true;
      }
    }
    return flag;
  };
  auto make_mod = [&v, &min] {
    for (int &x : v) {
      x %= min;
      if (x == 0)
        x = min;
    }
    return;
  };
  while (min != 1) {
    if (!find_min()) {
      break;
    } else {
      make_mod();
    }
  }
  if (K % min == 0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int MaxN = 50;
const LL INF =  5e17;
LL a[MaxN + 5], cnt[MaxN + 5];
LL k;
 
int main(){
	while(~scanf("%lld", &k)){
		int n = 50;
		LL temp = k / n;
		for(int i = 1; i <= n; i++) a[i] = n - 1;
		for(int i = 1; i <= n; i++)	a[i] += temp;
		for(int i = 1; i <= k % n; i++){
			a[i] += n;
			for(int j = 1; j <= n; j++){
				if(i == j) continue;
				a[j]--;
			}
		}
		printf("50\n");
		for(int i = 1; i <= n; i++) printf("%lld ", a[i]);
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        int a,b,c,k;
        cin>>a>>b>>c;
        cin>>k;
        int N,M;
        N=max(a,b);
        N=max(N,c);
        M=N;
        for(int i=0;i<k;i++){
                N=N*2;
        }
        cout<<a+b+c-M+N<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define v first
#define w second
#define pb push_back
#define ll long long
#define pi pair<int,ll>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n,ans[200100];
vector <pi> adj[200100];
void dfs(int u,int p,ll W)
{
    ans[u]=W%2;
    for(pi x:adj[u])
    {
        if(x.v==p) continue;
        dfs(x.v,u,W+x.w);
    }
}
int main()
{
    go;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        ll z;
        cin>>x>>y>>z;
        adj[x].pb({y,z});
        adj[y].pb({x,z});
    }
    dfs(1,-1,0);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 12160
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <string>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
using namespace std;


int main()
{
    int a,b,c;
    int B,C;
    cin >> a >> b >> c;
    
    B = abs(b-a);
    C = abs(c-a);
    
    if(B<=C){
        cout << "A" <<endl;
    }else{
        cout << "B" <<endl;
        }
}

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



int main(){
    
    ll N;cin>>N;
    ll a,b,cn=0;
    vector<pair<int, int> > p(N);
    rep(i,0,N){
        cin>>a>>b;
        p.at(i)=make_pair(b, a); 
        
    }
    sort(p.begin(),p.end());
    int ok=1;
    rep(i,0,N){
        tie(b,a)=p.at(i);
        cn+=a;
        if(cn>b){
            ok=0;
            break;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}






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

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin>>n;

    vector<int> a(n+1),b(n+1),c(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    vector<vector<long long>> dp(n+5,vector<long long>(4,0));
    for(int i=1;i<=n;i++){
        dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
        dp[i][3]=max(dp[i-1][2],dp[i-1][1])+c[i];
    }

    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<"\n";
    return 0;
}

Measured memory_bytes: 11336
#include<bits/stdc++.h>
using namespace std;
const int N = 6010100;
long long  n,k;
long long  S[N];
bool pd(int K)
{
	if(K<=0) return false;
	long long A = 0;
	for(int i = 1;i <= n;i++)
	{
		A += S[i]%K?S[i]/K:S[i]/K-1;
	}
	return A <= k;
}
int main()
{
	long long  ans = 0;
	scanf("%lld%lld",&n,&k);
	for(int i = 1;i <= n;i++)
	{
		scanf("%lld",&S[i]);
		ans= max(S[i],ans);
	}
	int r = ans,l = 1;
	while(l <= r)
	{
		long long mid = l+r>>1;
		if(pd(mid))
		{
			ans = min(ans,mid);
			r = mid-1;
		}
		else l = mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5180
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int n, int m){
    return n * (m / gcd(n, m));
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int64 ans=0;
    REP(i,N){
        REP(j,N){
            REP(k,N){
                ans+=gcd(i+1,gcd(j+1,k+1));
            }
        }
    }




    cout << ans << endl;
}

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

int main()
{
  string s,t;
  cin>>s>>t;
  map<char,vector<ll>> mp;
  set<char> st;
  for (ll i = 0; i < s.size(); ++i)
  {
    mp[s[i]].push_back(i+1);
    st.insert(s[i]);
  }
  bool flag=true;
  for (int i = 0; i < t.size(); ++i)
  {
    if (st.find(t[i])==st.end()) {
      flag=false;
      break;
    }
  }
  if (!flag) {
    cout<<-1<<endl;
    return 0;
  }

  vector<ll> index(t.size(),-1);
  index[0]=mp[t[0]].front();
  for (int i = 1; i < t.size(); ++i)
  {
    auto itr=upper_bound(mp[t[i]].begin(),
     mp[t[i]].end(),index[i-1]);

    if (itr!=mp[t[i]].end()) {
      index[i]=*itr;
    } else {
      index[i]=mp[t[i]].front();
    }
  }

  // for(const auto& e: index) 
  // {
  //   cout<<e<<" ";
  // }cout<<endl;

  ll ans=0;
  for (int i = 1; i < index.size(); ++i)
  {
    if (index[i-1]>=index[i]) {
      ans++;
    }
  }
  ans*=s.size();
  ans+=index.back();
  cout<<ans<<endl;
}

Measured memory_bytes: 5280
#include <iostream>
using namespace std;
int main() {
	int x, i;
	cin>> x;
	i=1;
	while(x > 0){
		cout<< "Case" << " " << i << ":" << " " << x <<endl;
	
	i=i+1;
	cin>> x;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    vi a(n);
    VIN(a);

    bool approve = true;
    REP(i,n){
        if(a[i]%2==1) continue;

        if(a[i]%3==0 || a[i]%5==0) continue;

        approve = false;
        break;
    }

    string ans = approve?"APPROVED" : "DENIED";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long ans = 0;
		if (N%(A+B) == 0) {
			ans = A*(N/(A+B));
		} else if (A <= N%(A+B)) {
			ans = A*(N/(A+B)) + A;
		} else {
			ans = A*(N/(A+B)) + N%(A+B);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i=0; i< N; i++) {
    cin >> A.at(i);
  }
  
  double s = 0;
  for (int i=0; i< N; i++) {
     s += 1.0/A.at(i);   
  }
  
  cout << 1/s << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if 0 < A[i] <= B[i]:
        ans += A[i]
        B[i] = B[i] - A[i]
        A[i] = 0
    elif A[i] > B[i]:
        A[i] -= B[i]
        ans += B[i]
        B[i] = 0

    if 0 < A[i+1] <= B[i]:
        ans += A[i+1]
        B[i] = B[i] - A[i+1]
        A[i+1] = 0
    elif A[i+1] > B[i]:
        A[i+1] -= B[i]
        ans += B[i]
        B[i] = 0

print(ans)


Measured memory_bytes: 19004
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
  vll a(n);
  rep(i,0,n) cin >> a[i];
  
  ll ans=0;
  
  rep(i,0,n){
   if((i+1)%2&&a[i]%2) ans++; 
  }
  
  cout << ans << endl;
}

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

Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    cin.ignore();
    string s;
    getline(cin,s);
    for(char c:s)if(c=='Y'){
        cout << "Four"<< endl;
        return 0;
    }
    cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


void solve(){
  ll n;std::cin >> n;
  vvl d = VV(n, 3, 0, ll);// l r k

  re(i, n) scanf("%lld %lld %lld", &d[i][2], &d[i][0], &d[i][1]);

  sort(all(d), [](vll a, vll b){
    return a[0]-a[1] > b[0] - b[1];
  });
  ll ans = 0;
  set<ll> st;
  for(int i=1;i<=n;i++) st.insert(i);
  ll cnt = 0;
  for(int i=0;i<n;i++) if(d[i][0]<d[i][1]) cnt++;
  for(int i=0;i<n;i++){
    if(d[i][0]<d[i][1]) break;
    //iが可能か？
    auto itr = st.upper_bound(d[i][2]);
    if(itr==st.begin()){
      ans += d[i][1];
      continue;
    }
    itr--;
    ans += d[i][0];
    st.erase(itr);
  }

  if(cnt==0){
    std::cout << ans << '\n';
    return;
  }


  vvl minus;
  for(int i=0;i<n;i++) {
    if(d[i][0]<d[i][1]){
      minus.push_back(d[i]);
    }
  }
  ll m = minus.size();
  st = set<ll>();

  for(int i=1;i<=m;i++) st.insert(i);

  for(int i=0;i<m;i++) {
    swap(minus[i][0], minus[i][1]);
    minus[i][2] = n - minus[i][2];
  }

  sort(all(minus), [](vll a, vll b){return a[0]-a[1] > b[0] - b[1];});

  for(int i=0;i<cnt;i++){
    auto itr = st.upper_bound(minus[i][2]);
    if(itr==st.begin()){
      ans += minus[i][1];
      continue;
    }
    itr--;
    ans += minus[i][0];
    st.erase(itr);
  }
  std::cout << ans << '\n';
}

int main(int argc, char const *argv[]) {
  ll T;std::cin >> T;
  re(t, T) solve();
  return 0;
}


Measured memory_bytes: 26348