akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
	double x[2],y[2],r[2];
	int n;
	cin >> n;
	while(n--){
		for(int i=0; i<2; i++){
			cin >> x[i] >> y[i] >> r[i];
		}
		double d = sqrt(pow(x[1]-x[0],2)+pow(y[1]-y[0],2));
		if(r[0]+r[1]<d) cout << "0" << endl;
		else if(r[0]>r[1]){
			if(r[0]-r[1]<=d&&d<=r[0]+r[1]) cout << "1" << endl;
			if(d < r[0] -r[1]) cout << "2" << endl;
		}else{
			if(r[1]-r[0]<=d&&d<=r[0]+r[1]) cout << "1" << endl;
			if(d < r[1] -r[0]) cout << "-2" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var score = new int[num];
        for (var i = 0; i < num; i++)
            score[i] = ToInt32(ReadLine());
        Array.Sort(score);
        var sum = score.Sum();
        var q = 0;
        while (sum % 10 == 0)
        {
            if (q == num) break;
            sum -= score[q]%10==0?0:score[q];
            q++;
        }
        WriteLine(q!=num?sum:0);
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll P, Q, R;
	cin >> P >> Q >> R;
	cout << min(P+Q, min(Q+R, P + R)) << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    bool ok = true;
    rep(i, n){
        int x;
        cin >> x;
        if(x%2 == 0){
            if(x%3 == 0 || x%5 == 0) continue;
            ok = false;
        }
    }

    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	vector<ll> v(3, 0);

	REP(i, 3) {
		cin >> v[i];
	}

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

	cout << v[0] * v[1] / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n,i;
    cin>>n;
    int d[n];
    for(i=0;i<n;i++)cin>>d[i];
    sort(d,d+n);
    cout<<d[n/2]-d[n/2-1]<<endl;
}


Measured memory_bytes: 640
N = int(input())

dp = [10 ** 9] * 100001
dp[0] = 1

for i in range(N):
    if dp[i] > 0:
        dp[i + 1] = min(dp[i] + 1, dp[i + 1])
        for j in range(1, 7):
            if 6 ** j + i <= N:
                dp[i + 6 ** j] = min(dp[i] + 1, dp[i + 6 ** j])
            if 9 ** j + i <= N:
                dp[i + 9 ** j] = min(dp[i] + 1, dp[i + 9 ** j])

print(dp[N] - 1)


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

int N,W,H,S,T,ans,cnt;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N,N){
        cin >> W >> H;
        vector<vector<int>> tree(W,vector<int>(H,0));
        for(int i=0;i<N;++i){
            int x,y; cin >> x >> y;
            ++tree[--x][--y];
        }
        cin >> S >> T;
        ans=0;
        for (int i=0;i+S-1<W;++i){
            for (int j=0;j+T-1<H;++j){
                cnt=0;
                for (int k=0;k<S;++k){
                    for (int l=0;l<T;++l){
                        cnt+=tree[i+k][j+l];
                    }
                }
                ans=max(ans,cnt);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int k = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);

		if (500 * k >= x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 32464
#include <cstdio>
#include <queue>
int N, K;
int a[500001], ref[500001], ans[500001];
int d[500001];
int T[1048576];
int head[500001], next[1000001], to[1000001], E;
int GL(int p, int l, int r, int x)
{
	if (!T[p])
		return 0;
	if (r <= x)
	{
		while (l < r)
		{
			int m = l + r >> 1;
			if (T[p << 1 | 1])
				p = p << 1 | 1, l = m + 1;
			else
				p <<= 1, r = m;
		}
		return l;
	}
	int m = l + r >> 1;
	int t = m + 1 <= x ? GL(p << 1 | 1, m + 1, r, x) : 0;
	return t ? t : GL(p << 1, l, m, x);
}
int GR(int p, int l, int r, int x)
{
	if (!T[p])
		return 0;
	if (l >= x)
	{
		while (l < r)
		{
			int m = l + r >> 1;
			if (T[p << 1])
				p <<= 1, r = m;
			else
				p = p << 1 | 1, l = m + 1;
		}
		return l;
	}
	int m = l + r >> 1;
	int t = m >= x ? GR(p << 1, l, m, x) : 0;
	return t ? t : GR(p << 1 | 1, m + 1, r, x);
}
void P(int x, int w)
{
	int p = 1, l = 1, r = N;
	T[p] += w;
	while (l < r)
	{
		int m = l + r >> 1;
		if (x <= m)
			p <<= 1, r = m;
		else
			p = p << 1 | 1, l = m + 1;
		T[p] += w;
	}
}
void add(int u, int v)
{
	d[u]++;
	next[++E] = head[v];
	to[E] = u;
	head[v] = E;
}
std::priority_queue < int > Q;
int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; i++)
		scanf("%d", a + i);
	for (int i = 1; i <= N; i++)
	{
		int L = GL(1, 1, N, a[i]), R = GR(1, 1, N, a[i]);
		if (L)
			add(ref[L], i);
		if (R)
			add(i, ref[R]);
		ref[a[i]] = i;
		P(a[i], 1);
		if (i >= K)
			P(a[i - K + 1], -1);
	}
	for (int i = 1; i <= N; i++)
		if (d[i] == 0)
			Q.push(i);
	for (int w = N; w; w--)
	{
		int pos = Q.top();
		Q.pop();
		ans[pos] = w;
		for (int e = head[pos]; e; e = next[e])
			if (!--d[to[e]])
				Q.push(to[e]);
	}
	for (int i = 1; i <= N; i++)
		printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 25560
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
//#define f first
//#define s second
//#define mp make_pair
#define gg return 0;
#define pii pair < int, int>
 
using namespace std;
 
const int maxn = 132675;
const int INF = (int)1e9 + 7;
 
ll a,b[maxn],c,d,cnt,e[(int)2e3 + 1][(int)2e3 + 1],cost[maxn],tout[maxn],mn = INF,mx = -INF,l,r;
 
ll x[maxn],y[maxn],x2[maxn],y2[maxn];
 
ll kol;

bool u[maxn], m, f;

set <int> s; 

 /*
void forn( int s, int f, int inter){
	for(int i = s; i <= f; i += inter){
		b[i] = i;
	}
}
*/ 
ll ans;

vector <int> primev; 

/*
void dfs(int v){
	lvlc++;
	lvl[v] = lvlc;
	d[lvl[v]].pb(v);
	u[v] = 1;
	for(int i = 0; i < g[v].size(); ++i){
		int to = g[v][i];
		if(!u[to]){
			dfs(to);
		}
	}
	lvlc--;
}*/

bool prime[45001];

char ch;


void find_divs( int n) {
   	int dlim, m = 1;
  	s.insert(1);
  	int op = n;
   	dlim = sqrt( n );
   	for(int d = 2; d <= dlim; ++d){
      if (n % d == 0){
         s.insert(m * d);
         if( m*d != n/d )
            s.insert(n/d);
         n /= d;
         m *= d;
         dlim = sqrt( n );
      }
   }
}

int main()
{	
    cin >> a >> c;
    kol = c;
    c -= (a * 2);
    if(c <= 0){
    	cout << kol / 2;
    	return 0; 
    }
    cout << a + c / 4;
    gg
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var d = ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(d);
        WriteLine(d[N/2]-d[N/2-1]);
    }
}


Measured memory_bytes: 35924
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N,A,B,C,D,E;
  cin>>N>>A>>B>>C>>D>>E;
  
  int64_t S=min(A,min(B,min(C,min(D,E))));
  
  cout<<4+(N+S-1)/S<<endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		char[][] s = new char[H][W];
		for (int i = 0; i < H; i++) {
			s[i] = in.next().toCharArray();
		}
		boolean isOk = true;
		for (int i = 0; i < s.length; i++) {
			for (int j = 0; j < s[i].length; j++) {
				if (s[i][j] == '#') {
					if ((i + 1 < s.length && s[i + 1][j] == '#') || (i - 1 > -1 && s[i - 1][j] == '#')
							|| (j + 1 < s[i].length && s[i][j + 1] == '#') || (j - 1 > -1 && s[i][j - 1] == '#')) {
					} else {
						isOk = false;
					}
				}
			}
			if (!isOk) {
				break;
			}
		}
		System.out.println(isOk ? "Yes" : "No");
		in.close();
	}
}

