akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env ruby
n = gets.chomp.to_i
inputs = gets.chomp.split(' ').map(&:to_i)
result = 0

inputs.each_with_index do |input, i|
  j = i + 1
  while j < n
    m = j + 1
    while m < n
      if [inputs[i], inputs[j], inputs[m]].uniq.length == 3 &&
        inputs[i] < inputs[j] + inputs[m] && inputs[j] < inputs[m] + inputs[i] && inputs[m] < inputs[j] + inputs[i]
        result += 1
      end
      m += 1
    end
    j += 1
  end
end

puts result


Measured memory_bytes: 14568
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005];
int main(void)
{
	int flag=1;
	long long sum=0;
	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>a[i];
		sum+=a[i];
	}
	if(sum%((1+n)*n/2)!=0)flag=0;
	long long m=sum/((1+n)*n/2);
	for (int i = 0; i < n; i++) {
		if((a[(i+n-1)%n]-a[i]+m)%n!=0)flag=0;
		if((a[(i+n-1)%n]-a[i]+m)/n <0)flag=0;

	}
	if(flag==1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = iB;
            if (iA >= 6 && iA <= 12) { iOut /= 2; }
            if (iA <= 5) { iOut = 0; }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
"""
Greedy algorithms - Huffman Coding
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_15_D&lang=jp

"""
import sys
from collections import Counter

class Node:
    def __init__(self, v, f):
        self.val = v
        self.freq = f
        self.left = None
        self.right = None


def solve(s):
    res = [Node(k, v) for k, v in Counter(s).items()]
    while len(res) > 1:
        res.sort(key=lambda x: x.freq)
        z = Node('@', res[0].freq + res[1].freq)
        z.left, z.right = res[0], res[1]
        res = res[2:]
        res.append(z)

    d = dict()
    stack = [(res[0], '')]
    while stack:
        n, st = stack.pop()
        if not n.left and not n.right:
            st = '0' if not st else st
            d[n.val] = st
        if n.left:
            stack.append((n.left, st+'0'))
        if n.right:
            stack.append((n.right, st+'1'))
    return len(''.join([d[ch] for ch in s]))


def main(args):
    s = input()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 7432
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord

import qualified Data.IntMap as M
import qualified Data.Sequence as S

import Data.Foldable

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)


main :: IO ()
main = do
    [n,q] <- r' :: IO [Int]


    ab <- replicateM (n-1) $ do
        [a,b] <- r'
        return (a, S.singleton b)
    
    let mp = M.fromListWith (S.><) ab :: M.IntMap (S.Seq Int)

    px <- replicateM q rp

    let pMap = M.fromListWith (+) px :: M.IntMap Int

    let slMp = solve 1 0 mp pMap
    putStrLn $ intercalate " " $ map (show . snd) (sortBy (comparing fst) $ toList slMp)


solve :: Int -> Int -> M.IntMap (S.Seq Int) -> M.IntMap Int -> S.Seq (Int,Int)
solve pos vac mp pMap =
    let children = case M.lookup pos mp of
                    Just c -> c
                    Nothing -> S.empty
        curVal = case M.lookup pos pMap of
                    Just v -> v
                    Nothing -> 0
        nVal  = curVal + vac
        nacMp = (pos,nVal)
    in -- traceShow (pos,vac,nVal) $
        nacMp S.<| (do  nPos <- children
                        solve nPos nVal mp pMap)



Measured memory_bytes: 169468
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000

