akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define DECIMAL 10

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

    int ans = 0;
    for(int i = 1; i <= n; i++){
        // 最大位と最小位の値を算出
        int iTmp = i;
        while ( iTmp > 9 ){
            iTmp /= DECIMAL;
        }
        int iLowest = i % DECIMAL;
        int iHighest = iTmp;
        // 0があったらスルー
        if(iLowest == 0){ continue; }
        // 同じだったらansに+1 条件にある一桁があるかどうかの確認
        if( iLowest == iHighest ){
            ans += 1;
        }
        // 二桁以上の数に足しこむ
        for (int nDigit = 2; nDigit < 10; nDigit++){
            // ペア候補の数の最大値と最小値を算出
            int pairMin = iLowest * pow(10, nDigit-1) + iHighest;
            int pairMax = pairMin;
            for (int j = 1; j < nDigit-1; j++){
                pairMax += 9*pow(10, j); 
            }
            // n が ペア候補の最大値以上のとき、最大位最小位以外は任意になるので、
            if ( n >= pairMax ){
                ans += pow(10, nDigit-2);
            }
            // nが ペア候補の最大値よりちいさく、ペア候補の最小値より大きい時
            else if ( n >= pairMin && n < pairMax ){
                // n の最大位と最小位を除いた数をansに足す
                int tmp = (n - pairMin) / DECIMAL;
                ans += tmp+1;
                // if (i==2012){
                //     cout << tmp << endl;
                // }
                // // n の最小位が ペア候補の最小値 の最小位以上だったら、ansに+1
                // if (i==2012){
                //     cout << n << n%DECIMAL << iHighest << endl;
                // }
                // if ( n%DECIMAL >= iHighest ){
                //     ans++;
                //     if (i==2012){
                //         cout << "OK" << endl;
                //     }
                // }
                // n の最小位が i の最小位より小さかったら、変動なし
            }
            // nが minより小さい時、追加はない、桁をあげてもペアは増えないので、ループを抜け、次の数に移行
            else{
                // cout << i << ' ' << ans << endl;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0)cout<<0<<endl;
    else{
        int x[]={a,b,c};
        sort(x,x+3);
        int n=x[0]*x[1];
        cout<<n<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int Par[101010];
int Rank[101010];

void init(int n) {
	for (int i = 0; i < n; i++) {
		Par[i] = i;
		Rank[i] = 0;
	}
}

int find(int x) {
	if (Par[x] == x) {
		return x;
	}
	else {
		return Par[x] = find(Par[x]);
	}
}

void unite(int  x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (Rank[x] < Rank[y]) {
		Par[x] = y;
	}
	else {
		Par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

int n, m;
int p[101010];
int x[101010], y[101010];
int main() {
	cin >> n >> m;
	init(n + 1);
	for (int i = 1; i <= n; i++)cin >> p[i];
	for (int i = 1; i <= m; i++) {
		cin >> x[i] >> y[i];
		unite(x[i], y[i]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (find(p[i]) == find(i))ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdlib.h>
#include <string.h>

using namespace std;

int n,w,d;

typedef struct{
	int w,d;
}BLOCK;

pair<bool,int> GetCut(int s,BLOCK &block){
	s %= (block.w + block.d) * 2;

	pair<bool,int> p;

	if(0 <= s && s <= block.w){ p.first = true; p.second = s; }
	else if(block.w <= s && s <= block.w + block.d){  p.first = false; p.second = s - block.w; }
	else if(block.w + block.d <= s && s <= block.w * 2 + block.d){  p.first = true; p.second = block.w * 2 + block.d - s; }
	else{  p.first = false; p.second = (block.w + block.d) * 2 - s; }

	return p;
}

bool Sort(const BLOCK& r,const BLOCK& l){
	return (r.d * r.w) < (l.d * l.w);
}

void solve()
{
	//ÅÌubNæ¾
	vector<BLOCK> bls(1);
	bls[0].w = w; bls[0].d = d;

	for(int i = 0; i < n; i++){
		int p,s;
		cin >> p >> s; p--;
		BLOCK block = bls[p]; //Ið³ê½ubN
		bls.erase(bls.begin() + p,bls.begin() + p + 1);
		pair<bool,int> cut_p = GetCut(s,block); //Jbg·éê

		BLOCK b1,b2; // b1 < b2ÌÊÏ
		if(cut_p.first){
			b1.d = b2.d = block.d;
			b1.w = min(cut_p.second,block.w - cut_p.second);
			b2.w = block.w - b1.w;
		} else {
			b1.w = b2.w = block.w;
			b1.d = min(cut_p.second,block.d - cut_p.second);
			b2.d = block.d - b1.d;
		}

		//V½ÈubNÌÇÁ
		bls.push_back(b1);
		bls.push_back(b2);
	}

	sort(bls.begin(),bls.end(),Sort);

	for(int i = 0; i < bls.size(); i++){
		cout << bls[i].w * bls[i].d;
		if( i != bls.size() - 1)
			cout << ' ';
	}
	cout << endl;

}

int main()
{
	while(cin >> n >> w >> d,(n||w||d)){
		solve();
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

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

signed main(){
  int n;
  cin>>n;
  vi a(n);
  map<int,int> mp;
  int ans=0;
  rep(i,n){
    cin>>a[i];

    mp[i+a[i]]++;
    if(i-a[i]>=0) ans+=mp[i-a[i]];

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

Measured memory_bytes: 18576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    auto f = [](int n, int m) {
        ll r = 0;
        for (int i = 1; i < n; i++) {
            r += (ll)i * (n - i) % P;
        }
        return r % P * m % P * m % P;
    };

    ll r = 1;

    int l = k - 2;
    for (int i = 0; i < l; i++) {
        (r *= i + 1) %= P;
    }
    r = inv(r);
    for (int i = 0; i < l; i++) {
        (r *= n * m - 2 - i) %= P;
    }

    cout << (f(n, m) + f(m, n)) % P * r % P << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

string s;
string p;


int sindex = 0;
int parse() {
	if (isalpha(s[sindex])) {
		return p[s[sindex++] - 'a'] - '0';
	}
	else {
		int x, y;
		sindex++;
		char op = s[sindex++];
		x = parse();
		y = parse();
		sindex++;
		if (op == '+')return x | y;
		else if (op == '*')return x & y;
		else return x^y;
	}
}


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


	

	while(cin>>s>>p){
		int ans = 0;
		sindex = 0;
		int h = parse();
		rep(x, 10000) {
			p[0] = x / 1 % 10 + '0';
			p[1] = x / 10 % 10 + '0';
			p[2] = x / 100 % 10 + '0';
			p[3] = x / 1000 % 10 + '0';
			sindex = 0;

			int g = parse();
			if (h == g)ans++;
		}

		cout << h << ' ' << ans << endl;
	}



	return 0;
}


Measured memory_bytes: 3208
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇
    let mut o = io.chars();
    let mut e = io.chars();
    for (&a, &b) in o.iter().zip(e.iter()) {
        io.write(a);
        io.write(b);
    }
    if o.len() > e.len() {
        io.write(o.last().unwrap());
    }
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
N=int(input())
A=[int(input()) for i in range(N)]
B=sorted(A,reverse=True)
maxA=B[0]
secondA=B[1]
i=0
for i in range(N):
    if A[i] == maxA:
        print(secondA)
    else:
        print(maxA)
    i += 1


Measured memory_bytes: 14112
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
from collections import deque

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

K = i_i()
q = deque(range(1, 10))

for _ in range(K):
    x = q.popleft()

    for i in range(-1, 2):
        d = x % 10 + i
        if d < 0 or d > 9: continue
        q.append(x * 10 + d)
        
print(x)

Measured memory_bytes: 12404
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	for(int i=10;i<=1000;i++){
		if(floor(i*0.08)==a&&floor(i*0.1)==b){
			cout<<i;
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<set>
#include<vector>
using namespace std;
#define PI acos(-1.0)
#define pppp cout<<endl;
#define EPS 1e-8
#define LL long long
#define ULL unsigned long long     //1844674407370955161
#define INT_INF 0x3f3f3f3f      //1061109567
#define LL_INF 0x3f3f3f3f3f3f3f3f //4557430888798830399
// ios::sync_with_stdio(false);
// 那么cin, 就不能跟C的 scanf，sscanf, getchar, fgets之类的一起使用了。
const int dr[]={0, 0, -1, 1, -1, -1, 1, 1};
const int dc[]={-1, 1, 0, 0, -1, 1, -1, 1};
int read()//输入外挂
{
    int ret=0, flag=0;
    char ch;
    if((ch=getchar())=='-')
        flag=1;
    else if(ch>='0'&&ch<='9')
        ret = ch - '0';
    while((ch=getchar())>='0'&&ch<='9')
        ret=ret*10+(ch-'0');
    return flag ? -ret : ret;
}
LL dp[55][2555];
int main()
{
    //freopen("D:\\chnegxubianji\\inORout\\in.txt", "r", stdin);
    //freopen("D:\\chnegxubianji\\inORout\\out.txt", "w", stdout);
    LL n,a;
    cin>>n>>a;
    dp[0][0]=1;//初始条件
    for(int i=1;i<=n;++i)//输入数据，直接dp就可以
    {
        LL tem;
        cin>>tem;
        for(int j=i;j>0;--j)//数字个数
        {
            for(int k=tem;k<=2500;++k)
            {
                dp[j][k]+=dp[j-1][k-tem];
                //当前累加个数为j和为k的是前一个累加为j-1 和为k-x的累加现在
            }
        }
    }
    LL sum=0;
    for(int i=1;i<=n;++i)
        sum+=dp[i][a*i];
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1280
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
string s;
const LL mod = 1e9 + 7;
int main(){
    cin >> n;
    cin >> s;
    REP(i, 2 * n){
        if((i + 1) % 2 == 0)continue;
        if(s[i] == 'B')s[i] = 'W';
        else           s[i] = 'B';
    }
    LL ans = 1;
    LL rcnt = 0, lcnt = 0;
    REP(i, 2 * n){
        if(s[i] == 'W')lcnt++;
        else{
            rcnt++;
            (ans *= lcnt) %= mod;
            lcnt--;
        }
    }
    if(rcnt != (2 * n  - rcnt)){
        cout << 0 << endl;
        return 0;
    }
    LL fact = 1;
    for(LL i = 1;i <= n;i++)(fact *= i) %= mod;
    cout << (ans * fact) % mod << endl;
}

Measured memory_bytes: 720
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		String S = scan.next();
		
		int count = 0;
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) == 'U' || S.charAt(i) == 'D') {
				continue;
			}
			
			if ((i + 1) % 2 == 1) {
				if (!(S.charAt(i) == 'R')) {
					System.out.println("No");
					count++;
					break;
				}
			}
			
			if ((i + 1) % 2 == 0) {
				if (!(S.charAt(i) == 'L')) {
					System.out.println("No");
					count++;
					break;
				}
			}
		}
		
		if (count == 0) {
			System.out.println("Yes");
		}
	}
}




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

using namespace std;

int main(){
    int n;cin >> n;
    int n_resident[5][4][11] = {};
    vector<int>b(n),f(n),r(n),v(n);
    for(int i=0;i<n;i++){
        cin >> b[i] >> f[i] >> r[i] >> v[i];//ここで代入されるのは1~10の数字
        n_resident[b[i]][f[i]][r[i]] += v[i]; //0が存在しないため各数字は1から始まることに留意する
    }
    for(int i=1;i<=4;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                cout << " " << n_resident[i][j][k];
            }
            cout << endl;
        }
        if(i!=4){
            cout << "####################" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


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

    string s, t;
    cin >> s;
    cin >> t;

    int n, m;
    n = s.length();
    m = t.length();

    int dp[n+1][m+1];
    // dp[i][j] : sのi文字目、tのj文字目のLCSの長さ
    rep(i, n+1) rep(j, m+1) dp[i][j] = 0;

    REP(i, 1, n+1) {
        REP(j, 1, m+1) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }


        }
    }
    // dp配列を逆からたどってLCSを作成する
    // LCSの長さが更新されたときの文字を追加していく
    string ans = "";
    int x = n;
    int y = m;
    while(x > 0 && y > 0) {
        if (dp[x][y] == dp[x-1][y]) {
            x--;
        } else if (dp[x][y] == dp[x][y-1]) {
            y--;
        } else {
            x--;
            y--;
            ans.push_back(s[x]);
        }

    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define maxi 200005
using namespace std;
map<string,int>mp;
int main()
{
    int n, c=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        string a;
        cin>>a;
        if(mp.count(a)==1){

        }
        else{
            c++;
            mp[a]=i;
        }

    }

    cout<<c;
}


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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;

	int res = N*(N+1)/2;

	cout << res << endl;

	return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  ll n;
  cin >> n;
  cout << (n/2)*((int)(n-1)/2*2+1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m, n, i, cnt = 0, sum = 0;
    float x;
    cin>>n>>m;
    int a[n];
    for(i = 0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i = 0; i<n; i++)
    {
        sum += a[i];
    }
    x = (1.0/(4.0*m))*sum;

    for(i = 0; i<n; i++)
    {
        if(a[i]>=x)
        {
            cnt++;
        }
    }
    if(cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    //return 0;
}


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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : b;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= 9; ++i){
		for(int j = 1; j <= 9; ++j){
			if(i*j == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using Pair = pair<int, int>;
using PP = pair<Pair, int>;
int MOD = 1000000007;


int N, P[10], Q[10];

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> Q[i];
	}
	vector<int> p;
	for (int i = 0; i < N; i++) {
		p.push_back(i+1);
	}
	int a,b;
	int i = 0;
	do {
		bool flag = true;
		for (int i = 0; i < N; i++) {
			if (P[i] != p[i]) {
				flag = false;
			}
		}
		if (flag) a = i;
		flag = true;
		for (int i = 0; i < N; i++) {
			if (Q[i] != p[i]) {
				flag = false;
			}
		}
		if (flag) b = i;
		i++;
	} while (next_permutation(p.begin(), p.end()));
	cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
using System;

namespace AB
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] number = Console.ReadLine().Split(' ');
            var numberA = int.Parse(number[0]);
            var numberB = int.Parse(number[1]);

            var ans = numberB % numberA == 0 ? numberB + numberA : numberB - numberA;
            Console.Write("{0}",ans);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define int long long
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for(; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}

const int N = 55;
int n, a[N], b[N];

inline bool can(int st) {
  static int vis[N];
  for(int i = 1; i <= n; i ++) {
    memset(vis, 0, sizeof vis);
    vis[a[i]] = true;
    for(int j = a[i]; j >= 1; j --) if(vis[j]) {
        for(int k = 1; k <= j; k ++)
          if(st >> k & 1)
            vis[j % k] = 1;
      }
    if(!vis[b[i]]) return false;
  }
  return true;
}                

main(void) {
  read(n);
  for(int i = 1; i <= n; i ++)
    read(a[i]);
  for(int i = 1; i <= n; i ++)
    read(b[i]);
  int ans = (1ll << 51) - 1;
  if(!can(ans)) return puts("-1"), 0;
  for(int i = 50; i >= 1; i --)
    if(can(ans ^ (1ll << i)))
      ans ^= 1ll << i;
  cout << ans - 1 << "\n";
}


Measured memory_bytes: 256
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    cin >> N;
    ll ans = 1;
    for(int i = 0; i < N; i++) {
        ll T;
        cin >> T;
        ans = lcm(ans, T);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    string s;
    cin >> s;
    int flag = 0;
    if (s.size() % 2 == 1)
    {
        cout << "No";
    }
    else
    {
        rep(i, s.size())
        {
            if (i % 2 == 0)
            {
                if (s[i] != 'h')
                {
                    flag = 1;
                    break;
                }
            }
            else
            {

                if (s[i] != 'i')
                {
                    flag = 1;
                    break;
                }
            }
        }
        if (flag == 0)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int d[10000];
    for(int i = 0; i<N; i++){
        cin>>d[i];
    }
    
    set<int> values;
    for(int i = 0; i<N; i++){
        values.insert(d[i]);
    }
    
    cout<<values.size()<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
x = y = z = 1
ans = [0]*N
while True:
    if x**2 + y**2 + z**2 + x*y + y*z + z*x > N:
        break
    while True:
        if x**2 + y**2 + z**2 + x*y + y*z + z*x > N:
            break
        while True:
            a = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if a <= N:
                if x != y and y != z and z != x:
                    ans[a-1] += 6
                elif x == y and y == z:
                    ans[a-1] += 1
                else:
                    ans[a-1] += 3
                z += 1
            else:
                break
        y += 1
        z = y
    x += 1
    z = y = x
for n in ans:
    print(n)

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

typedef unsigned long long uLL;
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
typedef pair <long long,long long> pll;
typedef pair <long long,pll> plll;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

string s;
int d;
vector <int> V;
int len;
LL dp[ N ][ 2 ][ 105 ];

LL go( int idx , int smaller , int sod  ) {
        if( idx >= len ) return sod%d == 0;
        if( dp[idx][smaller][sod] != -1 ) return dp[idx][smaller][sod];
        LL ret = 0;
        if( smaller ) {
                for( int i = 0; i <= 9; i++ ) {
                        ret += go( idx + 1 , 1 , (sod+i)%d );
                        ret %= MOD;
                }
        }
        else {
                for( int i = 0; i < V[idx]; i++ ) {
                        ret += go( idx + 1 , 1 , (sod+i)%d );
                        ret %= MOD;
                }
                ret += go( idx + 1 , 0 , (sod+V[idx])%d );
                ret %= MOD;
        }
        return dp[idx][smaller][sod] = ret%MOD;
}
LL solve( string s ) {
        V.clear();
        for( int i = 0; i < s.size(); i++ ) V.push_back( s[i]-'0' );
        len = V.size();
        memset( dp , -1 , sizeof( dp ) );
        return go( 0 , 0 , 0 );
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( NULL );
        cin >> s >> d;
        cout << ( solve( s ) - 1 + MOD )%MOD << endl;
        return 0;
}


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

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

int main()
{
   
    int n; cin >> n;
    vi a(n);
    int aa = 0, b = 0;
    
    for (int i = 0; i < n; i++)
        cin >> a[i];

    sort(a.rbegin(), a.rend());

    for (int i = 0; i < n; i++)
    {
        aa += (i % 2 == 0 ? a[i] : 0);
        b += (i % 2 != 0 ? a[i] : 0);
    }   

    cout << aa - b << "\n";
}


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

int main()
{
 	int N, L;
  	cin >> N;
  	cin >> L;
  
  	int min_diff = 100000000;
  	int result = 0;
  	int diff;
  
  	for (int eatN = 1; eatN <= N; eatN++) {
      int score_eat = 0;
      int score_remain = 0;
      int score_all = 0;
      for (int i = 1 ; i <= N; i++) {
        score_all += L + i - 1;
	    if (i == eatN) {
          score_eat = L + i - 1;
        }
        else {
          score_remain += L + i - 1;
       }
      }
      diff = abs(score_all - score_remain);
      if (diff < min_diff) {
        result = score_remain;
        min_diff = diff;
      }
    }
        
    cout << result << endl;
  
	return 0;
}

Measured memory_bytes: 256
n=int(input())
R=[int(input()) for _ in range(n)]
minR=10**9
ans=-10**9
for i in range(n):
  if i==0: 
    minR=min(minR,R[i])
    continue
  ans=max(ans,R[i]-minR)
  #print(ans)
  minR=min(minR,R[i])
print(ans)



Measured memory_bytes: 13600
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<ll> B(N-1);
  for(ll i=0;i<N-1;i++) {
cin>>B[i];
  }
  ll ans=0;
  ans+=B[0]+B.back();
  for(ll i=1;i<=N-2;i++) {
    ans+=min(B[i-1],B[i]);
  }
  
  
  cout<<ans<<endl;
}

  

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

using namespace std;

#define ll long long
#define endl "\n"

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

    int n, x, t, ans, i;
    cin >> n >> x >> t;
    i=1;
    while(i*x<n) {
        i++;
    }
    ans = i * t;
    cout << ans;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int cnt, A[500010];

void mergeSort(int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    cnt += right - left;
  }
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(i, N) cin >> A[i];
  mergeSort(0, N);
  sort(A, A + N);
  REP(i, N) {
    cout << A[i] << (i == N-1 ? '\n' : ' ');
  }
  cout << cnt << endl;
  return 0;
}

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


int main()
{
	int i, n;
	int a[100];
	
	cin >> n;
	
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	for (i = n - 1; i >= 0; i--)
	{
		if (i != n - 1)
		{
			cout << " ";
		}
		cout << a[i];
	}
	
	cout << endl;
 
return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    cin >> n;
    vector<int> b(n-1);
    for(int i = 0; i < n-1; i++) cin >> b[i];
    
    vector<int> a(n);
    a[0] = b[0];
    for(int i = 1; i <= n-2; i++){
        a[i] = min(b[i], b[i-1]);
    }
    a[n-1] = b[n-2];
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[i];
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define FUP(i, a, b) for(int i = a; i <= b; i++)
#define FDOWN(i, a, b) for(int i = a; i >= b; i--)
#define MS(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define CIN(a) cin >> a;
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a
#define COUT2(a, b) cout << a << ' ' << b
#define COUT3(a, b, c) cout << a << ' ' << b << ' ' << c
#define ENDL cout << '\n'
int dy[4] = { -1, 1, 0, 0 };
int dx[4] = { 0, 0, 1, -1 };

ll N, num, Max = 0, Sum = 0;

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

	CIN(N);
	while (N--)
	{
		CIN(num);
		if (num >= Max) Max = num;
		else Sum += (Max - num);
	}
	COUT(Sum);

	return 0;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    string s; cin>>s;
    if(s.size()==3) reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

int main()	
{
	#ifdef SANS
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\inputf.txt","r",stdin);
		freopen("C:\\Users\\ASUS\\Documents\\Sublime\\input_output\\outputf.txt","w",stdout);
	#endif
	fast
	int t=1;
	// cin>>t;
	while(t--)
	{
		ll a, b, c, d;
		cin>>a>>b>>c>>d;
		int i=0;
		while(a>0 && c>0)
		{
			if(i%2==0)
				c=c-b;
			else
				a=a-d;
			i++;
		}
		if(a>0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	#ifdef SANS
		cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
	#endif
}

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

int main()
{
	//ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	int count = 0;
	if(s[0] == 'R')
	{
	    count = 1;
	    if(s[1]=='R')
        {
            count = 2;
            if(s[2] == 'R')
            {
                count = 3;
            }
        }
	}
	else if(s[1] == 'R')
    {
        count = 1;
        if(s[2] == 'R')
            count = 2;
    }
    else if(s[2] == 'R')
        count = 1;
    cout << count;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
//typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int arr[200001],N=200001;
void Eratosthenes(){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
}
int main()
{
    int n;
    cin>>n;
    Eratosthenes();
    for(int i=n;i<200000;i++) if(arr[i]==1){
        cout<<i<<"\n";
        return 0;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

ll dp[202020];
ll sum[202020];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    c.erase(unique(ALL(c)), c.end());
    n = c.size();
    dp[0] = 1;
    for (int i = 0; i < n; i++)
    {
        (sum[c[i]] += dp[i]) %= MOD;
        (dp[i + 1] += sum[c[i]]) %= MOD;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9+7;
int bd[3001][3001], n;
char c;
int main() {
	cin >> n;
	memset(bd, 0, sizeof(bd));
	bd[0][0] = 1;
	for (int i=1; i<n; i++) {
		cin >> c;
		if (c=='<') {
			bd[i][0] = 0;
			for (int j=1; j<=i; j++) {
				bd[i][j] = (bd[i][j-1] + bd[i-1][j-1])%M;
			}
		}
		if (c=='>') {
			bd[i][i] = 0;
			for (int j=i-1; j>=0; j--) 
				bd[i][j] = (bd[i][j+1] + bd[i-1][j])%M;
		}
	}
	int ans = 0;
	for (int i=0; i<n; i++) {
		ans += bd[n-1][i];
		ans %= M;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 35456
#include<stdio.h>
int main(void){
  long long int n,k,i,a,b,c;
  c=0;
  scanf("%lld %lld",&n,&k);
  for(i=k;i<=n+1;i++){
    a=n*i-(i*(i-1)/2);
    b=i*(i-1)/2;
    c+=a-b+1;
    c%=1000000007;
  }
  printf("%lld\n",c);
  return 0;
}


Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
#define INF 10000000
#define PAIR pair<int,int>
class road {
public:
	int to;
	int money;
	int time;
	road(int a, int b, int c) :to(a), money(b), time(c) {}
};

vector<vector<int> > cost, fast;
vector<vector<road> > map;
void input(int);

int ccost(int, int);
int cfast(int, int);
int main() {
	int num, station;
	while (cin >> num >> station&&num != 0) {
		map.resize(station + 1);
		cost.resize(station + 1);
		fast.resize(station + 1);
		for (int i = 1; i <= station; ++i) {
			cost[i].resize(station + 1);
			fast[i].resize(station + 1);
			for (int j = 1; j <= station; ++j) {
				cost[i][j] = fast[i][j] = INF;
			}
		}
		input(num);
		int time;
		cin >> time;
		for (int i = 0; i < time; ++i) {
			int from, to, kind;
			cin >> from >> to >> kind;
			if (kind == 0) {
				cout << ccost(from, to) << endl;
			}
			else {
				cout << cfast(from, to) << endl;
			}
		}
		map.clear();
		fast.clear();
		cost.clear();
	}
	return 0;
}

int ccost(int from, int to) {
	int res = min(cost[from][to], cost[to][from]);
	if (res != INF)return res;
	priority_queue<PAIR, vector<PAIR>, greater<PAIR> > que;
	que.push(PAIR(0, from));
	cost[from][from] = 0;
	while (!que.empty()) {
		PAIR d = que.top();
		que.pop();
		if (d.first != cost[from][d.second]) {
			continue;
		}
		for (int i = 0; i < map[d.second].size(); ++i) {
			int dcost = d.first + map[d.second][i].money;
			int to = map[d.second][i].to;
			if (dcost < cost[from][to]) {
				cost[from][to] = dcost;
				que.push(PAIR(dcost, to));
			}
		}
	}
	return cost[from][to];
}
int cfast(int from, int to) {
	int res = min(fast[from][to], fast[to][from]);
	if (res != INF)return res;
	priority_queue<PAIR, vector<PAIR>, greater<PAIR> > que;
	que.push(PAIR(0, from));
	fast[from][from] = 0;
	while (!que.empty()) {
		PAIR d = que.top();
		que.pop();
		if (d.first != fast[from][d.second]) {
			continue;
		}
		for (int i = 0; i < map[d.second].size(); ++i) {
			int dtime = d.first + map[d.second][i].time;
			int to = map[d.second][i].to;
			if (dtime < fast[from][to]) {
				fast[from][to] = dtime;
				que.push(PAIR(dtime, to));
			}
		}
	}
	return fast[from][to];
}
void input(int num) {
	int a, b, cost, time;
	for (int i = 0; i < num; ++i) {
		cin >> a >> b >> cost >> time;
		map[b].push_back(road(a, cost, time));
		map[a].push_back(road(b, cost, time));
	}
}

Measured memory_bytes: 3264
k = int(input())
#k, x = map(int, input().split())
#al = list(map(int, input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

l = (9*k//7) if k % 7 == 0 else 9*k

if k == 1:
    ans = 1
elif k % 2 == 0 or k % 5 == 0:
    ans = -1
else:
    v = 1
    for i in range(1, l+1):
        v = (v*10) % l
        if v == 1:
            ans = i
            break
print(ans)


Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W, H, x, y;
		W = sc.nextInt();
		H = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();

		double ans = (double)W*H/ 2;
		int num = (W == x * 2 && H == y * 2 ) ? 1 : 0;
        System.out.println(String.format("%.10f", ans) + " " + num);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int k, m = 0; cin >> k;
	for(int i = 1; i <= 1e6; i++)
	{
		m = (10 * m + 7) % k;
		if(!m)
		{
			cout << i;
			return 0;
		}
	}
	cout << -1;

	return 0;
}

Measured memory_bytes: 3656
"use strict";
    
const main = arg => {
    arg = arg.split("\n");

    const k = parseInt(arg.slice(5, arg.length));
    const antennas = arg.slice(0, arg.length - 1).map(n=>parseInt(n));
    
    console.log(antennas[4] - antennas[0] > k ? ":(" : "Yay!");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <stdio.h>

int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];

int main()
{
	int q, i, t, f;

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &t, &f);
		for (i = 1; i <= 6; i++) {
			if (assign[i] == t) t = i;
			if (assign[i] == f) f = i;
		}
		printf("%d\n", assign[face[t][f][3]]);
	}
	return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#define loop(i,n) for(int i = 0; i < n; i++)
#define FOR(x,y,z) for(int x = y; x < z; x++)
#define INF 999999999;
#define VEC vector<int>
#define in push_back
#define ans(x) cout<<x<<endl
#define ll long long int 

using namespace std;

int main()
{
	ll a, b, c;
	ll count = 2;
	cin >> a >> b >> c;
	if ((a % 2 == 0 && b % 2 == 0) && (b % 2 == 0 && c % 2 == 1))ans("NO");
	else if (a == b&&c != 0)ans("NO");
	else
	{
		while (1)
		{
			if (count == 9999999)
			{
				ans("NO");
				break;
			}
			if (a*count%b == c)
			{
				ans("YES");
				break;
			}
			count++;
		}
	}
}


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

using namespace std;

template <typename T>
T gcd(T a, T b) {
  return (b ? gcd(b, a % b) : a);
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 1; i < N; i++) {
    A[0] = gcd(A[0], A[i]);
  }
  cout << A[0] << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

	ll n;
	cin >> n;
	vll a(n), x(n);
	REP(i, n){
		cin >> a[i];
		x[i] = a[i];
	}
	VSORT(x);
	ll med = x[n / 2];
	REP(i, n){
		if(a[i] >= med) cout << x[n / 2 - 1] << endl;
		else cout << med << endl;
	}
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
bool kaibun(string s){
  bool f=true;
  for(int i=0;i<=s.size()/2;i++){
    //cout<<s[i]<< " "<<s[s.size()-i-1]<<endl;
    if(s[i]!=s[s.size()-i-1])f=false;
  }
  return f;
}

int main() {
  string S;cin>>S;
  string ans="No";
  if(kaibun(S)&&kaibun(S.substr(0,(S.size()-1)/2))&&kaibun(S.substr((S.size()+3)/2-1,(S.size()-1)/2)))ans="Yes";
  cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

string reduce_safe_stones(string c) {
  auto left_W_i = c.find("W");
  auto right_R_i = c.rfind("R");

  if (left_W_i == string::npos || right_R_i == string::npos) {
    return "";
  } else {
    return c.substr(left_W_i, right_R_i - left_W_i + 1);
  }
}

int solve(string &c) {
  string tmp_c = reduce_safe_stones(c);

  int count = 0;
  while (!tmp_c.empty()) {
    tmp_c.erase(tmp_c.begin());
    tmp_c.erase(tmp_c.end() - 1);

    tmp_c = reduce_safe_stones(tmp_c);
    count++;
  }

  return count;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  string c;

  cin >> N;
  cin >> c;

  // main procedure
  int ans = solve(c);

  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4116
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  map<char,int> store;
  char s;
  int i;
  for(i=0;i<3;i++){
    scanf("%c",&s);
    store[s]=1;
  }
  if(store['A']==1 && store['B']==1){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 256