akhauriyash/Code-Regression huggingface dataset:
class Node
  attr_accessor :left, :right, :key, :priority

  def initialize(key:, priority:)
    @key = key
    @priority = priority
  end
end

def find(node, key)
  return node if node.nil? || node.key == key
  if key < node.key
    find(node.left, key)
  else
    find(node.right, key)
  end
end

def in_order(node, arr = [])
  return if node.nil?
  in_order(node.left, arr)
  arr << node.key
  in_order(node.right, arr)
  arr
end

def pre_order(node, arr = [])
  return if node.nil?
  arr << node.key
  pre_order(node.left, arr)
  pre_order(node.right, arr)
  arr
end


def right_rotate(t)
  s = t.left
  t.left = s.right
  s.right = t
  s
end

def left_rotate(t)
  s = t.right
  t.right = s.left
  s.left = t
  s
end

def insert(t, key, priority)
  return Node.new(key: key, priority: priority) if t.nil?
  return t if t.key == key

  if key < t.key
    t.left = insert(t.left, key, priority)
    t = right_rotate(t) if t.priority < t.left.priority
  else
    t.right = insert(t.right, key, priority)
    t = left_rotate(t) if t.priority < t.right.priority
  end
  t
end

def delete(t, key)
  return if t.nil?
  if key < t.key
    t.left = delete(t.left, key)
  elsif key > t.key
    t.right = delete(t.right, key)
  else
    return _delete(t, key)
  end
  t
end

def _delete(t, key)
  return nil if t.left.nil? && t.right.nil?

  if t.left.nil?
    t = left_rotate(t)
  elsif t.right.nil?
    t = right_rotate(t)
  else
    if t.left.priority > t.right.priority
      t = right_rotate(t)
    else
      t = left_rotate(t)
    end
  end
  delete(t, key)
end


node = nil
gets.to_i.times do
  command, key, priority = gets.split

  case command
  when 'insert'
    node = insert(node, key.to_i, priority.to_i)
  when 'find'
    puts find(node, key.to_i) ? 'yes' : 'no'
  when 'delete'
    node = delete(node, key.to_i)
  when 'print'
    puts "\s" + in_order(node).join("\s")
    puts "\s" + pre_order(node).join("\s")
  end
end




Measured memory_bytes: 37180
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int safety = sc.nextInt();
        int buy = sc.nextInt();
        int eat = sc.nextInt();
        
        if (-buy + eat <= 0) {
            System.out.println("delicious");
        } else if (-buy + eat <= safety) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}

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

int main() {
    for (int i = 0; i < 9; i++) {
        char c;
        cin >> c;
        if (i == 0 || i == 4 || i == 8){
            cout << c;
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from collections import Counter


n = int(input())
v = list(map(int, input().split()))
odd = Counter(v[0::2]).most_common(2) + [(0, 0)]
even = Counter(v[1::2]).most_common(2) + [(0, 0)]

n_half = int(n / 2)

if (len(odd) == 1 and len(even) == 1) and odd[0][0] == even[0][0]:
    ans = n_half
elif odd[0][0] == even[0][0]:
    ans = min(n_half - odd[0][1] + n_half - even[1][1],\
            n_half - odd[1][1] + n_half - even[0][1])
else:
    ans = n_half - odd[0][1] + n_half - even[0][1]

print(ans)


Measured memory_bytes: 15588
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
for i in S:
    i.insert(0, '.')
    i.append('.')
S.insert(0, ['.' for _ in range(W+2)])
S.append(['.' for _ in range(W+2)])

for i in range(1, H+1):
    for j in range(1, W+1):
        x = []
        if S[i][j] == '.':
            x.append(S[i-1][j-1])
            x.append(S[i-1][j])
            x.append(S[i-1][j+1])
            x.append(S[i][j-1])
            x.append(S[i][j])
            x.append(S[i][j+1])
            x.append(S[i+1][j-1])
            x.append(S[i+1][j])
            x.append(S[i+1][j+1])
            print(x.count("#"), end="")
        else:
            print('#', end="")
    print("\n")


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        long result;
        if (n * m == 1)
            result = 1;
        else if (n == 1 || m == 1)
            result = n * m - 2;
        else
            result = (n - 2) * (m - 2);
        System.out.println(result);
    }

}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll R;
    cin >> R;

    double res = 2*M_PI * R;
    cout << res << endl;
}


