akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)

const ll MOD = 1e9+7;

template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) v += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
    return is >> x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
  friend constexpr Fp<MOD> modinv(const Fp<MOD> &a) noexcept {
    return modpow(a, MOD - 2);
  }
};

using mint = Fp<MOD>;

vector<mint> fact, ifact;

int main () {
  int N, K;
  cin >> N >> K;
  fact = vector<mint>(N+2, 1);
  ifact = vector<mint>(N+2, 1);
  for(int i = 1; i <= N + 1; i++) {
    fact[i] = fact[i-1] * i;
    ifact[i] = modinv(fact[i]);
  }

  for(int i = 1; i <= K; i++) {
    if(N-K-i+1 < 0) {
      cout << 0 << endl;
      continue;
    }
    cout << fact[N-K+1]*ifact[N-K-i+1]*ifact[i]*fact[K-1]*ifact[K-i]*ifact[i-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n, k = gets.chomp.split(' ').map(&:to_i)

ds = (1..n).map do |i|
  d = 0
  while (k > i * 2 ** d) do
    d = d + 1
  end
  d
end

dmax = ds.max

puts ds.map { |d| 2 ** (dmax - d) }.reduce(:+) / (2 ** dmax * n).to_f


Measured memory_bytes: 3452
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <fstream>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
#define INF 4e18
using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*ll t,tcitr;
    cin>>t;
    tcitr=0;
    while(tcitr<t)
    {*/
        //cout<<"Case #"<<tcitr+1<<": ";
        ll n;
        cin>>n;
        cout<<1-n<<"\n";
        /*tcitr++;
    }*/
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(void)
{
	int i,a,b;
	
	for(i = 0;; i++){
		scanf("%d%d", &a,&b);
		if(a == 0 && b == 0) break;
		
		if(a <= b)
			printf("%d %d\n", a, b);
		else
			printf("%d %d\n", b, a);
	}
	return 0;
}


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

using namespace std;

const int DIM = 1e5 + 7;

bool v[DIM];
bool arb[DIM * 4];

int from[DIM];

void build(int pos, int l, int r)
{
	if(l == r)
	{
		arb[pos] = v[l];
		return ;
	}
	
	int mid = (l + r) / 2;
	
	build(pos * 2, l, mid);
	build(pos * 2 + 1, mid + 1, r);
	
	arb[pos] = (arb[pos * 2] | arb[pos * 2 + 1]);
}

int query(int pos, int l, int r, int x, int y)
{
	if(x <= l && r <= y)
	{
		if(arb[pos] == false)
			return -1;
		
		if(l == r)
			return l;
		
		int mid = (l + r) / 2;
		
		int p = query(pos * 2, l, mid, x, y);
		
		if(p != -1)
			return p;
		
		return query(pos * 2 + 1, mid + 1, r, x, y);
	}
	
	int mid = (l + r ) / 2;
	
	int p1 = -1;
	int p2 = -1;
	
	if(x <= mid)
		p1 = query(pos * 2, l, mid, x, y);
	
	if(y > mid)
		p2 = query(pos * 2 + 1, mid + 1, r, x, y);
	
	if(p1 != -1)
		return p1;
		
	return p2;
}

main()
{
	int n, k;
	cin >> n >> k;
	
	for(int i = 0; i <= n; i++)
	{
		char c;
		cin >> c;
		
		if(c == '0')
			v[i] = true;
	}
	
	build(1, 0, n);
	
	for(int i = 1; i <= n; i++)
	{
		int p = query(1, 0, n, max(0, i - k), i - 1);
		
		if(p == -1)
		{
			cout << -1;
			return 0;
		}
		
		from[i] = p;
	}
	
	vector <int> ops;
	
	int pos = n;
	
	while(pos != 0)
	{
		int p = from[pos];
		
		ops.push_back(pos - p);
		pos = p;
	}
	
	reverse(ops.begin(), ops.end());
	
	for(auto i : ops)
		cout << i << ' ';
}

Measured memory_bytes: 1660
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n;
    cin >> n;
    vector<int>a(n),b(n);
    map<int,int> mpa,mpb,mpc,mpd;
    rep(i,n){
        cin >> a[i];
        mpa[a[i]] = i;
    }
    rep(i,n){
        cin >> b[i];
        mpb[b[i]] = i;
    }
    vector<int> c = a;
    vector<int> d = b;
    sort(c.begin(),c.end());
    sort(d.begin(),d.end());
    rep(i,n){
        mpc[c[i]] = i;
        mpd[d[i]] = i;
        if(c[i]>d[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i,n-1){
        if(c[i+1]<=d[i]){
            cout <<"Yes" << endl;
            return 0;
        }
    }
    set<int>st;
    int k = c[0];
    int id = 0;
    while(st.count(id)==0){
        //cerr << id << " " << k << endl;
        st.insert(id);
        int i = mpa[k];
        id = mpd[b[i]];
        k = c[id];
        
    }
    if(st.size()==n){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

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

  if(a-b < c){
   cout << c-(a-b) << endl;
   } else if(a-b >= c) {
   cout << 0 << endl;
   }
   return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	as := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		as[i] = a
	}

	max := 0
	maxIndex := 0
	for i, a := range as {
		if a > max {
			max = a
			maxIndex = i
		}
	}

	secondMax := 0
	for i, a := range as {
		if i == maxIndex {
			continue
		}

		if a > secondMax {
			secondMax = a
		}
	}

	writer := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		if i == maxIndex {
			writer.WriteString(strconv.Itoa(secondMax) + "\n")
		} else {
			writer.WriteString(strconv.Itoa(max) + "\n")
		}
	}
	writer.Flush()
}


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

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

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

   vector<int> d(N);
   rep(i, N) cin >> d.at(i);
   sort(d.begin(), d.end());
   cout << d.at(N / 2) - d.at(N / 2 - 1) << endl;
 }


Measured memory_bytes: 640
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;

  std::vector<int> A;
  rep(i, n) {
    int a;
    cin >> a;
    A.push_back(a);
  }

  int count = 0;
  rep(i, n) {
    int minj = i;
    int j = i;
    while (j < n) {
      if (A[j] < A[minj]) {
        minj = j;
      }
      j++;
    }
    if (i != minj) {
      swap(A[i], A[minj]);
      count++;
    }
  }

  rep(i, A.size() - 1) { std::cout << A[i] << ' '; }
  std::cout << A.back() << '\n';

  std::cout << count << '\n';
  return 0;
}



Measured memory_bytes: 3112
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vi r(2 * n);
  ll open = 0, close = 0;
  ll ans = 1;
  rep(i, 2 * n) {
    if (s[i] == 'B')
      r[i] = 1;
    else
      r[i] = 0;

    if ((i & 1) == 0) {
      r[i] = !r[i];
    }

    if (r[i] == 0) {
      open++;
    } else {
      // cout << open << ":" << close << endl;
      ans = ans * (open - close) % MOD;
      close++;
    }
  }
  if (open != n) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, 1, n + 1) { ans = ans * i % MOD; }

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


Measured memory_bytes: 1404
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    res = 0
    for i in range(n):
        k = i
        for j in range(i+1, n):
            while(k < n and l[k] < l[i]+l[j]):
                k += 1
            res += k - (j+1)
    print(res)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10576
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static int[] S ;
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		String[] Ws = W.split(" ");
		long[] A = new long[Ws.length];
		for (int i = 0; i < Ws.length; i++) {
			A[i] = Long.parseLong(Ws[i]);
		}

		long ans = 1;
		for(;ans<=1000;ans++){
			if(Math.floor(ans * 0.08) == A[0] && Math.floor(ans * 0.1) == A[1]){
				break;
			}
		}
		if(ans == 1001){
			ans = -1;
		}
		System.out.println(ans);
	}


}


