akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main()
{
	long long int a, v;
	long long int b, w;
	long long int t;
	long long int sd, pd;
	int d = 1;
	int flag = 0;

	scanf("%lld %lld", &a, &v);
	scanf("%lld %lld", &b, &w);
	scanf("%lld", &t);

	/*sd = ((long long int)v - w) * t;
	pd = abs(a - b); */

	if (a > b)
		d = -1;

	a += v * t * d;

	b += w * t * d;

	if (d == -1) {
		if (a <= b)
			flag = 1;
	}
	else if (d == 1)
		if (a >= b)
			flag = 1;

	if (flag==1)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

Measured memory_bytes: 1664
N, m = gets.chomp.split.map(&:to_i)
money = Array.new(N) { gets.chomp.split.map(&:to_i) }.sort
i = 0
ans = 0
until m <= 0
  cnt = [m, money[i][1]].min
  ans += cnt * money[i][0]
  m -= money[i][1]
  i += 1
end
puts ans


Measured memory_bytes: 11128
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid ,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++)L[i]=A[left+i];
    for(int i=0;i<n2;i++)R[i]=A[mid+i];
    L[n1]=R[n2]=SENTINEL;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        cnt++;
        if(L[i]<=R[j]){
            A[k]=L[i++];
        }else {
            A[k]=R[j++];
        }
    }
}

void mergeSort(int A[],int n,int left,int right){
    if(left+1<right){
        int mid =(left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

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

    int A[MAX],n,i;
    cnt=0;

    cin>>n;
    for(i=0;i<n;i++){
        cin>>A[i];
    }

    mergeSort(A,n,0,n);

    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;

    cout<<cnt<<endl;

    return 0;
}





Measured memory_bytes: 6976
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N, D;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      D = sc.nextInt();
    }
    int unit = 2 * D + 1;
    int rest = N % unit;
    int answer = (N - rest)/unit + (rest > 0 ? 1 : 0);
    System.out.println(answer);
  }
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();
		int days = scanner.nextInt();
		int last = scanner.nextInt();
		int spans[] = new int[num];
		for(int i=0; i<num; i++) {
			spans[i] = scanner.nextInt();
		}
		int consum = 0;
		for(int span : spans) {
			consum += (int)Math.ceil((double)days / (double)span);
		}
		System.out.println(consum + last);
	}

}

Measured memory_bytes: 22228
#include <iostream>

using namespace std;

const int MAXN=2e5+1;
int ans[MAXN];
int N;

int main() {
	cin>>N;
	for (int i=2; i<=N; i++) {
		int act;
		cin>>act;
		ans[act]++;
	}
	for (int i=1; i<=N; i++) {
		cout<<ans[i]<<'\n';
	}
}


Measured memory_bytes: 4300
import sys
from collections import deque
input=sys.stdin.readline

n,m=map(int,input().split())
G=[[] for _ in range(3*(n+1))]
for _ in range(m):
    u,v=map(int,input().split())
    G[3*u].append(3*v+2)
    G[3*u+1].append(3*v)
    G[3*u+2].append(3*v+1)
s,t=map(int,input().split())

Q=deque()
Q.append(s*3)
D=[-3 for _ in range(3*(n+1))]
D[s*3]=0

while Q:
    q=Q.popleft()
    for i in G[q]:
        if D[i]==-3:
            D[i]=D[q]+1
            Q.append(i)