Measured memory_bytes: 3796
#include <stdio.h>
#define max(a, b) ((a > b) ? a : b)

int main() {
    int a[1001];
    int n, m;

    while (1) {
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0) { break; }
        for (int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
        }
        int ans = -1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                // i == j のときはループを飛ばす
                if (i == j) { continue; }
                if (a[i] + a[j] <= m) {
                    ans = max(ans, a[i] + a[j]);
                }
            }
        }
        if (ans == -1) { puts("NONE"); }
        else { printf("%d\n", ans); }
    }
    return 0;
}


Measured memory_bytes: 2100
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

//var sc = bufio.NewScanner(os.Stdin)

func main() {
	inputs := scanIntNums()
	//A := inputs[0]
	//B := inputs[1]
	M := inputs[2]

	aprices := scanIntNums()
	bprices := scanIntNums()

	coupon := make([][]int, M)
	for i := 0; i < M; i++ {
		coupon[i] = scanIntNums()
	}

	minPrice := 200000
	var tmp int
	// check coupon
	for i := 0; i < M; i++ {
		tmp = aprices[coupon[i][0]-1] + bprices[coupon[i][1]-1] - coupon[i][2]
		if tmp < minPrice {
			minPrice = tmp
		}
	}

	// check min
	nMin := min(aprices) + min(bprices)
	if nMin < minPrice {
		minPrice = nMin
	}
	fmt.Println(minPrice)
}

func min(nums []int) int {
	minNum := 100000
	for i := 0; i < len(nums); i++ {
		if minNum > nums[i] {
			minNum = nums[i]
		}
	}
	return minNum
}

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}


Measured memory_bytes: 12928
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	nums := make([]float64,n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	
	max_diff := 0.0
	for i := 0; i < n; i++ {
		diff := 0.0
		for j := i; j < n; j++ {
			diff = math.Abs(nums[i] - nums[j])
			
			if diff > max_diff {
				max_diff = diff
			}
		}
	}
	fmt.Println(int(max_diff))
}

Measured memory_bytes: 512
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
#include<math.h>
using namespace std;

#define rep(i,n) for(long long i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

const ll INF = ll(1e18) + 1;

//--------------------------------------------------

ulli gcd(ulli a, ulli b) {
	return (b <= 0) ? a : gcd(b, a % b);
}

ulli lcm(ulli a, ulli b) {
	return a * b / gcd(a, b);
}

//---------------------------------------------------

void Main()
{
	string s;
	cin >> s;
	vector<char> l,r;
	bool frag = true;
	int q; cin >> q;
	rep(i, q) {
		int t; cin >> t; t--;
		if (t) {
			int f;
			char c;
			cin >> f >> c;
			f--;
			if (f) {
				if (frag) r.push_back(c);
				else l.push_back(c);
			}
			else {
				if (!frag) r.push_back(c);
				else l.push_back(c);
			}
		}
		else {
			frag = (frag) ? false : true;
		}
	}
	if (frag) {
		reverse(l.begin(), l.end());
		for (auto x : l)cout << x;
		cout << s;
		for (auto x : r)cout << x;
		cout << endl;
	}
	else {
		reverse(r.begin(), r.end());
		reverse(s.begin(), s.end());
		for (auto x : r)cout << x;
		cout << s;
		for (auto x : l)cout << x;
		cout << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Main();
	
	return 0;
}

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

ll cmb(ll n) {
  if(n < 0)
    return 0;
  else
    return n * (n - 1) / 2;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> cnt;
  rep(i, n) {
    cin >> a[i];
    a[i]--;
    cnt[a[i]]++;
  }

  map<int, ll> ans;
  rep(i, cnt.size()) {
    int q = cnt[i];
    if(q == 0)
      continue;
    ll aa = cmb(q - 1);
    if(ans[q] == 0) {
      rep(j, cnt.size()) {
        if(j == i)
          continue;
        aa += cmb(cnt[j]);
      }
      ans[q] = aa;
    }
  }

  rep(i, n) cout << ans[cnt[a[i]]] << endl;
}


Measured memory_bytes: 13556
#include<stdio.h>
#include<string.h>
#include<math.h>

int main() {
	char s[200001];
	long long i,ans = 0,cnt=0;
	scanf("%s", s);
	for (i = 0; s[i] != '\0'; i++) {
		if (s[i] == 'W') {
			ans += i-cnt;
			cnt++;

		}

	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <queue>
typedef long long ll;

using namespace std;

const int N=1e5+5;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int n,k=2;
   cin>>n>>k;
   int arr[N]={},dp[N]={};
   for(int i=0;i<n;i++)
    cin>>arr[i];
   memset(dp,-1,sizeof(dp));
   dp[0]=0;
   for(int i=0;i<n;i++)
   {

     for(int j=1;j<=k;j++)
     {
         if(i-j>=0)
         {
             if(dp[i]==-1)
             {
                 dp[i]=dp[i-j]+abs(arr[i]-arr[i-j]);
             }
             else
             {
                 dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));


             }


         }

     }




   }
   cout<<dp[n-1];

   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int calc(IN(vi) A, int ptn) {
    int N = A.size();
    int d = 1;
    int sum = 0, term = 0;
    for(int i = N-1; i>=0; i--) {
        term += A[i] * d;
        if ((ptn & 0b01) == 1) {
            sum += term;
            term = 0;
            d = 1;
        } else {
            d *= 10;
        }
        ptn >>= 1;
    }
    sum += term;
    return sum;
}
int bitfs(IN(vi) A) {
    int N = A.size();
    int res = 0;
    REP(p, 1<<N) {
        int ptn = p;
        if ((ptn >> (N-1)) == 0)
            continue;
        int pres = calc(A, ptn);
        res += pres;
    }
    return res;
}

int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    str S; cin>>S;
    int N = S.size();
    vi A;
    REP(i,N)
        A.push_back(S[i]-'0');

    int ans = bitfs(A);

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }

int main() {
    int k; scanf("%d", &k);
    int even = k / 2;
    int odd = (k / 2) + !!(k % 2);
    printf("%d\n", even * odd);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int d,g;cin>>d>>g;
  int p[10], c[10];rep(i,d)cin>>p[i]>>c[i];
  int count = INF;
  rep(b,1<<d){
    int score = 0;
    int cou = 0;
    int mx = 0;
    rep(i,d){
      if(b & (1<<i)){
        score += (100 * (i+1) * p[i] + c[i]);
        cou += p[i];
      }else{
        mx = i;
      }
    }
    int j = 0;
    while(score < g && j < p[mx]){
      score += 100 * (mx+1);
      cou++;
      j++;
    }
    if(score >= g)count = min(count, cou);
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int p[15];
	int min=0,sum=0;
	for(int i=0;i<n;i++){
		cin >> p[i];
		if(p[i]>min) min=p[i];
		sum+=p[i];
	}
	cout << sum-min/2;	
	 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef vector<int64_t> vi;
typedef pair< int64_t,int64_t> ii;
typedef vector<pair<int64_t, int64_t> > vp;
typedef vector<pair<int64_t, ii> > vpp;
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
#define int int64_t
#define sz(x)       (int)x.size()
void solve();
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    solve();
    return 0;
}
void solve()
{
    int n,d;
    cin>>n>>d;
    d=2*d+1;
    int ans=0;
    ans+=n/d;
    if(n%d!=0)
        ans++;
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int s = n + 1 - (n & 1);
  int cnt = 0;
  vector<pair<int, int>> grh;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (i + j != s) {
        grh.push_back({i, j});
        cnt++;
      }
    }
  }
  cout << cnt << '\n';
  for (auto p : grh) {
    cout << p.first << ' ' << p.second << '\n';
  }
  return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

