akhauriyash/Code-Regression huggingface dataset:
def main():
    H, W = map(int, input().split())
    s = []
    for _ in range(H):
        S = input()
        s.append(S)
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1 if s[0][0] == '#' else 0 # #だと1にする
    for i in range(1, W):
        dp[0][i] = dp[0][i-1] + 1 if s[0][i] == '#' and s[0][i-1] == '.' else dp[0][i -1]
    for i in range(1, H):
        dp[i][0] = dp[i-1][0] + 1 if s[i][0] == '#' and s[i-1][0] == '.' else dp[i-1][0]
    for i in range(1, H):
        for j in range(1, W):
            if s[i][j] == '.':
                dp[i][j] = min(dp[i][j-1], dp[i-1][j])
            else:
                u = dp[i-1][j]
                r = dp[i][j-1]
                if s[i-1][j] == '.':
                    u += 1
                if s[i][j-1] == '.':
                    r += 1
                dp[i][j] = min(u, r)
    return dp[-1][-1]

print(main())

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

using static System.Console;

namespace Atcoder01_10 {
    class Class1 {
        static void Main() {
            string[] str = Console.ReadLine().Split();
            int k = int.Parse(str[0]);
            int x = int.Parse(str[1]);
            
            if(500 * k >= x) {
                WriteLine("Yes");
            } else {
                WriteLine("No");
            }
        }
    }
}


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

public class Main {
	
	static int n;
	static int INF = (int)1e9;
	static int[] h;
	static int[] memo;
	
	public static int dp(int i) {
		if(i == n - 1)
			return 0;
		if(memo[i] != -1)
			return memo[i];
		if(i == n - 2)
			return memo[i] = Math.abs(h[i] - h[i + 1]) + dp(i + 1);
		else
			return memo[i] = Math.min(Math.abs(h[i] - h[i + 1]) + dp(i + 1), Math.abs(h[i] - h[i + 2]) + dp(i + 2));
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		h = new int[n];
		for(int i = 0; i < n; i++)
			h[i] = sc.nextInt();
		
		memo = new int[n];
		Arrays.fill(memo, -1);
		System.out.println(dp(0));
	}
}


Measured memory_bytes: 62612
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000007

int main(){
    int N;cin>>N;
    vector<int> a(N);
    for(int i = 0; i < N ;i++){
        cin >> a[i];
    }
    vector<int> dp(N);
    dp.assign(N,INF);
    for(int i = 0; i < N ; i++){
        *lower_bound(dp.begin(),dp.end(),a[i]) = a[i];
    }
    cout << lower_bound(dp.begin(),dp.end(),INF)-dp.begin() << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

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

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,count=0;
  cin>>a>>b>>c;
  while(1){
    if(c<=0) break;
    c-=a;
    count++;
    if(count%7==0) c-=b;
  }
  cout<<count<<endl;
  return 0;
}
    



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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {

    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k-1] = s[k-1] - ('A' - 'a');
    cout << s << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(m);
    for(int i=1;i<=m;i++) cin >> a[i];
    
    int left=0, right=0;
    for(int i=1;i<=m;i++){
        if(a[i]<x) left++;
        else right++;
    }
    int ans = min(left, right);
    cout << ans << endl;
    
    return 0;
}


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

int main (){
    int h1,h2,k1,k2,a,b,c,d;
    cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
    int H=h1*a+h2*b;
    int K=k1*a+k2*b;

    if(h1/10>0){
        H+=h1/10*c;
    }
    else if (h1/20>0){
        H+=h2/20*d;
    }

    if(k1/10>0){
        K+=k1/10*c;
    }
    else if (k2/20>0){
        K+=k2/20*d;
    }
    
    if(H<K){
        cout << "kenjiro" << endl;
    }
    else if(H>K){
        cout << "hiroshi" << endl;
    }else{
        cout << "even" << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int prev = 0;
		int type = 0;
		int count = 1;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (i == 0) {
				prev = a;
				continue;
			}
			if (type == -1) {
				if (prev < a) {
					count++;
					type = 0;
				}
			} else if (type == 1) {
				if (prev > a) {
					count++;
					type = 0;
				}
			} else {
				if (prev < a) {
					type = 1;
				} else if (prev > a) {
					type = -1;
				}
			}
			prev = a;
		}
		System.out.println(count);
	}
			
}