print(D[t*3]//3)

Measured memory_bytes: 60224
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define i_inf INT_MAX
#define l_inf LLONG_MAX
#define mod 1000000007

bool compare(const pair<int,int>&a,const pair<int,int>&b){
  if(a.first==b.first&&a.second==b.second)return true;
  return false;
}
pair<int,int>solve(int prev,int root,map<int,vector<int>>&mp,vector<pair<int,int>>&dp){
  if(mp.find(root)==mp.end()){
    dp[root]={1,1};
    return dp[root];
  }
  int w,b;
  if(!compare(dp[root],{-1ll,-1ll}))return dp[root];
  w=1,b=1;
  for(int i=0;i<mp[root].size();i++){
    if(prev!=mp[root][i]){
    pair<int,int>x=solve(root,mp[root][i],mp,dp);
    w=(w*(x.first+x.second))%mod;
    b=(b*x.first)%mod;
  }
  }
  return dp[root]={w,b};
}

int32_t main(){
  int n;
  cin>>n;
  map<int,vector<int>>mp;

  for(int i=0;i<n-1;i++){
    int x,y;
    cin>>x>>y;
    mp[x].push_back(y);
    mp[y].push_back(x);
  }
  if(n==1){
    cout<<2;
    return 0;
  }

  vector<pair<int,int>>dp(n+1,{-1,-1});
  pair<int,int>p=solve(-1,1,mp,dp);
  cout<<(p.first+p.second)%mod;


}


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

int main(){
  int64_t A,B,C;
  cin >> A >> B >> C;
  int64_t sa=A;
  int64_t sb=B;
  int64_t sc=C;
  int64_t ta,tb,tc;
  for(int i=0;;i++){
    if((A%2!=0)||(B%2!=0)||(C%2!=0)){
      cout << i << endl;
      return 0;
    }
    ta=A;
    tb=B;
    tc=C;
    A=tb/2+tc/2;
    B=ta/2+tc/2;
    C=ta/2+tb/2;
    if((A==sa)&&(B==sb)&&(C==sc)){
      cout << -1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//Finite Disappointment and Infinite Hope
#include <bits/stdc++.h>
using namespace std;
#define help ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.first<<","<<v.second<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    for(auto &x:c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
const ll N=2e5+5,MOD=1e9+7;
int main(){
help
    ll h,n;cin>>h>>n;
    ll sum=0;
    for(ll i=0,x;i<n;i++)cin>>x,sum+=x;
    cout<<(sum>=h?"Yes":"No");
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int a, b, c;
    cin >> a >> b >> c;

    for (int i = 1; i <= b; i++) {
        if (a * i % b == c) {
            cout << "YES\n";
            return 0;
        }
    }

    cout << "NO\n";

    return 0;
}

Measured memory_bytes: 256
def solve(string):
    n, k = 7, int(string)
    if k % 2 == 0 or k % 5 == 0:
        return "-1"
    for i in range(k):
        if not n % k:
            return str(i + 1)
        n = (10 * n + 7) % k


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define fi first
#define se second
int a[100005], b[100005], n, m, ans, cnt;

vector<int> g[100005];
set<int> st;
void dfs(int u){
	b[u] = 1;
	st.insert(u);
	st.insert(a[u]);
	cnt ++;
	for(int v: g[u])
		if(!b[v]) dfs(v);
}
signed main(){
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i ++) cin >> a[i];
	while(m --){
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i = 1 ; i <= n ; i ++)
		if(!b[i]) {
			st.clear();
			cnt = 0;
			dfs(i);
			ans += 2*cnt - st.size();
		}
	cout << ans;
}


Measured memory_bytes: 14976
#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 EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


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


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

    int N;
    cin >> N;
    ll T = 1,A = 1;
    rep(i,0,N){
        ll t,a;
        cin >> t >> a;
        if(T < t && A < a){
            T = t;
            A = a;
        }else{
            auto cn = [](ll aiueo,ll AIUEO){
                return (aiueo/AIUEO) + !!(aiueo%AIUEO);
            };
            ll n = max(cn(T,t),cn(A,a));
            T = t * n;
            A = a * n;
        }
    }
    cout << T + A << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, X;
    cin >> A >> B >> X;
    bool ans;
    if(X - A < 0)
        cout << "NO" << endl;
    else if((X - A) > B)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef pair<string,string> P;

int main() {
  int n,f;
  cin >> n >> f;
  map<P,int> ma;
  for(int i=0; i<n; i++) {
    int m;
    cin >> m;
    string s[m];
    for(int j=0; j<m; j++) {
      cin >> s[j];
      for(int k=0; k<j; k++) {
        P p;
        p.first=s[j],p.second=s[k];
        if(p.first>p.second) swap(p.first,p.second);
        ma[p]++;
      }
    }
  }
  vector<P> v;
  for(map<P,int>::iterator it=ma.begin(); it!=ma.end(); it++) {
    if(it->second>=f) v.push_back(it->first);
  }
  cout << v.size() << endl;
  for(int i=0; i<v.size(); i++) cout << v[i].first << " " << v[i].second << endl;
  return 0;
}


Measured memory_bytes: 3544
/* ex3_2
   pandacodeb */

#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);
  int r = N % 10;
  switch(r){
    case 2: case 4: case 5: case 7: case 9:
      printf("hon\n");
      break;
    case 0: case 1: case 6: case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
      break;
    default: break;
  }
  return 0;
}

Measured memory_bytes: 1624
fun main(args: Array<String>) {
    while(true)
    {
        val n:Int = readLine()!!.toInt()
        var H_list=mutableListOf<Int>()
        var S_list=mutableListOf<Int>()
        var C_list=mutableListOf<Int>()
        var D_list=mutableListOf<Int>()
        for ( i in 0..n-1)
        {
            var list = readLine()!!.split(" ")
            if (list[0] == "H")
            {
                H_list.add(list[1].toInt())
            }
            else if (list[0]=="S")
            {
                S_list.add(list[1].toInt())
            }
            else if (list[0]=="C")
            {
                C_list.add(list[1].toInt())
            }
            else if (list[0]=="D")
            {
                D_list.add(list[1].toInt())
            }
        }
        for ( i in 1..13) {
            if (!S_list.contains((i))) {
                println("S %d".format(i))
            }
        }

        for ( i in 1..13) {
            if (!H_list.contains((i))) {
                println("H %d".format(i))
            }
        }
        for ( i in 1..13) {
            if (!C_list.contains((i))) {
                println("C %d".format(i))
            }
        }
        for ( i in 1..13) {
            if (!D_list.contains((i))) {
                println("D %d".format(i))
            }
        }
        return
    }
}


Measured memory_bytes: 33824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int s, w;
	cin >> s >> w;
	if(s <= w) cout << "unsafe" << endl;
	else cout << "safe" << endl;
	return 0;
}



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

int N;
int A[210];
int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

    while (true) {
        bool exist_odd = false;
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;
        }

        if (exist_odd) break;

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

    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

void insetrtionsort(int a[], int n);
void printarray(int n, int a[]);

void insetrtionsort(int a[], int n)
{
    int j, v;
    for (int i = 1; i < n; i++)
    {
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        for (int i = 0; i < n; i++)
        {
            cout << a[i] << " ";
        }
        cout << endl;
    }
}

void babblesort(int n, int a[])
{
    int flag = 1;
    int counter = 0;
    int tmp;
    while (flag)
    {
        flag = 0;
        for (int j = n - 1; j > 0; j--)
        {
            if (a[j] < a[j - 1])
            {
                swap(a[j], a[j - 1]);
                counter++;
                flag = 1;
            }
        }
    }
    printarray(n, a);
    cout << counter << endl;
}

void printarray(int n, int a[])
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i];
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
}