Measured memory_bytes: 22740
#include <stdio.h>

int main() {
	int big[3]={0};
	int b=0;
	int i;
	for(i=0; i<10; i++){
		scanf("%d",&b);
		if(big[0]<b){
			big[2]=big[1];
			big[1]=big[0];
			big[0]=b;
		}else{
			if(big[1]<b){
				big[2]=big[1];
				big[1]=b;
			}else{
				if(big[2]<b){
					big[2]=b;
				}
			}
		}
	}
	printf("%d\n%d\n%d\n",big[0],big[1],big[2]);
	return 0;
}

Measured memory_bytes: 600
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = lreads(N);
    auto m1 = new long[](N + 1);
    m1[] = long.min;
    auto m2 = new long[](N + 1);
    m2[] = long.min;
    foreach (i; 0 .. N)
    {
        m1[i + 1] = max(m1[i], A[i]);
    }
    foreach_reverse (i; 0 .. N)
    {
        m2[i] = max(m2[i + 1], A[i]);
    }
    foreach (i; 0 .. N)
    {
        max(m1[i], m2[i + 1]).writeln();
    }
}


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF ll(1e18)
#define MOD (ll)1e9+7
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum+=__gcd(__gcd(i,j),k);
            }
        }
	}
	cout<<sum<<"\n";
}