int main(){

	long long H,W;
	cin>>W>>H;
	
	vector<pair<long long,int>> V;
	
	for(int i=0;i<W;i++){
		long long P;
		cin>>P;
		V.emplace_back(P,0);
	}
	
	for(int i=0;i<H;i++){
		long long P;
		cin>>P;
		
		V.emplace_back(P,1);
	}
	
	sort(V.begin(),V.end());
	
	long long ans = 0;
	
	H++;
	W++;
	
	for(int i=0;i<V.size();i++){
		if(V[i].second == 0){
			ans += V[i].first * H;
			W--;
			if(W<0)W=0;
		}
		else{
			ans += V[i].first * W;
			H--;
			if(H<0)H=0;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <cmath>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )

int N, X;
int A[100];
int main() {
    cin >> N >> X;
    rep(i, 0, N) {
        cin >> A[i];
    }
    sort(A, A + N);
    int cnt = 0;
    rep(i, 0, N) {
        X -= A[i];
    }
    cout << N + (X/A[0]) << endl;
}

Measured memory_bytes: 888
x, n= map(int, input().split(' '))

if n!= 0:
	ps= input().split(' ')
else:
	ps=[]

def in_ps(x):
	for p in ps:
		if x==int(p):
			return True
	return False
d=1

while 1:
	if in_ps(x):
		x+= d*(-1)**d
		d+=1
	else:
		print(x)
		break

Measured memory_bytes: 9180
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		long N=stdIn.nextLong();
		long A=stdIn.nextLong();
		long B=stdIn.nextLong();
		if((B-A)%2==0){
			System.out.println((B-A)/2);
		}
		else{
			long X=0;
			if(A-1<N-B){
				X+=A;
				B-=A;A=1;
				if(B<1)
					B=1;
				X+=(B-A)/2;
				System.out.println(X);
			}
			else{
				X+=N-B;X++;
				A+=(N-B)+1;B=N;
				if(A>N)
					A=N;
				X+=(B-A)/2;
				System.out.println(X);
			}
		}
	}
}