Measured memory_bytes: 23124
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] str1 = sc.nextLine().split(" ");
    String[] str2 = sc.nextLine().split(" ");
    int x = Integer.parseInt(str1[0]);
    int n = Integer.parseInt(str1[1]);
    if(n==0) {
        System.out.println(x);
    }
    else {
        List<String> list = new ArrayList<String>();
        for(int i = 0 ; i < 102;i++) {
          list.add((((Integer)i).toString()));
        }
        for(int i = 0 ; i < str2.length;i++) {
            list.remove (str2[i]);
        }
        int cnt=9999;
        int ansX=9999;
        for(String num2 : list) {
            int num = Integer.parseInt(num2);
            if(Math.abs(num-x) <cnt) {
                cnt = Math.abs(num-x);
                ansX = num;
            }
        }
        System.out.println(ansX);
    }
  }
}

Measured memory_bytes: 35504
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    int64_t b = 0;
    char prev = -1;
    for (auto c : s) {
        if (prev != c) {
            ++b;
            prev = c;
        }
    }

    int64_t ans = n - b;
    if (b >= 3) {
        int64_t a = min((b - 1) / 2, k);
        b -= 2 * a;
        k -= a;
        ans += 2 * a;
    }

    if (b == 2 && k >= 1) {
        --b;
        --k;
        ans += 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
/*=======================
Author    : Shounak Dey
=======================	*/

#include<bits/stdc++.h>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;

#define PB push_back
#define MK make_pair
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << a*b + c*d - c*b - d*a << endl;
	return 0;
}



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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	
	vector<int> h(n);
	
	for (int i = 0; i < n; ++i)
		cin >> h[i];
	
	vector<vector<int>> roots(n);
	
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		
		--a;
		--b;
		roots[a].push_back(b);
		roots[b].push_back(a);
	}
	
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int size = roots[i].size();
		bool good = true;
		for (int j = 0; j < size && good; ++j) {
			good = h[i] > h[roots[i][j]];
		}
		
		if (good)
			++ans;
	}
	
	cout << ans << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