Measured memory_bytes: 48252
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
ll GCD(ll x,ll y){
    if(y==0){
        return x;
    }else{
        return GCD(y, x % y);
    }
}
ll LCM(ll x,ll y){
    return x / GCD(x, y) * y;
}
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main()
{
    int n;
    cin >> n;
    vector<int> vec(n + 1,0);
    vector<int> num(n + 1, 0);
    for (int i = 2;i<=n;++i){
        int k=i;
        for (int j = 2; j <= i;++j){
            if(k%j==0){
                while(1){
                    k /= j;
                    vec[j]++;
                   // cout<<j<<endl;
                    if(k%j!=0)
                        break;
                }
            }
        }
    }
    ll sum = 1;
  //  cout << vec[2] << " " << vec[3] << " " << vec[5] << endl;
    for (int i = 0; i <= n;i++){
        sum = sum * (vec[i] + 1) % MOD;
    }
    cout << sum % MOD << endl;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

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

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	N, C := nextInt(), nextInt()
	D := make([][]int, C+1)
	for i := 1; i <= C; i++ {
		D[i] = make([]int, C+1)
		for j := 1; j <= C; j++ {
			D[i][j] = nextInt()
		}
	}
	c := make([][]int, N)
	for i := range c {
		c[i] = nextInts(N)
	}

	blocks := make([][30 + 1]int, 3)
	for i := range c {
		for j := range c[i] {
			blocks[(i+1+j+1)%3][c[i][j]]++
		}
	}

	sum := func(x [3]int) int {
		res := 0
		for i := range blocks {
			for j := 1; j <= C; j++ {
				res += D[j][x[i]] * blocks[i][j]
			}
		}
		return res
	}

	ans := 1 << 60
	for i := 1; i <= C; i++ {
		for j := 1; j <= C; j++ {
			if i == j {
				continue
			}
			for k := 1; k <= C; k++ {
				if i == k || j == k {
					continue
				}
				ans = min(ans, sum([3]int{i, j, k}))
			}
		}
	}

	puts(ans)
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define prr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}

#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define pri(a) cout << a << endl;
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(a) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e4 + 1;

long long binpow(long long a, long long b, long long m = mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readc(n, a, b);
	int ans = binpow(2, n);
	
	int x = 1, z = 0;
	FOR (i, 1, a)
	{
	    x = x*(n-z)%mod;
	    z++;
	    x = x*binpow(i, mod - 2) % mod;
	}
	
	ans -= x;
	x = 1, z = 0;
	FOR (i, 1, b)
	{
	    x = x*(n-z)%mod;
	    z++;
	    x = x*binpow(i, mod - 2) % mod;
	}
	
	ans = (ans + 5*mod - x - 1) % mod;
	cout << ans;
}












Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

int N;
vector<int> a;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmpa;
		cin >> tmpa;
		a.push_back(tmpa);
	}
	bool is_first = false;
	for (int i = 0; i < N; i++)
	{
		if (a[i] % 2 == 1) {
			is_first = true;
			break;
		}
	}

	string ans;
	if (is_first) {
		ans = "first";
	}
	else {
		ans = "second";
	}

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



Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		WriteLine(GetString().Equals("ABC") ? "ARC" : "ABC");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 25648
#include <iostream>
#include <vector>
#include <cstdint>
#include <numeric>
#include <algorithm>

using Int = std::int64_t;

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

	std::vector<Int> vec(n);
	for (auto&& e : vec)
		std::cin >> e;

	Int sum = std::accumulate(vec.begin(), vec.end(), Int{ 0 });
	Int cur = 0;
	for (int i = 0; i < n; ++i) {
		Int next = cur + vec[i];

		if (next * 2 == sum) {
			std::cout << 0 << std::endl;
			return 0;
		}

		Int a = next * 2 - sum, b = sum - cur * 2;
		if (a > 0) {
			std::cout << std::min(a, b) << std::endl;

			return 0;
		}

		cur = next;
	}

	throw(0);
}