Measured memory_bytes: 23764
#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
int main() {
	int n, c[100001] ={0}, ans = 0, a = 0;
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d",&a);
		if (a>1e5) ans++;
		else c[a]++;
	}
	rep(i, 100001) {
		if (c[i] > i)ans += c[i] - i;
		else if (c[i] < i)ans += c[i];
	}
	printf("%d", ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000000000000
using namespace std;
ll dist[305][305];
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld", &a);
	for (i = 1; i <= a; i++) {
		for (j = 1; j <= a; j++) {
			scanf("%lld", &b);
			dist[i][j] = b;
		}
	}
	ll ans = 0;
	for (i = 1; i <= a; i++) {
		for (j = 1; j <= a; j++) {
			bool flag = true;
			for (k = 1; k <= a; k++) {
				if (k == j || k == i) continue; 
				if (dist[i][k] + dist[k][j] < dist[i][j]) {
					printf("-1\n");
					return 0;
				} else if (dist[i][k] + dist[k][j] == dist[i][j]) {
					flag = false;
				}
			}
			if (flag) ans += dist[i][j];
		}
	}
	printf("%lld\n", ans >> 1);
	return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from fractions import gcd
def resolve():
    for _ in range(int(input())):
        a,b,c,d=map(int,input().split())
        if(a<b):
            print("No")
            continue
        if(b>d):
            print("No")
            continue
        if(c>=b):
            print("Yes")
            continue

        g=gcd(b,d)
        a%=g
        a-=g
        u=(c-a)//g+1
        if(a+u*g>=b):
            print("Yes")
        else:
            print("No")
resolve()

Measured memory_bytes: 65516
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
#pragma endregion

int main()
{
  init_main();

  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll sum = 0;
  if (k >= a)
  {
    sum += a;
    k -= a;
  }
  else if (k > 0)
  {
    sum += k;
    k = 0;
  }

  if (k >= b)
  {
    k -= b;
  }
  else if (k > 0)
  {
    k = 0;
  }

  if (k > 0)
  {
    sum -= k;
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

vector<ll> p,q,r;

int main(){
    ll x,y,a,b,c;
    cin >> x >> y>> a>> b>> c;
    rep(i,a){
        ll P;
        cin >> P;
        p.push_back(P);
    }
    rep(i,b){
        ll P;
        cin >> P;
        q.push_back(P);
    }
    rep(i,c){
        ll P;
        cin >> P;
        r.push_back(P);
    }
    sort(p.begin(),p.end(),greater<ll>());
    sort(q.begin(),q.end(),greater<ll>());
    sort(r.begin(),r.end(),greater<ll>());
    ll ans=0;
    rep(i,x){
        pq.push(p[i]);
    }
    rep(i,y){
        pq.push(q[i]);
    }
    rep(i,c){
        pq.push(r[i]);
    }
    rep(i,x+y){
        ll k=pq.top();
        pq.pop();
        ans+=k;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4728
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long n = ILongs()[0];
            char[][] s = ICharsChars(n);

            for(int i=0;i<n;i++){
                Array.Sort(s[i]);
            }

            Array.Sort(s,CompareStr);

            long ans = 0;
            long kosuu = 1;

            for(int i=1;i<n;i++){
                bool equal = true;
                for(int j=0;j<10;j++){
                    if(s[i-1][j]!=s[i][j]){
                        equal = false;
                        break;
                    }
                }
                if(equal){
                    kosuu ++;
                }else{
                    ans += kosuu*(kosuu-1) / 2;
                    kosuu = 1;
                }
            }
            ans += kosuu * (kosuu-1) / 2;

            WriteLine(ans);
        }

        static public int CompareStr(char[] a,char[] b){
            for(int i=0;i<10;i++){
                if(a[i].CompareTo(b[i])>0){
                    return 1;
                }else if(a[i].CompareTo(b[i])<0){
                    return -1;
                }
            }
            return 0;
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

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

using namespace std;
using ll = long long;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(a+b>c+d){
    cout << "Left" << endl;
  }else if(a+b<c+d){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }


  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 100005;

int a[maxn],n;
int gcd(int n,int m) {
	return m?gcd(m,n%m):n;
}
bool PlayGame() {
	int even=0,odd=0;
	for (int i=1;i<=n;i++)
		a[i]&1?odd++:even++;
	if (even&1) return true;
	if (odd!=1) return false;
	int t=1;while (!(a[t]&1)) ++t;
	if (a[t]==1) return false;
	
	a[t]--;int o=a[t];
	for (int i=1;i<=n;i++) o=gcd(o,a[i]);
	for (int i=1;i<=n;i++) a[i]/=o;
	return !PlayGame();
}
int main()
{
	#ifdef Amberframe
		freopen("agc010d.in","r",stdin);
		freopen("agc010d.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	printf("%s",PlayGame()?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

type Node struct {
	key                 int
	parent, left, right *Node
}

var out bytes.Buffer

func (n *Node) find(k int) *Node {
	for n != nil && n.key != k {
		if n.key > k {
			n = n.left
			continue
		}
		n = n.right
	}
	return n
}

func (n *Node) insert(k int) {
	root := n
	var target *Node
	node := &Node{key: k, left: nil, right: nil}

	for root != nil {
		target = root
		if root.key > k {
			root = root.left
			continue
		}
		root = root.right
	}

	if target.key > node.key {
		target.left = node
		return
	}
	target.right = node
}

func (n *Node) inorder() {
	if n == nil {
		return
	}
	n.left.inorder()
	if n.key != 0 {
		out.WriteString(fmt.Sprintf(" %d", n.key))
	}
	n.right.inorder()
}

func (n *Node) preorder() {
	if n == nil {
		return
	}
	if n.key != 0 {
		out.WriteString(fmt.Sprintf(" %d", n.key))
	}
	n.left.preorder()
	n.right.preorder()
}

func answer(reader io.Reader) string {
	root := &Node{}

	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	for i := 0; i < n; i++ {
		sc.Scan()
		switch sc.Text() {
		case "insert":
			sc.Scan()
			k, _ := strconv.Atoi(sc.Text())
			root.insert(k)
		case "print":
			root.inorder()
			out.WriteString("\n")
			root.preorder()
			out.WriteString("\n")
		case "find":
			sc.Scan()
			k, _ := strconv.Atoi(sc.Text())
			t := root.find(k)
			if t != nil {
				out.WriteString("yes\n")
			} else {
				out.WriteString("no\n")
			}
		}
	}

	return strings.TrimRight(out.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}



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

int main(){
    int a, b, k;
    cin >> a >> b >> k;

    int n = min(a, b);
    vector<int> list;
    for(int i = 1; i <= n; i++){
        if(a % i == 0 && b % i == 0){
            list.push_back(i);
        }
    }

    int m = list.size();
    int ans = list[m - k];

    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;
typedef long double ld;

const ll INF = 1LL << 59;
const ll MOD = 1000000007;

struct Edge {
    int to;
    ll a;
    ll b;
    ll timing;
};

int N, M, S, T;
vector<Edge> G[202020];
ll dist[202020];

ll move(ll t, ll a, ll b) {
    return (b - 1) / (t + a) + 1;
}

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

    cin >> N >> M >> S >> T;
    --S; --T;

    REP(_, M) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        ll x = sqrt(b);
        if (x * x < b) ++x;
        G[u].push_back({v, a, b, max(0LL, x - a)});
        G[v].push_back({u, a, b, max(0LL, x - a)});
    }

    REP(i, N) dist[i] = INF;
    priority_queue<pair<ll, int>> pq;
    pq.push(make_pair(0LL, S));

    while (!pq.empty()) {
        auto p = pq.top();
        auto t = -p.first;
        auto n = p.second;
        pq.pop();
        if (t >= dist[n]) continue;
        dist[n] = t;
        for (auto e: G[n]) {
            ll nt;
            if (t <= e.timing) {
                nt = e.timing + move(e.timing, e.a, e.b);
            } else {
                nt = t + move(t, e.a, e.b);
            }
            if (nt >= dist[e.to]) continue;
            pq.push(make_pair(-nt, e.to));
        }
    }

    cout << (dist[T] == INF ? -1 : dist[T]) << endl;
}



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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = 0LL;

    vector<ll> X(N);
    rep(i, N) cin >> X[i];

    for (int i=1; i<N; i++) {
        ll walk_cost = (X[i] - X[i-1]) * A;
        ans += min(walk_cost, B);
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<string> W(N);
    REP(i,N)W[i] = in<string>();
    bool ok = 1;
    REP(i,N-1){
        if(W[i][W[i].size()-1] != W[i+1][0])ok = 0;
    }
    sort(ALL(W));
    UNIQUE(W);
    if(W.size() != N)ok = 0;
    cout << (ok ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;
const long long INF = 1LL<<60; // 仮想的な無限大の値
vector<bool> seen;

Graph G;

const int MAX_N = 10000;
int main() {
    
    int n = 0;
    cin >> n;
    int a[MAX_N];
    for(int i =0;i < n;i++) cin >> a[i];
    int c[MAX_N]={};
    //2の約数の個数を数える
    for(int i=0;i < n;i++){
        while(a[i] % 2 == 0){
            c[i]++;
            a[i] /= 2;
        }
    }
    int sum =0;

    for(int i=0;i < n;i++){
        sum += c[i];
    }

    cout << sum << endl;


    return 0;

}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<ll> A(N,0);
  vector<ll> B(N,0);
  vector<ll> C(M,0);
  vector<ll> D(M,0);
  for(int i=0;i<N;i++){
    cin >> A[i] >> B[i];
  }
  for(int j=0;j<M;j++){
    cin >> C[j] >> D[j];
  }
  for(int i=0;i<N;i++){
    ll d_min=abs(A[i]-C[0])+abs(B[i]-D[0]);
    int min_ind = 0;
    for(int j=1;j<M;j++){
      if(d_min>abs(A[i]-C[j])+abs(B[i]-D[j])){
        min_ind = j;
        d_min = abs(A[i]-C[j])+abs(B[i]-D[j]);
      }
    }
    cout << min_ind+1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> a(H, vector<char>(W));

	REP(i, H){
		REP(j, W){
			cin >> a.at(i).at(j);
		}
	}

	vector<bool> row(H, false);
	vector<bool> col(W, false);

	REP(i, H){
		REP(j, W){
			if(a[i][j] == '#'){
				row[i] = true;
				col[j] = true;
			}
		}
	}

	REP(i, H){
			if(row[i]){
				REP(j, W){
					if(col[j]){
						cout << a[i][j];
					}
				}
				cout << endl;
			}
	}
}


Measured memory_bytes: 3548
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    string S,T;
    cin >> N >> S >> T;
    rep(i,N) cout << S[i] << T[i];
    cout << endl;
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A_heap = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A_heap)

ans = 0

for i in range(M):
    x = heapq.heappop(A_heap) * (-1)
    heapq.heappush(A_heap, int(x/2) * (-1))

for i in range(N):
    ans -= A_heap[i]

print(ans)

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

typedef long long ll;
int main(){
    int N,C;
    cin >> N >> C;
    int D[C][C];
    map<int,int> m0, m1, m2;
    for(int i = 0; i < C; i++){
        m0[i] = 0;
        m1[i] = 0;
        m2[i] = 0;
    }

    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            int tmp;
            cin >> tmp;
            D[i][j] = tmp;
        }
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            int tmp;
            cin >> tmp;
            tmp--;
            if((i+j) % 3 == 0){
                m0[tmp]++;
            }
            if((i+j) % 3 == 1){
                m1[tmp]++;
            }
            if((i+j) % 3 == 2){
                m2[tmp]++;
            }
        }
    }

    int ans = 30*30*500*1000;
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            if(i == j) continue;
            for(int k = 0; k < C; k++){
                int tmp = 0;
                if(j == k || i == k) continue;
                for(auto x: m0){
                    tmp += D[x.first][i] * x.second;
                }
                for(auto x: m1){
                    tmp += D[x.first][j] * x.second;
                }
                for(auto x: m2){
                    tmp += D[x.first][k] * x.second;
                }
                if(tmp < ans){
                    ans = tmp;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    ab,bc,ca = map(int,input().split())
    ans = ab * bc // 2
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
#include<bits/stdc++.h>
using namespace std;
char s[10];
int cnt[500];
int main()
{
	cin>>s;
	for(int i=0;i<4;i++)cnt[s[i]]++;
	int cnt2=0;
	for(int i=0;i<=400;i++)if(cnt[i]==2)cnt2++;
	if(cnt2==2)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int sx = scanner.nextInt(), sy = scanner.nextInt(), tx = scanner.nextInt(), ty = scanner.nextInt(), dx = tx - sx, dy = ty - sy;

        for (int i = 0; i < dy; i++)
            System.out.print('U');
        for (int i = 0; i < dx; i++)
            System.out.print('R');
        for (int i = 0; i < dy; i++)
            System.out.print('D');
        for (int i = 0; i <= dx; i++)
            System.out.print('L');
        for (int i = 0; i <= dy; i++)
            System.out.print('U');
        for (int i = 0; i <= dx; i++)
            System.out.print('R');
        System.out.print("DR");
        for (int i = 0; i <= dy; i++)
            System.out.print('D');
        for (int i = 0; i <= dx; i++)
            System.out.print('L');
        System.out.print('U');
    }
}

Measured memory_bytes: 27268
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=	(a*a)%mod;b>>=1;}return (res%mod);}

const int N=2e5+5;
void solve(){
	int n;
	cin>>n;
	int arr[2*n];
	for ( int i=0;i<2*n;i++)
		cin>>arr[i];
	sort( arr,arr+2*n);
	int ans=0;
	for ( int i=0;i<2*n;i+=2)
		ans+=arr[i];
	cout<<ans<<'\n';

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N, K, C;
	string S;
	cin >>N >>K >>C >>S;
	vector<bool> s(N+1, false);
	Rep1(i, N)
		if ('o'==S.at(i-1))
			s.at(i)=true;
	vector<int> L(N+1, 0);
	int ix=-C;
	int c=0;
	Rep1(i, N) {
		if (s.at(i)) {
			if (i>ix+C) {
				ix=i;
				c++;
			}
		}
		L.at(i)=c;
	}
	vector<int> R(N+1, 0);
	ix=N+C+1;
	c=0;
	for (auto i=N; i>0; i--) {
		if (s.at(i)) {
			if (i<ix-C) {
				ix=i;
				c++;
			}
		}
		R.at(i)=c;
	}
	vector<int> IX(N+2, 0);
	int CC=max(1, C);
	for (auto wr=2; wr-CC<=N; wr++) {
		int S=0;
		int wl=wr-CC;
		if (wl-1>0)
			S +=L.at(wl-1);
		if (wr<=N)
			S +=R.at(wr);
		if (S>=K) {
			IX.at(max(1, wl))++;
			IX.at(min(N+1, wr))--;
		}
	}
	vector<int> A;
	int W=0;
	Rep1(i, N) {
		W +=IX.at(i);
		if (W>0)
			continue;
		// (0==W)
		int LL=i-C;
		int RR=i+C;
		int SS=1;
		if (LL>0)
			SS +=L.at(LL);
		if (RR<=N)
			SS +=R.at(RR);
		if (SS>=K)
			A.push_back(i);
	}
	for (auto AA: A)
		cout <<AA <<endl;
	return 0;
}



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

int main() {
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    int right = 0;
    int left = 0;
    for(int i = 0; i < m; i++){
        if(a[i] < x) right++;
        else if(a[i] > x) left++;
    }
    cout << min(right,left);
}

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

int main()
{
	string N;
	int K = 0;
	cin >> N >> K;
	char D[K];
	for(int i = 0; i < K; i++){
		cin >> D[i];
	}
	string val = N;
	bool pass = false;
	int no_go = false;
	if(K == 0){
		no_go = true;
	}
	while(!no_go){
		for(int i = 0; i < K; i++){
			bool bit_check = true;
			for(int j = 0; j < val.size(); j++){
				if(val[j] == D[i]){
					bit_check = false;
					break;
				}
			}
			if(bit_check == false)
				break;
			if(i == (K - 1))
				pass = true;
		}
		if(pass == true)
			break;
		else{
			int int_val = stoi(val);
//			cout << int_val << endl;
			int_val++;
			val = to_string(int_val);
		}
	}
	cout << stoi(val) << endl;
	return 0;
}

Measured memory_bytes: 256
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N,M;
    cin>>N>>M;
    //inputend
    if(N==M){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s; cin>>s;
    if(s.back()=='s') s+="es";
    else s+="s";
    cout<<s<<endl;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int N;

  cin>>N;

  long long a[300001];

  for(int i=0;i<3*N;i++){

    cin>>a[i];
    
  }

  sort(a,a+(N*3),greater<int>());

  long long ans=0;
  
  for(int i=1;i<N*2;i+=2){

    ans+=a[i];
    
  }

  cout<<ans<<endl;
  

  return 0;

}



Measured memory_bytes: 2560
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));
  vector<int> plus, minus;
  minus.push_back(A.front());
  plus.push_back(A.back());
  for (int i = 1; i < N - 1; i++) {
    if (A[i] >= 0) plus.push_back(A[i]);
    else minus.push_back(A[i]);
  }
  vector<pair<int, int>> v;
  while (plus.size() > 1) {
    int x = plus.back(); plus.pop_back();
    int y = minus.back(); minus.pop_back();
    v.push_back(MP(y, x));
    minus.push_back(y-x);
  }
  
  int ans = plus[0];
  for (auto e : minus) {
    v.push_back(MP(ans, e));
    ans -= e;
  }
  cout << ans << endl;
  for (auto e : v) {
    cout << e.FI << ' ' << e.SE << endl;
  }
  return 0;
}


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

using namespace std;

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

    for(int i = 0; i < N; ++i){
        if(i == (K-1)){
            cout << char(tolower(S[i]));
        }else{
            cout << S[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  double f,t;
  while(cin >> f >> t){
    if(f < 35.5 && t < 71.0) cout << "AAA" << endl;
    else if(f < 37.5 && t < 77.0) cout << "AA" << endl;
    else if(f < 40.0 && t < 83.0) cout << "A" << endl;
    else if(f < 43.0 && t < 89.0) cout << "B" << endl;
    else if(f < 50.0 && t < 105.0) cout << "C" << endl;
    else if(f < 55.0 && t < 116.0) cout << "D" << endl;
    else if(f < 70.0 && t < 148.0) cout << "E" << endl;
    else cout << "NA" << endl;
  }
}


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

int main() 
{
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    
    vector<int> ONE(N);
    for (int i = 0; i < N; i++) {
        ONE.at(i) = i + 1;
    }
    for (int i = 0; i < N; i++) {
        cin >> P.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> Q.at(i);
    }
    
    map<vector<int>, int> mp;
    do{
        mp[ONE] = (int)mp.size();
    }while(next_permutation(ONE.begin(), ONE.end()));

    int ans = abs(mp.at(P) - mp.at(Q));
    cout << ans << endl;
}

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


int main(){
	long long int num,temp,n;
	unordered_set< long long int >s;
 	cin>>n;
	for(int i=0;i<n;i++){
		cin>>temp;
		s.insert(temp);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int s = a + b;
	if (s < a - b)
		s = a - b;
	if (s < a * b)
		s = a * b;
	cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
ll a,b,c;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(a),read(b),read(c);
	ll t=min(a,c);
	a-=t,c-=t;
	t=min(b,c);
	b-=t,c-=t;
	print(a),putchar(' '),print(b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100000
#define LL long long
priority_queue<int>q;
int main(){
	int n,m,x;scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d",&x),q.push(x);
	for(int i=0;i<m;i++){
		int w=q.top();q.pop();
		if(!w)break;
		w>>=1;q.push(w);
	}
	LL ans=0;
	for(int i=0;i<n;i++){ans+=q.top();q.pop();}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
#include<stdlib.h>

int partition(int a[], int left, int right){
    int pivot, swap;
    int i,j;
    pivot = a[left];
    i = left;
    j = right;
    while(1){
        while(a[i] < pivot){
            i++;
        }
        while(pivot < a[j]){
            j--;
        }
        if(i < j){
            swap = a[i];
            a[i] = a[j];
            a[j] = swap;

        }else{
            return j;
        }
        i++;
		j--;
    }
    return j;
}

void quick_sort(int a[], int left, int right){
    int mid;
    if (left < right){
        mid = partition(a,left,right);
        quick_sort(a,left,mid);
        quick_sort(a,mid+1,right);
    }
}



int main(void){
    int N,i;
    scanf("%d",&N);
    int a[N],b[N];

    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
        b[i] = a[i];
    }
    quick_sort(a,0,N-1);
    for(i=0;i<N;i++){
        if(b[i] == a[N-1] && b[i] != a[N-2]){
            printf("%d\n",a[N-2]);
        }else{
            printf("%d\n",a[N-1]);
        }
    }
    return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#define N 250010
#define M 1000010
#define ls x << 1
#define rs x << 1 | 1
#define inf 0x3f3f3f3f
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define mid ((l + r) >> 1)
// #define int long long
//#define ll long long
#define XRZ 10000000000000
#define pai acos(-1)
#define debug() puts("XRZ TXDY");
#define mem(i, x) memset(i, x, sizeof(i));
#define Next(i, u) for(register int i = head[u]; i ; i = e[i].nxt)
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout);
#define Rep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
using namespace std;
inline int read() {
    register int x = 0, f = 1; register char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1;c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar(); 
    return x * f;
}
int dx[10] = {0, 1, 1, 2, 2, -1, -1, -2, -2};
int dy[10] = {0, 2, -2, 1, -1, 2, -2, 1, -1};
int exgcd(int a, int b, int &x, int &y) {
	if(b == 0) { x = 0, y = 1; return a;}
	int now = exgcd(b, a % b, x, y), yy = x; x = y, y = yy - a / b * y;
	return now;
}
signed main() { int A = read(), B = read(); printf("%d", A * B); 
	return 0;
}

Measured memory_bytes: 3748
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


x, a, b = map(int, sys.stdin.readline().split())
if abs(x - a) > abs(x - b):
    print("B")
else:
    print("A")

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

std::string s;
std::map<char, int>m;
int main() {
    std::cin >> s;
    for (int i = 0; i < 4; i++) {
        m[s[i]]++;
    }
    int cnt = 0;
    for (auto e: m) {
        cnt++;
        if (e.second != 2) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    if (cnt != 2) {
        std::cout << "No" << std::endl;
        return 0;
    }
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

ll T[1005];
ll A[1005];

ll max(ll a,ll b){
	if(a>b){return a;}
	else{return b;}
}

int main(){

	int N;

	scanf("%d",&N);

	int i,j;

	for(i=0;i<N;i++){
	scanf("%lld %lld",&T[i],&A[i]);
	}

	ll X=T[0];
	ll Y=A[0];
	for(i=1;i<N;i++){
		if(X>T[i]||Y>A[i]){
		if(X%T[i]==0ll){
			if(Y%A[i]==0ll){
			ll add=max(X/T[i],Y/A[i]);
			X=add*T[i];
			Y=add*A[i];
			}
			else{
			ll add=max(X/T[i],(Y/A[i])+1ll);
			X=add*T[i];
			Y=add*A[i];
			}
		}
		else{
			if(Y%A[i]==0ll){
			ll add=max((X/T[i])+1ll,Y/A[i]);
			X=add*T[i];
			Y=add*A[i];
			}
			else{
			ll add=max((X/T[i])+1ll,(Y/A[i])+1ll);
			X=add*T[i];
			Y=add*A[i];
			}
		}
		}
		else{
		X=T[i];
		Y=A[i];
		}
	}
	printf("%lld\n",X+Y);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 2e9;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	ll answer = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 && i % 5) {
			answer += i;
		}
	}
	cout << answer << '\n';
 	return 0;
}


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

int main() {
  int n,x;
  cin >> x >> n;
  if(n == 0){
    cout << x << endl;
    return 0;
  }
  int arr[300];
  int diff[n];
  int smallest = 200;
  int smallestVal = 0;
  for(int i = 0; i < n; i++){
    int t;
    cin >> t;
    arr[t+100] = 1;
  }
  for(int i = 199; i >= -100; i--){
    if(arr[i+100] == 1){
      continue;
    }
    if(abs(x-i) <= smallest){
      smallestVal = i;
      smallest = abs(x-i);
    }
  }
  cout << smallestVal << endl;
  return 0;
}

Measured memory_bytes: 3580
n = int(input())
s = input()
max_num = 0
for i in range(1, n):
  s_1 = s[:i]
  s_2 = s[i:]
  temp = len(set(s_1) & set(s_2))
  if temp > max_num:
    max_num = temp
print(max_num)
  

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        X = X - A;
        while (X >= B) {
            X = X - B;
        }
        System.out.println(X);

    }
}


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

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

  vector<int> height(N);
  rep(i, N) {
    cin >> height[i];
  }

  vector<bool> heighest(N);
  rep(i, N) {
    heighest[i] = true;
  }

  rep(i, M) {
    int b, a;
    cin >> b >> a;
    b--;
    a--;
    if (height[b] <= height[a]) {
      heighest[b] = false;
    }
    if (height[a] <= height[b]) {
      heighest[a] = false;
    }
  }

  int ans = 0;
  rep(i, N) {
    if (heighest[i] == true) {
      ans++;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 3796