akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main() {
    string N;
    int A, B, C, D;
    cin >> N;
    
    A = stoi(N.substr(0, 1));
    B = stoi(N.substr(1, 1));
    C = stoi(N.substr(2, 1));
    D = stoi(N.substr(3, 1));

    
    bool flag = 0;
    int check;
    bool op1, op2, op3;
    string sop1, sop2, sop3;
    for (int i = 0; i < 2; ++i)
    {
        for (int j = 0; j < 2; ++j)
        {
            for (int k = 0; k < 2; ++k)
            {
               if (i == 0)
               {
                   if (j == 0)
                   {
                       if (k == 0)
                       {
                           check = A + B + C + D;
                       }
                       else
                       {
                           check = A + B + C - D;
                       }
                   }
                   else
                   {
                       if (k == 0)
                       {
                           check = A + B - C + D;
                       }
                       else
                       {
                           check = A + B - C - D;
                       }
                   }
               }
                else
                {
                    if (j == 0)
                    {
                        if (k == 0)
                        {
                            check = A - B + C + D;
                        }
                        else
                        {
                            check = A - B + C - D;
                        }
                    }
                    else
                    {
                        if (k == 0)
                        {
                            check = A - B - C + D;
                        }
                        else
                        {
                            check = A - B - C - D;
                        }
                    }
                }
                if (check == 7)
                {
                    op1 = i;
                    op2 = j;
                    op3 = k;
                    flag = 1;
                    break;
                }
            }
            if (flag == 1)
            {
                break;
            }
        }
        if (flag == 1)
        {
            break;
        }
    }
    
    if (op1 == 0)
    {
        sop1 = "+";
    }
    else
    {
        sop1 = "-";
    }
    if (op2 == 0)
    {
        sop2 = "+";
    }
    else
    {
        sop2 = "-";
    }
    if (op3 == 0)
    {
        sop3 = "+";
    }
    else
    {
        sop3 = "-";
    }
    
    cout << to_string(A) + sop1 + to_string(B) + sop2 + to_string(C) + sop3 + to_string(D) + "=7"<< endl;

    
    return 0;
}

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

int main(void) {
    string str;
    cin >> str;
    
    int ans = 0;
    for (int i=0; i<4; i++) {
        if (str[i] == '+') ans++;
        else ans--;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3600
#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) - 1
#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 = 3;
    rep(i,0,N){
        rep(j,0,N){
            char tmp;
            cin >> tmp;
            if(i == j)cout << tmp;
        }
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
// warm-up
// Good one
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), i = 0, r = 0, t = 0, max=Integer.MIN_VALUE;
		int[][] g = new int[2][n];
		int[] ltor = new int[n];
		int[] rtol = new int[n];
		while (r<2) {
			while (i<n) g[r][i++] = sc.nextInt();	
			r++; i=0;
		}
		i=0; t=0;
		for (int a : g[0]) { t+=a; ltor[i++]=t; }
		i=0; t=0;
		for (i=n-1; i>=0; i--) { t+=g[1][i]; rtol[i]=t; }
		for (i=0; i<n; i++) max = Math.max(ltor[i]+rtol[i], max);
		System.out.println(max);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

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

int main(){
	// sengen
	LL n;
	// nyuryoku
	cin >> n;
	LL a[n];
	LL sum;
	for(LL i=0;i<n;i++){
		cin >> a[i];
		if(i == 0){
			sum = a[i];
		}else{
			sum = sum ^ a[i];
		}
	}
	// keisan
	for(LL i=0;i<n;i++){
		LL ans = sum ^ a[i];
		cout << ans << ' ';
	}
	// syutsuryoku
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
#define DBG(x) cerr << #x << “ = ” << (x) << endl
#define Rep(i,a,b) for (int i = a, to = b; i < to; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

typedef long long Long;

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	int x,y;
    cin>>x>>y;
    if(4*x>=y&&y>=2*x&&(y-2*x)%2==0&&(4*x-y)%2==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long  N;
    cin >> N;

    long long  count=0;
    for(;;){ 
      if(N==1){
          break;
      }
      N/=2;
      count++;
     }
 
     long long sum=0;
     for(int i=0;i<=count;i++){
         sum +=pow(2,i);
     }
     cout << sum << endl;
}

Measured memory_bytes: 4100
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    sort(d.begin(), d.end());

    int boundary;
    if(N%2==0) boundary = N/2 - 1;
    if(d[boundary+1] == d[boundary]) {
        cout << 0 << endl;
    } else {
        cout << d[boundary+1] - d[boundary] << endl;
    }

    return 0;
}

Measured memory_bytes: 768
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[derive(Eq, PartialEq, Clone, Debug)]
struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    #[inline]
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    #[inline]
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    let n = get!(usize);
    let mut aa = util::gets::<u64>();

    aa.sort_by_key(|&a| Rev(a));

    let ans = (0..n)
        .map(|i| unsafe { aa.get_unchecked(i * 2 + 1) })
        .sum::<u64>();

    println!("{}", ans);
}


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

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

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: usize = input();
    let a_vec = input_vec();
    let mut sum_vec: Vec<u64> = vec![0u64; n];
    for a in a_vec {
        sum_vec[(a - 1) as usize] += 1;
    }
    for n in sum_vec {
        println!("{}", n);
    }
}