//通常
struct UnionFind {
    V par, rank;
    UnionFind(int size) { init(size); }
    void init(int size) {
        REP(i, size) {
            par.push_back(i);
            rank.push_back(0);
        }
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            swap(x, y);
        } else {
            if(rank[x] == rank[y]) rank[x]++;
        }
        par[y] = x;
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

ll N, M;

int main() {
    cin >> N >> M;
    auto uf = UnionFind(N);
    REP(i, M) {
        CINT(X, Y, Z);
        uf.unite(X - 1, Y - 1);
    }
    map<ll, ll> memo;
    ll ans = 0;
    REP(i, N) {
        if(memo[uf.root(i)] == 0) {
            ans++;
            memo[uf.root(i)]++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 7284
N = int(input())
a = list(map(int, input().split()))

n1 = 0
n2 = 0
n4 = 0

for i in a:
    if i%2 == 0:
        if i%4 == 0:
            n4 += 1
        else:
            n2 += 1
    else:
        n1 += 1

if n1 <= n4:
    ans = 'Yes'
else:
    if n1 == n4 + 1 and n2 == 0:
        ans = 'Yes'
    else:
        ans = 'No'

print(ans)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))
 
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
void solve() {
    ll n;
    cin >>n;
    vector<ll> data(n);
    for(int i=0;i<n;i++) cin >>data[i];

    ll ans=0;
    for(int i=1;i<n;i++)
    {
        if(data[i]<data[i-1])
        { 
            ans+=data[i-1]-data[i];
            data[i]=data[i-1];
        }
    }
    cout <<ans<<"\n";
}
 
int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    solve();
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b;
string s;

int main() {
	cin >> a >> b >> s;
	
	bool f = true;
	inc(i, a + b + 1) { f &= ((i == a) == (s[i] == '-')); }
	
	cout << (f ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define true 1
#define false 0
#define N 100
int judge(char *,char *,int kei);
    int main()
{
  int kei,i,j,k[N],g[N],t,m,mini,minim,r,h,w;
  char s,a[N],n[N];
  scanf("%d",&kei);
  for(i=0;i<kei;i++){
    scanf(" %c%d",&a[i],&k[i]);
  }
  for(i=0;i<kei;i++)
    {
    n[i]=a[i];
    g[i]=k[i];
  }
  for(i=0;i<kei;i++)
    {
    for(j=kei-1;j>i;--j){
      if(k[j]<k[j-1]){
	m=a[j-1];
	t=k[j-1];
	a[j-1]=a[j];
	k[j-1]=k[j];
	a[j]=m;
	k[j]=t;
	
      }
    }
  }
  
  for(i=0;i<kei-1;i++)
    {
    mini=g[i];
    minim=n[i];
    r=i;
    for(j=i+1;j<kei;j++)
      {
	if(g[j]<mini)
	  {
      mini=g[j];
    minim=n[j];
    r=j;
	}
      }
      if(i != r){
	h=g[i];
	w=n[i];
	g[i]=g[r];
	n[i]=n[r];
	g[r]=h;
	n[r]=w;
      }
    }
  
  for(i=0;i<kei;++i){
    if(i>0)printf(" ");
    printf("%c%d",a[i],k[i]);
  }
  printf("\n");
  printf("Stable\n");
  for(i=0;i<kei;++i)
    {
    if(i>0)printf(" ");
    printf("%c%d",n[i],g[i]);
  }
  printf("\n");
  if(judge(a,n,kei)==1)printf("Stable\n");
  else printf("Not stable\n");
    return 0;
}

int judge(char x[],char y[],int kei)
{
  int i;
  for(i=0;i<kei;i++)
    {
      if(x[i] != y[i])return false;
    }
  return true;
}
  



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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	vector<pair<int,int> > arr(m);
	vii lft(n+10,vi());
	vii rght(n+10,vi());
	for(int i = 0; i < m; i++) {
		cin >> arr[i].first >> arr[i].second;
		lft[arr[i].first].push_back(i);
		rght[arr[i].second].push_back(i);
	}
	//cout << "a" << endl;
	set<int> curr;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		bool torem = false;
		for(int el : rght[i]) {
			if(curr.count(el)) {
				torem = true;
			}
		}
		if(torem) {
			ans++;
			curr.clear();
		}
		for(int el : lft[i]) {
			curr.insert(el);
		}
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 12668
#include <iostream>
#include <algorithm>

using namespace std;
int main() {
	int n, m;
	int max_x, min_y;

	cin >> n >> m >> max_x >> min_y;

	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		max_x = max(x, max_x);
	}

	for (int i = 0; i < m; i++) {
		int y;
		cin >> y;
		min_y = min(min_y, y);
	}
	if (max_x < min_y) {
		cout << "No War" << endl;
	} else {
		cout << "War" << endl;		
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	float m,n;
  	cin>>n>>m;
  	vector<int> a(110);
  	float total=0;//なんでここで異常値出てたんだ
  	for(int i=0;i<n;i++){
    	cin>>a[i];
      	total+=a[i];
    }

  
 	 int ok=0;
  
  
  	for(int j=0;j<n;j++){
      //total/4/mかなあ
      if(a[j]>=total/(4*m)){
        ok++;   	
      }
         	
    }
  
  	if(m>ok){
    	cout<<"No"<<endl;
    }
  
  	else{
    	cout<<"Yes"<<endl;
    }

}

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

int solve(bitset<10> s, int G, int D, vector<int> q, vector<int> bonus){
  int count = 0, sum = 0;
  for(int i=D-1; i>=0; i--){
    if(s.test(i)){
      for(int j=0; j<q.at(i); j++){         
        sum += 100*(i+1);
        count++;
        if(sum >= G){
          return count;
        }
      }
      sum += bonus.at(i);
      if(sum >= G){
        return count;
      }
    }
  }
  return 1001;
}
 
int main(){

  int D, G; cin >> D >> G;
  vector<int> q(D), bonus(D);
  for(int i=0; i<D; i++){
    cin >> q.at(i) >> bonus.at(i);
  }
  int ans = 1001;
  
  for(int tmp=0; tmp < (1 << 10); tmp++){
    bitset<10> s(tmp);
    int count = solve(s, G, D, q, bonus);
    if(count < ans){
      ans = count;
    }
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main( String... args ) throws Exception {

        BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
        String input = in.readLine();

        List<String> inputList = new ArrayList<>();
        List<String> outputList = new ArrayList<>();

        while ( input != null ) {
            inputList.add( input );
            input = in.readLine();
        }

        int number = Integer.parseInt( inputList.get( 0 ) );
        String array[] = inputList.get( 1 ).split( " " );

        for ( int i = number; i > 0; i = i - 2 ) {
            outputList.add( array[i - 1] );
        }

        for ( int i = (number % 2); i < number; i = i + 2 ) {
            outputList.add( array[i] );
        }

        System.out.println( String.join( " ", outputList ) );

    }
}


Measured memory_bytes: 62640
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

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

fn main() {
    let line = read_as_vec::<usize>();
    let (h, w) = (line[0], line[1]);
    let mut s: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        s.push(read_as_string().chars().collect::<Vec<char>>());
    }

    let mut dp: Vec<Vec<u64>> = vec![vec![0; w]; h];

    if s[0][0] == '#' {
        dp[0][0] = 1;
    }

    for i in 1..w {
        if s[0][i - 1] == '.' && s[0][i] == '#' {
            dp[0][i] = dp[0][i - 1] + 1;
        } else {
            dp[0][i] = dp[0][i - 1];
        }
    }

    for i in 1..h {
        if s[i - 1][0] == '.' && s[i][0] == '#' {
            dp[i][0] = dp[i - 1][0] + 1;
        } else {
            dp[i][0] = dp[i - 1][0];
        }
    }

    for i in 1..h {
        for j in 1..w {
            let cost_from_upper = if s[i - 1][j] == '.' && s[i][j] == '#' {
                dp[i - 1][j] + 1
            } else {
                dp[i - 1][j]
            };

            let cost_from_left = if s[i][j - 1] == '.' && s[i][j] == '#' {
                dp[i][j - 1] + 1
            } else {
                dp[i][j - 1]
            };
            dp[i][j] = cmp::min(cost_from_left, cost_from_upper);
        }
    }

    println!("{}", dp[h - 1][w - 1]);
}


Measured memory_bytes: 2280
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

s=s0()

ans=0
c=0
for x in s:
    if x in "ACGT":
        c+=1
    else:
        ans=max(ans,c)
        c=0
ans=max(ans,c)
print(ans)

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);



void solve()
{
    string s;
    cin >> s;
    int ans = 0;
    REP(i, 3) if(s[i] == '1') ans++;
    cout << ans << "\n";
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vii;

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

  string x;
  cin>>x;
  int ans = 0;
  for(auto i : x){
    if( i == '+') { ans++; }
    else if( i=='-'){ ans--;}
  }
  cout<<ans<<"\n";
  return 0;
}


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

s_list=[['#' for i in range(100)] for j in range(50)] \
            +[['.' for i in range(100)] for j in range(50)]

print(100,100)

n=0
for i in range(A-1):
    if 2*i-100*(n//2)<100:
        s_list[n][2*i-100*(n//2)]='.'
    else:
        n+=2
        s_list[n][2*i-100*(n//2)]='.'

n=52
for i in range(B-1):
    if 2*i-100*((n-52)//2)<100:
        s_list[n][2*i-100*(n-52)//2]='#'
    else:
        n+=2
        s_list[n][2*i-100*(n-52)//2]='#'
for s in s_list:
    print(''.join(s))



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

int main() {
  
  int A, B;
  cin >> A >> B;
  
  int useNum = 0;
  int curTaps = 1;
  while(curTaps < B) {
    
    if (useNum == 0)
      curTaps = A;
    else
      curTaps += A - 1;
    
    useNum++;
  }
  cout << useNum << endl;
  return 0;
}


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

int main()
{
  string buf;

  int cnt[ 26 ] = { 0 };
  int idx = 0;

  while( cin >> buf ) {
    for( int i = 0; i < buf.size(); i++ ) {
      char ch = buf[ i ];

      if( isupper( ch ) ) {
        idx = ch - 65;
        cnt[ idx ] += 1;
      }

      if( islower( ch ) ) {
        idx = ch - 97;
        cnt[ idx ] += 1;
      }
    }
  }

  for( int i = 0; i < 26; i++ ) {
    cout << (char)( i + 97 ) << " : " << cnt[ i ] << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}

int countBits(int in){
  int res=0;
  rep(i,10){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

int main() {
  int n,m;cin>>n>>m;
  vector<int> x(m);
  rep(i,m){
    cin>>x[i];
  }
  if(n>=m){
    cout<<0<<endl;
    return 0;
  }
  int ans=0;
  sort(all(x));
  multimap<int,int> d;
  rep(i,m-1){
    int dist=x[i+1]-x[i];
    d.insert(P(dist,i));
  }
  int cnt=0;
  for(auto it=d.begin();it!=d.end()&&cnt<m-n;++it,cnt++){
    ans+=it->first;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

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

	}

	public static void partB() {
		Scanner scB = new Scanner(System.in);
		int a = scB.nextInt();
		int b = scB.nextInt();
		int N = b - a;
		int sum = 0;

		for(int i = 0 ; i < N + 1 ; i++) {
			sum += i;
		}

		System.out.println(sum - b);
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> x(N), y(N), h(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      set<ll> s;
      set<pair<ll, ll>> zero_heights;
      ll H;
      for (int k = 0; k < N; k++) {
        if (h[k] == 0) {
          zero_heights.insert({x[k], y[k]});
          continue;
        }
        H = h[k] + abs(x[k] - i) + abs(y[k] - j);
        s.insert(H);
      }
      if (s.size() == 1) {
        bool succ = true;
        for (auto e : zero_heights) {
          if (H - abs(e.first - i) - abs(e.second - j) > 0) succ = false;
        }
        if (succ) {
          cout << i << " " << j << " " << H << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<time.h>
using namespace std;
#define int long long
#define inf 1e9+7
typedef pair<int, int> P;

int c[514], s[514], f[514];
int ans[514];

signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n-1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	for (int i = 0; i < n-1;i++) {
		int ntime = 0;
		for (int j = i; j < n - 1; j++) {
			if (ntime < s[j]) {
				ntime = s[j] + c[j];
			}
			else {
				ntime = (ntime + f[j] - 1) / f[j] * f[j];
				ntime += c[j];
			}
		}
		cout << ntime << endl;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
//0025 Hit and Blow
//4ツ古つづ個青板篠堋づ粂IT(ツ湘ェツ渉環、ツ値ツつェツ暗ェツ致ツ）ツ、Blow(ツ湘ェツ渉環づ債暗。ツつ、ツつェツ値ツづ債暗ェツ致ツ）ツづ個古つ青板づーツ板サツ津ィツつケツづヲ

#include<iostream>
#include<algorithm>
using namespace std;

int main(void)
{
	const int N = 4;
	int a[N], b[N];
	int i;

	while(1)
	{
		for(i = 0; i < N; i++)
			cin >> a[i];
		for(i = 0; i < N; i++)
			cin >> b[i];
		if(!cin)
			break;

		int hit = 0,
			blow = 0;
		for(i = 0; i < N; i++)
		{
			if(a[i] == b[i])
				hit++;
			else if(find(a, a+N, b[i]) != a+N)
				blow++;
		}

		cout << hit << ' ' << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 0
using namespace std;

#include <bits/stdc++.h>

int main(){
    int N, K;
    cin >> N >> K;
    int res = 0;
    for ( int i = 0; i < N; i ++ ){
        int t;
        cin >> t;
        if ( t >= K ) res ++;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define int long long
const int mod=1e9+7;
const int N=2e6+5;
int n,ans,a[N],sum[N],dp[N][2];
vector<int>v[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int solve(int x)
{
    dp[0][0]=1;dp[0][1]=1;
    for(int i=1;i<v[x].size();i++)
    {
        int xu=sum[v[x][i]-1]-sum[v[x][i-1]];
        dp[i][0]=(dp[i-1][0]+xu*dp[i-1][1]%mod)%mod;
        dp[i][1]=(dp[i-1][1]+dp[i][0])%mod;
    }
    return dp[v[x].size()-1][1];
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=a[i-1]^read();
		v[a[i]].push_back(i);
	}
	sum[0]=0;
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(a[i]==0);
	if(a[n])
	{
		ans=solve(a[n]);
		if(v[a[n]].size()>1)ans=(ans-dp[v[a[n]].size()-2][1]+mod)%mod;
        cout<<ans;
	}
	else{
		ans=1;
		for(int i=1;i<=sum[n]-1;i++)ans=ans*2%mod;
		for(int i=1;i<(1<<20);i++)
			if(v[i].size()>0)ans=(ans+solve(i))%mod;
		cout<<ans;
	}
}

Measured memory_bytes: 70988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll mod=1e9+7;


class comb{
	vector<ll> f,fr;
	ll MOD;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD * fr[n-r] % MOD;
	}
};

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

	ll N,M,K;
	cin >> N >> M >> K;
	comb co;
	co.init(N*M,mod);
	cout << (N+M)*co.nCr(K,2)%mod*co.nCr(N*M,K)%mod*co.calc(3,mod-2,mod)%mod << endl;
}


Measured memory_bytes: 3456
#!/usr/bin/perl
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @v = map { $_ - 0 } split(/\s+/,<STDIN>);

my $n2 = $n / 2;
my @v1 = (); my @v2 = ();
$#v1 = 100000;
$#v2 = 100000;
for(my $i=0;$i<$n;$i+=2){
  $v1[$v[$i]] ++;
  $v2[$v[1+$i]] ++;
}
my %v1 = () ; my %v2 = ();
for(my $i=0;$i<=$#v1;$i++){
  $v1{$i} = $v1[$i] if length('' . $v1[$i]);
  $v2{$i} = $v2[$i] if length('' . $v2[$i]);
}

my @s1 = sort { $v1{$b} <=> $v1{$a} } keys %v1;
my @s2 = sort { $v2{$b} <=> $v2{$a} } keys %v2;

my $ans = -1;
if( $s1[0] != $s2[0] ){
  $ans = $n - $v1{$s1[0]} - $v2{$s2[0]};
} else {
  my $a1 = $n - $v1{$s1[0]} - $v2{$s2[1]};
  my $a2 = $n - $v1{$s1[1]} - $v2{$s2[0]};
  $ans = ($a1 < $a2 ? $a1 : $a2);
}
print "$ans\n";
exit(0);


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

int main (){
  int N;
  std::vector<std::string> S;
  std::string tmp;
  std::cin >> N;

  for(int i;i < N;i++){
    std::cin >> tmp;
    S.push_back(tmp);
  }

  std::vector<std::string>::iterator itr = find(S.begin(),S.end(), "Y");
  
  if(itr != S.end()){
    std::cout << "Four" << std::endl;
  }else{
    std::cout << "Three" << std::endl;
  }
 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int s;
int main(){
  cin >> s;
  int i=1;
  while(s!=4&&s!=2&&s!=1){
    if(s%2==0) s/=2;
    else s=3*s+1;
    i++;
  }
  cout << i+3 << "\n";

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int T = sc.nextInt();
		int minCost = 1001;
		for(int i=0;i<N;i++){
		int c = sc.nextInt();
		int t = sc.nextInt();
			if(t<=T && c < minCost){
				minCost = c;
			}
		}
		if(minCost == 1001){
			System.out.println("TLE");
		}else{
			System.out.println(minCost);
		}
	}
}

Measured memory_bytes: 22228
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
int N, M, K, Q;
int pSsum[MAX], pTsum[MAX];

int main()
{
	int i, j, k;
	string S, T;
	cin >> S >> T;
	for (i = 0; i < S.size(); ++i) {
		int v = S[i] == 'B' ? 2 : 1;
		pSsum[i + 1] = pSsum[i] + v;
	}
	for (i = 0; i < T.size(); ++i) {
		int v = T[i] == 'B' ? 2 : 1;
		pTsum[i + 1] = pTsum[i] + v;
	}
	scanf("%d", &Q);
	int a, b, c, d;
	for (i = 0; i < Q; ++i) {
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int num1 = pSsum[b] - pSsum[a - 1];
		int num2 = pTsum[d] - pTsum[c - 1];
		if (num1 % 3 == num2 % 3) printf("YES\n");
		else printf("NO\n");
	}

}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,k,sum=0,ans=0;
    cin>>x>>k;
    pair<ll,ll>p[x];
    for (int i=0; i<x; i++)
        cin>>p[i].first>>p[i].second;
    sort(p,p+x);
    for (int i=0; i<x; i++)
    {
        if (p[i].second+sum>k)
        {
            ans+=(k-sum)*p[i].first;
            break;
        }
        else
        {
            sum+=p[i].second;
            ans+=p[i].second*p[i].first;
        }
    }
    cout<<ans<<endl;

}


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

const int max_n = 1000000;
const int MOD = 1e9+7;
int bit[65];
int main(){
    ll n;
    cin >> n;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        for(int i=0;i<61;i++){
            bit[i] += tmp&1;
            tmp >>= 1;
        }
    }
    ll num = 1;
    ll ans = 0;

    for(int i=0;i<61;i++){
        ll tmp = bit[i]*(n-bit[i]);
        for(int j=0;j<i;j++){
            tmp = (tmp % MOD)<<1 ;
        }
        ans = (ans+tmp)%MOD;
    }
    cout << ans <<endl;
    return 0;
}

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

using namespace std;

int main() {
   string n;
   cin >> n;
   for(int i = 0; i < 3; i++){
       if(n.at(i) == '1') n.at(i) = '9';
       else if(n.at(i) == '9') n.at(i) = '1';
   }

   cout << n << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
class SegmentTree:
    #for pypy
    #treeは1-based-index
    __slots__=["size","func","default_val","tree","first_idx"]
    def __init__(self,initial_value_list,func,default_val,first_index=0):
        n=len(initial_value_list)
        self.first_idx=first_index
        self.size=1<<(n-1).bit_length()
        self.func=func#適用関数
        self.default_val=default_val#初期値
        self.tree=[default_val for i in range(2*self.size)]
        # 木の構築
        for i in range(n):
            d=[0]*26;d[initial_value_list[i]-97]=1
            self.tree[self.size+i]=d
        for i in range(self.size-1,0,-1):
            self.tree[i]=self.func(self.tree[2*i],self.tree[2*i+1])

    def update(self,k,x):
        k+=self.size-self.first_idx
        self.tree[k]=x
        while k>1:
            k>>=1
            self.tree[k]=self.func(self.tree[2*k],self.tree[2*k+1])
    def query(self, l, r):
        l+=self.size-self.first_idx
        r+=self.size-self.first_idx
        lret,rret=self.default_val,self.default_val
        while l<r:
            if l&1:
                lret=self.func(lret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                rret=self.func(self.tree[r], rret) # モノイドでは可換律は保証されていないので演算の方向に注意
            l>>=1
            r>>=1
        return self.func(lret, rret)
n=int(input())
def add(x,y):
    v=[0]*26
    for i in range(26):
        v[i]=x[i]+y[i]
    return v
seg=SegmentTree(list(input().rstrip()),add,[0]*26,1)
q=int(input())

for i in range(q):
    a,s,d=input().split()
    if int(a)==1:
        s=int(s)
        v=[0]*26;v[int.from_bytes(d,'big')-97]+=1
        seg.update(s,v)
        
    else:
        r=seg.query(1,int(s))
        l=seg.query(1,int(d)+1)
        
        ans=0
        for i in range(26):
            if l[i]>r[i]:ans+=1
        print(ans)


Measured memory_bytes: 379224
# 68

def factorization(n):
    ans = []
    _max = int(n ** 0.5 + 1)
    while n % 2 == 0:
        n //= 2
        ans.append(2)
    for i in range(3, _max+1, 2):
        while n % i == 0:
            n //= i
            ans.append(i)
    if n != 1:
        ans.append(n)
    return ans


n = int(input())
ans = factorization(n)

print(n, ": ", sep="", end="")
print(*ans)



Measured memory_bytes: 5636
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var cnt int

func main() {
	reader.Split(bufio.ScanWords)
	A, _ := strconv.Atoi(read())
	B, _ := strconv.Atoi(read())
	a := A + B
	b := A - B
	c := A * B
	fmt.Println(max(a, b, c))
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i][0] < a[j][0] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640