akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

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

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

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

	int N=in();
	LOOP(N){
		string S=in<string>(),T=in<string>();
		int LS=S.size(),LT=T.size();
		vvll dp(LS+1,vll(LT+1,0));
		REP(i,LS){
			REP(j,LT){
				if(S[i]==T[j]){
					chmax(dp[i+1][j+1],max({dp[i+1][j],min(dp[i][j]+1,j+1)}));
				}
				else{
					chmax(dp[i+1][j+1],max({dp[i+1][j],dp[i][j+1]}));
				}
			}
		}
		out(dp[LS][LT]);
	}
	
	return 0;
}



Measured memory_bytes: 10788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    int n;
    cin >> n;
    int M = 0;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        M = max(M, a[i]);
    }
    vector<int> c(M+1, 0), d(M+1, 0);
    vector<bool> is_prime(M+1, true);
    is_prime[0] = 0;
    is_prime[1] = 0;
    repran(i, 2, M+1){
        if (is_prime[i]){
            int k = 1;
            while (i*k <= M){
                is_prime[i*k] = 0;
                d[i*k] = i;
                k++;
            }
        }
    }
    int gcd = 0;
    rep(i, n){
        int x = a[i];
        gcd = __gcd(gcd, a[i]);
        while (x > 1){
            int v = d[x];
            c[v]++;
            while (x % v == 0) x /= v;
        }
    }
    int cnt = 0;
    repran(i, 2, M+1){
        if (c[i] == n){
            cout << "not coprime" << endl;
            return 0;
        }
        cnt = max(cnt, c[i]);
    }
    if (cnt > 1) cout << "setwise coprime" << endl;
    else cout << "pairwise coprime" << endl;

}

Measured memory_bytes: 15144
a, b = map(int, input().split())

def factor(n):
    ans = []
    i = 2
    while i * i <= n:
        while n % i == 0:
            n /= i
            ans.append(i)
        i += 1
    if n > 1:
        ans.append(int(n))
    return ans

ans = len(set(factor(a)) & set(factor(b))) + 1
print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n, m, l;
        
        n =  sc.nextInt();
        m = sc.nextInt();
        l = sc.nextInt();
        
        int[][] a = new int[n][m];
        int[][] b = new int[m][l];
        long[][] c = new long[n][l];
        
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < l; j++) {
                b[i][j] = sc.nextInt();
            }
        }
        
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < l; j++) {
                c[i][j] = 0;
            }
        }
        
        
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < l; j++) {
                for(int k = 0; k < m; k++) {
                    c[i][j] += a[i][k] * b[k][j];
                }
            }
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            for(int j = 0; j < l; j++){
                sb.append(c[i][j]);
                if(j != l-1) sb.append(" ");
            }
            if(i != n-1) sb.append("\n");
        }
        System.out.println(sb);
        
    }
}



Measured memory_bytes: 51280
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

class Fibonacci {
private:
	vector<lint> fibo;
public:
	Fibonacci(int N) : fibo(N + 1) { // N > 0
		fibo[0] = 1, fibo[1] = 1;
		for (int i = 2; i <= N; i++) fibo[i] = fibo[i - 1] + fibo[i - 2];
	}

	lint val(int N) { return fibo[N]; }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W, K;
	cin >> H >> W >> K;

	// H=1,W=Nのvalidな通り→Fibonacci(1 1 2 3 5.....)
	Fibonacci Fibo(W);

	vector<vector<lint>> dp(H + 1, vector<lint>(W));
	dp[0][0] = 1;
	for (int i = 1; i <= H; i++) {
		for (int j = 0; j < W; j++) {

			dp[i][j] += dp[i - 1][j] * Fibo.val(W - 1 - j) % MOD * Fibo.val(j) % MOD;
			if (j != 0) {
				dp[i][j] += dp[i - 1][j - 1] * Fibo.val(W - 1 - j) % MOD * Fibo.val(j - 1) % MOD;
				dp[i][j] %= MOD;
			}
			if (j != W - 1) {
				dp[i][j] += dp[i - 1][j + 1] * Fibo.val(W - 1 - (j + 1)) % MOD * Fibo.val(j) % MOD;
				dp[i][j] %= MOD;
			}
		}
	}

	cout << dp[H][K - 1] << "\n";