Measured memory_bytes: 5024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a, b, c, x, y;

int main() {
	cin >> a >> b >> c >> x >> y;
	ll ans = min(a + b, 2 * c)*min(x, y);
	if (x < y) {
		ans += min(b*(y - x), 2 * c*(y - x));
	}
	else if (x > y) {
		ans += min(a*(x - y), 2 * c*(x - y));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		int[] c = new int[26];
		for (int i=0; i<S.length; i++) {
			c[S[i]-'a']++;
		}
		for (int i=0; i<c.length; i++) {
			if (c[i] == 0) {
				System.out.println((char)(i + 'a'));
				return;
			}
		}
		System.out.println("None");
	}
}


Measured memory_bytes: 25172
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for _ in range(M)]
idx=sorted(range(M),key=lambda x:PY[x][1])
PY.sort(key=lambda x:x[1])
flag=[1]*N
keep=[]
for P,Y in PY:
  keep.append(str(P).zfill(6)+str(flag[P-1]).zfill(6))
  flag[P-1]+=1
  
ans=[0]*M
for i,k in zip(idx,keep):
  ans[i]=k
  
for a in ans:
  print(a)

Measured memory_bytes: 41448
#include<stdio.h>
int main(){
  int x,y,h;

  while(scanf("%d%d",&x,&y)!=EOF)
    {
      while(y!=0)
	{
	  x=x%y;
	  h=x;
	  x=y;
	  y=h;
	}

      printf("%d\n",x);
    }    
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		char[] a = sc.next().toCharArray();
		
		System.out.println(solve(N, a));
		sc.close();
	}
	
	static int solve(int N, char[] a) {
		int[] b = new int[N-1];
		boolean[] used = new boolean[3];
		for(int i=0; i<N-1; i++) {
			b[i] = Math.abs(a[i]-a[i+1]);
			used[b[i]] = true;
		}
		
		if(used[0] && used[1] && used[2]) {
			for(int i=0; i<N-1; i++) {
				if(b[i]==2)
					b[i] = 0;
			}
			return solve2(N-1, b);
		}
		if(used[0] && used[1] && !used[2]) {
			return solve2(N-1, b);
		}
		if(used[0] && !used[1] && used[2]) {
			for(int i=0; i<N-1; i++) {
				if(b[i]==2)
					b[i] = 1;
			}
			return solve2(N-1, b)*2;
		}
		if(!used[0] && used[1] && used[2]) {
			int[] c = new int[N-2];
			for(int i=0; i<N-2; i++) {
				c[i] = Math.abs(b[i]-b[i+1]);
			}
			return solve2(N-2, c);
		}
		if(N-1==1)
			return b[0];
		else
			return 0;
	}
	
	static int solve2(int N, int[] v) {
		int ans = 0;
		for(int i=0; i<N; i++) {
			if(v[i]==1)
				ans += get(N-1, N-i-1);
		}
		return ans%2;
	}
	
	static int get(int y, int x) {
		int v=1;
		while(v<=y)
			v<<=1;
		v>>=1;
		while(v>1) {
			y%=v;
			x%=v;
			if(y<x)
				return 0;
			v>>=1;
		}
		return 1;
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  string s;
  cin >> s;
  string t = "CODEFESTIVAL2016";
  assert(s.size()==t.size());
  int ans = 0;
  for(int i=0;i<s.size();i++)if(s[i]!=t[i])ans++;
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <bitset>

using namespace std;

typedef pair <int, int> ii;

//#define DEBUG

int N;
vector <int> adjList[100005];

int k;
int getMaxK(int u, int prevP)
{
    if (u != 1 && adjList[u].size() == 1) return 1;
    vector <int> labels;
    for (int v : adjList[u])
    {
        if (prevP == v) continue;
        labels.push_back(getMaxK(v, u));
    }

    #ifdef DEBUG
    printf("%d:", u);
    for (int label : labels)
    {
        printf(" %s", bitset<3>(label).to_string().c_str());
    }
    printf("\n");
    #endif // DEBUG

    bool found = false;
    int closestZero;
    for (int k = 20; k >= 0 && !found; k--)
    {
        bool allZero = true;
        bool hasOne = false;
        for (int label : labels)
        {
            if (label & (1 << k))
            {
                allZero = false;
                if (hasOne)
                {
                    found = true;
                    break;
                }
                else
                {
                    hasOne = true;
                }
            }
        }
        if (allZero) closestZero = k;
    }
    k = max(k, closestZero);
    int resLabel = 0;
    for (int label : labels) resLabel |= label;
    resLabel &= ~((1 << closestZero) - 1);
    resLabel |= (1 << closestZero);
    return resLabel;
}

int main()
{
    scanf("%d", &N);
    for (int i = 1; i < N; i++)
    {
        int a, b; scanf("%d%d", &a, &b);
        adjList[a].push_back(b), adjList[b].push_back(a);
    }
    int label = getMaxK(1, -1);
    k = max(k, (int) log2(label & -label));
    printf("%d\n", k);
    return 0;
}


Measured memory_bytes: 12544
#include<cstdio>

int main(){
	bool sub[30];

	for(int i=0;i<30;i++)sub[i] = false;

	for(int i=0;i<28;i++){
		int tmp;
		scanf("%d",&tmp);
		sub[tmp-1] = true;
	}

	for(int i=0;i<30;i++){
		if(!sub[i])printf("%d\n",i+1);
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int diff[100010];
int main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> diff[i];
	}
	sort(diff, diff + n);
	int left = diff[n/2-1];
	int right = diff[n/2];
	cout << right - left << endl;
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N = Scanner.int()
    if N >= 30:
        print('Yes')
    else:
        print('No')


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10680
//Prachurja
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n1,n2,n3,N;
    scanf("%d",&n1);
    scanf("%d",&n2);
    scanf("%d",&n3);
    N=n1+n2+n3;


    if(N>=22)
        printf("bust");
    else
        printf("win");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>

#define PB push_back

using namespace std;

const int N = 2005;

vector < int > v[N];
int n, k;

int rezi(int x, int lst,int dis, int lim){
	int ret = (dis > lim);
	for(int y : v[x])
		if(y != lst)
			ret += rezi(y, x, dis + 1, lim);
	return ret;
}

int main(){
	scanf("%d%d", &n, &k);
	for(int i = 1;i < n;i++){
		int x, y; scanf("%d%d", &x, &y);
		v[x].PB(y), v[y].PB(x);
	}
	int sol = n;
	for(int i = 1;i <= n;i++){
		int ekstra = 0, sve = 0;
		for(int y : v[i]){
			sve += rezi(y, i, 1, k / 2);
			ekstra = max(ekstra, rezi(y, i, 1, k / 2) - rezi(y, i, 1, (k + 1) / 2));
		}
		sol = min(sol, sve - ekstra);
	}
	printf("%d\n", sol);
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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

int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll b1 = b;
    double b2 = b - b1;
    ll res = b1 * a;
    ll b3 = ll(b2 * 100 + 0.5);
    b3 *= a;
    ll res2 = b3 / 100;
    cout << res2 + res << endl;
}

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

int main() {
  int n;
  long result,pre,prepre;
  cin >> n;
  pre=1ll;
  prepre=2ll;
  if (n==1){
    result=pre;
  }else{
    for (int i=2;i<=n;i++){
      result=pre+prepre;
      prepre=pre;
      pre=result;
    }
  }
  cout<<result<<endl;
}


Measured memory_bytes: 256
now = [0, 0, 0, 0]

for i in range(3):
    a, b = map(int, input().split())
    now[a-1]+=1
    now[b-1]+=1
    
f1 = 0
f2 = 0

flag = -1

for i in range(4):
    if now[i]==1:
        f1 += 1
    elif now[i]==2:
        f2 += 1

if f1==2 and f2==2:
    flag = 1
    
if flag>0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner cin=new Scanner(System.in);
                String s=cin.next();
                if((s.equals("abc"))||(s.equals("acb"))||(s.equals("bac"))||(s.equals("cab"))||(s.equals("bca"))||(s.equals("cba"))){
                                System.out.println("Yes");
                }
                else{
                        System.out.println("No");
                }
        }
}

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