int gcd(int a, int b)
{
    if (a < b)
    {
        int t = a;
        a = b;
        b = t;
    }
    cout << a << " " << b << endl;
    if (b == 0)
        return a;
    else
        return gcd(b, b % a);
}

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    babblesort(n, a);
    return 0;
}



Measured memory_bytes: 3128
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 101000
char s[MAXN];
int len;
int main()
{
	scanf("%s",s);
	len=strlen(s);
	if(s[0]==s[len-1])
	{
		if(len%2==1) printf("Second\n");
		else printf("First\n");
	}
	else
	{
		if(len%2==0) printf("Second\n");
		else printf("First\n");
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

const (
	A = 0
	B = 1
	C = 2
)

type Int2DMap map[ // IntMap は、map[Int][Int]に便利メソッドを追加します.
int]IntMap

type IntMap map[ // IntMap は、map[Int][Int]に便利メソッドを追加します.
int]int

func lib_MaxInt(values ...int) (max int, err error) {
	if len(values) == 0 {
		return 0, errors.New("empty slice is given")
	}
	max = values[0]
	for _, value := range values {
		if max < value {
			max = value
		}
	}
	return
}
func lib_MustMaxInt(values ...int) (max int) {
	max, err := lib_MaxInt(values...)
	if err != nil {
		panic(err)
	}
	return max
}
func lib_NewInt2DMap() Int2DMap {
	return map[int]IntMap{}
}
func (m Int2DMap) ChMax(key1, key2, value int, values ...int) (replaced bool, valueAlreadyExist bool) {
	max, _ := lib_MaxInt(append(values, value)...)
	if v, ok := m.Get(key1, key2); ok {
		if v < max {
			m.Set(key1, key2, max)
			return true, true
		} else {
			return false, true
		}
	}
	m.Set(key1, key2, max)
	return true, false
}
func (m Int2DMap) Get(key1, key2 int) (int, bool) {
	v1, ok := m[key1]
	if !ok {
		return 0, false
	}
	v2, ok := v1[key2]
	if !ok {
		return 0, false
	}
	return v2, true
}
func (m Int2DMap) Set(key1, key2, value int) (isNewValue bool) {
	v1, ok := m[key1]
	if !ok {
		m[key1] = map[int]int{}
		v1 = m[key1]
	}
	_, ok = v1[key2]
	v1[key2] = value
	return !ok
}
func (m IntMap) Values() (values []int) {
	for _, v := range m {
		values = append(values, v)
	}
	return
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N = parseInt(scanner.Text())
	a := make([]int, N)
	b := make([]int, N)
	c := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		a[i] = parseInt(scanner.Text())
		scanner.Scan()
		b[i] = parseInt(scanner.Text())
		scanner.Scan()
		c[i] = parseInt(scanner.Text())
	}
	fmt.Println(solve(N, a, b, c))
}
func parseInt(s string) int {
	ret, _ := strconv.ParseInt(s, 10, 64)
	return int(ret)
}
func solve(N int, a []int, b []int, c []int) int {
	m := lib_NewInt2DMap()
	m.Set(0, A, 0)
	m.Set(0, B, 0)
	m.Set(0, C, 0)
	for i := 0; i < N; i++ {
		m.ChMax(i+1, A, m[i][B]+a[i], m[i][C]+a[i])
		m.ChMax(i+1, B, m[i][A]+b[i], m[i][C]+b[i])
		m.ChMax(i+1, C, m[i][A]+c[i], m[i][B]+c[i])
	}
	return lib_MustMaxInt(m[N].Values()...)
}


Measured memory_bytes: 27520
#include "bits/stdc++.h"
using namespace std;

int main() {
	char ch;
	int a[26]={};

	while (cin >> ch) {
		ch=tolower(ch);
		if(isalpha(ch)){a[ch-'a']++;}
	}
	for (int i = 0; i < 26; ++i) {
		printf("%c : %d\n",i+'a',a[i]);
	}
	return 0;
}

Measured memory_bytes: 3208
// {{{
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)x.size())
#define FOR(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
using LL=long long;
using PII=pair<int,int>;
using VI=vector<int>;