int L,N;
int X[222222];
int acc[222222];
int ans;

void solve(){
	for(int i=0;i<N;i++)acc[i+1]=acc[i]+X[i];
	for(int i=1;i<=N;i++){
		int num=min(i-1,N-i);
		int tmp=(acc[i-1]-acc[i-1-num])*2;
		tmp+=(num*L-(acc[i+num]-acc[i]))*2;
		tmp+=X[i-1];
		chmax(ans,tmp);
		if(i==N)continue;
		num=min(i,N-i);
		tmp=(acc[i]-acc[i-num])*2;
		tmp+=(num*L-(acc[i+num]-acc[i]))*2;
		tmp-=X[i-1];
		chmax(ans,tmp);
	}
}
signed main(){
	cin>>L>>N;
	rep(i,N)cin>>X[i];
	

	solve();
	rep(i,N){
		X[i]=L-X[i];
	}
	reverse(X,X+N);
	solve();
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3328
package main

import (
	"fmt"
)

func main() {

	var H, N int
	fmt.Scanf("%d %d", &H, &N)

	A := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
		H = H - A[i]
	}
	if H <= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 6320
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

using namespace std;
using ll = long long;

typedef struct route {
	int cost;
	int time;
} R;

bool pairCompTime(R& f, R& s)
{
	return f.time < s.time;
}

int main()
{
	int N, T;
	cin >> N >> T;
	vector<R> x(N);

	for (int i = 0; i < N; ++i)
		cin >> x[i].cost >> x[i].time;

	sort(x.begin(), x.end(), pairCompTime);

	int ans = INT_MAX;
	for (int i = 0; i < N; ++i) {
		if (x[i].time > T)
			continue;
		if (x[i].cost < ans)
			ans = x[i].cost;
	}

	if (ans == INT_MAX) {
		cout << "TLE" << endl;
		return 0;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 5005;
int n;
int h[maxn], p[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &h[i], &p[i]);
  }
  return true;
}

pair<int, int> tosort[maxn];
long long dp[maxn][maxn];

void solve() {
  for (int i = 0; i < n; i++) {
    tosort[i] = make_pair(h[i] + p[i], i);
  }
  sort(tosort, tosort + n);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i][j] = infll;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    int id = tosort[i].second;
    for (int j = 0; j <= i; j++) {
      auto cur = dp[i][j];
      dp[i + 1][j] = min(dp[i + 1][j], cur);
      if (cur > h[id]) {
        continue;
      }
      auto &nxt = dp[i + 1][j + 1];
      nxt = min(nxt, cur + p[id]);
    }
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (dp[n][i] < infll) {
      res = max(res, i);
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 195840
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES(n)          cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n)          cout << ((n) ? "Yes" : "No"  ) << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;

  bool ans = regex_match(s, regex("A?KIHA?BA?RA?"));

  YES(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll n, k; cin >> n >> k;
	ll ans = 0;
	
	if (k % 2 == 0) {
		ll cnt0 = n / k;
		ll cnt1 = (n + k / 2) / k;
		ans = cnt0 * cnt0 * cnt0 + cnt1 * cnt1 * cnt1;
	} else {
		ll cnt0 = n / k;
		ans = cnt0 * cnt0 * cnt0;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
ll pow(int b, int e) {
  if(e == 0) return 1LL;
  if(e % 2 == 1) return pow(b, e - 1) * b;
  ll m = pow(b, e >> 1);
  return m * m;
}
vector<ll> a(55), b(55);

ll f(ll n, ll x) {
  if(n == 0) return x <= 0 ? 0 : 1;
  if(x <= 1 + a[n - 1]) return f(n - 1, x - 1);
  return b[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
}

int main() {
  ll n, x;
  cin >> n >> x;
  rep(i, n + 1) {
    a[i] = pow(2, i + 2) - 3;
    b[i] = pow(2, i + 1) - 1;
  }
  cout << f(n, x) << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

	lt := len(t)
	var tCnt int
	for i := 0; i < len(s)-lt+1; i++ {
		// 比較文字列
		c := s[i : i+lt]
		var cnt int
		for j := 0; j < len(c); j++ {
			if c[j] == t[j] {
				cnt++
			}
		}
		if cnt > tCnt {
			tCnt = cnt
		}
	}
	fmt.Println(len(t) - tCnt)
}


Measured memory_bytes: 1856
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<queue>
#include<algorithm>
using namespace std;
#define N 5000
struct mzls
{
	int to;
	double cost;
}as;
struct mzls1
{
	double x,y,z;
}a1[N+5];
vector<mzls>g[N+5];
queue<int>q;
bool f[N+5],f1;
int n;
double dist[N+5];
inline void prepare()
{
	scanf("%lf%lf%lf%lf",&a1[1].x,&a1[1].y,&a1[2].x,&a1[2].y);
	a1[1].z=a1[2].z=0;
	dist[1]=dist[2]=1e18;
	scanf("%d",&n);
	n+=2;
	for(int i=3;i<=n;i++)
	{
		scanf("%lf%lf%lf",&a1[i].x,&a1[i].y,&a1[i].z);
		dist[i]=1e18;
	}
	for(int i=2;i<=n;i++)
		for(int j=1;j<i;j++)
		{
			double ml=sqrt((a1[i].x-a1[j].x)*(a1[i].x-a1[j].x)+(a1[i].y-a1[j].y)*(a1[i].y-a1[j].y));
			ml-=a1[i].z+a1[j].z;
			if(ml<0.0)
				ml=0.0;
			as.cost=ml;
			as.to=j;
			g[i].push_back(as);
			as.to=i;
			g[j].push_back(as);
		}
}
inline void SPFA(int s)
{
	dist[s]=0,f[s]=1;
	q.push(s);
	while(!q.empty())
	{
		int v=q.front();q.pop();
		f[v]=0;
		for(int i=0;i<g[v].size();i++)
		{
			mzls ml=g[v][i];
			if(dist[ml.to]>dist[v]+ml.cost)
			{
				dist[ml.to]=dist[v]+ml.cost;
				if(!f[ml.to])
				{
					q.push(ml.to);
					f[ml.to]=1;
				}
			}
		}
	}
}
int main()
{
	prepare();
	SPFA(1);
	printf("%.10lf\n",dist[2]);
}



Measured memory_bytes: 16512
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int h, w;
  cin >> h >> w;
  string m[h];
  rep(i, h) cin >> m[i];

  // 行方向
  int rowIndex[h][w];
  int rowN[h][w];
  rep(i, h) {
    int _index=0, count=0;
    rep(j, w+1) {
      if(j==w || m[i][j]=='#') {
        rowN[i][_index] = count;
        _index++;
        count = 0;
      } else {
        rowIndex[i][j] = _index;
        count++;
      }
    }
  }

  // 列方向
  int colIndex[h][w];
  int colN[h][w];
  rep(j, w) {
    int _index=0, count=0;
    rep(i, h+1) {
      if(i==h || m[i][j]=='#') {
        colN[_index][j] = count;
        _index++;
        count = 0;
      } else {
        colIndex[i][j] = _index;
        count++;
      }
    }
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if(m[i][j] == '#') continue;
      int _rowIndex = rowIndex[i][j];
      int _rowN = rowN[i][_rowIndex];
      int _colIndex = colIndex[i][j];
      int _colN = colN[_colIndex][j];
      ans = max(ans, _rowN + _colN - 1);
      // printf("i: %d, j: %d => _rowN: %d, _colN: %d => sum: %d\n", i, j, _rowN, _colN, _rowN+_colN);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 66816
#include<iostream>
#include<vector>

using namespace std;

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

typedef long long ll;

#define INF (1e18)

struct RMQ {
    ll n;
    vector<ll> node;

    RMQ(ll *a_,ll n_) {
        vector<ll> a;
        rep(i,n_)a.push_back(a_[i]);
        initialize(a);
    }
    RMQ(vector<ll> a) {
        initialize(a);
    }

    void initialize(vector<ll> a) {
        ll n_ = (ll)a.size();
        n = 1;
        while(n<n_)n *= 2;

        node.resize(2*n,INF);

        rep(i,n_) node[n + i] = a[i];
        for(int i=n-1;i > 0;i--)node[i] = min(node[2*i],node[2*i+1]);
    }

    void update(ll k,ll a) {// k番目(0-indexed)の値をaに更新
        k += n;
        node[k] = a;

        while(k > 1) {
            k /= 2;
            node[k] = min(node[k * 2],node[k * 2 + 1]);
        }
    }

    ll query(ll a,ll b,ll k=1,ll l=0,ll r=0) {//query(a,b) min{ node[i] | i∈[a,b) } を返す
        //k  節点のインデックス
        //その節点が[l,r)に対応づいている
        if(l>=r)r = n;//外から呼ばれる時 l=0,r=nとする必要があるのでこうなる。
        if(r <= a || b <= l)return INF;//範囲外
        if(a <= l && r <= b)return node[k]; //[a,b)に[l,r)が含まれる

        ll vl = query(a,b,2 * k,l,(l + r) / 2);
        ll vr = query(a,b,2 * k + 1,(l + r) / 2,r);
        return min(vl,vr);
    }
    void print() {
        for(int i = 1;i < 2 * n;i++) {
            if(__builtin_popcount(i) == 1)
                cerr << endl;
            cerr << node[i] << " ";
        }
        cerr << endl;
    }
};

ll n,L;
ll a[1000000];

int main() {
    cin >> n >> L;

	rep(i,n)cin >> a[i];

	RMQ rmq(a,n);

	rep(i,n - L + 1) {
		cout << rmq.query(i,i+L);
		if(i < n - L)cout << " ";
	}
	cout << endl;

    return 0;

}



Measured memory_bytes: 42784
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

vector<int> v[100005];

pii dfs(int a, int par)
{
    ll white = 1;
    ll black = 1;
    for(int b: v[a])
    {
        if(b != par)
        {
            pii p = dfs(b, a);
            white = (white * (p.F + p.S)) % mod; // either black or white
            black = (black * p.F) % mod; // only if black;
        }
    }
    return mp(white, black);
} 

int main()
{
    int n;
    scanf("%d", &n);
    int a,b;
    for(int i=0; i<n-1;i++)
    {
        scanf("%d%d", &a,  &b);
        v[a].pb(b);
        v[b].pb(a);
    }

    pii ans = dfs(1, -1);
    printf("%d\n", (ans.F+ans.S) % mod);

}       


Measured memory_bytes: 12672
#include <cstdio>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool fst = false;
  while(true) {
    bool pos = false;
    REP(i,1,s.size()-1) {
      if(s[i-1] != s[i+1]) {
        s.erase(i,1);
        pos = true;
        break;
      }
    }
    if(pos) {
      fst = !fst;
    } else {
      break;
    }
  }
  cout << (fst ? "First\n" : "Second\n");
  return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	ll re=1;
	for(int x:a) re*=(x%2?1:2);
	ll pw=1;
	rep(i,n) pw*=3;
	cout<<pw-re<<endl;
  return 0;
}


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

int a[10];

int main(){
	for(int i=0; i<10; i++)
		std::cin >> a[i];
	std::sort(a,a+10);
	for(int i=0; i<3; i++)
		std::cout << a[9-i] << std::endl;
	return 0;
}

Measured memory_bytes: 0
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#define inf 1<<30
#define ll long long
#define db double
#define c233 cout<<"233"<<endl
#define mem(s) memset(s,0,sizeof(s))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
const int N=10050;
const int M=20050;
using namespace std;

bool v[N];
int nxt[M*2],to[M*2],w[M*2],co[M*2],head[N],dis[N],lastco[N];
int n,m,ans,maxe;

void fre(){
  freopen("in","r",stdin);
  freopen("out","w",stdout);
}

inline int gi(){
  int x=0,res=1;char ch=getchar();
  while(ch>'9'||ch<'0'){if(ch=='-')res*=-1;ch=getchar();}
  while(ch<='9'&&ch>='0')x=(x<<1)+(x<<3)+ch-48,ch=getchar();
  return x*res;
}

void clear(){
  ans=maxe=0;
  mem(head);
  mem(lastco);
}

void build(int a,int b,int c,int d){
  nxt[++maxe]=head[a];to[maxe]=b;
  co[maxe]=d;w[maxe]=c;head[a]=maxe;
}

void init(){
  for(int i=1;i<=m;i++){
    int a=gi(),b=gi(),c=gi(),d=gi();
    build(a,b,c,d);
    build(b,a,c,d);
  }
}

void spfa(){
  queue<int> q;
  while(!q.empty())q.pop();
  for(int i=1;i<=n;i++)dis[i]=inf,v[i]=0;
  q.push(1);dis[1]=0;v[1]=1;
  while(!q.empty()){
    int x=q.front();q.pop();v[x]=0;
    for(int i=head[x];i;i=nxt[i]){
      int u=to[i];
      if(dis[u]==dis[x]+w[i])
	lastco[u]=min(lastco[u],co[i]);
      if(dis[u]>dis[x]+w[i]){
	dis[u]=dis[x]+w[i];
	lastco[u]=co[i];
	if(!v[u])q.push(u),v[u]=1;
      }
    }
  }
}

void work(){
  spfa();
  for(int i=1;i<=n;i++)
    ans+=lastco[i];
  printf("%d\n",ans);
}

int main(){
  //fre();
  while(1){
    clear();
    n=gi();m=gi();
    if(m==0&&n==0)break;
    init();
    work();
  }
  return 0;
}

Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int t[10][10];

void gen() {exit(0);}
int main() {
    #ifdef DEBUG
    freopen("input", "r", stdin);
//    freopen("output", "w", stdout);
//    gen();
    #endif
    int h, w;
    scanf("%d %d", &h, &w);
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            scanf(" %d", &t[i][j]);
        }
    }
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                t[i][j] = min(t[i][j], t[i][k]+t[k][j]);
            }
        }
    }
    int ans = 0;
    forn(i, 0, h) {
        forn(j, 0, w) {
            int x;
            scanf(" %d", &x);
            if (x != -1) {
                ans += t[x][1];
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int my_ceil(int a, int b){
  return (a + b - 1) / b;
}

int main(){
  int A, B;
  cin >> A >> B;
  cout << my_ceil(B-1, A-1) << endl;
}


Measured memory_bytes: 3564
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    vector<int> a(3);
    REP(i, 3) cin >> a[i];
    sort(ALL(a), greater<int>());
    int sum = 0;
    if(a[0]%2 == a[1]%2 && a[1]%2 != a[2]%2) {
        a[0]++;
        a[1]++;
        sum++;
    } else if(a[0]%2 != a[1]%2 && a[1]%2 == a[2]%2) {
        a[1]++;
        a[2]++;
        sum++;
    } else if(a[0]%2 == a[2]%2 && a[0]%2 != a[1]%2) {
        a[0]++;
        a[2]++;
        sum++;
    }
    sum += (a[0]-a[1])/2 + (a[0]-a[2])/2;
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 384
# Problem A - キャンディーと2人の子供

# input
a, b, c = map(int, input().split())

# initialization
is_ok = False

# check
if a+b==c:
    is_ok = True
elif a+c==b:
    is_ok = True
elif b+c==a:
    is_ok = True

# output
if is_ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}
template <class T>
inline bool chmax(T &a, T b) //change max
{
        if (a < b)
        {
                a = b;
                return true;
        }
        return false;
}

typedef long long ll; //64bit型

using namespace std;

// const long long INF = 1LL << 60; //無限大の値
int INF = 1000000;

int main()
{
        int N, L;
        cin >> N >> L;
        int s = 0, t = 0;

        REP(i, N)
        {
                s += L + i;
        }
        int ans = 1e9;

        REP(i, N)
        {
                int t = s - (L + i);
                if (abs(t - s) < abs(ans - s))
                        ans = t;
        }
        cout << ans << endl;

        return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int sx = l[0], sy = l[1], tx = l[2], ty = l[3];

            var dx = tx - sx;
            var dy = ty - sy;

            var ans = "";
            ans += new string('U', dy);
            ans += new string('R', dx);

            ans += new string('D', dy);
            ans += new string('L', dx);

            ans += new string('L', 1);
            ans += new string('U', dy + 1);
            ans += new string('R', dx + 1);
            ans += new string('D', 1);

            ans += new string('R', 1);
            ans += new string('D', dy + 1);
            ans += new string('L', dx + 1);
            ans += new string('U', 1);

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11360
#include <iostream>
#include <cmath>
using namespace std;

const int INF = 1 << 29;

int N;
int H[100010];

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

    int dp[100010];
    for (int i = 0; i < 100010; ++i) dp[i] = INF;
    dp[0] = 0;

    for (int i = 1; i < N; ++i) {
        dp[i] = min(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]));
        if (i >= 2) dp[i] = min(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]));
    }

    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
 
