akhauriyash/Code-Regression huggingface dataset:
package main

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

var scanner = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 0x100000)
var wtr = bufio.NewWriter(os.Stdout)

// SplitSpace 空白で分割設定
func SplitSpace() {
	scanner.Split(bufio.ScanWords)
}

// NextLine 標準入力から１行読み込む
func NextLine() string {
	scanner.Scan()
	return scanner.Text()
}

// NextInt 標準入力から数値を一つ読み込む
func NextInt() int {
	n, _ := strconv.Atoi(NextLine())
	return n
}

func ToInt( s string ) int {
	n, _ := strconv.Atoi(s)
	return n
}

// ReadLine 標準入力から長めの1行を読み込む
func ReadLine() string {
	buf := make([]byte, 0, 0x100000)
	for {
		line, isPrefix, err := rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func ChMin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func ChMax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

//================

func main() {
	SplitSpace()
	S := NextLine()
	// S := "12345"
	n := uint(len(S))
	sum := 0
	for i := 0; i < (1<<(n-1)); i++ {
		// fmt.Println("----------")
		w := []rune{}
		for l := 0; l < int(n); l++ {
			w = append( w, rune(S[l]) )
			if (i & (1<<uint(l))) != 0 {
				sum += ToInt(string(w))
				// fmt.Println(string(w))
				w = []rune{}
			}
		}
		sum += ToInt(string(w))
		// fmt.Println(string(w))
	}
	fmt.Println(sum)
}


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

int main() {
    string S; cin >> S;
    int res = 0;
    int l = 0, r = S.size() - 1;
    while(l < r) {
        if(S[l] != S[r]) ++res;
        ++l; --r;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
S = input()
N = input()

for i in range(len(S)):
    if S == N:
        a = 1
        break
    elif S[-i:] + S[0:len(S) - i] == N:
        a = 1
        break

    else:
        a = 0

if a == 1:
    print("Yes")

else:
    print("No")

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

int main(){
    using namespace std;
    constexpr long double eps = 0.000000001;
    using real = long double;
    using point = complex<real>;
    using circle = pair<point, real>;
    unsigned long N;
    cin >> N;
    vector<point> p(N);
    for(auto& i : p){
        real im, re;
        cin >> im >> re;
        i.imag(im);
        i.real(re);
    }
    const auto& circle_from_diameter = [](const point& a, const point& b) -> circle {
        auto center = (a + b) / 2.0L;
        return {center, norm(a - center)};
    };
    const auto& circle_from_triangle = [](const point& a, const point& b, const point& c) -> circle {
        if(abs(((a - b) / (a - c)).imag()) < eps)return {0, 0};
        auto center = ((a - b) * norm(c) + (b - c) * norm(a) + (c - a) * norm(b)) / ((a - b) * conj(c) + (b - c) * conj(a) + (c - a) * conj(b));
        return {center, norm(a - center)};
    };
    const auto& is_included = [](const circle& c, const point& a) -> bool {
        return norm(a - c.first) <= c.second + eps;
    };
    const auto& is_all_include = [&p, &is_included](const circle& c) -> bool {
        return all_of(p.begin(), p.end(), [&c, &is_included](const point& a){return is_included(c, a);});
    };
    auto c = circle_from_diameter(p[0], p[1]);
    for(unsigned long i{2}; i < N; ++i)if(!is_included(c, p[i])){
            c = circle_from_diameter(p[0], p[i]);
            for(unsigned long j{1}; j < i; ++j)if(!is_included(c, p[j])){
                    c = circle_from_diameter(p[i], p[j]);
                    for(unsigned long k{0}; k < j; ++k)if(!is_included(c, p[k]))c = circle_from_triangle(p[i], p[j], p[k]);
                }
        }
    cout << setprecision(15) << sqrt(c.second) << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
 
int main(void){
 int x,n;
  int s=0;
  scanf("%d%d",&x,&n);
  int p[n];
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(int j=0;;j++){
    s=0;
    if(j%2!=0){
      x=x-j;
      for(int i=0;i<n;i++){
        if(x==p[i]) s=1;
        }
      if(s==0){
        printf("%d\n",x);
        return 0;
      }
    }else{
      x=x+j;
      for(int i=0;i<n;i++){
        if(x==p[i]) s=1;
        }
      if(s==0){
        printf("%d\n",x);
        return 0;
      }
    }
  }
    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> dp(n, vector<int>(n, INF<int>));
    for (int i = 0; i < n; ++i) dp[i][i] = 0;
    for (int i = 0; i < n; ++i) {
        int r, k;
        cin >> r >> k;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            dp[r-1][x-1] = 1;
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--; b--;
        if(dp[a][b] >= c) puts("NA");
        else cout << dp[a][b]+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int r, g, b;
    cin >> r >> g >> b;
    int x = r * 100 + g * 10 + b;
    CFYN(x % 4 == 0)

    return 0;
}

Measured memory_bytes: 256
/*
      author : Nishikawa
      created: 06.08.2020 14:01:46
*/

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

ll SUM(ll n){
    return n*(n+1)/2;
}

//Xまでの正の約数の総和を数えるプログラム
int main(){
    ll X; 
    cin >> X;
   // vector<int> vec(X+1,0);
   ll sum=0;
   for(ll i=1; i<=X; i++)
    sum+=SUM(X/i)*i;
        cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll mpow(ll x, ll n){ //x^n(mod mo) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mo;
        x = x*x % mo;
        n = n >> 1;
    }
    return ans;
}
 
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000010);

int main(){
    ll K;
    string S;
    cin >> K;
    cin >> S;
    ll N = S.size();
    //vector<vector<mint>> dp(N+K+10, vector<mint>(26));
    //dp[0][0] = 1;
    mint ans = 1;
    rep(i,K){
        ans *= 25;
    }
    mint tmp = ans;
    ans *= comb(N+K-1,N-1);
    ll q=1;
    while(N+K-1-q>=N-1){
        mint a = tmp; 
        a *= comb(N+K-1-q,N-1);
        a *= 26;
        a /= 25;
        ans += a;
        tmp *= 26;
        tmp /= 25;
        q++;
    }
    cout << ans << endl;
    /*
    mint tmp = ans;
    rep(i,N+K){
        rep(j,26){
            dp[i+1][j] = dp[i][j]*25;
        }
    }

    /*
    rep(k,K){
        rep(i,N){
            dp[i+k][S[i]-'a']++;
        }
    }*/

    //cout << N << endl;*/
}


Measured memory_bytes: 36556
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    V<int> a(n);
    cinf(n,a);
    for(int i=k;i<n;i++){
        if(a[i]>a[i-k])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int A, B; cin >> A >> B;
    int Q; cin >> Q;
    vector<ll> s(A), t(B);
    rep(i,A) cin >> s[i];
    rep(i,B) cin >> t[i];

    rep(i,Q){
        ll x; cin >> x;
        //cout << "x = " << x << endl;
        int ai = lower_bound(all(s), x) - s.begin();
        int bi = lower_bound(all(t), x) - t.begin();
        ll ans = LINF;
        for(int i=-1;i<=0;i++){
            for(int j=-1;j<=0;j++){
                int ii = ai + i;
                int jj = bi + j;
                if(ii<0 || ii >= A || jj < 0 || jj >= B) continue;

                ll dist = LINF;
                ll ss = abs(s[ii] - x);
                ll tt = abs(t[jj] - x);

                if(i==j){
                    dist = min(dist, max(ss,tt));
                }
                dist = min({dist, ss*2+tt, ss+tt*2});

                //cout << s[ii] << " " << t[jj] << " " << dist << endl;
                chmin(ans, dist);
            }
        }
        cout << ans << endl;
    }
}


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

using namespace std;

const int N = 200000 + 10;

int p[N];
int sum[N];

int main()
{
	int res, n, k, i;
	cin>>n>>k;
	for (i=1; i<=n; i++) cin>>p[i];
	sum[0] = 0;
	for (i=1; i<=n; i++) sum[i] = sum[i-1] + p[i];
	res = 0;
	for (i=k; i<=n; i++) res = max(res, sum[i] - sum[i-k]);
	cout<<fixed<<setprecision(10)<<(res + k) / 2.0<<endl;
	return 0;
}

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

bool p(string s) {
	string t = s;
	reverse(t.begin(), t.end());
	return s==t;
}

int main() {
	string s;
	cin >> s;
	int N = s.size();
	bool x = true;
	if (!p(s))x = false;
	if (!p(s.substr(0, (N - 1) / 2)))x = false;
	if (x)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    while(--q >= 0){
        int v, w;
        cin >> v >> w;

        if(n == 1){
            cout << min(v, w) << endl;
        }
        else{
            while(v != w){
                if(v < w)
                    swap(v, w);
                v = (v + n - 2) / n;
            }
            cout << v << endl;
        }
    }

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> W(N);
  for(int i = 0; i < N; i++) {
    cin >> W.at(i);
  }
  bool b = true;
  for(int i = 0; i < N; i++) {
    for(int j = i+1; j < N; j++) {
      if(W.at(i) == W.at(j)) {
        b = false;
        break;
      }
    }
  }
  for(int i = 0; i < N-1; i++) {
    if(W.at(i).at(W.at(i).size()-1) != W.at(i+1).at(0)) {
      b = false;
      break;
    }
  }
  if(b == true) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
	char szS[101];
	char szT[101];
	memset(szS, NULL, sizeof(szS));
	memset(szT, NULL, sizeof(szT));
	cin >> szS >> szT;

	// szS文字列は昇順に並べ替え
	int nLenS = strlen(szS);
	for (int i = 0; i < nLenS-1; i++)
	{
		for (int j = i + 1; j < nLenS; j++)
		{
			char cTmp;
			if (szS[i] > szS[j])
			{
				cTmp = szS[i];
				szS[i] = szS[j];
				szS[j] = cTmp;
			}
		}
	}
	// szT文字列は降順に並べ替え
	int nLenT = strlen(szT);
	for (int i = 0; i < nLenT - 1; i++)
	{
		for (int j = i + 1; j < nLenT; j++)
		{
			char cTmp;
			if (szT[i] < szT[j])
			{
				cTmp = szT[i];
				szT[i] = szT[j];
				szT[j] = cTmp;
			}
		}
	}

	int nRet = strcmp(szS, szT);
	if (nRet < 0)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

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

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

typedef long long ll;

class State{
public:
  int x,y,d,cost;
  State(){}
  State(int _x,int _y,int _d,int _cost){
    x = _x;
    y = _y;
    d = _d;
    cost = _cost;
  }
  bool operator<(const State &st)const{
    return cost > st.cost;
  }
};

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

int w,h;
int t[32][32];
int change[4];

void solve(){
  priority_queue<State> open;
  bool closed[32][32][4];
  memset(closed,0,sizeof(closed));
  open.push(State(0,0,1,0));

  while(!open.empty()){
    State st = open.top();
    open.pop();
    if(closed[st.x][st.y][st.d]) continue;
    closed[st.x][st.y][st.d] = true;

    if(st.x == w-1 && st.y == h-1){
      cout<<st.cost<<endl;
      return;
    }

    rep(i,4){
      int nd = (st.d + i) % 4;
      int nx = st.x + dx[nd];
      int ny = st.y + dy[nd];

      if(nx>=0 && w>nx && ny>=0 && h>ny){
        if(i == t[st.y][st.x]){
          open.push(State(nx,ny,nd,st.cost));
        }
        else{
          open.push(State(nx,ny,nd,st.cost+change[i]));
        }
      }
    }
  }

}

int main(){
  while(cin>>w>>h,w||h){
    rep(i,h){
      rep(j,w){
        cin>>t[i][j];
      }
    }

    rep(i,4){
      cin>>change[i];
    }

    solve();
  }
}

Measured memory_bytes: 1044
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}


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

    long long N;
    N = inputValueLongLong();

    long long i=0;
    long long count = 0;
    for(i=1;i<=N/2;i++){
        long long sabun = N-i;
        if(sabun!=i){
            count++;
        }
    }

    cout << count << endl;    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF 100000000
int main(void){
	int n, m, x1, x2, y1, y2;
	int a, b, c, d;
	int exp[20][20];
	int answer;
	int i, j, k;

	for(i=0; i<20; i++){
		for(j=0; j<20; j++){
			exp[i][j] = INF; 
		}
	}
	scanf("%d", &n);
	scanf("%d", &m);
	for(i=0; i<m; i++){
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		exp[a-1][b-1] = c;
		exp[b-1][a-1] = d;
	}
	for(i=0; i<n; i++){
		exp[i][i] = 0;
	}

	for(k=0; k<n; k++){
		for(i=0; i<n; i++){
			for(j=0; j<n; j++){
				if(exp[i][j] > exp[i][k] + exp[k][j]){
					exp[i][j] = exp[i][k] + exp[k][j];
				}
			}
		}
	}
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	answer = y1 - (exp[x1-1][x2-1] + exp[x2-1][x1-1] + y2);

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

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(void){
  
  string s;
  cin >> s;
  for(int i = 0;i < s.size() - 1;i++){
    if(s.at(i) == s.at(i+1)){
      cout << "Bad";
      return 0;
    }
  }
  cout << "Good";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 1005
#define eps 0.0000000001
#define pdi pair<double,int>
using namespace std;
struct point {
	double x,y,r;
}arr[maxn];
double cal(point a,point b) {
	double dx = a.x - b.x , dy = a.y - b.y;
	return max(sqrt(dx*dx + dy*dy) - a.r - b.r,0.0);
}
vector<pdi> G[maxn];
bool vis[maxn];
double dis[maxn];
inline bool equ(double a,double b) {
	return fabs(a-b) < eps;
}
double Dijkstra(int n) {
	vis[n+1] = true;
	dis[n+1] = 0;
	priority_queue<pdi> pq;
	pq.push(pdi{-dis[n+1],n+1});
	while(!pq.empty()) {
		pdi now = pq.top();
		pq.pop();
		int u = now.second;
		if(!equ(-now.first,dis[u]))	continue;
		for(pdi e : G[u]) {
			double cost = e.first;
			int v = e.second;
			if(!vis[v] || (!equ(dis[u]+cost,dis[v]) && dis[u] + cost < dis[v])) {
				dis[v] = dis[u] + cost;
				vis[v] = true;
				pq.push(pdi{-dis[v],v});
			}
		}
	}
	return dis[n+2];
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	point st,ed;
	cin >> st.x >> st.y >> ed.x >> ed.y;
	st.r = ed.r = 0.0;
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> arr[i].x >> arr[i].y >> arr[i].r;
	arr[n+1] = st;	arr[n+2] = ed;
	for(int i=1;i<=n+2;i++)
		for(int j=1;j<=n+2;j++)
			if(i != j)
				G[i].emplace_back(pdi{cal(arr[i],arr[j]),j});
	cout << fixed << setprecision(10) << Dijkstra(n) << endl;
	return 0;
}


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

int main(int argc, char const *argv[]) {
  int h, w;  // h行w列
  cin >> h >> w;
  vector<string> a(h);
  for (size_t i = 0; i < h; i++) cin >> a[i];
  vector<vector<int>> dist(h, vector<int>(w, -1));
  queue<pair<int, int>> que;
  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

  for (size_t i = 0; i < h; i++) {
    for (size_t j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        dist[i][j] = 0;             // 初始: 黑色: 0 白色: -1
        que.push(make_pair(i, j));  // 黑色节点的坐标(x,y)加入队列
      }
    }
  }

  // 幅優先探索(BFS)
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    for (size_t k = 0; k < 4; k++) {  // 上下左右四个方向
      int x = p.first + dx[k];        // 相邻节点的x坐标
      int y = p.second + dy[k];       // 相邻节点的y坐标
      if (0 <= x && x < h && 0 <= y && y < w) {
        if (dist[x][y] == -1) {
          dist[x][y] = dist[p.first][p.second] + 1;  // 记录是第几次操作被染黑的
          que.push(make_pair(x, y));  // 当前黑色节点的坐标(x,y)加入队列
        }
      }
    }
  }

  int ans = 0;
  for (size_t i = 0; i < h; i++)
    for (size_t j = 0; j < w; j++) ans = max(ans, dist[i][j]);

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

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

int main() {
    vector<vector<int>> a(3, vector<int>(3));
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> a.at(i).at(j);
        }
    }

    int n;
    cin >> n;

    vector<int> b(n);
    for (int i=0; i<n; i++) {
        cin >> b.at(i);
    }

    string ans = "No";

    vector<vector<int>> c(3, vector<int>(3, 0));

    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            for (int p=0; p<n; p++) {
                if (a.at(i).at(j) == b.at(p)) {
                    c.at(i).at(j) = 1;
                    break;
                }
            }
        }
    }

    for (int i=0; i<3; i++) {
        if (c.at(i).at(0)) {
            for (int j=1; j<3; j++) {
                if (c.at(i).at(j) == 0) break;
                if (j == 2) ans = "Yes";
            }
        }
    }

    for (int i=0; i<3; i++) {
        if (c.at(0).at(i)) {
            for (int j=1; j<3; j++) {
                if (c.at(j).at(i) == 0) break;
                if (j == 2) ans = "Yes";
            }
        }
    }

    if (c.at(0).at(0)) {
        if (c.at(1).at(1)) {
            if (c.at(2).at(2)) ans = "Yes";
        }
    }
    if (c.at(2).at(0)) {
        if (c.at(1).at(1)) {
            if (c.at(0).at(2)) ans = "Yes";
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  xs <- map read . words <$> getLine
  print $ solve n xs

solve :: Int -> [Int] -> Int
solve n = sum . drop (n-1) . reverse . sort . distances . sort

distances :: [Int] -> [Int]
distances xs = zipWith subtract xs (tail xs)


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

int main(){
  int x,y;
  cin >> x >> y;
  int gx =0;
  int gy =0;

  if(x == 1){
    gx = 1;
  }else if(x == 2){
    gx = 3;
  }else if(x == 3){
    gx = 1;
  }else if(x == 4){
    gx = 2;
  }else if(x == 5){
    gx = 1;
  }else if(x == 6){
    gx = 2;
  }else if(x == 7){
    gx = 1;
  }else if(x == 8){
    gx = 1;
  }else if(x == 9){
    gx = 2;
  }else if(x == 10){
    gx = 1;
  }else if(x == 11){
    gx = 2;
  }else if(x == 12){
    gx = 1;
  }
  
    if(y == 1){
    gy = 1;
  }else if(y == 2){
    gy = 3;
  }else if(y == 3){
    gy = 1;
  }else if(y == 4){
    gy = 2;
  }else if(y == 5){
    gy = 1;
  }else if(y == 6){
    gy = 2;
  }else if(y == 7){
    gy = 1;
  }else if(y == 8){
    gy = 1;
  }else if(y == 9){
    gy = 2;
  }else if(y == 10){
    gy = 1;
  }else if(y == 11){
    gy = 2;
  }else if(y == 12){
    gy = 1;
  }
  
  if(gx == gy){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#abcdef
#a*b,a*c,a*d,a*e,a*f
#b*c,b*d,b*e,b*f
#c*d,c*e,c*f
#d*e,d*f
#e*f

n = int(input())
l = list(map(int,input().split()))

mod = 10**9 + 7
all_l = 0
for i in range(n):
    all_l += l[i]
    all_l %= mod

ans = 0
for i in range(n-1):
    all_l = (all_l-l[i])%mod
    ans += (l[i]*all_l)%mod
    ans %= mod

print(ans)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dp[101010][20];

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

    string S;
    cin >> S;

    ll kake = 1;
    REP(i, 101010)REP(j, 20) dp[i][j] = 0;
    dp[0][0] = 1;

    REP(i, S.size()){
    	char tar = S[S.size()-1-i];
    	//dump(tar)
    	if(tar == '?'){
    		REP(val, 10){
    			ll tasu = (val * kake)%13;
    			//dump(tasu)
	    		REP(j, 13){
	    			//dump((j+tasu)%13)
	    			dp[i+1][(j+tasu)%13] += (dp[i][j]%mod);
	    			dp[i+1][(j+tasu)%13] %= mod;
	    		}
	    		//cout << endl;
	    	}
    	}else{
    		ll val = tar - '0';
    		ll tasu = (val * kake)%mod;
    		REP(j, 13){
    			dp[i+1][(j+tasu)%13] += dp[i][j];
    			dp[i+1][(j+tasu)%13] %= mod;
    		}
    	}
    	kake *= 10;
    	kake %= 13;
    }
    cout << dp[S.size()][5] << endl;
    return 0;
}

Measured memory_bytes: 16256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

class Cake
{
public:
	int w, d;
	Cake (int ww, int dd)
		:w(ww), d(dd) {}
	Cake cut(int s)
	{
		s %= (w+w+d+d);
		int w2, d2;
		if (s < w) {
			w2 = w-s;
			d2 = d;
			w -= w2;
		} else if (s < w+d) {
			w2 = w;
			d2 = s-w;
			d -= d2;
		} else if (s < w+d+w) {
			w2 = s-w-d;
			d2 = d;
			w -= w2;
		} else {
			w2 = w;
			d2 = s-w-d-w;
			d -= d2;
		}
		if (w > w2)
			swap(w, w2);
		if (d > d2)
			swap(d, d2);
		return Cake(w2, d2);
	}
};

class LessArea
{
public:
	bool operator () (const Cake& lhs, const Cake& rhs)
	{
		return lhs.d*lhs.w < rhs.d*rhs.w;
	}
};

int main()
{	
	//freopen("C", "r", stdin);

	int n, w, d;
	while (scanf("%d %d %d", &n, &w, &d) != EOF) {
		if (n == 0 && w == 0 && d == 0)
			break;
		vector<Cake> c;
		c.push_back(Cake(w, d));

		for (int i = 0; i < n; ++i) {
			int p, s;
			scanf("%d %d", &p, &s);
			--p;
			Cake cc = c[p];
			Cake cc2 = cc.cut(s);
			c.erase(c.begin()+p);
			c.push_back(cc);
			c.push_back(cc2);
		}
		sort(c.begin(), c.end(), LessArea());
		
		for (int i = 0; i < c.size()-1; ++i)
			printf("%d ", c[i].w*c[i].d);
		printf("%d\n", c.back().w*c.back().d);
	}
	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
class Fact{
	vector<ll>fact;
	vector<ll>inv;
public:
	Fact(){}
	Fact(int n){
		n=n*2+10;
		fact=inv=vector<ll>(n);
		fact[0]=inv[0]=1;
		for(int i=1;i<n;i++){
			fact[i]=(fact[i-1]*i)%MOD;
		}
		inv[n-1]=ppow(fact[n-1],MOD-2);
		for(int i=n-2;i>=0;i--){
			inv[i]=(inv[i+1]*(i+1))%MOD;
		}
	}
	ll get(int n){
		return fact[n];
	}
	ll get_inv(int n){
		return inv[n];
	}
	ll nPr(int n,int r){
		return fact[n]*inv[n-r]%MOD;
	}
	ll nCr(int n,int r){
		return nPr(n,r)*inv[r]%MOD;
	}
	ll nrP(int n,int r){
		return nPr(n+r,n);
	}
	ll nrC(int n,int r){
		return nCr(n+r,n);
	}
};
ll dp[3000][3000];
int main(){
	int K;cin>>K;
	string s;cin>>s;
	ll ans=0;
	Fact fac(s.size()+K);
	for(int i=s.size();i<=s.size()+K;i++){
		ll D=fac.nCr(i-1,s.size()-1)*ppow(25,i-s.size())%MOD*ppow(26,s.size()+K-i)%MOD;
		//~ cout<<i<<' '<<D<<endl;
		(ans+=D)%=MOD;
	}
	//~ ll ans=fac.nCr(s.size()+K,s.size())*ppow(25,K-1)%MOD*26%MOD;
	cout<<ans<<endl;
	//~ dp[0][0]=1;
	//~ rep(i,s.size()+K)rep(j,s.size()+1){
		//~ if(dp[i][j]==0)continue;
		//~ (dp[i+1][j+1]+=dp[i][j])%=MOD;
		//~ int d=(j<s.size()?25:26);
		//~ (dp[i+1][j]+=dp[i][j]*d)%=MOD;
	//~ }
	//~ cout<<dp[s.size()+K][s.size()]<<endl;
}

Measured memory_bytes: 66804
#!/usr/bin/env python3

from collections import deque

H, W = map(int, input().split())

field = []
for _ in range(H):
    line = list(input())
    field.append(line)
# print(H, W, field)


def is_valid(i, j):
    cond_i = 0 <= i <= H - 1
    cond_j = 0 <= j <= W - 1
    return cond_i and cond_j


def is_reachable(i, j, ):
    if is_valid(i, j):
        if field[i][j] == '.':
            return True
    return False


def adj(i, j):
    up, down = [i - 1, j], [i + 1, j]
    left, right = [i, j - 1], [i, j + 1]
    res = []
    for i_adj, j_adj in up, down, left, right:
        if is_reachable(i_adj, j_adj):
            res.append([i_adj, j_adj])
    return res


def bfs(que, dist):
    while len(que) > 0:
        i, j = que.popleft()
        # print(f"i, j: {i}, {j}")
        for i_adj, j_adj in adj(i, j):
            # print(f"i_adj, j_adj: {i_adj}, {j_adj}")
            if dist[(i_adj, j_adj)] == -1:
                que.append([i_adj, j_adj])
                dist[(i_adj, j_adj)] = dist[(i, j)] + 1


que = deque()
keys = [(i, j) for i in range(H) for j in range(W)]
values = [-1 for _ in range(H * W)]
dist = dict(zip(keys, values))
# print(dist)

n_black = 0
for i in range(H):
    for j in range(W):
        if field[i][j] == '#':
            n_black += 1

que.append([0, 0])
dist[(0, 0)] = 0
bfs(que, dist)

if dist[(H - 1, W - 1)] == -1:
    print(-1)
else:
    steps_min = dist[(H - 1, W - 1)] + 1
    n_white = W * H - n_black
    ans = n_white - steps_min
    print(ans)


Measured memory_bytes: 44764
#include<bits/stdc++.h>
using namespace std;
#define M 1e9 + 5
#define C 998244353
#define pi 3.14159265359
#define loop(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define rloop(i,a,b) for(ll i = ll(a); i >= ll(b); --i)
#define sloop(i,a) for (std::set<ll>::iterator i = a.begin(); i != a.end(); ++i)
#define pb push_back
#define all(v) v.begin(), v.end()
typedef long long int ll;
typedef unsigned long long int ull;

int solve(){
    ll m=0,n,ans=0,j,i;
    // cin >> n;
    // vector<ll> a(n),pref;
    string s;
    cin >> s;
    ll temp=0;
    while(m<s.length()){
        if(s[m]=='R'){
            temp++;
        }
        else{
            ans = max(ans,temp);
            temp = 0;
        }
        m++;
    }
    ans = max(ans,temp);
    cout << ans << "\n";
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    loop(f,0,t){    
        solve();
    }   
}

Measured memory_bytes: 3644
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,M = MI()
	dp = [float("inf")] * (2**N)
	dp[0] = 0
	for _ in range(M):
		a,b = MI()
		cc = LI()
		state = 0
		for c in cc:
			c -= 1
			state += (1 << c)
		for i in range(2**N):
			if(dp[i]!=float("inf")):
				dp[i|state] = min(dp[i|state], dp[i]+a)
	if(dp[-1]!=float("inf")):
		print(dp[-1])
	else:
		print(-1)


main()

Measured memory_bytes: 44508
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	x := 0
	for i := 1; i <= n; i++ {
		x += i
		if x >= n {
			x = i
			break
		}
	}
	for i := x; i >= 1; i-- {
		if n >= i {
			n -= i
			fmt.Println(i)
		}
	}
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
  string s,ans;
  cin >> s;
  for(int i=0; i<s.size(); ++i){
    if(s[i]=='0' || s[i]=='1'){
      ans.push_back(s[i]);
    }
    else if(ans.size()>=1){
      ans.pop_back();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void swap(int *x, int *y) {
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

int main(void) {
  int n;
  int a, b, c;

  cin >> n;
  
  for(int i = 0; i < n; i++) {
    cin >> a >> b >> c;

    if (a > b) {
      swap(a, b);
    }
    if (b > c) {
      swap(b, c);
    }
    
    if (a*a + b*b == c*c) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <random>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

typedef long long int ll;
ll gcd(ll a, ll b){
  return b ? gcd(b, a % b) : a;
}

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(auto &x : a){
    cin>>x;
  }

  int res=gcd(a[0],a[1]);
  for(int i=2;i<n;i++){
    res=gcd(res,a[i]);
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;

class _selectionSort {
	// define variables & initialize
	private static int cnt = 0;	// how many bubbleSort is used
	// Default Constructor
	public _selectionSort() {
	}
	// sort method :: sort given array using insertion Sort
	public static void sort(int[] _A, int _n) {
		for (int i = 0; i <= _n - 1; ++i) {
			int p_min = i;
			for (int j = i; j <= _n - 1; ++j) {
				if (_A[j] < _A[p_min])
					p_min = j;
			}
			if (i != p_min) {
				_A[i] = _A[i] ^ _A[p_min];
				_A[p_min] = _A[i] ^ _A[p_min];
				_A[i] = _A[i] ^ _A[p_min];
				++cnt;
			}
		}
	}
	// print method :: print array
	public static void print(int[] _A) {
		for (int i = 0; i < _A.length; ++i) {
			System.out.print(_A[i]);
			if (i != _A.length - 1)
				System.out.print(" ");
		}
		System.out.println();
	}
	// get method :: get cnt (how many bubbleSort was used)
	public static int get() {
		return cnt;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		////////////////////////////////////
		int n = 0;
		int[] A;

		n = sc.nextInt();
		A = new int[n];
		for (int i = 0; i < n; ++i) {
			A[i] = sc.nextInt();
		}
		_selectionSort.sort(A, n);
		_selectionSort.print(A);
		System.out.println(_selectionSort.get());
		////////////////////////////////////
		sc.close();
	}
}

Measured memory_bytes: 26324
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main () {
	let s = read_line();
	let s2 = s.split_whitespace().collect::<Vec<&str>>();
	let atd = s2[0];
	let tcd = s2[1];
	let r = ans(&atd,&tcd);
	println!("{}",r);
}
fn ans(atd: &str,tcd: &str) -> &'static str {
	if atd == "H" {
		if tcd == "H" {
			"H"
		}else {
			"D"
		}
	}else {
		if tcd == "H" {
			"D"
		}else {
			"H"
		}
	}
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, d; cin >> n >> d;
    int ans = 0;
    while (n > 0) {
        ans++;
        n -= 2*d+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

#define INF 1e+9
#define MAX_V 1000000

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
typedef pair<int,int> P;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}


int main()
{
	int n,m;
	cin>>n>>m;
	V = n;
	int E = m;
	 for (int i=0; i<E; ++i) {
        int a, b;
        cin >> a >> b;
		a--;
		b--;
		int x1,x2;
		x1 = min(a,b);
		x2 = max(a,b);
        edge e = {x2, 1};
        G[x1].push_back(e);
		edge e2 = {x1,1};
		G[x2].push_back(e2);
    }
	dijkstra(0);
	bool areNotAllInf = true;
	rep(i,n){
		if( d[i] == INF){
			areNotAllInf = false;
			break;
		}
	}
	//rep(i,n) cout<<d[i]<<endl;
	int *arrow = new int[n];
	rep(i,n) arrow[i] = 0;
	arrow[0] = 0;
	if( areNotAllInf == false){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
		for(int i = 0; i < n; i++){
			for( auto iter = G[i].begin(); iter != G[i].end(); iter++){
				if( d[iter->to] == d[i] + 1 ){
					arrow[iter->to] = i+1;
				}
			}
		}
		for(int i = 1; i < n; i++){
			cout<<arrow[i]<<endl;
		}
	}
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<n; ++i)
#define FOR(i, a, b) for(int i=a; i<b; ++i)
#define FORR(i, a, b) for(int i=b-1; i>=a; --i)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin>>a>>b;
	a<=b ? cout<<a<<'\n' : cout<<a-1<<'\n';
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	string S, T;
	cin >> S >> T;

	int result = (S[0] == T[0]) + (S[1] == T[1]) + (S[2] == T[2]);
	cout << result << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

import static java.lang.Integer.parseInt;

/**
 * Substring
 */
public class Main {

	static final long B =  37;
	static final long Binv = 1495681951922396077L;

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

//		long st, et;
//		st = System.nanoTime();

		line = br.readLine();
		int n, m;
		n = parseInt(line.substring(0, line.indexOf(' ')));
		m = parseInt(line.substring(line.indexOf(' ') + 1));

		char[] s = br.readLine().toCharArray();
		int l = 0, r = 0;
		long hash = s[0];
		Set<Long> hashs = new HashSet<>();

		for (int i = 0; i < m; i++) {
			switch (br.readLine()) {
				case "L++":
					hash -= s[l] * power(B, r - l);
					l++;
					break;
				case "L--":
					l--;
					hash += s[l] * power(B, r - l);
					break;
				case "R++":
					r++;
					hash = hash * B + s[r];
					break;
				case "R--":
					hash = (hash - s[r]) * Binv;
					r--;
					break;
			}
			hashs.add(hash);
		}
		System.out.println(hashs.size());

//		et = System.nanoTime();
//		System.out.println((et - st) / 1000 / 1000);
	}

	static long power(long m, long n) {
		if (n == 0) return 1;
		if (n % 2 == 0) {
			return power(m * m, n / 2);
		} else {
			return power(m * m, n / 2) * m;
		}
	}
}

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

typedef long long ll;
const int Maxn=100;

int N;
int cx,cy;
ll h;
struct Node {
	int X,Y;
	ll H;
	bool operator < (const Node &rhs) const {return H>rhs.H;}
}A[Maxn+5];

inline ll abs(ll a) {
	if(a<0)return -a;
	return a;
}

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
		scanf("%d %d %lld",&A[i].X,&A[i].Y,&A[i].H);
	sort(A+1,A+N+1);
	for(cx=0;cx<=100;cx++) {
		bool flag=false;
		for(cy=0;cy<=100;cy++) {
			ll th=max(0LL,abs(A[1].X-cx)+abs(A[1].Y-cy)+A[1].H);
			if(th<1)break;
			for(int i=2;i<=N;i++)
				if(max(0LL,th-abs(A[i].X-cx)-abs(A[i].Y-cy))!=A[i].H) {
					th=-1;
					break;
				}
			if(th!=-1) {
				h=th;
				flag=true;
				break;
			}
		}
		if(flag)
			break;
	}
	printf("%d %d %lld",cx,cy,h);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+6;
typedef long long ll;
const ll M=1000000007;
ll f[maxn],nf[maxn],inv[maxn],n,m,p[maxn],ans,dp[maxn][2][2],v[maxn],mx,l;
char s[maxn];
ll work_dp(int n){
    if (n==1) return 1;
    dp[1][0][0]=dp[1][1][1]=1;
    for (int i=2;i<=n;i++){
        for (int o=0;o<=1;o++){
            dp[i][o][0]=(dp[i-1][o][0]+dp[i-1][o][1])%M;
            dp[i][o][1]=dp[i-1][o][0];
        }
    }
    return (dp[n][0][0]+dp[n][0][1]+dp[n][1][0])%M;
}

int main(){
    inv[1]=1; for (int i=2;i<maxn;i++) inv[i]=M-(M/i)*inv[M%i]%M;
    nf[0]=f[0]=p[0]=1; for (int i=1;i<maxn;i++) f[i]=f[i-1]*i%M,nf[i]=nf[i-1]*inv[i]%M,p[i]=p[i-1]*2%M;
    cin >> n >> l;
    scanf("%s",s+1);
    if (s[1]=='B'){
        for (int i=1;i<=l;i++) if (s[i]=='B') s[i]='R'; else s[i]='B';
    }
    for (int i=1;i<=l;i++) if (s[i]=='R') v[i]=v[i-1]+1; else v[i]=0;
    if (v[l]==l){
        cout << work_dp(n) << endl;
        return 0;
    }
    for (int i=1;i<l;i++) if (v[i]>0&&v[i+1]==0){
        if (mx==0) mx=v[i]/2*2+1;
        else if (v[i]%2==1) mx=min(mx,v[i]);
    }
    if (n%2==1){puts("0");return 0;}
    n/=2; m=(mx+1)/2;
    for (int i=0;i*(m+1)<=n&&n-i*m-1>=0;i++){
        int u=n-i*(m+1);
        if (i&1) (ans-=p[u]*f[n-i*m-1]%M*nf[i]%M*nf[u])%=M;
        else (ans+=p[u]*f[n-i*m-1]%M*nf[i]%M*nf[u])%=M;
    }
    ans=(ans*n-1)%M;
    cout << (ans+M)*2%M << endl;
}


Measured memory_bytes: 29440
from sys import stdin
import itertools

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

nums = [int(x) for x in range(1, 10)]

kuku = itertools.combinations_with_replacement(nums, 2)

ans = "No"

for i in list(kuku):
    if i[0] * i[1] == n:
        ans = "Yes"
        break

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m;
	cin>>n>>m;
	ll ch[3];
	for(ll i=0;i<3;i++){
		ch[i]=-1;
	}
	for(ll i=0;i<m;i++){
		ll x,z;
		cin>>x>>z;
		x--;
		if(ch[x]==-1){
			ch[x]=z;
		}
		else{
			if(ch[x]!=z){
				cout << -1;
				return 0;
			}
		}
	}
	if(ch[0]==0&&n!=1){
		cout <<-1;
		return 0;
	}
	for(ll i=0;i<n;i++){
		if(ch[i]==-1){
			if(i==0&&n!=1){
				cout << 1;
			}
			else{
			cout << 0;
			}
		}
		else{
		cout << ch[i];
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String str1 = sc.next();
        String str2 = sc.next();
        String ans = "";
        
        for(int i=0; i<N*2; i++){
            if(i%2==0){
                ans += str1.charAt(i/2);
            }else{
                ans += str2.charAt(i/2);
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 39332
char s[999][99],*a;i;j;k;main(l,n,m){for(scanf("%d%d ",&n,&m);gets(s[j++]););for(;l&&i<=n-m;++i)for(j=0;l&&j<=n-m;++j)for(l=0,k=0;k<m;)a=&s[i+k][j],l|=a-strstr(a,s[n+k++]);puts(l?"No":"Yes");}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

int main(void) {
  string s1, s2;
  cin >> s1 >> s2;
  int t = s1.size();
  rep(i, t) {
    s1.push_back(s1[0]);
    s1.erase(s1.begin());
    if (s1 == s2) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256