#ifdef FEI
template<typename T>
void _dump(const char* s, T&& head) { cerr<<s<<"="<<head<<endl; }
template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
    int c=0;
    while (*s!=',' || c!=0) {
        if (*s=='(' || *s=='[' || *s=='{') c++;
        if (*s==')' || *s==']' || *s=='}') c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1, tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, ##__VA_ARGS__); \
} while(0);

template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<'[';
    for (auto it=b; it!=e; it++) s<<(it==b?"":",")<<*it;
    s<<']';
    return s;
}

template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) { return s<<"("<<p.first<<","<<p.second<<")";}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &x) { return _out(s,ALL(x)); }
template<typename T, size_t N>
ostream& operator <<(ostream &s, const array<T,N> &x) { return _out(s,ALL(x)); }
template<typename T>
ostream& operator <<(ostream &s, const set<T> &x) { return _out(s,ALL(x)); }
template<typename A, typename B>
ostream& operator <<(ostream &s, const map<A,B> &x) { return _out(s,ALL(x)); }
#else
#define dump(...)
#endif

template<typename T>
void _R(T &x) { cin>>x; }
void _R(int &x) { scanf("%d",&x); }
void _R(LL &x) { scanf("%" PRId64,&x); }
void _R(double &x) { scanf("%lf",&x); }
void _R(char &x) { scanf(" %c",&x); }
void _R(char *x) { scanf("%s",x); }