	return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main () {
    let mut n = String::new();
    stdin().read_line(&mut n).unwrap();
    let n: usize = n.trim().parse().unwrap();

    let result = (0..n).map(|_| {
        let mut xu = String::new();
        stdin().read_line(&mut xu).unwrap();
        let xu: Vec<_> = xu.trim().split_whitespace().collect();
        let x: f64 = xu[0].parse().unwrap();
        let u = xu[1];

        match u {
            "JPY" => x,
            "BTC" => x * 380000.0,
            _     => panic!(),
        }
    }).sum::<f64>();
    println!("{:.11}", result);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifdef STOPIT
#define debug(...) 0
#else
#define debug(...)\
do {\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;\
} while (false)
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

template < template < typename ... > class Tuple,  typename... Args, std::size_t ... Inds, std::size_t = std::tuple_size< Tuple < Args ... > >::value >
std::istream& tuple_input_impl(std::istream& os, Tuple<Args...>& tuple, std::integer_sequence<std::size_t, Inds...>)
  { (void)std::initializer_list<int>{((void)(os >> std::get< Inds >(tuple)), 0)...}; return os; }
template < template < typename ... > class Tuple,  typename... Args, std::size_t = std::tuple_size< Tuple < Args ... > >::value >
std::istream& operator>> (std::istream& os, Tuple<Args...>& tuple)
  { return tuple_input_impl(os, tuple, std::index_sequence_for<Args...>()); }

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< double > x(n), y(n);
  rep(i,0,n) std::cin >> x.at(i) >> y.at(i);
  std::vector< int > ord(n);
  std::iota(all(ord), 0);
  double ans = 0;
  do {
    double tmp = 0;
    rep(i,0,n-1) {
      double dx = std::abs(x.at(ord.at(i)) - x.at(ord.at(i+1)));
      double dy = std::abs(y.at(ord.at(i)) - y.at(ord.at(i+1)));
      tmp += std::sqrt(dx*dx + dy*dy);
    }
    ans += tmp;
    // debug(ord,tmp);
  } while (std::next_permutation(all(ord)));
  rep(i,0,n) {
    ans /= (i+1);
  }
  std::cout << std::setprecision(8) << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
def powmod b, e, m
	result = 1
	while 0 < e
		result = result * b % m if e&1 == 1
		b, e = b*b%M, e>>1
	end
	return result
end
def xgcd a, b
	x, y, u, v = 1, 0, 0, 1
	until b == 0
		q, a, b = a/b, b, a%b
		x, y, u, v = u, v, x-q*u, y-q*v
	end
	return a, x, y
end
def imod a, m
	d, x, = xgcd a, m
	return nil unless d == 1
	return 0<x ? x : x+m
end

M = 1000000007
n,a,b = gets.split.map(&:to_i)

x = powmod(2,n,M)
y = n.downto(a).take([n-a,a].min).inject(1){|p,m| p*m%M } *
    imod([n-a,a].min.downto(1).inject(1){|p,m| p*m%M },M) %M
z = n.downto(b).take([n-b,b].min).inject(1){|p,m| p*m%M } *
    imod([n-b,b].min.downto(1).inject(1){|p,m| p*m%M },M) %M
p (x-y+M-z+M-1)%M


Measured memory_bytes: 4860
#include <stdio.h>
#include <iostream>
#include <cstring>
using namespace std;

#define maxn 1000005
int arr[maxn];


void init()
{
	for (int i = 0; i < maxn; ++i){
		arr[i]=(i+1)*(i+1);
	}

}

int main(int argc, char const *argv[])
{
	

	init();
	int t=0; cin>>t;

	for (int i = 0; i < maxn; ++i)
	{
		if(arr[i+1]>t){
			cout<<arr[i]<<endl;
			break;
		}
	}



	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 101
using namespace std;

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

int main() {
    int N, a[MAX_N];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    
    sort(a, a + N, greater<int>());
    
    int Alice_score = 0, Bob_score = 0;
    
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            Alice_score += a[i];
        } else {
            Bob_score += a[i];
        }
    }
    
    cout << Alice_score - Bob_score << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define vi vector<int>
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long 
using namespace std;
const int mod = 1e9+7;
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;cin >> n >>k;
	vi v(n+1);
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	for (int i = k+1; i <= n; i++) {
		if (v[i] > v[i-k]) cout <<"Yes\n";
		else cout <<"No\n";
	}
}

Measured memory_bytes: 3980
n = int(input())
A = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1
for i in range(n):
  a = A[i]
  ans *= int(a==x) + int(a==y) + int(a==z)
  if a == x:
    x += 1
  elif a == y:
    y += 1
  elif a == z:
    z += 1
  else:
    print(0)
    exit()
print(ans%(10**9+7))

Measured memory_bytes: 13964
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 22 10:08:31 2018

@author: Yuya
"""

s=list(input())

x, y = map(int, input().split())

N = len(s)
count=0
flag = 1

x_s = []
y_s = []

for i in range(N):
    if s[i]=="F":
        count+=1
    else:
        if flag>0:
            x_s.append(count)
        else:
            y_s.append(count)     
        flag=flag*-1
        count=0

if flag>0:
    x_s.append(count)
else:
    y_s.append(count)
    
if s[0]=="F":
    x = x-x_s[0]
    del x_s[0]
    
def t_dfs(move, target):

    move.sort()
    move.reverse()

    for dx in move:
        if target > 0:
            target -= dx
        else:
            target += dx

    return target == 0    

if t_dfs(x_s, x) and t_dfs(y_s, y):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    String[] days = new String[]{"-1", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    Scanner sc = new Scanner(System.in);
    String day = sc.next();
    for (int i = 0; i < days.length; i++) {
      if (days[i].equals(day)) System.out.println(i);
    }
  }
}



Measured memory_bytes: 22612
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    i = 0
    ans = 0

    while i < n:
        s = a[i]
        j = i
        k = i
        while j < n and s <= a[j]:
            s = a[j]
            j += 1
        while k < n and s >= a[k]:
            s = a[k]
            k += 1
        i = max(j, k)
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 85500
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final long[] array = new long[n];

        long sum = 0;
        for (int i = 0; i < n; i++) {
            final long tmp = scanner.nextLong();
            array[i] = tmp;
            sum += tmp;
        }

        long tmp = 0;
        int i;
        for (i = 0; i < n; i++) {
            tmp += array[i];
            if (tmp * 2 == sum) {
                System.out.println(0);
                return;
            }

            if (tmp * 2 > sum) {
                break;
            }
        }

        System.out.println(Math.min(tmp * 2 - sum, sum - (tmp - array[i]) * 2));
    }
}


Measured memory_bytes: 89604
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int W, H, N;
vector<vector<int>> get_dis(int nx, int ny, const vector<pair<int,int>>&bombs) {
	int dx[] = { -1,-1,0,1,1,1,0,-1 };
	int dy[] = { 0,1,1,1,0,-1,-1,-1 };


	vector<vector<int>>times(H,vector<int>(W,1e9));

	times[ny][nx]=0;

	queue<pair<int,int>>que;
	que.emplace(nx,ny);
	while (!que.empty()) {
		auto atop(que.front());
		que.pop();

		int now_x=atop.first;
		int now_y=atop.second;
		int now_time=times[now_y][now_x];
		for (int way = 0; way < 8; ++way) {
			int next_x=now_x+dx[way];
			int next_y=now_y+dy[way];

			if(next_x<0||next_x>=W||next_y<0||next_y>=H)continue;
			if(find(bombs.begin(),bombs.end(),make_pair(next_x,next_y))!=bombs.end())continue;

			if (times[next_y][next_x] > now_time + 1) {
				times[next_y][next_x]=now_time+1;
				que.push(make_pair(next_x,next_y));
			}
		}
	}

	return times;
}

int get_atime(int nx, int ny, const vector<pair<int, int>>&path, const int ntime,const vector<pair<int,int>>bombs) {

	auto times=get_dis(nx,ny,bombs);

	for (int i = ntime; i < path.size(); ++i) {
		int px=path[i].first;
		int py=path[i].second;

		int dis=times[py][px];

		if(dis<=i-ntime)return i;
	}
	return -1;
}


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

	int sx,sy;cin>>sx>>sy;
	sx--;sy--;

	vector<vector<pair<int,int>>>paths(N);

	vector<pair<int,int>>bombs(N);
	for (int i = 0; i < N; ++i) {
		int p;cin>>p;
		for (int j = 0; j < p; ++j) {
			int x,y;cin>>x>>y;x--;y--;

			if (j == p - 1) {
				bombs.emplace_back(x,y);
			}
			else {

				paths[i].emplace_back(x, y);

			}
		}
	}

	vector<int>perms(N);

	iota(perms.begin(),perms.end(),0);


	int ans=1e8;
	do {

		int now_x=sx;
		int now_y=sy;
		int now_time=0;
		for (int i = 0; i < N; ++i) {
			const int next_bomb_id=perms[i];

			int next_time=get_atime(now_x,now_y,paths[next_bomb_id],now_time,bombs);
			if (next_time == -1) {
				now_time=1e8;
				break;
			}
			else {
				now_time=next_time;
				now_x=paths[next_bomb_id][next_time].first;
				now_y=paths[next_bomb_id][next_time].second;
			}
		}
		ans=min(ans,now_time);
	}while(next_permutation(perms.begin(),perms.end()));

	if(ans>1e7)ans=-1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3172
X, Y = map(int, input().split())
mod = 10**9+7

if (X+Y) % 3 != 0:
    print(0)
else:
    n = (2*Y-X)//3
    m = (2*X-Y)//3
    '''
    n*(1,2) + m*(2,1) = (x, y)
    x = n+2m
    y = 2n+m
    2x = 2n+4m
    2x-y = 3m
    m = (2x-y)/3
    n = (2y-x)/3 
    '''
    if 0 > n or 0 > m:
        print(0)
    else:
        ans = 1
        for i in range(1,n+1):
            ans *= (n+m+1-i)*pow(i,mod-2,mod)
            ans %= mod
        print(ans)


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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double ans = 0.0;
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) ans += dist(i, j) * 2 / N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return;
}

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


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

deque<int> A, B;
int c;

void work(long long n){
	if(n == 1) return;
	if(n > 1){
		work(n >> 1);
		A.push_back(++c), B.push_back(c);
	}
	if(n & 1) A.push_back(++c), B.push_front(c);
}

long long n;

int main(){
	cin >> n;
	work(n + 1);
	int x = A.size() + B.size();
	printf("%d\n", x);
	for(int v : A) printf("%d ", v);
	for(int v : B) printf("%d ", v);
	return 0;
}

Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-12-22
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    int H; cin >> H;
    int W; cin >> W;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int A,B; cin >> A >> B;
        if(H <= A && W <= B){
            ans ++;
        }
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=1;
		while(true) {
			int x=scan.nextInt();
			int y=scan.nextInt();
			if(x==0 && y==0) break;
			else if(y<x) {
				a=x;
				x=y;
				y=a;
			}
			System.out.println(x+" "+y);
		}
		scan.close();
}
}


Measured memory_bytes: 36448
package main

import "fmt"

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

	hs := make([]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Scan(&hs[i])
	}

	max := 0

	cnt := 0
	prev := hs[0]
	for i := 1; i < n; i++ {
		if hs[i] <= prev {
			cnt++
			prev = hs[i]
			if max < cnt {
				max = cnt
			}
			continue
		}
		cnt = 0
		prev = hs[i]
	}
	fmt.Println(max)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    P s,t;
    cin >> get<0>(s) >> get<1>(s) >> get<0>(t) >> get<1>(t);

    for(int i = get<1>(s); i < get<1>(t); ++i){
        cout << "U";
    }
    for(int i = get<0>(s); i < get<0>(t); ++i){
        cout << "R";
    }
    for(int i = get<1>(s); i < get<1>(t); ++i){
        cout << "D";
    }
    for(int i = get<0>(s); i < get<0>(t); ++i){
        cout << "L";
    }
    cout << "L";
    for(int i = get<1>(s); i < get<1>(t) + 1; ++i){
        cout << "U";
    }
    for(int i = get<0>(s); i < get<0>(t) + 1; ++i){
        cout << "R";
    }
    cout << "D";
    cout << "R";
    for(int i = get<1>(s); i < get<1>(t) + 1; ++i){
        cout << "D";
    }
    for(int i = get<0>(s); i < get<0>(t) + 1; ++i){
        cout << "L";
    }
    cout << "U" << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Darts
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt(), m = sc.nextInt();
			if((n|m)==0)break;
			int[] p = new int[n+1];
			for(int i=0;i<n;i++)p[i]=sc.nextInt();
			int[] a = new int[(n+1)*(n+2)/2];
			int N = 0;
			for(int i=0;i<=n;i++)for(int j=i;j<=n;j++)if(p[i]+p[j]<=m)a[N++]=p[i]+p[j];
			Arrays.sort(a);
			int max = 0;
			int s = 0;
			int t = a.length-1;
			while(s<=t){
				if(max==m)break;
				if(a[s]+a[t]<=m){
					max=Math.max(max, a[s]+a[t]);
					s++;
				}
				else t--;
			}
			System.out.println(max);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }

void main() {
    dchar[] s = readln.chomp.to!(dchar[]);
    dchar[] t = readln.chomp.to!(dchar[]);

    bool can() {
        foreach (_; 0..s.length+1) {
            bringToFront(s[0..1], s[1..$]);
            if (s == t) return true;
        }
        return false;
    }

    writeln(can() ? "Yes" : "No");
}


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

const int MOD = 1e9 + 7;
int N, K;
long ans = 1;
vector<int> graph[100000];

void dfs(int from, int now) {
    // permtation(nPr)
    int n = K - 2;
    int r = graph[now].size() - 1;
    if (from == -1) {
        n = K;
        r += 2;
    }
    rep(i, r) {
        ans *= n - i;
        ans %= MOD;
    }
    for (int to: graph[now]) {
        if (to == from) continue;
        dfs(now, to);
    }
}

int main() {
    cin >> N >> K;
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(-1, 0);
    cout << ans << endl;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
inline int val(string &s)
{
	int c=0;
	for(int i=0;i<s.size();i++)
	{
		c=c*3+s[i]-'0';
	}
	return c;
}
inline int cnt(string &s)
{
	int c=0;
	for(int i=0;i<s.size();i++)
	{
		c+=(s[i]=='2');
	}
	return c;
}
int n;
vector<pair<int,bool> > v[16];
int dp[16][14348906];

int f(int pos,string mask)
{
	if(pos==n)
	{
		return cnt(mask);
	}
	int ret=dp[pos][val(mask)];
	if(ret!=-1)return ret;
	int a=0,b=0,ff=1;
	char temp=mask[pos];
	if(mask[pos]!='2')
	{
		mask[pos]='1';
		a=f(pos+1,mask);
		mask[pos]=temp;
	}
	if(mask[pos]=='1')
	{
		ret=a;
		return a;
	}
	else
	{
		temp=mask[pos];
		mask[pos]='2';
		for(int i=0;i<v[pos].size();i++)
		{
			int x=v[pos][i].first;
			if(v[pos][i].second)
			{
				if(mask[x]=='1')
				{
					ff=0;
					break;
				}
				mask[x]='2';
			}
			else
			{
				if(mask[x]=='2')
				{
					ff=0;
					break;
				}
				mask[x]='1';
			}
		}
		if(temp=='0')
		{
			if(ff)
			{
				b=f(pos+1,mask);
			}
			ret=max(a,b);
			return ret;
		}
		else
		{
			if(ff)
			{
				b=f(pos+1,mask);
				ret=b;
				return b;
			}
			ret=0;
			return 0;
		}
	}
}
int main(int argc, char const *argv[])
{
	memset(dp,-1,sizeof dp);
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a,x,y;
		scanf("%d",&a);
		for(int j=0;j<a;j++)
		{
			scanf("%d %d",&x,&y);
			v[i].emplace_back(x-1,(bool)y);
		}
	}
	printf("%d\n",f(0,string(15,'0')));
	return 0;
}


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

using namespace std;
using ll = long long;

const int N = 200005;

int n;
ll k, a[N], b[N];

bool f(ll lim) {
	ll req = 0;

	for(int i = 0; i < n; i++) {
		req += max(0LL, a[i] - lim / b[i]);
	}

	return req <= k;
}

int main() {
	scanf("%d %lld", &n, &k);
	for(int i = 0; i < n; i++) scanf("%lld", a + i);
	for(int i = 0; i < n; i++) scanf("%lld", b + i);
	sort(a, a + n);
	sort(b, b + n); reverse(b, b + n);

	ll lo = 0, hi = 1e13, ans = -1;
	while(lo <= hi) {
		ll mid = (lo + hi) / 2;
		if(f(mid)) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3328
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	s := nextString()
	if s[2] == s[3] && s[4] == s[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

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


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<vector<mint> > dp(n+1, vector<mint> (k+1, 0));
    for(int i=0;i<=k;i++)dp[0][i] = 1;
    for(ll i=1;i<=n;i++){
    	for(ll j=1;j<=k;j++){
    		dp[i][j] = dp[i][j-1] + ((i>=j)?dp[i-j][j]:0LL);
    	}
    }
    cout << dp[n][k] << endl;
    return 0;
}



Measured memory_bytes: 10756
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] G = new int[n][n];
		
		for (int i = 0; i < n; i++) {
			int u = sc.nextInt();
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int v = sc.nextInt();
				G[u][v] = sc.nextInt();
			}
		}
		solve1(n, G);
	}
	
	public static void solve1(int n, int[][] G) {
		int[] dist = new int[n];
		int[] cand = new int[n];
		Arrays.fill(dist, -1);
		Arrays.fill(cand, Integer.MAX_VALUE);
		dist[0] = 0;
		
		int s = 0;
		int count = n;
		while(count > 0) {
			for (int i = 0; i < n; i++) {
				if (G[s][i] == 0)
					continue;
				cand[i] = Math.min(G[s][i] + dist[s], cand[i]);
			}
			
			int minI = s;
			int minD = Integer.MAX_VALUE;
			for (int i = 0; i < n; i++) {
				if (dist[i] < 0 && cand[i] < minD) {
					minI = i;
					minD = cand[i];
				}
			}
			if (minI != s) {
				dist[minI] = minD;
				s = minI;
			}
			count--;
		}
		for (int i = 0; i < n; i++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}

Measured memory_bytes: 31832
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long ans=1;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	  ans*=2;
	printf("%d\n",(1900*m+100*(n-m))*ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map> 
#include<cstdlib>
#include<cctype>
#include<cstring>
#include<string> 
#define maxn 200007
#define SDOI2020 RP++ 
using namespace std;
int n,maxx,cnt; 
string s[maxn],qwq[maxn];
map<string,int> m;
inline int read()
{
	int x=0;
	int flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
		}
		if(flag==1) x=-x;	
		return x;
}


bool cmp(string  a,string b)
{
    return a < b;
}

int main()
{
	n = read();
	for(register int i = 1;i <= n;i++)
	{
		cin>>qwq[i];
		string b = qwq[i];
		m[b] += 1;;
		maxx = max(maxx,m[qwq[i]]);
	}
	for(register int i = 1;i <= n;i++)
	{
		if(m[qwq[i]] == maxx)
		{
			s[++cnt] = qwq[i];
			m[qwq[i]] = 0;
		}
	}
	sort(s + 1,s + cnt + 1,cmp);
	for(register int i = 1;i <= cnt;i++)
	{
		cout<<s[i]<<endl;
	}
	
	return 0;
}

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

//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
vector<int> a[100001];
bool d[100001][4]; 
int ans = -1;
int s, e;

int main() {
	// 오늘 할 것!  종만북 보기! 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		a[y].push_back(x);
	}
	cin >> s >> e;
	priority_queue<pair<int, pair<int, int>>> q;
	q.push({ 0,{e,0 } });
	while (!q.empty()) {
		int z = -q.top().first; 
		int x = q.top().second.first;
		int y = q.top().second.second; q.pop(); 
		if (x == s && y == 0) {
			cout << z << '\n'; return 0;
		}
		for (int i = 0; i < a[x].size(); i++) {
			int nx = a[x][i]; 
			int ny = (y + 1) % 3; 
			int nz = z;if (y + 1 == 3)nz += 1; 
			if (!d[nx][ny]) {
				d[nx][ny] = true; 
				q.push({ -nz,{nx,ny} });
			}
		}
	}
	cout << -1 << '\n';



}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int H, W;
    cin >> H >> W;
    int A[H][W], B[H][W], C[H][W];
    rep(i, H) rep(j, W) cin >> A[i][j];
    rep(i, H) rep(j, W) cin >> B[i][j];
    rep(i, H) rep(j, W) C[i][j] = abs(A[i][j]-B[i][j]); 
    int L = 12801;
    bool dp[H][W][L];
    rep(i, H) rep(j, W) rep(k, L) dp[i][j][k] = false;
    dp[0][0][C[0][0]] = true;
    rep(i, H){
        rep(j, W){
            rep(k, L){
                if(!dp[i][j][k]) continue;
                if(i != H-1){
                    int a = k + C[i+1][j];
                    int b = abs(k - C[i+1][j]);
                    dp[i+1][j][a] = dp[i+1][j][b] = true;
                }
                if(j != W-1){
                    int a = k + C[i][j+1];
                    int b = abs(k - C[i][j+1]);
                    dp[i][j+1][a] = dp[i][j+1][b] = true;
                }
            }
        }
    }
    rep(k, L){
        if(dp[H-1][W-1][k]){
            cout << k << endl;
            break;
        }
    }
}

Measured memory_bytes: 80384
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
ans=0
mon1=a[0]
mon2=a[0]+a[1]
for i in range(n):
   if b[i] <= mon1:
      ans+=b[i]
      mon1=a[i+1]
      if i<=n-2:
         mon2=a[i+1]+a[i+2]
   elif mon1<b[i]<=mon2:
      ans+=b[i]
      mon1=a[i+1]-(b[i]-mon1) #ここmon2-b[i]のほうがきれい？
      if i<=n-2:
         mon2=mon1+a[i+2]
   else: 
      ans+=mon2 #ここmon2にしないと動かないぞ
      mon1=0
      if i<=n-2:
         mon2=a[i+2]
print(ans)

Measured memory_bytes: 19648
//
// Created by 吉川純平 on 2019-12-01.
//

#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
//using ull = unsigned long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll h;
  cin >> h;
  vector<ll> vec(h);
  rep(i,h){
    cin >> vec[i];
  }
  rep(i,h){
    printf("node %d:",i+1);
    printf(" key = %lld,",vec[i]);
    if(i != 0){
      printf(" parent key = %lld,",vec[(i-1)/2]);
    }
    if(i * 2 + 1 < h){
      printf(" left key = %lld,",vec[i*2+1]);
    }
    if(i * 2 + 2 < h){
      printf(" right key = %lld,",vec[i*2+2]);
    }
    cout << " " << endl;
  }
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define SORT(v) sort(v.begin(),v.end())
#define fori(i,a,b) for(ll i=a;i<b;i++)
#define M 1000000007
#define deb(x) cout<< #x << " " << x << endl;

double pi=3.14159265358979323846;

typedef pair<int,int> pii;
typedef pair<long long int, long long int>pll;
typedef vector<int>vi;
typedef vector<long long int>vl;
#define M 1000000007



int main ()
{
    ll T;
   T=1;
   //cin>>T;
    while(T--)
    {	
   ll n,wtl;
   cin>>n>>wtl;
   vl v(n+1),w(n+1);
   fori(i,1,n+1){cin>>w[i]>>v[i];}
   vl dp(wtl+1,0);
   for(ll item=1;item<=n;item++){
   	for(ll cap=wtl;cap>=0;cap--){
   		ll nc,c;
   		nc=dp[cap];
   		if(w[item]>cap){c=dp[cap];}
   		else{
   			c=max(dp[cap-w[item]]+v[item],nc);
   		}
   		dp[cap]=c;
   	}
   }
   cout<<dp[wtl]<<endl;
   
    
    }
    return 0;
}


Measured memory_bytes: 4012
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	sort(a, a+5);
	reverse(a, a+5);
	cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << " " << a[4] << endl;
	return 0;
}

Measured memory_bytes: 1180
from functools import reduce
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return b // gcd(a, b) * a
n=int(input())
a=list(map(int,input().split()))
x=reduce(lambda x,y: lcm(x,y), set(a))
ans=0
for i in a:
  ans+=x//i
ans%=1000000007
print(ans)

Measured memory_bytes: 5216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'o') cnt++;
	}

	if (cnt + 15 - s.size() >= 8) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import fileinput


def algorithm(n, m, a):
    foods = set(a[0][1:])
    for f in a[1:]:
        foods &= set(f[1:])
    return len(foods)


def pass_inputs(input_lines):
    n, m = input_lines[0]
    return algorithm(n, m, input_lines[1:])


def convert_int(s):
    try:
        r = int(s)
    except ValueError:
        r = s
    return r


def run():
    out = pass_inputs([[convert_int(v) for v in l.strip().split(" ")] for l in fileinput.input()])
    print(out)


if __name__ == "__main__":
    run()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n;
    cin >> n;
    vector<char> ans;
    while (n > 0) {
        ll x = n % 26;
        if (x == 0) x = 26;
        ans.emplace_back((char)((x - 1) + 'a'));
        n = (n - 1) / 26;
    }
    REV(ans);
    for (auto c : ans) cout << c;
    cout << endl;
}


Measured memory_bytes: 3652
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    int h,w;
    cin>>h>>w;
    char a[h+2][w+2];
    fill(&a[0][0],&a[0][0]+sizeof(a),'#');
    rep(i,h)rep(j,w) cin>>a[i+1][j+1];
    rep(i,h+2){
        rep(j,w+2) cout<<a[i][j];
        cout<<endl;
    }
 
    return 0;
}

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

using namespace std;

int main()
{
    while(1)
    {
        int H,W,i,j;
        cin >> H >> W;
        if(H==0 && W==0){
            break;
        }
        for(i = 0; i<H ; i++){
            if(i%2 == 0){
                for(j=0;j<W;j++){
                    if(j%2==0){
                        cout << "#";
                    }
                    else
                        cout << ".";
                }
            }
            else{
                for(j=0;j<W;j++){
                    if(j%2==0){
                        cout << ".";
                    }
                    else
                        cout << "#";
                }
            }
            cout << endl;
        }
cout << endl;

    }
    return 0;
}





Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    using P = pair<ll, ll>;

    ll h, w, m;
    cin(h); cin(w); cin(m);

    vector<ll> hs(h), ws(w);
    set<P> s;

    rep2(i, m) {
        ll _h, _w;
        cin(_h); cin(_w);
        --_h; --_w;

        ++hs[_h]; ++ws[_w];
        s.emplace(_h, _w);
    }

    ll mh = 0, mw = 0;
    rep2(i, h) mh = max(mh, hs[i]);
    rep2(i, w) mw = max(mw, ws[i]);

    vector<ll> hi, wi;
    rep2(i, h) if (hs[i] == mh) hi.push_back(i);
    rep2(i, w) if (ws[i] == mw) wi.push_back(i);

    ll result = mh + mw;

    for (auto i: hi) for (auto j: wi) {
        if (s.count({ i, j }) > 0) continue;

        print(result);
        return 0;
    }

    --result;
    print(result);
    return 0;
}

Measured memory_bytes: 35056
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdlib>
#include <cstdio>
using namespace std;

#define next '\n'
#define rep(i, n) for(int (i) = (0); (i) < (n); (i++))
using ll = long long;

int a[5];

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

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

    int ans = 0;
    if(b * 2 >= a) ans = 0;
    else ans = a - (b * 2);

    cout << ans << next;
}

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

char name[] = {
	'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
	'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
	'u', 'v', 'w', 'x', 'y', 'z', '.'
};

int index(char c){
	if(c == '.') return 26;
	return ((int)c - 97);
}

char change(char c, int i){
	if(c == '.') return '.';
	if(c == ' ') return ' ';
	return name[(index(c) + i) % 26];
}

char rchange(char c, int i){
	if(c == '.') return '.';
	if(c == ' ') return ' ';
	return name[(index(c) + 26 - i) % 26];
}

bool search(string s, const string& t, int i){
	string t2;
	for(string::const_iterator iter = t.begin();
		iter != t.end(); iter++)
	{
		t2.push_back(rchange(*iter,i));
	}
	string::const_iterator it = search(s.begin(), s.end(), t2.begin(), t2.end());
	if(it != s.end()){
		if(it == s.begin() || it[-1] == ' ')
			if(it + t2.size() == s.end() || (it[t2.size()] == ' ' || it[t2.size()]))
				return true;
	}
	return false;
}

int main(){
	string s;
	const string t1("the"), t2("this"), t3("that");
	while(getline(cin, s)){
		int i = 0;
		for(; i < 26; i++){
			if(search(s, t1,i) || search(s, t2, i) || search(s, t3, i))
				break;
		}
		for(string::const_iterator it = s.begin();
			it != s.end(); it++)
		{
			cout << change(*it, i);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int t, x;
    cin >> t >> x;
    cout << (double)t / x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for (register int i=a;i<=n;i++)
#define per(i,a,n) for (register int i=n;i>=a;i--)
#define FOR(i,a,n,x) for (register int i=a;i<=n;i+=x)
#define ROF(i,a,n,x) for (register int i=n;i>=a;i-=x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define VI vector<int>
#define ll long long
#define ull unsigned long long
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls (p << 1)
#define rs (p << 1 | 1)
using namespace std;

template <typename T>

inline void read(T &X) {
  X = 0; char ch = 0; T op = 1;
  for(; ch > '9' || ch < '0'; ch = getchar())
    if(ch == '-') op = -1;
  for(; ch >= '0' && ch <= '9'; ch = getchar())
    X = (X << 3) + (X << 1) + ch - 48;
  X *= op;
}

const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 5;

int arr[MAXN];
int n;

int main() {
#ifdef WiLe
  freopen ("input.txt", "rt", stdin);
#endif

  read(n);
  rep (i, 1, n) read(arr[i]);

  sort(arr+1, arr+n+1, greater<int>());

  ll ans = 0;
  int inx = 4;
  rep (i, 1, n) {
    if (i == 1) ans += 0;
    else if (i == 2) ans += arr[1];
    else ans += arr[inx/2], inx++;
    // cout << i << " " << ans << endl;
  }

  printf("%lld\n", ans);

#ifdef WiLe
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}
/*
# author : WiLe
# date : 2020/07/18
*/

Measured memory_bytes: 4536
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


int main() {
	int n, d;
	cin >> n >> d;
	puts((n + 2 * d) / (2 * d + 1));
	return 0;
}

Measured memory_bytes: 256