typedef long long ll;

int main() {
    ll N, M, MOD = 1e9 + 7, ans = 1;
    cin >> N >> M;
    if (abs(N - M) > 1) ans = 0;
    for (int i = 1; i <= N; i++) ans = (ans * i) % MOD;
    for (int i = 1; i <= M; i++) ans = (ans * i) % MOD;
    if (N == M) ans = (ans * 2) % MOD;
    cout << ans << "\n";
}


Measured memory_bytes: 3600
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

using namespace std;
typedef long double ld;
const int N = 3e3+5;
ld p[N];
ld dp[N][N/2];
bool visited[N][N/2];

class ICoins {
public:
    int n;
    ld rec(int i, int tails) {
        if(tails > n/2) return 0;
        if(i == n) return 1;
        if(visited[i][tails]) return dp[i][tails];
        ld res = p[i]*rec(i+1, tails) + (1-p[i])*rec(i+1, tails + 1);
        visited[i][tails] = true;
        return dp[i][tails] = res;
    }
	void solve(std::istream& in, std::ostream& out) {
        in >> n;
        for(int i = 0; i < n; ++i) in >> p[i];
        memset(visited, false, sizeof visited);
        out << setprecision(10);
        out << rec(0, 0);
	}
};


int32_t main() {
	ICoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 75264
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B0Or1Swap solver = new B0Or1Swap();
        solver.solve(1, in, out);
        out.close();
    }

    static class B0Or1Swap {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (check(a, n)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
            out.println("NO");
        }

        boolean check(int a[], int n) {
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            }
            return true;
        }

    }
}