void R(){}
template<typename T, typename... X>
void R(T& head, X&... tail) { _R(head); R(tail...); }
// }}}


const int N = 100005;
int arr[N*3];
LL pre[3*N], post[3*N];

int main() {
    int n, n3;
    R(n);
    n3 = n*3;

    for (int i=0; i<n3; i++)
        R(arr[i]);


    priority_queue<int> maxQ;
    priority_queue<int, vector<int>, greater<int>> minQ;


    for (LL i=0, sum=0; i<n3; i++) {
        sum += arr[i];
        minQ.push(arr[i]);
        if (minQ.size() > n) {
            sum -= minQ.top();
            minQ.pop();
        }
        pre[i] = sum;
    }

    for (LL i=n3-1, sum=0; i>=0; i--) {
        sum += arr[i];
        maxQ.push(arr[i]);
        if (maxQ.size() > n) {
            sum -= maxQ.top();
            maxQ.pop();
        }
        post[i] = sum;
    }


    LL ans = LLONG_MIN;
    for (int i=n-1; i<n+n; i++) {
        ans = max(ans, pre[i] - post[i+1]);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x))
#define SORT(x) sort(ALL(x))
#define SUM(x) accumulate(ALL(A), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef vector<char> VC;
typedef vector<VC> VVC;
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 BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll N;
	ll result=0;
	cin>>N;
	vector<string> v(N);
	map<string, int> m;
	REP(i,N){
		string S;
		cin>>S;
		SORT(S);
		v[i]=S;
	}
	VI cnt;
	ll tmp=0;
	REP(i,N){
		m[v[i]]++;
	}
	for(auto w:m){
		if(w.second==1) continue;
		result+=(ll)w.second*(w.second-1)/2;
	}

	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int n,k;
string s;