Measured memory_bytes: 1792
### 3
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

score = 0

for i in range(0,N):
    # Bi のほうが多く殺せる
    if A[i] <= B[i]:
        score = score + A[i]
        B[i] = B[i] - A[i]
        # 不要だけど一応やっとく
        A[i] = 0
        
        #余力で隣を殺せる分だけ殺す
        if A[i+1] <= B[i]:
            score = score + A[i+1]
            A[i+1] = 0
            # 不要だけど一応やっとく
            B[i] = B[i] - A[i+1]
        else:
            score = score + B[i]
            A[i+1] = A[i+1] - B[i]
            B[i] = 0
        
    else:
        score = score + B[i]
        
        # 不要だけど一応やっとく
        A[i] = A[i] - B[i]
        B[i] = 0


print(score)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

signed main(){
	int N, M, a, i;
	scanf("%lld%lld", &N, &M);
	vector<int> dp(N + 1, 0), can_on(N + 1, 1);
	for(i = 0; i < M; i++){
		scanf("%lld", &a);
		can_on[a] = 0;
	}
	dp[0] = 1;
	dp[1] = can_on[1];
	for(i = 2; i <= N; i++){
		dp[i] = (can_on[i] * (dp[i - 1] + dp[i - 2])) % p;
	}
	printf("%lld\n", dp[N]);
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()

typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int a,b;

int main(){
    cin >> a >> b;
    put(max({a+b,a+a-1,b+b-1}));
    return 0;
}


Measured memory_bytes: 256
// https://gist.github.com/draftcode/1357281 を参考にした
// キーボード入力とファイルからの入力で結果が異なっているのは，改行コードのせい
#include <iostream>
#include <string>
#include <cctype>

using namespace std;
typedef string::const_iterator State;

class ParseError{};

void consume(State &begin, char expected);
int expression(State &begin);
int term(State &begin);
int factor(State &begin);
int number(State &begin);

// beginがexpectedを指していたらbeginを一つ進める。
void consume(State &begin, char expected) {
	if (*begin == expected) {
		begin++;
	} else {
		cerr << "Expected '" << expected << "' but got '" << *begin << "'"
			<< endl;
		cerr << "Rest string is '";
		while (*begin) {
			cerr << *begin++;
		}
		cerr << "'" << endl;
		throw ParseError();
	}
}

// 四則演算の式をパースして，その評価結果を返す．
int expression(State &begin) {
	int ret = term(begin);
	
	while (true) {
		if (*begin == '+') {
			begin++;
			ret += term(begin);
		} else if (*begin == '-') {
			begin++;
			ret -= term(begin);
		} else {
			break;
		}
	}
	
	return ret;
}

// 乗算除算の式をパースして，その評価結果を返す．
int term(State &begin) {
	//int ret = number(begin);
	int ret = factor(begin); // 括弧がある式に対応
	
	while (true) {
		if (*begin == '*') {
			begin++;
			//ret *= number(begin);
			ret *= factor(begin); // 括弧がある式に対応
		} else if (*begin == '/') {
			begin++;
			//ret /= number(begin);
			ret /= factor(begin); // 括弧がある式に対応
		} else {
			break;
		}
	}
	
	return ret;
}

// 括弧か数をパースして，その評価結果を返す．
int factor(State &begin) {
	if (*begin == '(') {
		begin++; // '('を飛ばす．
		int ret = expression(begin);
		begin++; // ')'を飛ばす．
		return ret;
	} else {
		return number(begin);
	}
}

// 数字の列をパースして，その数を返す．
int number(State &begin) {
	int ret = 0;
	
	while (isdigit(*begin)) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	
	return ret;
}

int main() {
	int n;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++) {
		string s;
		getline(cin, s);
		
		State begin = s.begin();
		int ans = expression(begin);
		consume(begin, '=');
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

ll n, A[maxn];

void MAIN() {

    cin >> n;
    fori (i, n) cin >> A[i];
    sort(A, A + n, greater<ll>());
    ll i = 0;
    while (i < n && A[i] > i) ++i;
    --i;
    ll j = i + 1;
    while (j < n && A[j] > i) ++j;
    if ((A[i] - i) % 2 == 0 || (j - i) % 2 == 0) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }

}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
3
1 2 1
    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 1024
import sys
from itertools import permutations
from random import randrange
readline = sys.stdin.readline

mod = 10**9+9
base = 2009   
def rollinhash(S):
    N = len(S)           
    has = 0
    for i in range(N):
        s = S[i]
        has = (has*base + s)%mod
    return has

phr = []
while len(set(phr)) != 26:
    phr = [randrange(1, 10**9) for _ in range(26)]
def shash(S):
    N = len(S)            
    has = 0
    for i in range(N):
        has = has + phr[S[i]]*phr[S[N-1-i]]
    return has

H, W = map(int, readline().split())
G = [list(map(ord, readline().strip())) for _ in range(H)]

ans = 'NO'
fh = H//2
ch = H-fh
lir = list(range(H))
seen = set()
for k in permutations(lir, ch):
    k = list(k)
    sk = set(k)
    for i in range(H):
        if i not in sk:
            k.append(i)
    
    sh = shash(k)
    if sh in seen:
        continue
    seen.add(sh)
    
    
    G2 = []
    for j in k:
        G2.append(G[j])
    G2 = list(map(list, zip(*G2)))
    G2h = [rollinhash(g) for g in G2]
    G2hi = [rollinhash(g[::-1]) for g in G2]
    
    used = [False]*W
    w1 = 0
    match = W//2
    while match and w1 < W:
        if used[w1]:
            w1 += 1
            continue
        sa = G2hi[w1]
        for w2 in range(w1+1, W):
            if used[w2]:
                continue
            if G2h[w2] == sa:
                used[w1] = True
                used[w2] = True
                match -= 1
                break
        w1 += 1
    if sum(used) >= W-1:
        if sum(used) == W-1:
            mid = used.index(False)
            if G2h[mid] == G2hi[mid]:
                ans = 'YES'
        else:
            ans = 'YES'
    if ans == 'YES':
        break
print(ans)

Measured memory_bytes: 57436
package main

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

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func readInt(sc *bufio.Scanner) (res int) {
	res, _ =strconv.Atoi(readLine(sc))
	return
}

func readInts(sc *bufio.Scanner, n int) []int {
	ns := strings.Split(readLine(sc), " ")
	res := make([]int, n)

	for i, n := range ns {
		res[i], _ = strconv.Atoi(n)
	}
	return res
}

func readInt64s(sc *bufio.Scanner, n int) []int64 {
	ns := strings.Split(readLine(sc), " ")
	res := make([]int64, n)

	for i, n := range ns {
		res[i], _ = strconv.ParseInt(n, 10, 64)
	}
	return res
}

func readMatrix(sc *bufio.Scanner, rows, cols int) [][]int {
	res := make([][]int, rows)
	for i := 0; i < rows; i ++ {
		res[i] = readInts(sc, cols)
	}
	return res
}

func abs(i int) int {
	if i < 0 {
		return -i
	} else {
		return i
	}
}

func max(a ,b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	n := readInt(sc)

	var m int = int(math.Sqrt(float64(n))) + 1

	min := 11
	for i := 1; i <= m; i ++ {
		d := n / i
		r := n % i

		if r != 0 {
			continue
		}

		x := max(len(fmt.Sprint(d)), len(fmt.Sprint(i)))
		if x <= min {
			min = x
		}
	}

	fmt.Println(min)
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

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; }
const int INF = 1LL << 60;

signed main() {
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, K;
  cin >> N >> K;
  long ans;
  if(N % K == 0)ans = 0;
  else {
    ans = N % K;
    ans = min(ans, abs(K - ans));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
ll gcd(ll a, ll b, ll c)
{
    ll ans1;
    ans1 = __gcd(a, b);
    ans1 = __gcd(ans1, c);

    return ans1;

}
int main()
{
    ll ans = 0, i, j, k, n;
    cin>>n;
    for(i = 1; i<=n; i++)
    {
        for(j = 1; j<=n; j++)
        {
            for(k = 1; k<=n; k++)
            {
              ans+=gcd(i, j, k);
              //printf("%lld %lld %lld and gcd %lld", i, j, k, gcd(i, j, k));
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	int len = s.size();
	int cnt = 0;
	for (int i = 0; i < len; i++) {
		if (s[i] == 'o')cnt++;
	}
	if ((15-len)+cnt >= 8)cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 3616
import java.util.*;
import java.io.*;

public class Main {
   public static void main(String[] args) {
	   
	   	FastScanner in = new FastScanner();
	   	int k = in.nextInt();
	   	if(k == 1) {
	   		System.out.println("ACL");
	   	}	else if(k == 2) {
	   		System.out.println("ACLACL");
	   	}	else if(k == 3) {
	   		System.out.println("ACLACLACL");
	   	}	else if(k == 4) {
	   		System.out.print("ACLACLACLACL");
	   	}	else {
	   		System.out.println("ACLACLACLACLACL");
	   	}
		
	}
	
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

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

using namespace std;

bool a[1000000];

int main()
{
    memset(a, true, sizeof(a));

    for (int i = 2; i < 1000000; i += 1 + (i & 1)) {
        if (!a[i]) continue;
        for (int j = i*2; j < 1000000; j += i) a[j] = false;
    }

    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i = 2; i <= n; ++i) cnt += a[i];
        cout << cnt << endl;
    }
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int a,b,n;
  	cin >> n;
  	cin >> a;
  	cin >> b;
   
  	if( a*n > b ){
      	cout << b << endl;
    }else{
     	cout << a*n << endl; 
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,m,k;
    cin >> n >> m >> k;
    for(int i = 0;i <= n;i++)
    {
        for(int j = 0;j <= m;j++)
        {
            if(i * (m - j) + j * (n - i) == k)
            {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vi;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define fori(i, n) forifrom(i, 0, n)

#define debuga(A, n) fori (i123, n) {cout << A[i123] << ' ';} cout << endl;
#define debugaa(A, n, m) fori (i1234, n) {debuga(A[i1234], m);}

#define Add(a, b) a = (a + b) % MOD;

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

const ll MOD = 924844033;
const ll maxn = 2010;

ll N, K, M, dp[maxn][maxn][2][2], cnt[maxn][maxn], fact[maxn];

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

    cin >> N >> K;
    M = (N + K - 1) / K;

    dp[0][0][1][0] = 1;
    fori (i, M) {
        fori (j, M + 1) {
            Add(dp[i + 1][j][0][0], dp[i][j][0][0]);
            Add(dp[i + 1][j + 1][0][0], dp[i][j][0][0]);
            Add(dp[i + 1][j + 1][0][1], dp[i][j][0][0]);

            Add(dp[i + 1][j][0][0], dp[i][j][1][0]);
            Add(dp[i + 1][j + 1][0][1], dp[i][j][1][0]);

            Add(dp[i + 1][j][1][0], dp[i][j][0][1]);
            Add(dp[i + 1][j + 1][1][0], dp[i][j][0][1]);
            Add(dp[i + 1][j + 1][1][1], dp[i][j][0][1]);

            Add(dp[i + 1][j][1][0], dp[i][j][1][1]);
            Add(dp[i + 1][j + 1][1][1], dp[i][j][1][1]);
        }
    }
    cnt[0][0] = 1;
    fori (i, K) {
        fori (j, N + 1) {
            fori (k, M + 1) {
                ll t = M - (N % K != 0 && i >= N % K);
                ll s = 0;
                Add(s, dp[t][k][0][0]);
                Add(s, dp[t][k][1][0]);
                Add(cnt[i + 1][j + k], 1LL * cnt[i][j] * s);
            }
        }
    }
    fact[0] = 1;
    fori (i, N) fact[i + 1] = 1LL * fact[i] * (i + 1) % MOD;
    ll ans = 0;
    fori (i, N + 1) {
        ll v = 1LL * cnt[K][i] * fact[N - i] % MOD;
        if (i % 2) v = MOD - v;
        Add(ans, v);
    }
    cout << ans << '\n';

}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int minz(int a, int b) {
    if (a == 0) return b;
    if (b == 0) return a;
    return min(a, b);
}

int main() {
    int N;
    while (cin >> N, N) {
        vs S;
        vs in(N);
        REP(i, N) cin >> in[i];
        SORT(in);
        in.erase(unique(ALL(in)), in.end());
        N = SZ(in);
        REP(i, N) {
            bool ok = true;
            REP(j, N) {
                if (i == j) continue;
                if (in[j].find(in[i]) != string::npos) {
                    ok = false;
                    break;
                }
            }
            if (ok) S.push_back(in[i]);
        }

        N = SZ(S);
        vvi tail(N, vi(N));
        REP(i, N) REP(j, N) {
            if (i == j) continue;
            RREP(k, S[i].length()) {
                if (k < (int)S[j].length()) {
                    bool ok = true;
                    REP(l, k) {
                        if (S[i][S[i].length()-k+l] != S[j][l]) {
                            ok = false;
                            break;
                        }
                    }
                    if (ok) {
                        tail[i][j] = S[j].substr(k).length();
                        break;
                    }
                }
            }
        }

        vvi dp(N, vi(1<<N));
        REP(i, N) {
            dp[i][1<<i] = S[i].length();
        }

        REP(X, 1<<N) {
            REP(i, N) if (BIT(X, i)) {
                REP(j, N) if (!BIT(X, j)) {
                    dp[j][X|(1<<j)] = minz(dp[j][X|(1<<j)], dp[i][X] + tail[i][j]);
                }
            }
        }
        int mi = 1000000;
        REP(i, N) {
            mi = minz(mi, dp[i][(1<<N)-1]);
        }
        cout << mi << endl;
    }
}

Measured memory_bytes: 3848
#include <bits/stdc++.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)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll x;
	cin >> x;
	FOR (i, -1000, 1000) {
	  FOR (j, -1000, 1000) {
		ll t = (ll)i * i * i * i * i - ((ll)j * j * j * j * j);
		if (t == x) {
		  cout << i << " " << j << endl;
		  return 0;
		}
	  }
	}
    
    return 0;
}


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

inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn = 1e5 + 10;
vector<int> linker[maxn], son[maxn];
int n, m, fa[maxn], vis[maxn];
void dfs(int x)
{
	vis[x] = 1;
	for (int cur : linker[x])
		if (!vis[cur]) dfs(cur);
}
int main()
{
	cin >> n >> m;
	if (m < n + 2) return puts("No"), 0;
	for (int i = 1; i <= m; i ++)
	{
		int u = read(), v = read();
		linker[u].push_back(v);
		linker[v].push_back(u);
	}
	for (int i = 1; i <= n; i ++)
		if (linker[i].size() & 1) return puts("No"), 0;
	for (int i = 1; i <= n; i ++)
		if (linker[i].size() >= 6) return puts("Yes"), 0;
	int cnt = 0;
	for (int i = 1; i <= n; i ++)
		if (linker[i].size() == 4) ++ cnt;
	if (cnt >= 3) return puts("Yes"), 0;
	if (cnt < 2) return puts("No"), 0;
	int st = 0, ed;
	for (int i = 1; i <= n; i ++)
		if (linker[i].size() == 4)
		{
			if (!st) st = i;
			else ed = i;
		}
	cnt = 0;
	for (int cur : linker[st])
	{
		memset(vis, 0, sizeof vis);
		vis[st] = 1;
		dfs(cur);
		if (vis[ed]) ++ cnt;
	}
	puts(cnt == 2 ? "Yes" : "No");
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

struct str{
    ll to,cost;
};
vector<vector<str>>g;
vector<ll>d;
void dfs(ll v,ll now,ll p=-1){
    d[v]=now;
    for(auto u:g[v]){
        if(p==u.to)continue;
        dfs(u.to,now+u.cost,v);
    }
}

int main(){
   ll n;cin >>n;
   g.resize(n);
   d.resize(n);
    for (int i = 0; i < n-1; ++i) {
        ll a,b,c;cin >>a>>b>>c;
        a--;b--;
        g[a].push_back({b,c});
        g[b].push_back({a,c});
    }
    ll q,k;cin >>q>>k;
    k--;
    dfs(k,0);
//    for (int j = 0; j < n; ++j) {
//        cout <<j<<" "<<d[j]<<endl;
//    }
    for (int i = 0; i < q; ++i) {
        ll x,y;cin >>x>>y;
        x--;y--;
        cout <<d[x]+d[y]<<endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

void change(int n, vector<int> &V){
 int i = 0;
  while(n > 0){
    int x;
    x = n%2;
    V[ i ] = x;
    n /= 2;
   i++;
  }
}

int main(){
  int D, G;
  cin >> D >> G;
  
  vector<vector<int>> V(10,  vector<int> (2));
  rep(i, D) rep(j, 2) cin >> V[i][j];
  
  int ans = 1000;
  
  for(int i = 0; i < pow(2, D); i++){
    int sum_score = 0;
    int sum_number = 0;
    vector<int> V2(D,0);
    
    change(i, V2);
    
   
    
    
    rep(j, D){
      if(V2[j] == 1){
        sum_score += 100*(j+1)*V[j][0]+V[j][1];
        sum_number += V[j][0];
      }
    }
    
    //cout <<  sum_score << endl;
    
    if(sum_score < G){
      for(int j = D-1; j>=0; j--){
        if(V2[j] == 0){
          int k = 0;
          
          //cout <<  V[j][0] << endl;
        
          while(sum_score < G && k < V[j][0]-1){
            sum_score += (j+1)*100;
            k++;
            
          }
          sum_number += k;
          break;
        }
      }
    }
    
    // cout <<  sum_score << endl;
    //cout <<  sum_number << endl;
    
    if(sum_score >= G){
      ans = min(ans, sum_number);
      
   //  cout << ans << endl;
    
      
    }
  }    
                          
 cout << ans << endl;
}
   
      

    

   
      
    
      
      
      
          
      
      
      
      
      

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];
	int ans = 0, active = 0;
	for (int i = 0; i < N; i++) {
		if (active < h[i]) {
			ans += h[i] - active;
			active = h[i];
		}
		else active = h[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
const int N = 16777217;
 
int n;
char data[16777217];
 
int conv(char c){
  switch(c){
  case 'A':
    return 1;
    break;
  case 'C':
    return 2;
    break;
  case 'G':
    return 3;
    break;
  case 'T':
    return 4;
    break;
  }
}
 
int hash(char str[10]){
  int res = 0, size = strlen(str), r = 1, i;
  for(i=size-1;i>=0;i--){
    res += r * conv(str[i]);
    r *= 4;
  }
  return res;
}
 
void insertElm(int d){
  data[d] = 1;
}
 
char findElm(int d){
  return data[d];
}
 
main(){
  char ope[13], str[13];
  int i;
  memset(data, 0, 16777217);
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s", ope);
    scanf("%s", str);
    if(!strcmp(ope, "insert")) insertElm(hash(str));
    else printf("%s\n", (findElm(hash(str)) ? "yes" : "no"));
  }
  return 0;
}



Measured memory_bytes: 18096
using System;

namespace AtCoder.Abcdef
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //Input string
            string s = Console.ReadLine();

            if (Char.IsUpper(s[0]))
            {
                Console.WriteLine("A");
            }
            else 
            {
                Console.WriteLine("a");
            }

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 25672
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

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

  ll a, b, c; cin >> a >> b >> c;
  ll d = c - a - b;
  if(d > 0 && d * d > 4 * a * b){
    cout << "Yes";
  }else{
    cout << "No";
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    if(a == b) {
        cout << 'H';
    }
    else {
        cout << 'D';
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    string Color;
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> Color;
        if (Color == "Y"){
            cout << "Four" << endl;
            break;
        }else if (i == N - 1 && Color != "Y"){
            cout << "Three" << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int modlist[2020];


int main(){
    string s;
    int sum = 0, ans= 0;
    int ten = 1;
    cin >> s;

    for(int i=s.length()-1;i>=0;i--){
        if(i!=s.length()-1)
            ten = (ten*10) % 2019;
        
        sum = (((s[i]-'0')*ten)%2019 + sum)%2019;
        modlist[sum]++;
    }
    ans+=modlist[0];

    ten = 1; sum = 0;
    for(int i=s.length()-1;i>=0;i--){
        if(i!=s.length()-1)
            ten = (ten*10) % 2019;
        
        sum = (((s[i]-'0')*ten)%2019 + sum)%2019;
        modlist[sum]--;
        ans += modlist[sum];
    }

    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3728
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if A[i] > A[i+1]:
        ans += A[i] - A[i+1]
        A[i+1] = A[i]
print(ans)

Measured memory_bytes: 91960
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i=0; i<N; i++) {
			X[i] = sc.nextInt();
		}
		
		int ans = Integer.MAX_VALUE;
		
		for(int p=1; p<=100; p++) {
			int sum = 0;
			for(int i=0; i<N; i++)
				sum += (X[i]-p)*(X[i]-p);
			ans = Math.min(ans, sum);
		}

		System.out.println(ans);
		sc.close();
	}
}


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

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

using namespace std;
using lint=long long;

lint solve(lint n,vector<pair<lint,lint>>& d){
	if(d.empty()) return n;

	auto [a,b]=d.back();
	if(d.size()==1) return n+(n/a)*(b-a);

	lint res=n;
	rep(i,n/a+1){
		d.pop_back();
		res=max(res,i*b+solve(n-i*a,d));
		d.emplace_back(a,b);
	}
	return res;
}

int main(){
	int n,a[3],b[3]; cin>>n;
	rep(i,3) cin>>a[i];
	rep(i,3) cin>>b[i];

	vector<pair<lint,lint>> d1,d2;
	rep(i,3){
		if(a[i]<b[i]) d1.emplace_back(a[i],b[i]);
		if(a[i]>b[i]) d2.emplace_back(b[i],a[i]);
	}

	cout<<solve(solve(n,d1),d2)<<'\n';

	return 0;
}


Measured memory_bytes: 3636
import java.io.*;
import java.util.*;

public class Main {

    static int K;
    static long[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        K = sc.nextInt();
        A = sc.nextLongArray(K);

        System.out.println( solve() );
    }

    static String solve() {
        long min = 2;
        long max = 2;

        for (int i = K-1; i >= 0; i--) {
            long a = A[i];

            if (min % a != 0 && max % a != 0) {
                long min_q = min / a;
                long max_q = max / a;

                if( !(min_q < max_q) ) return "-1";
            }

            min = min % a == 0 ? min : ((min / a) + 1) * a;
            max = (max / a) * a + (a-1);
        }

        return min + " " + max;
    }

    @SuppressWarnings("unused")
    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 38364
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=500010;
ll a,b,c,d,e,x,y,z,k,m,n,l,q,ans=0;
vl v(100010,0),anss(100010,0);
vp p[100010];
string s;
ll par[110000];//親の頂点
ll size[110000];
ll solve(void){
    a=0;
    b=0;
    if(n/100<13)a++;
    if(n%100<13)b++;
    if(a==1&&b==1){
        cout<<"AMBIGUOUS"<<endl;
    }
    if(a==0&&b==1){
        cout<<"YYMM"<<endl;
    }
    if(a==1&&b==0){
        cout<<"MMYY"<<endl;
    }
    if(a==0&&b==0){
        cout<<"NA"<<endl;
    }
    return 0;
}
ll root(ll x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
}
bool same(ll x,ll y){
    return root(x)==root(y);
}
void unite(ll x,ll y){
    if(same(x,y))return;
    size[root(y)]+=size[root(x)];
  par[root(x)]=y;
}
int main(){
    cin>>n>>m;
    ans=n;
    for(int i=0;i<n+1;i++){//初期化
        par[i]=i;
        size[i]=1;
    }
 
    rep(i,m){
        cin>>x>>y>>z;
        if(!same(x,y)){
        unite(x,y);
        ans--;
      }
    }
 
    cout<<ans<<endl;
}

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

int main(void){
    int n, m, l;
    cin >> n >> m >> l;
    ll a[n][m], b[m][l], c[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++) cin >> a[i][j];
    } 
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++) cin >> b[i][j];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            c[i][j] = 0;
            for(int k = 0; k < m; k++) c[i][j] += a[i][k] * b[k][j];
        }
    }
    for(int i = 0; i < n; i++){
        cout << c[i][0];
        for(int j = 1; j < l; j++) cout << ' ' << c[i][j];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3232