akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

        int num = 0;
        for (int i = 1; i < K + 1; i++) {
            for (int j = 1; j < K + 1; j++) {
                int cache = gcd(i, j);
                for (int k = 1; k < K + 1; k++) {
                    num += gcd(cache, k);
                }
            }
        }
        System.out.println(num);
    }

    public static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        } else {
            a = a % b; // 残り部分
            return gcd(b, a); // 残り部分から最小の正方形を見つける
        }
    }
}

Measured memory_bytes: 27236
def resolve():
    n = int(input())
    li = list(map(int, input().split()))

    count = 0
    while True:
        for i in range(n):
            a = li[i]
            if a % 2 == 1:
                print(count)
                return 0
            li[i] = int(a/2)
        count += 1
resolve()

Measured memory_bytes: 9100
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k,x;
		k = sc.nextInt();
		x = sc.nextInt();
		if(500 * k >= x){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
"""Rooted Trees."""

class Node:
    def __init__(self, num, parent, *children):
        self.id = num
        self.parent = parent
        self.children = list(children)
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print(self.children)


class RootedTree():
    def __init__(self, n):
        self.nodes = [Node(i, -1) for i in range(n)]
    
    def set_node(self, i_p):
        i_p = list(map(int, i_p.split()))
        num = i_p[0]
        children = i_p[2:]
        if children:
            self.nodes[num].children = children
            for n in children:
                self.nodes[n].parent = num

    def set_depth(self):
        for n in self.nodes:
            t_n = n
            while t_n.parent != -1:
                n.depth += 1
                t_n = self.nodes[t_n.parent]

    def show_nodes_info(self):
        for n in self.nodes:
            n.show_info()



import sys

n = int(sys.stdin.readline())

T = RootedTree(n)

for x in sys.stdin.readlines():
    T.set_node(x)

T.set_depth()

T.show_nodes_info()

Measured memory_bytes: 61852
#include<iostream>
#include<cstdio>
using namespace std;
int n,x,y;
inline int read(){
	int ans=0,k=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')k=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=(ans<<3)+(ans<<1)+(c-'0');c=getchar();}
	return ans*k;
}
int main(){
	n=read();
	for(register int i=1;i<=n;i++){
		x=read();
		y^=x;
	}
	if(!y)printf("Yes");
	else printf("No"); 
	return 0;
} 

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

#define ll long long

ll n;
string s;
ll dp[5][2][2][2][4005];

ll solve(ll pos, ll r, ll g, ll b, ll last)
{
	if(pos>=3)
	{
		if(r && g && b) return 1;
		return 0;
	}

	ll &ret = dp[pos][r][g][b][last];

	if(ret!=-1) return ret;

	ll sm = 0;
	for(int I=last+1;I<=n;I++)
	{
		int i= I-1;
		if(s[i] == 'R')
			sm+= solve(pos+1,1,g,b,I);
		else if(s[i] == 'G')
			sm+= solve(pos+1,r,1,b,I);
		else
			sm+= solve(pos+1,r,g,1,I);
	}

	return ret = sm;
}

int main()
{
	memset(dp,-1,sizeof dp);
	cin >> n;
	cin >> s;

	ll ans = solve(0,0,0,0,0);

	for(int i=1;i<n;i++)
	{
		for(int j=0;j+i+i<n;j++)
		{
			char a = s[j];
			char b = s[j+i];
			char c = s[j+i+i];

			if(a !=b &&  b!=c && a!=c) ans--;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4888
N = int(input())
lis = list(map(int,input().split()))
lisans = []
i = N-1
while i >= 0:
  lisans.append(lis[i])
  i -= 2
if N % 2 == 0:
  i += 1
else:
  i += 3
while i < N-1:
  lisans.append(lis[i])
  i += 2
print (" ".join(list(map(str,lisans))))

Measured memory_bytes: 29760
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

inline void decreaseByOne(multiset<int>& mset, int val) {
    mset.erase(mset.lower_bound(val));
}

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

    const int INF = 10000000;
    map <int, int> dp;
    multiset <int> cand;

    for (int p = 1; p <= W; ++p) {
        dp[p] = 0;
        cand.insert(0);
    }

    for (int h = 0; h < H; ++h) {
        int A;
        int B;
        cin >> A >> B;

        int newVal = INF;
        // update interval [A, B]
        auto iter = dp.lower_bound(A); // to be confirmed
        while (iter != dp.end() && iter->first <= B) {
            int dist = B+1 - iter->first + iter->second;
            newVal = min(newVal, dist);
            // erase candidates
            decreaseByOne(cand, iter->second);

            auto nextIter = iter;
            ++nextIter;
            dp.erase(iter);
            // cout << "ERASE DEBUG " << iter->first << " " << cand.size() << endl;
            iter = nextIter;
        }

        if (newVal != INF) {
            if (B+1 <= W) {
                if (dp.count(B+1)) { // update
                    if (newVal < dp[B+1]) {
                        decreaseByOne(cand, dp[B+1]);

                        dp[B+1] = newVal;
                        cand.insert(newVal);
                    }
                } else {
                    dp[B+1] = newVal;
                    cand.insert(newVal);
                }
            }
        }

        // cout << "DEBUG " << cand.size() << endl;
        if (cand.empty()) {
            cout << -1 << endl;
        } else {
            cout << *cand.begin() + h + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 22280
//wherever you are,whatever you do, be in love

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	string s,t;
	cin>>s>>t;
	ll mi=1e18;
	forn(i,s.length()-t.length()+1){
		ll c=0;
		forn(j,t.length()){
			if(s[i+j]!=t[j]) c++;
		}
		mi=min(mi,c);
	}
	cout<<mi;
}

Measured memory_bytes: 3628
# coding:UTF-8
import sys
from math import factorial

MOD = 10 ** 9 + 7
INF = 10000000000

def binary_search_section(list, min, max):
    low = 0
    high = len(list) - 1
    upper = len(list)
    lower = -1
    while low <= high:
        mid = (low + high) // 2
        guess = list[mid]
        if guess >= min:
            high = mid - 1
        else:
            low = mid + 1
            lower = mid
    low = 0
    high = len(list) - 1
    while low <= high:
        mid = (low + high) // 2
        guess = list[mid]
        if guess > max:
            high = mid - 1
            upper = mid
        else:
            low = mid + 1

    return [lower, upper]

def main():
    # ------ 入力 ------#
    # 1行入力
    n = int(input())    # 数字
    aList = list(map(int, input().split()))     # スペース区切り連続数字
    bList = list(map(int, input().split()))     # スペース区切り連続数字
    cList = list(map(int, input().split()))     # スペース区切り連続数字

    # ------ 処理 ------#
    aListSorted = sorted(aList)
    bListSorted = sorted(bList)
    cListSorted = sorted(cList)

    result = 0
    # for a in aListSorted:
    #     sec = binary_search_section(bListSorted, a+1, bListSorted[-1])
    #     for j in range(sec[0]+1, len(bListSorted)):
    #         b = bListSorted[j]
    #         sec2 = binary_search_section(cListSorted, b+1, cListSorted[-1])
    #         result += len(cListSorted) - (sec2[0] + 1)
    for b in bListSorted:
        sec = binary_search_section(aListSorted, aListSorted[0], b-1)
        sec2 = binary_search_section(cListSorted, b+1, cListSorted[-1])
        result += (sec[1] - sec[0] - 1)*(sec2[1] - sec2[0] - 1)

    # ------ 出力 ------#
    print("{}".format(result))
    # if flg == 0:
    #     print("YES")
    # else:
    #     print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 28492
/*
　 　 　 　 　　　　　　　　　　　／￣ ヽ
　　　　　 　　　　　　　　　　 /　　　__ﾉ
　 　 　 　 　　　　　　　　　　|　　　　　　　,　‐: : ' ¨￣￣ ¨`: :　、
　　__　　　/ }　　　　　　　　 ヽ　　　　／: : : : : : : : : : : : : : : : : : ＼
　　＼＼__|　! 　 　 　 　　　　　`ｰ,―‐ ': : : : : : : : : : : : : : : :.ヽ: : : :＼
r―- '　　 x┴‐､　　　　　　　　／: : : : : : : : : : : : : : : : : :＼ : : :ヽ : : : ヽ
(二二　 //:⌒ヽﾍ 　　　　　／: : : : : : : / : : : /: : : : : : : : : :.ヽ!: : :',: : : :ハ
. `ｰ―;//::::::::::::::V} 　　　 /:.〃.: : : : :.:/ : : : /: : : : :{^ヽ: : : !: :|: : : ﾄ､:.只: .:,
　　　 ｉ {::::::::::::::::::::::＼　 /:.// : : : :!: : !: :! ! :| ! : : |: | 斗-:､:| : !: : : !Ｘ|! :!ヽﾊ
　　　 { |::::::::::::::::::::::::::::`/:/ ,' : :!: : :!: : | イ厂`ヽ!:.:!ヾ　 !　ヽ|: :|: : : |Ｘ|!: |! 》ﾊ
　　　 { |::::::::::::::::::::::::::::〃＼!: /!: : :|: : :V.ﾊx=ﾐ 从|　　　____ハ.|: : : |__|!: |〃:ハ
　　　 V1:::::::::::＿::::::::::{!::::::::|:ﾑ|: : ::! : : ﾊ〈 fい　　　　 ''"⌒ヾ | : : :ｉ :.|!: |!: : : :.ヽ
　　　　込_,／　　 ＼::::!:::::::::!!八|: 八: : :ﾊ　Vr} 　 　 　　.:::::.　,': : /}: :|! :|! : : : : :.＼
　　　　　　　　　　　 ＼:::::::::!:::::八: : ﾄ､ : ﾊ　`´　'　＿　　　　/: :厶': : : : : : : : : : : : ＼
　　　　　　　　　　　　　＼:::::::/: : :＼!: ヽ:込、 　ヽ　 ﾉ　　 ｨ: : /: : !＼:.: : : ﾄ､ヽ＼ : : :ヽ
　　　　　　　　　　　　　　 ヽ/: :/ : : : :/!: ＼:!: ＞ ､_,. 　'　/イﾊ: :.ハ: :!＼: :|　} }　 !: ハ:}
　　　　　　　　　　　　　　　/: :/!: :/|/:::|: √⌒^V｢　}　r‐‐'"/7∨　 Ｖ　　}ﾉ　リ　 |/　 ﾘ
　 　 　 　 　　　　　　　　　! : :ｉ ∨:::!／⌒　　`y勹>'￣⌒ヾ::::＞､　　　　/　　　　/
　　　　　　　　　　　　　　 从: |　√（￣￣¨,＞ﾍf⌒¨　　　　〉::::::::::＼
　　　　　　　　　　　　　　　　N 人　 ｀ﾌ￣｢:|ｧ个い　　　 ／::::::／⌒::}
　 　 　 　 　　 　　　　　　　　 ,'::::::V´:::::／:/　/　ヽ}＿／::::::／::::::::::::,'
　 　 　 　 　　　　　　　　　　　!::::::::::::::/::::く__〆ヽ、　　 ＼:::::::::::::::::::/
　　　　　　　　　　　　　　　　　〉::::::::::/::::::::::::::::::::::::＼_ノ⌒::::::::::::::::,'
　　　　　　　　　　　　　　　　 /::::::::::/::::::::::::::::::::::::::::::::::::/|::::::::::::::::,'
　 　 　 　 　　　　　　　　　　/::::::C/:::::::::::::::::::::::::::::::::::/　|:::::::::::::::ｉ
　　　　　　　　　　　　　　　 ,':::::::::::ｉ:::::::::::::::::::::::::::::::／　　!:::::::::::::::ｉ
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif

int main(void)
{
  ll a, b;
  cin >> a >> b; 
  
  cout << max({a+b, a-b, a*b});
  
  return 0;
}


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

int n;
long long maxlen;

struct Node {
	Node *ch[2]; // binary
	bool leaf;
	Node() { for (int i = 0; i < 2; ++i) ch[i] = NULL; leaf = false; }
	~Node() { for (int i = 0; i < 2; ++i) delete ch[i]; leaf = false; }
} *Trie = new Node();

void add(string &s) {
	Node *cur = Trie;
	for (int i = 0; i < s.size(); ++i) {
		int v = s[i] - '0';
		if (cur -> ch[v] == NULL) cur -> ch[v] = new Node();
		cur = cur -> ch[v];
	}
	cur -> leaf = true;
}

long long get(long long x) {
	return x & -x;
}

long long grundy(Node *cur, long long len) {
	if (cur -> leaf) return 0;
	long long x = 0;
	for (int i = 0; i < 2; ++i) {
		if (cur -> ch[i] == NULL) x ^= get(len);
		else x ^= grundy(cur -> ch[i], len - 1);
	}
	return x;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> maxlen;
	for (int i = 1; i <= n; ++i) {
		string s; cin >> s;
		add(s);
	}
	long long x = grundy(Trie, maxlen);
	printf(x > 0 ? "Alice\n" : "Bob\n");
}

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

typedef long long int ll;
#define f(a, b) for(auto i = a;i < b;i++)

bool sortbysec(const pair<ll, ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 
double pi = 3.14159265358979323846;
void solve()
{
	return ;
}

int main()
{
	double R;
	cin >> R;

	cout << setprecision(22)<<  2.0 * pi *(R) << "\n";
}

Measured memory_bytes: 3788
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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! {R:f32};
    println!("{}", R * 3.1415926535 * 2.0);
}


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

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

int n, ans=0;

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    //freopen(".in","r",stdin);
	//freopen(".out","w",stdout); 
	
	cin >> n;
	
	ans+=n/500*1000;
	ans+=n%500/5*5;
	
	cout << ans; 
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const int MOD = 1e9 + 7;
const int MAXV = 1e5;

int main() {
    FAST_IO();
    string S; cin >> S;
    int K; cin >> K;
    set<string> arr;
    int N = sz(S);
    rep(i, N) {
        repp(j, 1, min(K, N - i)) {
            arr.insert(S.substr(i, j));
        }
    }
    for(auto &x : arr) {
        if(--K > 0) continue;
        cout << x << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 1664
from sys import stdin

while True:
    a, op, b = stdin.readline().rstrip().split()
    if op == "+":
        print(int(a)+int(b))
    elif op == "-":
        print(int(a)-int(b))
    elif op == "*":
        print(int(a)*int(b))
    elif op == "/":
        print(int(a)//int(b))
    else: # op == "?"
        break



Measured memory_bytes: 5596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] a) throws IOException{

    	String strLine ="";
    	BufferedReader stdReader =
            new BufferedReader(new InputStreamReader(System.in));

    	String[] inputStr = new String[2];
    	Integer[] keta = new Integer[200];

    	int i = 0;

    	while ( i < 200 && ((strLine = stdReader.readLine()) != null) ){
    		inputStr = strLine.split(" ",0);
    		int temp1 = Integer.parseInt(inputStr[0]);
    		int temp2 = Integer.parseInt(inputStr[1]);

    		keta[i] = caulKeta(temp1 + temp2);

    		i++;
	   	}

    	for(int c = 0; c < i; c++){
    		System.out.println(keta[c]);
    	}


    }

public static int caulKeta(int suuji){

	int keta = 1;

	for(int i = 10; suuji/i !=0; i =i*10 ){

		keta ++;
	}

	return keta;
}

}

Measured memory_bytes: 24232
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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


int main() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        ans += a - 1;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
stack <int> s1;
queue <int> s2;
vector <int> v;
char s[200006],t[200005];
int l,a,c=0;
void push(int a)
{
  for(int i=a;i<l;i++){
   // cout<<s[i]<<" "<<i<<endl;
    if(s[i]=='*'){
      c++;
      if(i-c>-1) s[i-c]='*';
    } 
    else{
      c=0;
      if((s[i]=='<') || (s[i]=='>')) return;
    
      else if(s[i]=='#') continue;
      else v.push_back(i);
    }
  }
}
int main()
{
    /*scanf("%s",s);
    l=strlen(s);
    s1.push(0);
    for(int i=1;i<l;i++){
      if(s[i]=='#') c++;
      if(s[i]>='0' && s[i]<='9'){
        if(c%2) s[i]='#';
      }
      if(s[i]=='<') s1.push(i+1);
      if(s[i]=='>') s2.push(i+1);
    }
    
    while(!s1.empty()){
      push(s1.top());
      s1.pop();
    }
    while(!s2.empty()){
      push(s2.front());
      s2.pop();
    }
    l=v.size();
    for(int i=0;i<l;i++){
      if(s[v[i]]!='*') printf("%c",s[v[i]]);
    }*/
      scanf(" %s %s",s,t);
      l=strlen(s);
      for(int i=0;i<l;i++){
        if(s[i]!=t[i]) c++;
      }
      printf("%d\n",c);
    return 0;
}

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



int main() {
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}

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

const int N=1e5+30;
typedef long long ll;
ll n,k;
int main()
{
    cin>>n>>k;
    if(n%k==0){
        cout<<0<<endl;
    }
    else{
        ll a=n%k;
        ll b=k%a;
        if(a+b==k)
        cout<<min(a,b)<<endl;
        else
        cout<<n<<endl;
    }
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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 transpose<T: Copy>(vs: Vec<Vec<T>>) -> Vec<Vec<T>> {
    let mut w = Vec::new();
    for x in 0..vs[0].len() {
        let mut row = Vec::new();
        for y in 0..vs.len() {
            row.push(vs[y][x]);
        }
        w.push(row);
    }

    w
}

fn calc_across(sh: Vec<Vec<char>>) -> Vec<Vec<i32>> {
    let mut h = Vec::new();
    let mut cur = 0;
    let mut count = 0;
    for row in sh {
        let mut w = Vec::new();
        for ch in row {
            if ch == '#' {
                for _ in 0..count {
                    w.push(cur);
                }

                cur = 0;
                count = 0;
                w.push(0);
            } else {
                cur += 1;
                count += 1;
            }
        }

        for _ in 0..count {
            w.push(cur);
        }

        cur = 0;
        count = 0;
        h.push(w);
    }

    h
}

fn solve(sh: Vec<Vec<char>>, h: i32, w: i32) -> i32 {
    let v1 = calc_across(sh.clone());
    let v2 = calc_across(transpose(sh));
    let mut m = 0;

    for y in 0..h {
        for x in 0..w {
            m = ::std::cmp::max(m, v1[y as usize][x as usize] + v2[x as usize][y as usize]);
        }
    }

    m-1
}

fn main() {
    input!{
        h: i32,
        w: i32,
        sh: [String; h],
    }

    println!("{:?}", solve(sh.into_iter().map(|vs| vs.chars().collect::<Vec<char>>()).collect::<Vec<_>>(), h, w));
}


Measured memory_bytes: 57592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int h, n;
    cin >> h >> n;
    int a[n], b[n];
    rep (i, 0, n) cin >> a[i] >> b[i];
    int dp[n + 1][20000];
    rep (i, 0, n + 1) rep (j, 0, 20001) dp[i][j] = inf;
    rep (i, 0, n + 1) dp[i][0] = 0;
    rep (i, 0, n) {
        rep (j, 0, 19999) {
            if (j + 1 >= a[i])
                dp[i + 1][j + 1] = min (dp[i + 1][j + 1 - a[i]] + b[i],
                                        dp[i][j + 1 - a[i]] + b[i]);
            dp[i + 1][j + 1] = min (dp[i + 1][j + 1], dp[i][j + 1]);
        }
    } /*
     rep (i, 0, n + 1) {
         rep (j, 0, 110) cout << dp[i][j] << " ";
         cout << "\n";
     }*/
    int ans = inf;
    rep (i, h, 20001) {
        ans = min (ans, dp[n][i]);
        // cout << ans << " ";
    }
    cout << ans << "\n";
}

Measured memory_bytes: 78464
#include<bits/stdc++.h>
#define inf 2147483647
int a[110][110],p[110][110];
int read() {
	int s=0,w=1;
	char ch=getchar();
	while (!(ch>='0' && ch<='9'))
		w=-1*(ch=='-'),ch=getchar();
	while (ch>='0' && ch<='9') 
		s=s*10+(ch-'0'),ch=getchar();
	return s;
}
int max(int x,int y) {
	return x>y?x:y;
}
int main() {
	int n=read();
	while (n) {
		int r=read(),c=read();
		memset(a,0,sizeof(a));
		for (int i=1; i<=n; i++) {
			int x=read(),y=read();
			a[x][y]=1;
		}
		for (int i=1;i<=r;i++) 
			for (int j=1;j<=c;j++)	
				p[i][j]=p[i-1][j]+p[i][j-1]-p[i-1][j-1]+a[i][j];
		int s=read(),t=read(),ans=-inf;
		for (int i=s;i<=r;i++)
			for (int j=t;j<=c;j++) {
				int k=i-s,l=j-t,num=p[i][j]-p[k][j]-p[i][l]+p[k][l];
				ans=max(num,ans);
			}
		printf("%d\n",ans);
		n=read();
	}
	return 0;
}


Measured memory_bytes: 3208
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        System.out.println(a <= d && c <= b ? Math.min(b, d) - Math.max(a, c) : 0);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
static const int N=100;

int main(){
  int m[N][N],n,u,k,v,i,j;

  cin >> n;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) m[i][j]=0;
  }
  for(i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(j=0;j<k;j++){
      cin >> v;
      v--;
      m[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j) cout << " ";
      cout << m[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

int n;
string s;
int main() {
	cin >> n;
	REP(i, INF) {
		if (n == 0) break;
		if (n % -2 == 0) s.push_back('0');
		else s.push_back('1');
		if (n < 0) n--;
		n /= -2;
	}
	reverse(ALL(s));
	if (s == "")s.push_back('0');
	cout << s << endl;
}
	


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

int f(int n)
{
  if(n&1)
    return 3*n+1;
  return n/2;
}

int main()
{
 int s;
  cin>>s;
  set<int> st;
  int n=1;
  st.insert(s);
  while(1)
  {
    n++;
    s=f(s);
    if(st.find(s)!=st.end())
    {
      cout<<n<<"\n";
      return 0;
    }
    st.insert(s);
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    cout << vec.at(N / 2) - vec.at(N / 2 - 1) << endl;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = input()
    
    if N[0] == "9":
        print("Yes")
        sys.exit()
    if N[1] == "9":
        print("Yes")
        sys.exit()
    else:
        print("No")
    
		
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,child,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int L[10];
int main(){
  int N;
  cin >> N;
  rep(i, N) cin >> L[i];
  int sum = 0;
  rep(i, N) sum += L[i];
  sort(L, L + N);
  bool ans = L[N - 1] * 2 < sum;
  puts(ans ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
  int A[100],i,j,N,a=0,n=0,minj;
  
  scanf("%d",&N);
  
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  for(i=0; i<N-1; i++){
    minj = i;
    
    for(j = i;j<N; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    if(minj!=i){
      a = A[i];
      A[i] = A[minj];
      A[minj] = a;
      n++;
    }
      
  }

  for(i=0; i<N; i++){
    printf("%d",A[i]);
if(i!=N-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",n);
  return 0;
}

Measured memory_bytes: 604
#include<stdio.h>

int main()
{
    int i,y;
    int ara[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    scanf("%d",&y);
    i=y-1;
    printf("%d\n",ara[i]);
    return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())

#コイン投げの回数
def coincnt(base,k):
    ans = 0
    while base<k:
        ans+=1
        base*=2
        
    return ans

p=0.0
for i in range(1,n+1):
    p+=(1/n)*(1/2)**coincnt(i,k)
    
print(p)

Measured memory_bytes: 9432
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def soinsubunkai_e(n,m): #高速素因数分解 m[n]=nを割ることの出来る最小の素数
    a = set()
    i = 1
    while n>1:
        a.add(m[n])
        n=n//m[n]
    nokori=n
    a.add(nokori)
    return a

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def era(n): #b[n]=nを割ることの出来る最小の素数　の配列を生成　エラトステネスの篩
    b=[i for i in range(n+1)]
    for i in range(2,int(math.sqrt(n)+10)):
        j=1
        temp=i*j
        while temp<=n:
            b[temp]=min(i,b[temp])
            temp+=i
    return b


def main():
    #l,r,d=map(int,input().split())
    n=int(input())
    print(-(n-1))









if __name__ == "__main__":

    main()


Measured memory_bytes: 72772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int y = in.nextInt();
		boolean aohashi = false;
		int[] ans = new int[3];
		for(int i=0;i<=n;i++) {
			for(int j=0;j<=n-i;j++) {
				int k = n-i-j;
				int sum = i*1000 + j*5000 + k*10000;
				if(y==sum) {
					aohashi = true;
					ans[0] = i;
					ans[1] = j;
					ans[2] = k;
					break;
				}
			}
			if(aohashi) break;
		}
		
		if(aohashi) System.out.println(ans[2]+" "+ans[1]+" "+ans[0]);
		else System.out.println("-1 -1 -1");
		in.close();

	}

}


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

using namespace std;
const int MAXN = 2E5 + 5;
const int MOD = 1E9 + 7;
int dp[800][2005], sum[2005];
int len, s;

template <class T>
void read(T &x, T f = 1, char ch = getchar()) {
    x = 0;
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int main() {
    cin >> s;
    len = s / 3;
    dp[0][0] = 1;
    for (int i = 0; i <= s; i++) sum[i] = 1;
    for (int i = 1; i <= len; i++) {
        for (int j = i * 3; j <= s; j++)
            dp[i][j] =
                ((sum[j - 3] - (i > 1 ? sum[(i - 1) * 3 - 1] : 0)) % MOD +
                 MOD) %
                MOD;
        for (int j = 0; j <= s; j++) sum[j] = 0;
        for (int j = i * 3 - 1; j <= s; j++)
            sum[j] = (sum[j - 1] + dp[i][j]) % MOD;
    }
    int ans = 0;
    for (int i = 1; i <= len; i++) ans += dp[i][s], ans %= MOD;
    cout << ans;
    return 0;
}

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

main(){

  ll n;
  cin>>n;
  vector<ll> a(n+1),b(n);
  rep(i,n+1)cin>>a[i];
  rep(i,n)cin>>b[i];

  auto c=a;
  rep(i,n){
    if(b[i]>=a[i]){
      b[i]-=a[i];
      a[i]=0;
      if(b[i]>=a[i+1]){
        b[i]-=a[i+1];
        a[i+1]=0;
      }
      else{
        a[i+1]-=b[i];
        b[i]=0;
      }
    }
    else{
      a[i]-=b[i];
      b[i]=0;
    }
  }
  ll ans=0;
  rep(i,n+1){
    ans+=c[i]-a[i];
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 2560
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f
inline int read() {
    int x = 0, neg = 1; char op = getchar();
    while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
    while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
    return neg * x;
}
inline void print(int x) {
    if (x < 0) { putchar('-'); x = -x; }
    if (x >= 10) print(x / 10);
    putchar(x % 10 + '0');
}
const int maxn = 2e5 + 10;
int k,n,a[maxn];
signed main() {
    IO;
    cin >> k >> n;
    rep(i,1,n) cin >> a[i];
    int mx = -1;
    rep(i,2,n) mx = max(mx,a[i] - a[i-1]);
    mx = max(mx,k - a[n] + a[1]);
    cout << k - mx << endl;
    return 0;
}

Measured memory_bytes: 1792
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

const mod = 10^^9+7;
alias mint = FactorRing!mod;

void main()
{
  int n, m; readV(n, m);

  if (n < m) swap(n, m);

  if (n >= m+2) {
    writeln(0);
    return;
  }

  auto fact = new mint[](n+1);
  fact[0] = 1;
  foreach (i; 1..n+1) fact[i] = fact[i-1]*i;

  if (n == m)
    writeln(fact[n]*fact[n]*2);
  else
    writeln(fact[n]*fact[m]);
}

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) union { long vl; struct { int vi2; int vi; } } else union { long vl; int vi; }
  alias FR = FactorRing!(m, pos);
  @property static init() { return FR(0); }
  @property int value() { return vi; }
  @property void value(int v) { vi = mod(v); }
  alias value this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref auto opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const { static if (pos) return v%m; else return (v%m+m)%m; }
  pure auto mod(long v) const { static if (pos) return cast(int)(v%m); else return cast(int)((v%m+m)%m); }

  static if (!pos) pure ref auto opUnary(string op: "-")() { return FR(mod(-vi)); }

  static if (m < int.max / 2) {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vi"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vi"~op~"r")); return this; }
  } else {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vl"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vl"~op~"r")); return this; }
  }
  pure ref auto opBinary(string op: "*")(int r) { return FR(mod(vl*r)); }
  ref auto opOpAssign(string op: "*")(int r) { vi = mod(vl*r); return this; }

  pure ref auto opBinary(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opBinary!op(r.vi); }
  ref auto opOpAssign(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(r.vi); }
}


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;

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


    string s, ans = "Yes";
    cin >> s;
    
    string a;
    
    cin >> a;
    
    for(int i=0; i<s.size(); i++)
    {
        if(s[i] != a[i])
        {
            ans = "No";
            break;
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
    int a,i;
    i = 0;
    do{
        i ++;
        scanf("%d", &a);
        if (a == 0)
        {
            break;
        }
        printf("Case %d: %d\n",i,a);

    }while (1);


    return 0;
}


Measured memory_bytes: 2056
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Foldable
import Data.Char
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    _ <- readLn :: IO Int
    as <- map (pred.snd) . IM.toList . IM.fromListWith (+) . (flip zip) (repeat 1) <$> r'
    let n = length as
    print $ if odd (sum as) then n-1 else n


Measured memory_bytes: 15740
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100;

int n;
int a[MAX_N];
ll memo[MAX_N][21];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	fill(memo[0], memo[n], 0);
	memo[0][a[0]]++;
	for(int i = 1; i < n - 1; i++){
		for(int j = 0; j <= 20; j++){
			if(j - a[i] >= 0) memo[i][j] += memo[i - 1][j - a[i]];
			if(j + a[i] <= 20) memo[i][j] += memo[i - 1][j + a[i]];
		}
	}
	cout << memo[n - 2][a[n - 1]] << endl;
	return 0;
}



Measured memory_bytes: 3096
def solve():
    s = input()
    t = input()

    dp = [[0] * (len(t)+1) for _ in range(len(s)+1)]

    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])
    
    res = ""
    i = len(s)
    j = len(t)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            res = s[i-1] + res
            i -= 1
            j -= 1
    
    print(res)
if __name__ == '__main__':
    solve()

Measured memory_bytes: 112348
from math import hypot

n = int(input())
ls = [list(map(int, input().split())) for i in range(n)]

def f(x,y):
    dist = 0
    for i in range(n):
        dx = x - ls[i][0]
        dy = y - ls[i][1]
        dist = max(dist, hypot(dx, dy))
    return dist

def g(x):
    l = 0
    r = 1000
    for _ in range(100):
        c1 = (l*2+r)/3
        c2 = (l+r*2)/3
        if f(x, c1) > f(x ,c2):
            l = c1
        else:
            r = c2
    return f(x, l)

l = 0
r = 1000


for _ in range(100):
    c1 = (l*2+r)/3
    c2 = (l+r*2)/3
    if g(c1) > g(c2):
        l=c1
    else:
        r=c2

print(g(l))

Measured memory_bytes: 46812
H,W = map(int,input().split(" "))
grid = []
h = H
for i in range(h):
    row = input()
    if row == "."*W:
        H -= 1
        continue
    grid.append(list(row))
for i in range(W):
    flag = True
    for j in range(H):
        if grid[j][i] == "#":
            flag = False
    if flag == True:
        for j in range(H):
            grid[j][i] = ""
for i in range(H):
    row = ""
    for j in range(W):
        row += grid[i][j]
    print(row)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a*b%2==0) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
		}
}

Measured memory_bytes: 23764
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N, M;
bool E[601][601];
int kazu[601];
double memo[601];
double dfs(int v) {
	if (memo[v] != -1) return memo[v];
	double ret = 0;
	for (int i = v + 1; i <= N; i++) if (E[v][i]) {
		ret += dfs(i);
	}
	return memo[v] = 1 + ret / kazu[v];
}

double K[601];
double omomi(int v) {
	if (K[v] != -1) return K[v];
	double ret = 0;
	rep1(i, v - 1) if (E[i][v]) {
		ret += omomi(i) / kazu[i];
	}
	return K[v] = ret;
}

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


	cin >> N >> M;
	rep1(i, M) {
		int s, t;
		cin >> s >> t;
		kazu[s]++;
		E[s][t] = 1;
	}

	rep1(i, N) memo[i] = -1;
	memo[N] = 0;

	double kotae = dfs(1);

	rep1(i, N) K[i] = -1;
	K[1] = 1;

	double saishou = 0;
	rep1(i, N) {
		if (kazu[i] > 1) {
			double saidai = 0;
			double kei = 0;
			for (int j = i + 1; j <= N; j++) if (E[i][j]) {
				kei += dfs(j);
				chmax(saidai, dfs(j));
			}
			double are = (kei - saidai) / (kazu[i] - 1) - kei / kazu[i];
			are *= omomi(i);
			chmin(saishou, are);
		}
	}

	cout << setprecision(12) << kotae + saishou << endl;

	Would you please return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	int nums[3] = { a, b, c };
	sort(nums, nums + 3);

	int diff = nums[2] - nums[1];
	nums[0] += diff;

	int ans;
	if ((nums[2] - nums[0]) % 2 == 1) ans = diff + (nums[2] - nums[0] + 1) / 2 + 1;
	else ans = diff + (nums[2] - nums[0]) / 2;

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

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			if(n==0)
				return;
			char ch[]=new char[n];
			char mo[]=new char[n];
			for(int i=0;i<n;i++)
			{
				ch[i]=in.next().charAt(0);
				mo[i]=in.next().charAt(0);
			}
			int  s =in.nextInt();
			char sh[] = new char[s];
			for(int i=0;i<s;i++)
				sh[i]=in.next().charAt(0);

			for(int i=0;i<s; i++)
			{
				for(int j=0;j<n;j++)
				{
					if(sh[i]==ch[j])
					{
						sh[i]=mo[j];
						break;
					}
				}
				System.out.print(sh[i]);
			}
			System.out.println();
		}
	}
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
    int n, ans = 0;
    cin>>n;

    int a[n];
    for (int i=1;i<n;i++)
        cin>>a[i];
    
    a[0]=a[n]=INF;
    for (int i=1;i<=n;i++)
        ans+=min(a[i-1],a[i]);
    
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> ll_i;
struct edge { int u, v; ll w; };