int cnt; // order
int ans = 1;
int l,r; // syakutori
int main() {
    cin >> n >> k >> s;
    while(true) {
        while(r<n-1 && cnt<k) { 
            if(s[r]=='0' && s[r+1]=='1') cnt++;
            if(cnt==k) {
                while(r+1<n && s[r+1]=='1') {
                    r++;
                }
                r--;
            }
            r++;
        }
        ans = max(ans,r-l+1);
        if (cnt<k) break;

        cnt--;
        bool flg = true;
        while(flg) {
            if(s[l]=='0' && s[l+1]=='1') flg = false;
            l++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import sys
# input = sys.stdin.readline
inf = 10 ** 18
P = 10 ** 9 + 7

N = int(input())
A = [int(input()) for _ in range(N)]

A_sorted = sorted(A)

for Ai in A:
    if Ai == A_sorted[-1]:
        print(A_sorted[-2])
    else:
        print(A_sorted[-1])


Measured memory_bytes: 14112
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll N;
llvec e[100100];
llvec d;

ll bfs(ll s){
  queue<ll> q;
  q.push(s);
  d=llvec(N, 1e10);
  d[s]=0;
  while(!q.empty()){
    ll a = q.front();q.pop();
    rep(i, e[a].size()){
      if(d[e[a][i]]!=1e10){
        continue;
      }else{
        d[e[a][i]]=d[a]+1;
        q.push(e[a][i]);
      }
    }
  }
}
ll rF, rS;

ll dfs(ll from, ll cur, ll s){
  if(cur==N-1)return s;
  ll ans = -10;
  ll tmp = -10;
  rep(i, e[cur].size()){
    if(e[cur][i]==from)continue;
    else{
      tmp = dfs(cur, e[cur][i], s+1);
      if(tmp==-10)continue;
      if(tmp/2==s){
        rF = cur;
        rS = e[cur][i];
      }
    }
    if(tmp!=-10){
      return tmp;
    }
  }
  return ans;
}
llvec p,cnt;

P root(ll a){
  ll atmp=a;
  ll c=0;
  while(atmp!=p[atmp]){
    atmp=p[atmp];
    c++;
  }
  p[a]=atmp;
  return{c, atmp};

}
ll con(ll a, ll b){
  P ar=root(a);
  P br=root(b);
  if(ar.second!=br.second){
    if(ar.first<br.first)swap(ar,br);
    p[br.second]=ar.second;
    cnt[ar.second]+=cnt[br.second];
  }
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N;
  llvec a(N), b(N);
  p = llvec(N);
  cnt = llvec(N,1);
  rep(i, N-1){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    e[a[i]].push_back(b[i]);
    e[b[i]].push_back(a[i]);
    p[i]=i;
  }
  p[N-1]=N-1;
  ll dist = dfs(-1, 0, 0);

  //cout << rF+1<< " "<<rS+1<<" " << dist;
  //e[rF].erase(lower_bound(ALL(e[rF]), rS));
  //e[rS].erase(lower_bound(ALL(e[rS]), rF));

  rep(i, N-1){
    if(a[i]==rF and b[i]==rS)continue;
    if(b[i]==rF and a[i]==rS)continue;
    con(a[i], b[i]);
  }
  if(cnt[root(rF).second]<=cnt[root(rS).second]){
    cout << "Snuke";
  }else{
    cout << "Fennec";
  }
  
  return 0;
}


Measured memory_bytes: 16640
#include <iostream>

int main() {
    int N;
    int A, B;

    std::cin >> N;
    if (N == 1) {
        std::cout << "Hello World" << std::endl;
    } else {
        std::cin >> A >> B;
        std::cout << A+B << std::endl;
    }

    return 0;
}


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

using namespace std;

int main()
{
	while(1)
	{
		double x,y;
		int s;
		map<int,int> zei;//税が加わる前
		int ans=0;
		cin>>x>>y>>s;
		x+=100.0f;
		y+=100.0f;
		if(s==0)
			break;
		
		for(int i=0;i<1001;i++)
		{
			int tmp=(double)i*x/100.0f;
			zei[tmp]=i;
		}

		//全探索
		for(int i=1;i<s;i++)
		{
			int kei=floor((double)zei[i]*y/100.0f)+floor((double)zei[s-i]*y/100.0f);
			ans=max(kei,ans);
		}

		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
int a[100001];
vector<int> G[100005];
vector<int> rG[100005];
int dist[100005];

int main(void){
	scanf("%d%d",&n,&k);
	queue<int> que;
	memset(dist,-1,sizeof(dist));
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>0){
			G[a[i]-1].push_back(i);
			rG[i].push_back(a[i]-1);
		}
	}
	for(int i=0;i<n;i++){
		if(G[i].size()==0){
			que.push(i);
			dist[i]=0;
		}
	}
	while(que.size()){
		int v=que.front();
		que.pop();
		for(int i=0;i<rG[v].size();i++){
			if(dist[rG[v][i]]==-1){
				dist[rG[v][i]]=dist[v]+1;
				que.push(rG[v][i]);
			}
		}
	}
	int res=0;
	for(int i=0;i<n;i++){
		if(dist[i]<k || rG[i].size()==0)res++;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 15004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
	int a; string s;
	cin>>a>>s;
	if(a>=3200){
		cout<<s<<endl;
	}else{
		cout<<"red"<<endl;
	}
	
}


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

using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back

int main(){
	fast;
	lli s,w;
	cin>>s>>w;
	if (w>=s) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
int powe(int n,int m){if(m==0)return 1;int t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
int mpowe(int n,int m){if(m==0)return 1;int t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
int logtwo(int n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid]<=x){y=mid;ceilsearch(ar,mid+1,high,x,y);}else{ceilsearch(ar,low,mid-1,x,y);}}
int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
   int n;
   cin>>n;
   map<ll,ll> m;
   ll x;
   int f=0;
   for(int i=0;i<n;i++)
   {
       cin>>x;
       if(m[x]==0)
       {
           m[x]=1;
       }
       else
       {
           f=1;
       }
   }
   if(f==0)
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;

}

Measured memory_bytes: 12800
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    REP(i, N) cin >> m[i];

    SORT(m);

    int sum = 0;
    REP(i, N) sum += m[i];

    X -= sum;

    int ans = N + X / m[0];
    cout << ans << endl;

    return 0;
}

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

int main() {
  int n, num=0;
  bool cnt=true;
  
  cin >> n;
  int a[n];
  for (int i=0; i<n; i++)
    cin >> a[i];
  while(1) {
    for (int i=0; i<n; i++) {
      if (a[i]%2 == 0) {
        a[i] /= 2;
      } else {
        cnt = false;
        break;
      }
    }
    if (cnt)
      num++;
    else
      break;
  }
  cout << num << endl;
    
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	for(int i=1;i<=min((int)sqrt(n),9);i++) {
		if((n/i)*i==n&&n/i<=9&&n/i>0){
			cout<<"Yes";
			return;
		}
	}
	cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3596
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A, B, C = in.next().toLong
  val s = Array.fill[String](N+2)("")
  for (i <- 1 to N) {
    s(i) = in.next()
  }
  val cnt = Array[Long](A, B, C)

  def f(now: String, a: Char): Unit = { // s(i), choice
    val b = now.filter(_ != a)(0)
    a match {
      case 'A' => cnt(0) += 1
      case 'B' => cnt(1) += 1
      case 'C' => cnt(2) += 1
    }
    b match {
      case 'A' => cnt(0) -= 1
      case 'B' => cnt(1) -= 1
      case 'C' => cnt(2) -= 1
    }
  }


  //
  var flag = true
  var ans = new Array[Char](N+1)
  val char = Array[Char]('A','B','C')

  breakable {
    if (cnt.sum == 0)
      flag = false
    else if (cnt.sum == 1) {
      for (i <- 1 to N) {
        val now = s(i)
        var a = '-'

        val (x, y, z) =
          now match {
            case "AB" => (0, 1, 2)
            case "BC" => (1, 2, 0)
            case "AC" => (2, 0, 1)
          }

        if (cnt(x) == 1)
          a = char(y)
        else if(cnt(y) == 1)
          a = char(x)
        else {
          flag = false
          break
        }

        f(now, a)
        ans(i) = a

      }
    }
    else {
      for (i <- 1 to N) {
        val now = s(i)
        var a = '-'

        val (x, y, z) =
          now match {
            case "AB" => (0, 1, 2)
            case "BC" => (1, 2, 0)
            case "AC" => (2, 0, 1)
          }

        if (cnt(x) == 0 && cnt(y) == 0) {
          flag = false
          break
        }
        else if (cnt(x) == 0)
          a = char(x)
        else if (cnt(y) == 0)
          a = char(y)
        else if (cnt(x) == 1 && cnt(y) == 1) {
          if (s(i+1).contains(char(x)))
            a = char(x)
          else
            a = char(y)
        }
        else {
          if (cnt(x) >= cnt(y))
            a = char(y)
          else
            a = char(x)
        }

        f(now, a)
        ans(i) = a
      }
    }
  }

  // output
  if (flag) {
    println("Yes")
    println(ans.drop(1).mkString("\n"))
  }
  else
    println("No")
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 64876
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<mint> dp(s+1);
  mint ans = 0;
  rep(i,n) {
    dp[0] += 1; // q += 1
    // { // q *= (1 + x^a[i])
      vector<mint> dpNext(s+1);
      rep(j,s+1) {
        dpNext[j] += dp[j];
        if (j+a[i] <= s) dpNext[j+a[i]] += dp[j];
      }
      dp = dpNext;
    // }
    ans += dp[s];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(){
  std::string s;
  std::cin>>s;
  
  int p = 0;
  for(size_t i = 0;i < s.size(); ++i)
    if(s[i]=='p')
      ++p;
  
  std::cout<<s.size()/2 - p<<'\n';
}

Measured memory_bytes: 512
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

# K個までの和，N-K個からの和
## print(min(N, K)*X+max(0, N-K)*Y)

result = 0
for i in range(1, N+1):
    if i <= K:
        result += X
    else:
        result += Y
print(result)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	if s == "a" || s == "i" || s == "u" || s == "e" || s == "o" {
		fmt.Println("vowel")
		return
	}
	fmt.Println("consonant")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    set<int> s;
    int now = 0;
    while (true) {
        now = (now + A % B) % B;
        if (s.count(now)) {
            break;
        } else {
            s.insert(now);
        }
    }
    if (s.count(C)) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
#include<cstring>
#include<cstdlib>

using namespace std;

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

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < 3; ++i) cnt += s[i] == 'o';

  cout << 700 + 100 * cnt << endl;
}


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

int main(){
int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  
  int tot=A*100, sug=0; // 砂糖水の質量、溶けている砂糖の質量を入れる変数
  for(int i=0; i<=100; i++){
   for(int j=0; j<=100; j++){
    for(int k=0; k<=100; k++){
     for(int l=0; l<=100; l++){
      int total_water=i*A*100+j*B*100;
      int total_sugar=k*C+l*D;
       if(total_water+total_sugar<=F){
        if(total_sugar*100<=E*total_water){ // total_sugar/total_water<=E/100より。
         if(sug*(total_sugar+total_water)<=total_sugar*tot){// ↑割ると0になるから掛けるる
          sug=total_sugar; // 初期値sugより大きいtotal_sugar+total_waterが来たら更新される
          tot=total_sugar+total_water;} // 全探索して最大値を入れる
        }
       }
     }
    } 
   }
  }
  
  cout<<tot<<" "<<sug<<endl;
}

Measured memory_bytes: 256
#include <cstdint>
#include <cstddef>

using i32 = std::int_fast32_t;
using u32 = std::uint_fast32_t;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

#include <iostream>
#include <cmath>

template<class Tp>
Tp digits_sum (Tp x, Tp base = Tp(10)) {
	Tp value = Tp(0);
	while (x > 0) {
		value += (x % base);
		x /= base;
	}
	return value;
}


template<class Tp>
inline void chmin (Tp &a, const Tp &b) {
	if (a > b) a = b;
}

constexpr i64 INF = (1LL << 60);

int main() {
	i64 n, s;
	std::cin >> n >> s;

	if (n == s) {
		std::cout << n + 1 << '\n';
		return 0;
	}
	
	const i64 sqrt = std::sqrt(n) + 1;
	for (i64 b = 2; b <= sqrt; b++) {
		if (digits_sum(n, b) == s) {
			std::cout << b << '\n';
			return 0;
		}
	}
	
	i64 ans = INF;
	for (i64 p = 1; p <= sqrt; p++) {
		i64 b = (n - s) / p + 1;
		if (b < 2) continue;
		if (digits_sum(n, b) == s) chmin(ans, b);
	}
	
	if (ans == INF) ans = -1;
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
int main()
{
	int n,a[100][100],b,f,r,v,i,j;
	
	for(i=1;i<13;i++)
	{
		for(j=1;j<11;j++)
		{
			a[i][j]=0;
		}
	}
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d %d",&b,&f,&r,&v);
		
		a[3*(b-1)+f][r]=a[3*(b-1)+f][r]+v;
	}
	
	for(i=1;i<13;i++)
	{
		
		
		for(j=1;j<11;j++)
		{
			printf(" %d",a[i][j]);
		}
		
		printf("\n");
		
		if((i==3)||(i==6)||(i==9))
			printf("####################\n");
	}
	
	
	
	return 0;
}

Measured memory_bytes: 624
#!/usr/bin/env python3


def main():
    T = list(input())
    N = len(T)
    i = 0
    while i < N:
        if T[i] == '?':
            if i == 0 or i == N-1:
                T[i] = 'D'
                i += 1
            elif T[i-1] == 'D':
                if T[i+1] == '?':
                    T[i] = 'P'
                    T[i+1] = 'D'
                    i += 2
                elif T[i+1] == 'D':
                    T[i] = 'P'
                    i += 1
                else:
                    T[i] = 'D'
                    i += 1
            else:
                T[i] = 'D'
                i += 1
        else:
            i += 1
    U = ''.join(T)
    print(U)

if __name__ == "__main__":
    main()


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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    println!("{}{}{}", s[0], s.len() - 2, s.last().unwrap());
}


Measured memory_bytes: 4352