Measured memory_bytes: 21588
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
	sync;
	ll n,q;
	string s;
	cin>>n>>q>>s;
	ll arr[n+1]={0};
	for(ll i=2;i<=n;i++)
	{
		arr[i]=arr[i-1];
		if(s[i-2]=='A'&&s[i-1]=='C')
		arr[i]+=1;
	}
	while(q--)
	{
		ll l,r;
		cin>>l>>r;
		ll ans=arr[r]-arr[l-1];
		if(arr[l]!=arr[l-1])ans--;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1872
#include<stdio.h>
int Block[30][6];
int score=0,n;
void Jo();
int main()
{
  int i,j,score1[1000],m=0;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<20;i++){
      for(j=0;j<6;j++){
	Block[i][j]=0;
      }
    }
    for(i=10;i<n+10;i++){
      for(j=0;j<5;j++){
        scanf("%d",&Block[i][j]);
      }
    }
    Jo();
    score1[m]=score;
    score=0;
    m++;
  }
  for(i=0;i<m;i++){
    printf("%d\n",score1[i]);
  }
  return 0;
}

void Jo()
{
  int i,j,m,s,score1=0,k,l;
  while(1){
    for(i=10;i<n+10;i++){
      for(j=0;j<3;j++){
	if(Block[i][j]!=0 &&Block[i][j]==Block[i][j+1]&&Block[i][j]==Block[i][j+2]){
	  score1+=3*Block[i][j];
	  if(j==0&&Block[i][j]==Block[i][j+3]){
            score1+=Block[i][j];
            if(Block[i][j]==Block[i][j+4])score1+=Block[i][j];
	  }
	  if(j==1 && Block[i][j]==Block[i][j+3])score1+=Block[i][j];
	  j+=2;
}
      }
    }
    if(score1==0)return;
    score+=score1;
    score1=0;
    for(i=10;i<n+10;i++){
      if(Block[i][0]!=0){
        s=Block[i][0];
        m=1;
      }
      for(j=1;j<6;j++){
	if(Block[i][j-1]==0 &&Block[i][j]!=0){
	  s=Block[i][j];
	  m=0;
	}
	if(s==Block[i][j])m++;
	if(m>=3 && s!=Block[i][j]){
	  for(k=j-1;m>0;k--){
            for(l=i;l>0;l--){
	      Block[l][k]=Block[l-1][k];
	    }
            m--;
	  } 
	}
	if(s!=Block[i][j]){
	  s=Block[i][j];
	  m=1;
	}
      }
    }
  }
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

const int MAX_V = 10001;
const double INF = 1e+8;
typedef pair<double,int> P;

struct edge{
	int to;
	double cost;
	edge(int v, double cost_){
		to = v;
		cost = cost_;
	}
};

// 頂点数
int V;
// G[u][i] = ノード u に接続している i 番目の edge が返ってくる
vector<edge> G[MAX_V];
// 始点 s からの最短距離 (存在しない場合は INF )
double d[MAX_V];
// prev[v] := ノード v の直前に訪れた頂点 (存在しないときは -1 )
int prev[MAX_V];

// vector の出力
template<class T>
void output(vector<T> v){
	for(int i = 0 ; i < v.size() ; i++ ){
		cout << v[i]+1;
		if( i < v.size()-1 )
			cout << " ";
	}
	cout << endl;
}

// 初期化
void init(int n){
	V = n;
	for(int i = 0 ; i < MAX_V ; i++ ){
		G[i].clear();
	}
}

// 始点 s としたダイクストラ法
void dijkstra(int s){
	// greater<P> を指定することで first が小さい順に取り出せる
	priority_queue<P, vector<P>, greater<P> > q;
	fill( d , d+V , INF );
	fill( prev , prev+V , -1 );
	d[s] = 0.0;
	q.push( P(0.0,s) );
	
	while( !q.empty() ){
		P p = q.top(); q.pop();
		int v = p.second;
		if( d[v] < p.first ) continue;
		for(int i = 0 ; i < G[v].size() ; i++ ){
			edge e = G[v][i];
			if( d[e.to] > d[v] + e.cost ){
				d[e.to] = d[v] + e.cost;
				q.push( P(d[e.to],e.to) );
				prev[e.to] = v;
			}
		}
	}
}

// 重み cost の辺 (u,v) の追加
void add_edge(int u, int v, double cost){
	edge e( v , cost );
	G[u].push_back( e );
	e.to = u;
	G[v].push_back( e );
}

// 経路復元
vector<int> get_path(int t){
	vector<int> path;
	for( ; t != -1 ; t = prev[t] ){
		path.push_back( t );
	}
	reverse( path.begin() , path.end() );
	return path;
}

double D(int x1, int y1, int x2, int y2){
	return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

int main(){
	int n;
	while( cin >> n ){
		if( n == 0 ) break;
		// 初期化
		init( n );
		
		vector<pair<int,int> > v(n*2);
		for(int i=0 ; i < n*2 ; i++ ){
			v[i] = pair<int,int>(100000,100000);
		}
		for(int i=0 ; i < n ; i++ ){
			int b, x, y;
			cin >> b >> x >> y;
			v[b-1] = pair<int,int>(x,y);
		}
		
		for(int i=0 ; i < v.size() ; i++ ){
			for(int j=i+1 ; j < v.size() ; j++ ){
				int x1 = v[i].first;
				int y1 = v[i].second;
				int x2 = v[j].first;
				int y2 = v[j].second;
				if( x1 == 100000 || x2 == 100000 ) continue;
				double dist = D( x1 , y1, x2 , y2 );
				if( dist <= 50.0 ){
					add_edge( i , j , dist );
				}
			}
		}
		
		int m;
		cin >> m;
		for(int i = 0 ; i < m ; i++ ){
			int s,g;
			cin >> s >> g;
			s--; g--;
			dijkstra( s );
			int ans = d[g];
			if( ans == INF ){
				cout << "NA" << endl;
			}else{
				//cout << "path : " << endl;
				vector<int> path = get_path( g );
				//cout << path.size()+1 << endl;
				output( path );
			}
		}
	}
}

Measured memory_bytes: 0
import java.util.*;

public class Main{

	public static void main (String[] args) throws java.io.IOException{

		int x,y,z;
		Scanner in = new Scanner(System.in);
		x = in.nextInt();
		y = in.nextInt();
		z = in.nextInt();
		if(x < y && y < z){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17216
package main

import (
	"fmt"
	"sort"
)

type restaurant struct {
	id    int
	city  string
	point int
}

type restaurants []restaurant

func (r restaurants) Len() int {
	return len(r)
}

func (r restaurants) Less(i, j int) bool {
	if r[i].city == r[j].city {
		return r[i].point > r[j].point
	}
	return r[i].city < r[j].city
}

func (r restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	var n int
	fmt.Scan(&n)

	rs := make([]restaurant, n)
	for i := range rs {
		rs[i].id = i + 1
		fmt.Scan(&rs[i].city, &rs[i].point)
	}

	sort.Sort(restaurants(rs))

	for _, v := range rs {
		fmt.Println(v.id)
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

inline int gcd(int a, int b) { return (a%b == 0) ? b : gcd(b, a%b); }
inline int fac(int n) { return (n==0) ? 1 : n * fac(n - 1); }

int main() {
    ll n, d;
    cin >> n >> d;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

struct City {
	int id, pref, year;
};
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> city_count(n, 0);
	std::vector<City>city(m);
	for (auto i = 0; i < m; ++i) {
		std::cin >> city[i].pref >> city[i].year;
		city[i].id = i;
	}
	std::sort(city.begin(), city.end(), [](const City& a, const City& b) {return a.year < b.year; });
	std::vector<std::pair<City, int>> result;
	for (const auto& c : city) {
		result.emplace_back(c, ++city_count[c.pref - 1]);
	}
	std::sort(result.begin(), result.end(), [](const std::pair<City, int>& a, const std::pair<City, int>& b) {return a.first.id < b.first.id; });
	std::cout << std::setw(6) << std::setfill('0');
	for (const auto& r : result) {
		std::cout << std::setw(6) << std::setfill('0') << r.first.pref << std::setw(6) << std::setfill('0') << r.second << '\n';
	}
}



Measured memory_bytes: 4720
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read_vec::<usize>()[0] - 2;
    let v = read_vec::<i32>();

    let mut count = 0;
    for i in 0..n {
        if (v[i] < v[i + 1] && v[i + 1] < v[i + 2])
            || (v[i + 2] < v[i + 1] && v[i + 1] < v[i])
        {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <stdio.h>

char map[10][10];

int main(){
	for(int i = 1; i <= 3; i++){
		for(int j = 1; j <= 3; j++){
			scanf("%c",&map[i][j]);
		}
		char c; scanf("%c",&c);
	}
	printf("%c%c%c",map[1][1],map[2][2],map[3][3]);
}

Measured memory_bytes: 128
A, B = [int(item) for item in input().split()]
is_found = False

for i in range(10001):
    A_cal = int(i * 0.08)
    B_cal = int(i * 0.10)

    if A_cal == A and B_cal == B:
        print(i)
        is_found = True
        break
    
if not is_found:
    print(-1)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int A = 0, B = 0;
	for (int i = 0; i < 4; i++) {
		int a; cin >> a;
		A += a;
	}
	for (int i = 0; i < 4; i++) {
		int b; cin >> b;
		B += b;
	}
	cout << max(A, B) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;

int read() {
	int hh, mm;
	scanf("%d%d", &hh, &mm);
	return hh * 60 + mm;
}

int main() {
	int a = read(), b = read(), c;
	scanf("%d", &c);
	printf("%d\n", max(b - a - c, 0));
	return 0;
}

Measured memory_bytes: 3816
#include <stdio.h>
#define M 100000
main(){
	int n,k,str[M],flag = 0;
	scanf("%d",&n);
	scanf("%d",&k);
	if(k<1||k>500){
		return 0;
	}
	int i;
	for(i=0; i<n; i++){
		scanf("%d",&str[i]);
		if(k<1||k>500)
			return 0;
		if(str[i]>=k)
			flag++;
	}
	printf("%d",flag);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long

using namespace std;

vector<int> v[100005];
int n , m;
ll mem[100005];
ll dp(int s)
{
    if (v[s].size() == 0)return 0;
    if (mem[s] != -1)return mem[s];
    ll ret = 0;
    for (int i=0;i<v[s].size();i++)
    {
        int u = v[s][i];
        ret = max(ret , 1 + dp(u));
    }
    return mem[s] = ret;
}
int deg[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> m;
    for (int i=0;i<m;i++)
    {
        int x,y;
        cin >> x >> y;
        v[x].push_back(y);
        deg[y]++;
    }
    ll ans = 0;
    memset(mem,-1,sizeof mem);
    vector<int> roots;
    for(int i=1;i<=n;i++)
        if (!deg[i])roots.push_back(i);
    for (int i=0;i<roots.size();i++)
        ans = max(ans , dp(roots[i]));
        cout << ans << endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 11648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N,A;cin>>N>>A;
  if(N % 500 <= A) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AizuOnlineJudge {
    class Program {
        static void Main() {
            var nml = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ab = Enumerable.Range(0, 2).Select(i => Enumerable.Range(1, nml[i]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray()).ToArray();

            for (var i = 0; i < nml[0]; ++i) {
                var c = new long[nml[2]];
                for (var j = 0; j < nml[1]; ++j) {
                    for (var k = 0; k < nml[2]; ++k) {
                        c[k] += ab[0][i][j] * ab[1][j][k];
                    }
                }

                Console.WriteLine(string.Join(" ", c));
            }
        }
    }
}



Measured memory_bytes: 18504
import numpy as np

def solve(n, m, a, b):
    p = [-1] * (n+1)
    u = [1] * (n+1)
    def find(x):
        if p[x] == -1:
            return x
        else:
            return find(p[x])
    total = n * (n-1) // 2
    res = [total]
    for i in range(m-1, 0, -1):
        x, y = a[i], b[i]
        px = find(x)
        py = find(y)
        if px > py:
            px, py = py, px
        if px != py:
            n1 = u[px]
            n2 = u[py]
            p[py] = px
            u[px] = n1 + n2
            total -= n1 * n2
        res.append(total)
    return res[::-1]

n, m = map(int, input().split())
a = np.zeros(m, dtype=int)
b = np.zeros(m, dtype=int)
for i in range(m):
    a[i], b[i] = map(int, input().split())
print("\n".join(map(str, solve(n, m, a, b))))

Measured memory_bytes: 28956
n = int(input())
data = list(map(int, input().split()))

count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            i_ = data[i]
            j_ = data[j]
            k_ = data[k]
            # 全て異なる値
            if i_ != j_ and i_ != k_ and j_ != k_:
                # 三角形が作成可能
                if sum([i_, j_, k_]) - max(i_, j_, k_) > max(i_, j_, k_):
                    # print("作れる　:", i_, j_, k_)
                    count += 1
                else:
                    pass
                    # print("作れない:", i_, j_, k_)

print(count)


Measured memory_bytes: 9148
#include <bits/stdc++.h>
    using namespace std ;
     
    #define pb(n) push_back(n)
    #define fi first
    #define se second
    #define all(r) begin(r),end(r)
    #define vmax(ary) *max_element(all(ary))
    #define vmin(ary) *min_element(all(ary))
    #define debug(x) cout<<#x<<": "<<x<<endl
    #define fcout(n) cout<<fixed<<setprecision((n))
    #define scout(n) cout<<setw(n)
    #define vary(type,name,size,init) vector< type> name(size,init)
    #define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
    #define mp(a,b) make_pair(a,b)
     
    #define rep(i,n) for(int i = 0; i < (int)(n);++i)
    #define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
    #define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
    #define repa(n,array) for(auto &n :(array))
     
    using ll = long long;
    using pii = pair<int,int> ;
    using pll = pair<ll,ll> ;
     
    template<typename T>
    void O(T t){
      cout << t << endl;
    }
     
    const ll mod = 1e9+7;
    constexpr ll inf = 1e18;
    constexpr double PI = acos(-1.0) ;
    double eps = 1e-10 ;
    const int dy[] = {-1,0,1,0,1,-1,1,-1};
    const int dx[] = {0,-1,0,1,1,-1,-1,1};
     
    ll da[300001],db[300001],v[300001];
     
    int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      ll N;
      cin >> N;
      rep(i,3*N){
        cin >> v[i];
      }
      priority_queue<ll,vector<ll>,greater<ll>> a;
      ll A = 0,B = 0;
      rep(i, N * 2){
        A += v[i];
        a.push(v[i]);
        if(i >= N){
          ll k = a.top(); a.pop();
          A -= k;
        }
        if(i >= N -1){
          da[i] = A;
        }
      }
      priority_queue<ll> b;
      for(int i = 3*N - 1; i >= N; i--){
        B += v[i];
        b.push(v[i]);
        if(i < 2 * N){
          ll k = b.top(); b.pop();
          B -= k;
        }
        if(i <= 2 * N){
          db[i] = B;
        }
      }
      ll ans = -inf;
      for(int i = N - 1; i < 2 * N; i++){
        /* cout << da[i] << ' ' << db[i+1] << endl; */
        ans = max(ans,da[i]-db[i+1]) ;
      }
      cout << ans << endl;
     
      return 0;
    }

Measured memory_bytes: 8820
loop do

n, x = gets.split.map{|v|
  v.to_i
}
  if n == 0 && x == 0
    break
  end
  count = 0
  for i in 1..n
    for j in i+1..n
      for k in j+1..n
        if x == i + j + k
          count += 1
        end
      end
    end
  end

print count, "\n"

end


Measured memory_bytes: 6876
import java.util.*; 
import java.io.*; 


public class Main {
	public static void main(String[] args) throws IOException { 
      InputReader in = new InputReader(System.in) ;
      String a = in.readString(); 
      String b = in.readString(); 
      String c = in.readString(); 
      if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
    	  System.out.println("YES"); 
      }
      else System.out.println("NO"); 
    }
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 23380
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001
#define mod 1000000007
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl>
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define google cout << "Case #" << ++it << ": " << ans << endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll it = 0, ans = 0;

ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (auto i=2; i<MAXN; i++)
  		spf[i] = i;
  	for (auto i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (auto i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (auto j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
	return;
}

vl getFactorization(ll x)
{
    vl ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}


void check()
{
	ll k;
	string s;
	cin >> k >> s;
	if(s.size()<=k) cout << s;
	else {
		// cout << k << endl;
		for(int i=0;i<k;i++) cout << s[i];
		cout << "...";
	}
    return ;
}

int32_t main()
{
    fastio
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}


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

 int main() {
   int L;

   cin >> L;

   cout << fixed << setprecision(10) << (L / 3.0) * (L / 3.0) * (L / 3.0) << endl;

 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

ll inf=1e18;

int main() {
  ll v,e;
  cin >> v >> e;
  vector<vector<ll>> d(v,vector<ll>(v,inf));
  for(ll i=0;i<v;i++) {
    d[i][i]=0;
  }
  for(ll i=0;i<e;i++) {
    ll s,t,dis;
    cin >> s >> t >> dis;
    d[s][t]=dis;
  }
  for(ll k=0;k<v;k++) {
    for(ll f=0;f<v;f++) {
      for(ll t=0;t<v;t++) {
        if(d[f][k]!=inf&&d[k][t]!=inf) {
          d[f][t]=min(d[f][t],d[f][k]+d[k][t]);
        }
      }
    }
  }
  for(ll f=0;f<v;f++) {
    if(d[f][f]<0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }
  for(ll f=0;f<v;f++) {
    for(ll t=0;t<v;t++) {
      if(t!=0) {
        cout << " ";
      }
      if(d[f][t]==inf) {
        cout << "INF";
      }
      else {
        cout << d[f][t];
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3240