Measured memory_bytes: 3660
N,D =map(int, input().split())
all_list = [list(map(int, input().split())) for i in range(N)]
#>>>4
count = 0
for n in range (N):
    for nn in range(n):
        distance = 0
        for d in range(D):
            kou = (all_list[n][d] - all_list[nn][d])**2
            distance += kou
        for s in range(250):
            if distance == s**2:
                count += 1
                break
print(count)


Measured memory_bytes: 3060
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }


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

	vector<string> S(N);
	rep(i, N)
		cin >> S[i];


	ll ans = 0;
	for (int d = 0; d < N; d++) {

		if (d != 0) {
			string u = S[0];
			S.erase(S.begin());
			S.push_back(u);
			

		}


		bool flag = true;
		rep(i, N) {
			rep(j, N) {
				if (S[i][j] != S[j][i]) { flag = false;  break; }


			}
		}


		if (flag == true) {

			ans += N;
		}

	}

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

Measured memory_bytes: 384
# include <bits/stdc++.h>
# define lli long long int
# define pb push_back
# define loop(i,a,b) for(int i=a;i<b;i++)
# define loopl(i,a,b) for(lli i=a;i<b;i++)
# define MAXN 1000
# define INF 1000000000
# define mod 1000000007

using namespace std;

void sumod(lli n)
{
	lli k=n,ans=0;
	while(k!=0)
	{
		ans+=k%10;
		k/=10;
	}
	if(n%ans==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
int main()
{
  lli n,k,count=0;
  cin>>n>>k;
  lli a[n];
  loopl(i,0,n) cin>>a[i];
  sort(a,a+n);
  lli mini=a[0],mincount=1;
  loop(i,1,n)
  {
  	if(a[i]==mini) mincount++;
  	else break;
  }
  
  lli temp=n-mincount;
  temp-=k-1;
  count++;
  count+=temp/(k-1) ;
  if(temp%(k-1) != 0) count++ ;
  cout<<count<<endl;
  
} 

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
long long __lcm(long long a, long long b) { return a / __gcd(a, b) * b; }

long long solve(long long ub, long long waru) {
  return ub / waru;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long a, b, c, d; cin >> a >> b >> c >> d;
  long long ans = b - a + 1;
  ans -= solve(b, c) - solve(a - 1, c);
  ans -= solve(b, d) - solve(a - 1, d);
  ans += solve(b, __lcm(c, d)) - solve(a - 1, __lcm(c, d));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    let ans = s.into_iter().filter(|&ch| ch == '1').collect::<Vec<char>>().len();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    ll ans=0;
    REP(i,n){
        int x;cin>>x;
        ans += 2*min(x,abs(k-x));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        A, B, C = [list(map(int, input().split())) for _ in range(3)]

        m = 0
        for i in range(N):
            m += B[A[i] - 1]
            if i > 0:
                if A[i - 1] == A[i] - 1:
                    m += C[A[i - 1] - 1]
        print(m)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define S(n) (n*(n+1)/2)
int main(){
  int n,h,t;
  cin>>n;
  while(n>0){
    h=0,t=5000;
    while(t-h>1){
      if(S((h+t)/2)>n)t=(h+t)/2;
      else if(S((h+t)/2)<n)h=(h+t)/2;
      else {t=(h+t)/2; break;}
    }
    cout<<t<<"\n";
    n-=t;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,k,i;
  int64_t c=0;
  cin>>n>>k;
  vector<int> h(n);
  for(i=0;i<n;i++) cin>>h.at(i);
  sort(h.begin(),h.end());
  for(i=0;i<n-k;i++) c+=h.at(i);
  cout<<c<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;


int main(void) {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  // 1 -> 2
  REP(i, y2-y1) {
    putchar('U');
  }
  REP(i, x2-x1) {
    putchar('R');
  }

  // 2 -> 1
  REP(i, y2-y1) {
    putchar('D');
  }
  REP(i, x2-x1) {
    putchar('L');
  }
  
  // 1 -> 2
  putchar('L');
  REP(i, y2-y1+1) {
    putchar('U');
  }
  REP(i, x2-x1+1) {
    putchar('R');
  }
  putchar('D');

  // 2 -> 1
  putchar('R');
  REP(i, y2-y1+1) {
    putchar('D');
  }
  REP(i, x2-x1+1) {
    putchar('L');
  }
  putchar('U');

  putchar('\n');
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

struct Score {
  int ac, penalty, idx;
  bool operator<(const Score& other) const {
    if (ac != other.ac) return ac > other.ac;
    if (penalty != other.penalty) return penalty < other.penalty;
    return idx < other.idx;
  }
};

int T, P, R;
Score score[52];
int wa[52][12];

char msg[100];

int main() {
  while (scanf("%d%d%d", &T, &P, &R), T | P | R) {
    rep(i,T) {
      score[i].ac = score[i].penalty = 0;
      score[i].idx = i+1;
    }
    memset(wa, 0, sizeof wa);
    
    int tid, pid, tm;
    rep(i,R) {
      scanf(" %d%d%d%s", &tid, &pid, &tm, msg);
      --tid; --pid;
      if (msg[0] == 'C') {
        score[tid].ac += 1;
        score[tid].penalty += (1200 * wa[tid][pid] + tm);
      } else {
        ++wa[tid][pid];
      }
    }

    sort(score, score + T);
    rep(i,T) {
      printf("%d %d %d\n", score[i].idx, score[i].ac, score[i].penalty);
    }
  }
  return 0;
}

Measured memory_bytes: 0
using System;

namespace CA {
	class Prg {
		static void Main() {
			string[] s = Console.ReadLine().Split(' ');
			try {
				checked {
					byte x = byte.Parse(s[2]);
					byte y = byte.Parse(s[3]);
					byte r = byte.Parse(s[4]);
					byte W = (byte)(int.Parse(s[0]) - x);
					byte H = (byte)(int.Parse(s[1]) - y);
					W -= r;
					H -= r;
					x -= r;
					y -= r;
					Console.WriteLine("Yes");
				}
			}catch {
				Console.WriteLine("No");
			}
		}
	}
}

Measured memory_bytes: 9716
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int a,b;
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;

    a = x2 - x1,b = y2 - y1;

    cout << x2-b << " " << y2+a << " " << x1-b << " " << y1+a;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

class segment_tree
{
    public:
    vector<vector<int> >v;
    vector<int>sumv;
    string inp;
    segment_tree(string s)
    {
        inp=s;
        int n=s.length(),w=2*n-1;
        for(int i=0;i<w;i++)
        {
            vector<int>t;
            v.push_back(t);
        }
        vector<int>t(26,0);
        sumv=t;
        form_tree(0,0,n-1);
    }
    vector<int> sum(vector<int>a1,vector<int>a2)
    {
        vector<int>a3;
        for(int i=0;i<a1.size();i++)
            a3.push_back(a1[i]+a2[i]);
        return a3;
    }
    int distinct(vector<int>v)
    {
        int r=0;
        for(int i=0;i<v.size();i++)
            if(v[i]!=0)
                r+=1;
        return r;
    }
    void form_tree(int ind,int l,int r)
    {
        if(r==l)
        {
            vector<int>t(26,0);
            int i=inp[l]-97;
            t[i]=1;
            v[ind]=t;
            return;
        }
        int m=(l+r)/2;
        form_tree(2*ind+1,l,m);
        form_tree(2*ind+2,m+1,r);
        v[ind]=sum(v[2*ind+1],v[2*ind+2]);
    }
    void update(int ind,int mi,char c,int l,int r,int t,int t1)
    {
        //cout << ind << " " << l << " " << r << endl;
        if(mi<l or mi>r)
            return;
        if(l==r)
        {
            v[ind][t]-=1;
            v[ind][t1]+=1;   
            return;
        }
        v[ind][t]-=1;
        v[ind][t1]+=1;
        //cout << v[ind][t] << " " << v[ind][t2] << endl;
        int m=(l+r)/2;
        update(2*ind+1,mi,c,l,m,t,t1);
        update(2*ind+2,mi,c,m+1,r,t,t1);
    }
    void get_sum(int ind,int l,int r,int l1,int r1)
    {
        if(l>=l1 and r<=r1)
        {
            vector<int>t=v[ind];
            for(int i=0;i<26;i++)   
                sumv[i]+=t[i];
            return;
        }
        if(l>r1 or l1>r)
            return;
        int m=(l+r)/2;
        get_sum(2*ind+1,l,m,l1,r1);
        get_sum(2*ind+2,m+1,r,l1,r1);
    }
    void queries(int n)
    {
        for(int i=0;i<n;i++)
        {
            int a;
            cin >> a;
            if(a==1)
            {
                int pos;
                char c;
                cin >> pos >> c;
                pos-=1;
                if(inp[pos]!=c)
                {
                    int t=inp[pos]-97,t1=c-97;
                    update(0,pos,c,0,inp.length()-1,t,t1);
                }
                inp[pos]=c;
            }
            else
            {
                int a,b;
                cin >> a >> b;
                a-=1;b-=1;
                fill(sumv.begin(), sumv.end(), 0);
                get_sum(0,0,inp.length()-1,a,b);
                cout << distinct(sumv) << endl;
            }
            //cout << inp << endl;
        }
    }
};

int main()
{
    fast;
    int l;
    cin >> l;
    string s;
    cin >> s;
    segment_tree Tree(s);
    int n;
    cin >> n;
    Tree.queries(n);
}

Measured memory_bytes: 150916
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n, k, q;
  cin >> n >> k >> q;
  map<ll, ll> mp;
  REP(i, q) {
    ll a;
    cin >> a;
    a--;
    mp[a]++;
  }

  REP(i, n) {
    if (k - (q - mp[i]) > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	
	int add(int x,int y){
		x+=y;
		while(x>=mod)x-=mod;
		while(x<0)x+=mod;
		return x;
	}
	int mul(int a,int b){
		return (a*b)%mod;
	}
	int fast(int a,int b){
		int res=1ll;
		while(b){
			if(b&1)res=mul(res,a);
			a=mul(a,a);
			b>>=1;
		}
		return res;
	}
	int inverse(int x){
		return fast(x,mod-2);
	}
	int divide(int a,int b){
		return mul(a,inverse(b));
		
	}
	int fact[200066];
	void factorial(){
		fact[0]=1;
		for(int i=1;i<200066;i++){
			fact[i]=mul(fact[i-1],i);
		}
	}
	
	int Comb(int n,int k){
		return divide(fact[n],mul(fact[k],fact[n-k]));
	}
	
/*-----------------------------------------------------------------------------------------------------*/	
/*-----------------------------------------------------------------------------------------------------*/	

	
	int32_t main(){
		IOS;
		int l,r,d;
		cin>>l>>r>>d;
		int x=l/d;
		int y=r/d;
		if(l%d==0)
		cout<<y-x+1<<endl;
		else cout<<y-x<<endl;
		return 0;
	}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

const ll INF = 1LL << 50;

template <class T>
class Dijkstra {
    private:
        using P = pair<T, int>;
        struct edge {
            int to;
            T cost;
        };
        T identity;
        vector<vector<edge>> graph;
        vector<T> dist;
    public:
        Dijkstra(int node_num, T _identity):
        identity(_identity), graph(vector<vector<edge>>(node_num)), dist(vector<T>(node_num, identity)) {}
        void add_edge(int from, int to, T cost) {
            edge now_edge = {to, cost};
            graph[from].push_back(now_edge);
        }
        void calc_shortest_path(int start_node) {
            priority_queue<P, vector<P>, greater<P>> PQ;
            dist[start_node] = 0;
            PQ.push(P(0, start_node));
            while (!PQ.empty()) {
                P now = PQ.top();
                PQ.pop();
                int now_u = now.second;
                if (dist[now_u] < now.first) continue;
                for (int i = 0; i < graph[now_u].size(); i++) {
                    edge e = graph[now_u][i];
                    if (dist[e.to] > dist[now_u] + e.cost) {
                        dist[e.to] = dist[now_u] + e.cost;
                        PQ.push(P(dist[e.to], e.to));
                    }
                }
            }
        }
        T get_dist(int u) {
            return dist[u];
        }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int L, R;
    ll C;
    Dijkstra<ll> dijkstra(N, INF);
    rep(i, 0, M) {
        cin >> L >> R >> C;
        --L, --R;
        dijkstra.add_edge(L, R, C);
    }
    rep(i, 1, N) {
        dijkstra.add_edge(i, i - 1, 0);
    }
    dijkstra.calc_shortest_path(0);
    ll ans = dijkstra.get_dist(N - 1);
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 9336
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int x, y; scanf("%d%d", &x, &y);
	REP(i, 200){
		REP(j, 200){
			if(i+j == x && i*2+j*4 == y){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0

using namespace std;

vector<string> grid;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ret;
int blacks;
int h, w;
struct Point{int x; int y;};
vector<Point> vec;
vector<Point> black_point;

bool inner_black(Point p)
{
    for(int i = 0; i < 4; i++)
    {
        int nx = p.x + dx[i], ny = p.y + dy[i];
        if(min(nx, ny) < 0 || nx >= h || ny >= w) continue;
        if(grid[nx][ny] == '#') continue;
        return true;
    }
    return false;
}

void flood()
{
    vector<Point> temp;
    while(!black_point.empty())
    {
        auto cur = black_point.back(); black_point.pop_back();
        for(int k = 0; k < 4; k++)
        {
            auto nx = cur.x + dx[k], ny = cur.y + dy[k];
            if(min(nx, ny) < 0 || nx >= h || ny >= w) continue;
            if(grid[nx][ny] == '#') continue;
            
            grid[nx][ny] = '#';
            blacks += 1;
            
            if(inner_black(Point{nx, ny}))
                temp.push_back(Point{nx, ny});
        }
        
        if(inner_black(cur))
            temp.push_back(cur);
    }
    
    for(auto b : temp)
        black_point.push_back(b);
}


int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> h >> w;
    for(int i = 0; i < h; i++)
    {
        string temp; cin >> temp; grid.push_back(temp);
        for(int j = 0; j < temp.size(); j++)
            if(temp[j] == '#') black_point.push_back(Point{i, j});
    }
    blacks = (int)black_point.size();
    
    while(blacks < h * w)
    {
        flood();
        ret += 1;
    }
    
    
    cout << ret << endl;

    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
  }
  sort(A.rbegin(),A.rend());
  ll ans(0);
  for(int i(0);i<N-1;i++){
    ans+=A[(i+1)/2];
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 4028
#include <stdio.h>

int main(void) {
	int A, B;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	if (A == 1) A = 999;
	if (B == 1) B = 999;
	puts(A > B ? "Alice" : (A < B ? "Bob" : "Draw"));
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	vector< vector<int> > c(3, vector<int>(3));
	
	for(int i = 0; i < 3; ++i) {
		for(int j = 0; j < 3; ++j) {
			cin >> c[i][j];
		}
	}
	
	for(int i = 0; i < 2; ++i) {
		int a = c[0][i] - c[0][i + 1];
		if( a != c[1][i] - c[1][i + 1] || a != c[2][i] - c[2][i + 1] ) {
			cout << "No" << endl;
			return 0;
		}
		
		a = c[i][0] - c[i + 1][0];
		if( a != c[i][1] - c[i + 1][1] || a != c[i][2] - c[i + 1][2] ) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
signed main(){
    int N,M,R;
    cin >> N >> M >> R;
    vector<int> r(R);
    int a,b,c;
    vector<vector<int>> d(N+1,vector<int>(N+1,INF));
    for(int i=0;i<=N;i++) d[i][i] = 0;
    for(int i=0;i<R;i++) cin >> r[i];
    for(int i=0;i<M;i++){
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }
    
    for(int k=0;k<=N;k++){
        for(int i=0;i<=N;i++){
            for(int j=0;j<=N;j++){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans = INF ,sum = 0;
    sort(r.begin(),r.end());
    do{
        for(int i=0;i<R-1;i++){
            sum += d[r[i]][r[i+1]];
        }
        ans = min(ans,sum);
        sum = 0;
    }while( next_permutation(r.begin(),r.end()) ); 

    cout << ans << endl;
}

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

main() {
    string S; cin >> S;
    rep(i,S.size()){
        if(S[i]=='A') cout <<"T";
        else if(S[i]=='T') cout << "A";
        else if(S[i]=='C') cout << "G" ;
        else cout << "C" ;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int i = n%10;
    if(i== 2 || i==4 || i== 5 || i==7 || i==9)cout << "hon"<<endl;
    else if(i==0 || i==1 || i== 6 || i==8)cout << "pon"<<endl;
    else cout<<"bon"<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=100005;
const LL INF=1e18;
int n,m,rt;
LL a[N],b[N],c[N];
vector <int> son[N];
namespace Build_Tree{
	vector <int> e[N];
	int id[N];
	bool cmp(int x,int y){
		return c[x]<c[y];
	}
	int fa[N],vis[N];
	int getf(int x){
		return fa[x]==x?x:fa[x]=getf(fa[x]);
	}
	void main(){
		For(i,1,m){
			int x=read(),y=read();
			e[x].pb(y),e[y].pb(x);
		}
		For(i,1,n)
			id[i]=fa[i]=i;
		sort(id+1,id+n+1,cmp);
		For(i,1,n){
			int x=id[i];
			for (auto y : e[x])
				if (vis[y]&&getf(y)!=x){
					son[x].pb(getf(y));
					fa[getf(y)]=x;
				}
			vis[x]=1;
		}
		rt=id[n];
	}
}
LL sb=0;
LL size[N];
LL dfs(int x){
	size[x]=b[x];
	if (son[x].empty())
		return sb+c[x];
	LL res=INF;
	for (auto y : son[x]){
		LL tmp=dfs(y);
		res=min(res,max(c[x]+sb-size[y],tmp));
		size[x]+=size[y];
	}
	return res;
}
int main(){
	n=read(),m=read();
	For(i,1,n)
		a[i]=read(),b[i]=read(),c[i]=max(a[i]-b[i],0LL),sb+=b[i];
	Build_Tree::main();
	cout<<dfs(rt)<<endl;
	return 0;
}

Measured memory_bytes: 18172
#include<iostream>
//#include<string>
using namespace std;
int main() {
	int n,x,x2=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int s, t;
		cin >> s >> t;
		x=t-s + 1;
		x2 += x;
	}
	cout << x2 << endl;
	
	//system("pause");
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
int n;
int main(){
	scanf("%d",&n);
	if((int)std::sqrt(8*n+1)*(int)std::sqrt(8*n+1)!=8*n+1) return puts("No"),0;
	puts("Yes");
	int x=(std::sqrt(8*n+1)-1)/2;
	printf("%d\n",x+1);
	for(int i=1;i<=x+1;++i){
		printf("%d",x);
		int now=i-1;
		for(int j=1;j<i;++j) printf(" %d",now), now+=x-j;
		for(int j=i;j<=x;++j) printf(" %d",++now);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <cstdio>
const double PI = 3.141592;
using namespace std;
int main (int argc, char *argv[]) {
	double x = 0.0, y = 0.0;
	int size, t_deg;
	double deg = 90.0;
	while (true) {
		scanf("%d,%d",&size,&t_deg);
		//cout << x << " " << y << endl;
		x += -cos(deg * PI / 180.0) * size;
		y += sin(deg * PI / 180.0) * size;
		if (size == 0 && t_deg == 0) break;
		deg += t_deg;
	}
	cout << (int)x << endl;
	cout << (int)y << endl;
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int count(int x, int y) {
  if (x == y) {
    return 0;
  } else if (x < y) {
    return y - x;
  } else {  // x > y
    return x - y + 2;
  }
}

int main() {
  int x, y; cin >> x >> y;
  int cnt = count(x, y);
  cnt = min(cnt, count(-x, y) + 1);
  cnt = min(cnt, count(x, -y) + 1);
  cnt = min(cnt, count(-x, -y) + 2);

  cout << cnt << endl;
}


Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AISing
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s1 = Console.ReadLine().Split(' ');
            int A = int.Parse(s1[0]);
            int B = int.Parse(s1[1]);
            string[] s2 = Console.ReadLine().Split(' ');

            int q1 = 0, q2 = 0, q3 = 0;
            foreach(string s in s2)
            {
                int P = int.Parse(s);
                if (P <= A) q1++;
                else if (P <= B) q2++;
                else q3++;
            }

            int ncon = Math.Min(Math.Min(q1, q2), q3);
            Console.WriteLine(ncon);
        }

    }
}


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

int main() {
  string s;
  cin>>s;
  long long n = s.length();

  map<char, int> m;
  for (int i=0; i<n; i++) {
    ++m[s[i]];
  }

  long long ans = n * (n - 1) / 2;
  for (auto e: m) {
    long long v = e.second;
    ans -= v * (v - 1) / 2;
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;
const int INF = 1000100100;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int dp[1000005][2];

int main()
{
    string s; cin >> s;
    reverse(s.begin(), s.end());
    s += '0';   // 桁が1つだけ上る可能性があるので
    int n = s.size();
    rep(i,n+1) rep(j,2) dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i,n) rep(j,2){
        int x = s[i]-'0';   // 今の桁、nのi桁目
        x += j; // 繰り下がりを引く数をプラス1することで対応している

        rep(a,10){
            // ni：次の桁に行くだけなのでi+1
            // nj：繰り下がりが遷移先で起こる場合1、起こらない場合0、デフォルトは0
            int ni = i+1, nj = 0;    // 次の遷移先
            int b = a-x;
            if(b<0){
                nj = 1; // 繰り下がりを1にして、次の桁で繰り下がりが起こるようにする
                b += 10;
            }
            dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b);
        }
    }
    int ans = dp[n][0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12136
#include <iostream>
#include <vector>
#include <algorithm>
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(void) {
	ll num, k, i, j, b = false, ans = 0;
	cin >> num >> k;
	vector<int> d(num);
	vector<ll> a(num, k * (k - 1) / 2), l(num, 0), r(num, 0);
	for (i = 0; i < num; i++)
		scanf("%d", &d[i]);
	for (i = 0; i < num; i++) {
		for (j = 0; j < i; j++) {
			if (d[i] > d[j])
				l[i]++;
		}
		for (j = i + 1; j < num; j++) {
			if (d[i] > d[j])
				r[i]++;
		}
	}
	for (i = 0; i < num; i++) {
		a[i] %= MOD;
		a[i] *= l[i] + r[i];
		a[i] % MOD;
		a[i] += k * r[i];
		a[i] %= MOD;
		ans += a[i];
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;
using namespace boost;

struct Mod {
    static constexpr auto kMod = 1000000007L;
 
    // can be implicitly converted
    Mod(int64_t n) : n(n) {}
 
    Mod operator*(Mod m) const { return (n * (m.n % kMod)) % kMod; }
 
    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }
 
    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }
 
        int64_t r = this->pow(p / 2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }
 
    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }
 
        return *this * m.pow(kMod - 2);
    }
 
    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }
 
    Mod operator+(Mod m) const { return (n + m.n) % kMod; }
 
    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }
 
    Mod operator-(Mod m) const { return (kMod + n - m.n) % kMod; }
 
    Mod& operator-=(Mod m) {
        *this = *this - m;
        return *this;
    }
 
    int64_t n;
};

Mod combi(int64_t a, int64_t b) {
  Mod c(1);
  
  for (auto i : irange(0L, b)) {
    c *= a - i;
    c /= i + 1;
  }
  
  return c;
}

main() {
  int64_t n;
  cin >> n;
  unordered_map<int64_t, int64_t> a;
  int64_t dist = -1;
  for (auto i : irange(0L, n + 1)) {
    int64_t aa;
    cin >> aa;
    if (a.count(aa) > 0) {
      dist = i - a[aa];
    }
    a[aa] = i;
  }
  
  Mod c = 1; // C(n + 1, 0)
  Mod d = 1; // C(n - dist, 0)
  for (auto k : irange(1L, n + 2)) {
    // C(n + 1, k) = C(n + 1, k - 1) * (n - k + 2) / k
    c *= n - k + 2;
    c /= k;
    // C(n - dist, k - 1) = C(n - dist, k - 2) * (n - dist - k + 2) / (k - 1)
    if (k >= 2) {
        d *= n - dist - k + 2;
        d /= k - 1;
    }
    if (k - 1 <= n - dist) {
      cout << (c - d).n << endl;
    } else {
      cout << c.n << endl;
    }
  }
}

Measured memory_bytes: 5284
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#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)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long N;
    cin >> N;
    vector<long long>a(N);
    vector<long long>ans(N);

    bool right=true;
    rep(i,N){
        cin >> a[i];
        if((i+1)%2) {
            ans[N / 2 + (i + 1) / 2] = a[i];
        }else{
            ans[N / 2 - (i + 1) / 2] = a[i];
        }
    }

    if(N%2==1){
        reverse(ans.begin(), ans.end());
    }
    rep(i,N){
        cout << ans[i];
        if(i!=N-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}



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

int main(void){
	int n;
	while(~scanf("%d",&n)){
		if(n==0)break;
		int res=0;
		while(n!=1){
			res++;
			if(n%2==0)n=n/2;
			else n=n*3+1;
		}
		printf("%d\n",res);
	}
    return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    REP(i, 1, 9) {
        REP(j, 1, 9) {
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	int n;
	cin >> n;
	cout << n / 3 << endl; 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  double ans=0;
  rep(i,n){
    double a;cin >> a;
    string s;cin >> s;
    if(s=="JPY") ans+=a;
    else ans+=380000*a;
  }
  cout << ans << endl;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()

typedef pair<int, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n, k; cin >> n >> k;
    if( k == 1 ) cout << 0 << endl;
    else{
        cout << n - k << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> hairetu(N);
    for(int i = 0;i < N;i++){
        cin >> hairetu.at(i);
    }
    sort(hairetu.begin(),hairetu.end());
    cout << hairetu.at(N - 1) - hairetu.at(0);
    return 0;
}

Measured memory_bytes: 256