void sieve(int n, bool a[]) {
	fill(a, a + n, true);
	a[0] = a[1] = false;
	for (int i = 2; i * i < n; i++)
		if (a[i])
			for (int j = i * 2; j < n; j += i)
				a[j] = false;
}

bool a[1000000];
int b[1000000];

int main() {
	sieve(1000000, a);
	for (int i = 1; i < 1000000; i++)
		b[i] = b[i - 1] + (a[i] ? 1 : 0);
	int n;
	while (cin >> n) cout << b[n] << endl;
}

Measured memory_bytes: 6044
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

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

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	a := make([]int, n)

	for i := range a {
		a[i] = nextInt()
	}
	sort.Ints(a)
	l := int64(-1e18)
	r := int64(1e18)

	for l+1 < r {
		m := (l + r) / 2
		total := 0
		for i := range a {
			ll, rr := i, n
			if a[i] < 0 {
				for ll+1 < rr {
					mm := (ll + rr) / 2
					if int64(a[i])*int64(a[mm]) < m {
						rr = mm
					} else {
						ll = mm
					}
				}
				total += n - rr
			} else {
				for ll+1 < rr {
					mm := (ll + rr) / 2
					if int64(a[i])*int64(a[mm]) < m {
						ll = mm
					} else {
						rr = mm
					}
				}
				total += ll - i
			}
		}
		if total < k {
			l = m
		} else {
			r = m
		}
	}

	/*
		b := make([]int, n*(n-1)/2)

		c := 0
		for i := 0; i < len(a)-1; i++ {
			for j := i + 1; j < len(a); j++ {
				b[c] = a[i] * a[j]
				c++
			}
		}
		sort.Ints(b)

		_, _ = fmt.Fprintf(writer, "%d", b[k-1])
	*/
	_, _ = fmt.Fprintf(writer, "%d", l)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main(){
  string s;
  cin>>s;
  s[3]='8';
  cout<<s<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //int a, b;
    string s, t;
    while(cin >> s >> t) {
        sort(s.begin(), s.end());
        sort(t.begin(), t.end(), greater<int>());
        if(s < t) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ');

  const a = s[0];
  const b = s[1];

  let ans = '';

  if (a === 'H') {
    ans = b;
  } else {
    if (b === 'H') ans = 'D';
    if (b === 'D') ans = 'H';
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
A = list(map(int, input().split()))
A = sorted(A)

if (A[2]-A[0]-(A[2]-A[1]))%2==0:
  ans = A[2]-A[1]+(A[2]-A[0]-(A[2]-A[1]))//2
else:
  ans = A[2]-A[1]+(A[2]-A[0]-(A[2]-A[1]))//2+2
                   
print(ans)

Measured memory_bytes: 9204