int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    //10^9 + 7を格納
    ll limit = pow(10, 9)+7;
    //今回求める整数列Bでの転倒数を記録する変数
    ll ans = 0;
    //整数列A内での転倒数を求める
    ll cnt = 0;
    rep(i, N){
        for(int j = i + 1; j < N; j++){
            if(A[i] > A[j]) cnt++;
        }
    }
    //整数列A内での転倒数にKをかけたものをansに格納
    ans = (K * cnt) % limit;
    //K個の整数列から、2つを選ぶ選び方を格納
    ll val = (K*(K-1)/2) % limit;
    //整数列A内で、大小関係（あるA[i]よりも小さい要素がいくつ存在するかを調べ、その和をとる）を取得する
    ll v = 0;
    rep(i, N){
        rep(j, N){
            if(A[i] > A[j]) v++;
        }
    }
    ans = (ans + val * v) % limit;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int d = sc.nextInt();
			long sum=0;
			for(int i=d; i<=600-d; i+=d) sum += d*i*i;
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 12000
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#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(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y);

const ll LINF = 2e18;
const int INF = 1e9;

typedef pair<int, int> P;

vector<vector<ll>> dp(3005, vector<ll>(3005));

void solve(ll N, ll T, std::vector<ll> A, std::vector<ll> B) {
  vector<P> p(N);
  rep(i, N) p.at(i) = {A.at(i), B.at(i)};
  sort(all(p));

  ll ans = 0;
  rep(i, N) {
    rep(j, T) {
      chmax(dp.at(i + 1).at(j), dp.at(i).at(j));
      int nj = j + p.at(i).first;
      if (nj < T) chmax(dp.at(i + 1).at(nj), dp.at(i).at(j) + p.at(i).second);
    }
    ll now = dp.at(i).at(T - 1) + p.at(i).second;
    chmax(ans, now);
  }

  cout << ans << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  ll T;
  scanf("%lld", &T);
  std::vector<ll> A(N);
  std::vector<ll> B(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, T, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 74352
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var N = int.Parse(ss[0]);
            var A = int.Parse(ss[1]);
            var B = int.Parse(ss[2]);

            Console.WriteLine(Math.Min(A * N, B));
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main(){
  int a,b,c,i,n=0;
  scanf("%d%d%d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c%i==0)
      n++;
  }
  printf("%d\n",n);
  return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 998244353;


int main(){
  ll n;cin>>n;
  vll x(n),y(n);
  rep(i,0,n){
    cin>>x[i]>>y[i];
  }
  map<P,ll> m;
  rep(i,0,n){
    rep(j,i+1,n){
      m[make_pair(x[i]-x[j],y[i]-y[j])]++;
      m[make_pair(x[j]-x[i],y[j]-y[i])]++;
    }
  }
  ll ans=0;
  for(auto u:m){
    ans=max(ans,u.second);
  }
  cout<<n-ans<<endl;
}




Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
//#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int
main()
{
  int N, P; cin >> N >> P;
  string s; cin >> s;
  map<ll, ll> m;
  ll digit = 1;
  ll current = 0;
  ll ans = 0;
  m[0] += 1;

  if(P == 2 || P == 5){
    ll inc = 0;
    rep(i, 0, N){
     if((s[i] - '0') % P == 0) ans += i + 1;
    }
    cout << ans << endl;
    return 0;
  }

  for(ll i = N - 1; i >= 0; --i){
    current = (digit* (s[i] - '0') + current) % P;
    digit *= 10; digit %= P;
    m[current] += 1;
  }

  for(auto x: m){
    ans += x.second * (x.second - 1) / 2;
  }

  cout << ans << endl;

}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int a, b, q;
ll s[maxx], t[maxx], dd;

int main() {
	scanf("%d %d %d", &a, &b, &q);
	for(int i = 1; i <= a; i++) scanf("%lld", &s[i]);
	for(int i = 1; i <= b; i++) scanf("%lld", &t[i]);
	s[0] = s[1], t[0] = t[1];
	s[a + 1] = s[a], t[b + 1] = t[b];
	while(q--) {
		scanf("%lld", &dd);

		int cnt1 = lower_bound(s + 1, s + a + 1, dd) - s;
		cnt1 = a - cnt1 + 1; //s中有pos1个比dd大的

		int cnt2 = lower_bound(t + 1, t + b + 1, dd) - t;
		cnt2 = b - cnt2 + 1; //t中有pos2个比dd大的

		ll res = 0;
		ll ans1 = abs(dd - s[a - cnt1]);
		ll ans2 = abs(dd - s[a - cnt1 + 1]);
		ll res1 = abs(s[a - cnt1] - t[b - cnt2]);
		ll res2 = abs(s[a - cnt1 + 1] - t[b - cnt2]);
		res = min(ans1 + res1, ans2 + res2);

		ans1 = abs(dd - s[a - cnt1]);
		ans2 = abs(dd - s[a - cnt1 + 1]);
		res1 = abs(s[a - cnt1] - t[b - cnt2 + 1]);
		res2 = abs(s[a - cnt1 + 1] - t[b - cnt2 + 1]);
		ll tmp1 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp1);

		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1]);
		ll tmp2 = min(ans1 + res1, ans2 + res2);
		res = min(res, tmp2);

		ans1 = abs(dd - t[b - cnt2]);
		ans2 = abs(dd - t[b - cnt2 + 1]);
		res1 = abs(t[b - cnt2] - s[a - cnt1 + 1]);
		res2 = abs(t[b - cnt2 + 1] - s[a - cnt1 + 1]);
		ll tmp3 = min(ans1 + res1, ans2 + res2);

		res = min(res, tmp3);
		cout << res << endl;
	}
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << c+(b-d) << ' ' << d+c-a << ' ' <<  a+b-d << ' ' << b+c-a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  cin >> h >> w;
  string s;
  REP(i,h){
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
}


Measured memory_bytes: 256