akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int n, m, k;
	bool b = false;
	scanf("%d%d%d", &n, &m, &k);
	rep(i, n + 1){
	  rep(j, m + 1){
	      if(i * (m - j) + j * (n - i) == k)b = true;
		}
	}
	printyn(b);
	
	Please AC;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    int s = a[2] - a[1];
    a[0] += s;
    s += (a[2] - a[0]) / 2;
    if((a[2] - a[0]) % 2 != 0) s += 2;
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    ll n,k;
    cin >> n >> k;
    ll ans = n % k;
    ans = min(ans,(k-ans));

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

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

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

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    int k;
    read(k);
    
    print(50);
    FOR(50) {
        int nof = k / 50;
        int rem = k % 50;
        
        if (rem > i) {
            nof++;
        }
        int dec = k - nof;
        write(i + nof * 50 - dec, " ");
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        //write("Case #", i + 1, ": ");
        solve();
        
    }
    
}



Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
typedef long long ll;

bool f[300001];

void solve(int n){
    cout << n << ":";
    vector<int> v;
    for(int i=2;i*i<=n;i++){
        if(n%i==0 and f[i]) v.push_back(i);
        if(n%i==0 and f[n/i]) v.push_back(n/i);
    }
    if(f[n]) v.push_back(n);

    sort(ALL(v));


    v.erase(unique(ALL(v)),v.end());
    for(int i=0;i<v.size();i++) cout << " " << v[i];
    cout << endl;
}

int main(){

    REP(i,300001) f[i] = true;

    f[0] = false;
    f[1] = false;
    f[2] = false;
    f[3] = false;
    f[4] = false;
    f[5] = false;
    f[6] = true;

    for(int i=6;i<300001;i++){
        if(f[i] and (i%7==1 or i%7==6)){
            for(ll j=i;i*j<300001;j++){
                f[i*j] = false;
            }
        }else{
            f[i] = false;
        }
    }

    int n;
    while(cin>>n){
        if(n==1) return 0;
        solve(n);
    }
}

Measured memory_bytes: 3404
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(M):
  x,y,c=map(int,input().split())
  ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)

Measured memory_bytes: 18608
#include <stdio.h>

int main(void){
	int n;
	scanf("%d", &n );
	int b[n-1];
	for(int i=0;i<n-1;i++){
		scanf("%d", &b[i]);
	}
	
	//int a[n];
	//int a[n-1]=b[n-2];
	int ans = b[n-2];
	
	for(int i=n-2;i>=0;i--){
		if(i>0){
          if(b[i] > b[i-1])	ans += b[i-1];
          else	ans+=b[i];
        }else	ans+=b[i];
	}
	
	
	printf("%d", ans);

	return 0;
	
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long X = long.Parse(str[0]);
		long Y = long.Parse(str[1]);
		long ans = 0;
		long mod = 1000000007;
		if((X+Y)%3==0){
			if(X<=Y*2 && Y<=X*2){
				ans = Ncr((X+Y)/3,Y-(X+Y)/3,mod);
			}
		}
		Console.WriteLine(ans);
	}
	
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}

	public static long Ncr(long n,long r,long m)
	{
		long ans = 1;
		for(var i=n-r+1;i<=n;i++){
			ans = ans * i % m;
		}
		for(var i=2;i<=r;i++){
			ans = ans * Mpow(i,m-2,m) % m;
		}
		return ans;
	}
}

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

bool check(string &s, int Q, int N, int pos, vector<char> &t, vector<char> &d, bool left_check)
{
  char c = s[pos];
  rep(i, Q){
    if(t[i] == c){
      pos += d[i] == 'L' ? -1 : 1;
      if(pos < 0) return left_check ? false : true;
      if(pos >= N) return left_check ? true : false;
      c = s[pos];
    }
  }
  return true;
}

int main()
{
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<char> t(Q);
  vector<char> d(Q);
  rep(i, Q){
    cin >> t[i] >> d[i];
  }
  int ans = N;
  {
    int ok = N;
    int ng = -1;
    while(ok - ng > 1){
      int mid = (ok + ng) / 2;
      (check(s, Q, N, mid, t, d, true) ? ok : ng) = mid;
    }
    ans -= ng + 1;
  }
  {
    int ok = -1;
    int ng = N;
    while(ng - ok > 1){
      int mid = (ok + ng) / 2;
      (check(s, Q, N, mid, t, d, false) ? ok : ng) = mid;
    }
    ans -= N - ng;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

using P = pair<int, int>;

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

  int H, W;
  cin >> H >> W;

  vector<vector<int>> G_sub(10);
  vector<vector<int>> G(10);
  int tmp;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> tmp;
      G_sub[i].push_back(tmp);
      G[i].push_back(0);
    }
  }

  // ダイクストラのために転置する
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      G[i][j] = G_sub[j][i];
    }
  }

  vector<int> cost(10); // 0から0~9まで行く方法
  int INF = 1<<30;
  for(int i = 0; i < 10; i++){
    cost[i] = INF;
  }

  cost[1] = 0;

  priority_queue<P, vector<P>, greater<P>> que;
  que.push(P(0, 1));

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

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

  vector<int> tar;
  for(int i = 0; i < H*W; i++){
    cin >> tmp;
    if(tmp >= 0){
      tar.push_back(tmp);
    }
  }

  int ans = 0;
  for(int i = 0; i < tar.size(); i++){
    ans += cost[tar[i]];
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 640
#include<iostream>
using namespace std ;
int main()
{
	int m,n;
	cin >> m >> n;
	char a[110][110] ;
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++)
			cin >> a[i][j];
			
	int c=0,s[110];
	for(int i=0;i<m;i++){
		int flag=0;
		for(int j=0;j<n;j++)
			if(a[i][j]=='.') flag++;
		if(flag==n) {
			for(int k=0;k<n;k++)
				{a[i][k]='1' ;s[i]=1;}
		}
		else s[i]=0;
	}
	int d=0,f[110];
	for(int i=0;i<n;i++){
		int flag=0;
		for(int j=0;j<m;j++)
		if(a[j][i]=='.'||a[j][i]=='1') flag++;
		if(flag==m) {
			for(int k=0;k<m;k++)
				a[k][i]='1' ;
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++)
			if(a[i][j]!='1' ) cout << a[i][j] ;
		if(s[i]!=1) cout << endl ;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main() {

    int num;
    cin >> num;

    vector<long> arr(num);
    for (int i = 0; i < num; i++) {
        cin >> arr[i];
    }

    long min_left = arr[0];
    long max_right = -2 * pow(10, 9);
    for (int i=1; i<num; i++) {
        if (max_right < arr[i] - min_left) {
            max_right = arr[i] - min_left;
        }
        if (min_left > arr[i]) {
            min_left = arr[i];
        }
    }

    cout << max_right << endl;
}



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

int main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) cin >> d[i];
  sort(d.begin(), d.end());
  cout << d[N/2] - d[N/2-1] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	char S[51];
	int i, N, K;

	scanf("%d %d", &N, &K);
	scanf("%s", S);

	for (i = 0; i < N; i++) {
		if (i == K - 1) {
			S[i] = tolower(S[i]);
		}
	}

	printf("%s\n", S);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	string S;
	string T[4] = { "dream","dreamer","erase","eraser" };
	cin >> S;

	reverse(S.begin(), S.end());
	for (int i = 0; i < 4; i++) {
		reverse(T[i].begin(), T[i].end());
	}

	bool ans = false;
	while (1) {
		ans = false;
		for (int i = 0; i < 4; i++) {
			if (S.substr(0, T[i].size()) == T[i]) {
				ans = true;
				S.erase(0, T[i].size());
			}
		}
		if (!ans) break;
		if (S == "") break;
	}

	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 512
A = map(int, input().split())
A = sorted(A)
v1 = 0
for i in range(len(A) - 1):
    v1 += abs(A[i + 1] - A[i])
A = sorted(A, reverse=True)
v2 = 0
for i in range(len(A) - 1):
    v2 += abs(A[i + 1] - A[i])
ans = min(v1, v2)
print(ans)


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	ll n; cin >> n;
	ll a[101];
	for (int i = 0;i < n;i++){
		cin >> a[i];
	}

	ll dp[21][101];
	memset(dp,0,sizeof(dp));

	dp[a[0]][1] = 1;

	for (int i = 1;i < n-1; i++){
		for (int j = 0;j <= 20;j++){
			//cout << dp[j][i] << " ";
			if(dp[j][i] == 0) continue;
			ll p = j+a[i];
			ll m = j-a[i];
			if(p <= 20) dp[p][i+1] += dp[j][i];
			if(m >= 0) dp[m][i+1] += dp[j][i];
		}
		//cout << endl;
	}

	cout << dp[a[n-1]][n-1] << endl;

	return 0;

}



Measured memory_bytes: 3148
suffixes = %w[dream dreamer erase eraser]
suffixes.each(&:reverse!)

s = gets.strip
s.reverse!

# greedy
i = 0
no =
  while i < s.size
    suffix = suffixes.find { |d| s[i, d.size] == d }
    if suffix
      i += suffix.size
    else
      break 'NO'
    end
  end

puts no || 'YES'


Measured memory_bytes: 1916
#include<iostream>
#include<iomanip>

int main(){
  int a,b;
  std::cin >> a >> b;
  std::cout << a/b << " " << a%b << " ";
  std::cout << std::setprecision(5) << std::fixed << (double)a/b << std::endl;
  return 0;
}

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

int p[]={11,31,61,71,101,131,151,181,191,211,241,251,271,281,331,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1321,1381,1451,1471,1481,1511,1531};

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cout<<p[i]<<" ";
    cout<<endl;
	return 0;
}

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

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

int main(){
	ll h,w;cin>>h>>w;
	if(h==1||w==1){puts("1");return 0;}
	ll x=(w+1)/2,y=w/2;
	ll X=(h+1)/2,Y=h/2;
	cout<<x*X+y*Y<<endl;
}

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

using namespace std;

long long n;

int main(){
	scanf("%lld",&n);
	int l = 1,r = n,re = n;
	while(l <= r){
		int mid = l + r >> 1;
		if(1LL * mid * (mid + 1) / 2 >= n)
			re = mid,r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n",re);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pll;
const int MAXN = 100000 + 10;
const int mod = 1e9 + 7;
const LL inf = (1LL<<63) - 1;
int n;
LL dists[MAXN], distt[MAXN], cnts[MAXN], cntt[MAXN];
vector<pll> edges[MAXN];

void dijkstra(LL dist[], LL cnt[], LL s, LL t) {
    for (int i = 1; i <= n; i++) {
        dist[i] = inf;
    }
    dist[s] = 0;
    cnt[s] = 1;
    priority_queue<pll, vector<pll>, greater<pll> > pq;
    pq.push({0LL, s});
    while (!pq.empty()) {
        pll cur = pq.top(); pq.pop();
        if (cur.first > dist[cur.second]) continue;
        if (cur.second == t) return;
        for (auto nxt : edges[cur.second]) {
            if (cur.first+nxt.second < dist[nxt.first]) {
                dist[nxt.first] = cur.first + nxt.second;
                pq.push({dist[nxt.first], nxt.first});
                cnt[nxt.first] = cnt[cur.second] % mod;
            }
            else if (cur.first+nxt.second == dist[nxt.first]) {
                cnt[nxt.first] = (cnt[nxt.first] + cnt[cur.second]) % mod;
            }
        }
    }
}

int main(){
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int m, s, t;
    cin >> n >> m >> s >> t;
    LL a, b, c;
    for (int i = 0; i < m; i++) {
        cin >> a >> b >> c;
        edges[a].push_back({b, c});
        edges[b].push_back({a, c});
    }
    dijkstra(dists, cnts, s, t);
    dijkstra(distt, cntt, t, s);
    double half = dists[t] / 2.0;
    LL ret = cnts[t] * cnts[t] % mod;
    for (int i = 1; i <= n; i++) {
        if (dists[i] == half) {
            LL tmp = cnts[i] * cntt[i] % mod;
            ret = (ret + mod - tmp*tmp%mod) % mod;
        }
        for (auto item : edges[i]) {
            int j = item.first;
            if (dists[i]+item.second+distt[j] != dists[t]) continue;
            if (dists[i]<half && dists[j] > half) {
                LL tmp = cnts[i] * cntt[j] % mod;
                ret = (ret + mod - tmp*tmp%mod) % mod;
            }
        }
    }
    cout << ret << endl;


}

Measured memory_bytes: 17952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int INF = 1 << 20;
int N, MA, MB;
int a[40], b[40], c[40];
int dp[410][410];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> MA >> MB;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  fill_n((int*)dp, 410 * 410, INF);
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 400; j >= 0; j--) {
      for (int k = 400; k >= 0; k--) {
        if (j - a[i] >= 0 && k - b[i] >= 0) {
          dp[j][k] = min(dp[j][k], dp[j - a[i]][k - b[i]] + c[i]);
        }
      }
    }
  }
  int ans = INF;
  for (int i = 1; MA * i < 410 && MB * i < 410; i++) {
    ans = min(ans, dp[MA * i][MB * i]);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main(){
  int W,H,x,y,r;
  cin >> W;
  cin >> H;
  cin >> x;
  cin >> y;
  cin >> r;

  if( ((W-x)>=r&&(H-y)>=r) && (x>=r&&y>=r) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println((Math.abs(x - a) < Math.abs(x - b)) ? "A" : "B");


		sc.close();


	}

}





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

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

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
	int n,m;
	int i;
	int p;
	int k;
	int a[50];
	int b[50];
	int c[50];
	int d[50];
	int aa[50];
	int num[50];
	int temp;
	
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		
		
	}
	for(i=0;i<m;i++){
		
		scanf("%d%d",&c[i],&d[i]);
		
	}
	for(i=0;i<n;i++){
		for(p=0;p<m;p++){
		aa[p]=abs((a[i])-(c[p]))+abs((b[i])-(d[p]));
		if(aa[p]<0){aa[p]*=-1;}
		num[p]=p+1;
		}
		k=i;
		
	
	for(i=0;i<m;i++){
		
		for(p=m-1;p>i;p--){
			
			if(aa[p]<aa[p-1]){
				temp=aa[p-1];
				aa[p-1]=aa[p];
				aa[p]=temp;
				temp=num[p-1];
				num[p-1]=num[p];
				num[p]=temp;
				
				
				
				
				
				
				
				
			}
			
			
			
			
			
			
			
			
			
			
			
			
		}
		
		
		
		
		
		
	}/*
printf("\n");
	for(i=0;i<m;i++){
		
		printf("%d %d\n",aa[i],num[i]);
		
	}
	printf("\n");
	*/
	i=k;
	printf("%d\n",num[0]);
	}
	
	return 0;
}

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

void solve(int A, int B){
    printf("%d\n", max({A+B, A-B, A*B}));
;}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int A;
    scanf("%d",&A);
    int B;
    scanf("%d",&B);
    solve(A, B);
    return 0;
}

Measured memory_bytes: 3708
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int H,W;
		while(true){
			H=scan.nextInt();
			W=scan.nextInt();
			if(H==0&&W==0) break;
			
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if((i+j)%2==0)System.out.print("#");
					else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
		scan.close();
	}
}

Measured memory_bytes: 26896
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;
int main() {
	ll n;
	cin>>n;
	vector<ll> v(n);
	for (ll i=1; i<=n; ++i) {
		cin>>v[i-1];
		v[i-1]-=i;
	}
	sort(v.begin(), v.end());
	
	ll median;
	if (n%2) {
		median=v[n/2];
		ll ans=0;
		for (ll i=0; i<n; ++i)
			ans+=abs(v[i]-median);
		cout<<ans<<endl;
	} else {
		median=v[n/2];
		ll ans=0;
		for (ll i=0; i<n; ++i)
			ans+=abs(v[i]-median);
		ll ans2=0;
		median=v[(n/2)-1];
		for (ll i=0; i<n; ++i)
			ans2+=abs(v[i]-median);
		cout<<min(ans, ans2)<<endl;
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll x;
  cin >> x;
  ll cnt = 0, ans = 0, r;

  ans = (x / 11) * 2;
  r = x % 11;
  if (0 < r && r <= 6)
    ans += 1;
  else if (6 < r && r < 11)
    ans += 2;

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


Measured memory_bytes: 256
//2020-04-12 17:29:15
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    ll n;cin>>n;
    
    set<ll> s1,s2,s3;
    rep(i,0,n){
        char a;cin>>a;
        if(a=='R')s1.insert(i);
        else if(a=='G')s2.insert(i);
        else s3.insert(i);
    }
    ll ans=0;
    ll n1=s1.size(),n2=s2.size(),n3=s3.size();
    for(auto x: s1){
        for(auto y : s2){
            ll val=x+y;
            if(val%2==0 && s3.count(val/2))ans++;
        }
    }
    
    for(auto x: s2){
        for(auto y : s3){
            ll val=x+y;
            if(val%2==0 && s1.count(val/2))ans++;
        }
    }
    
    for(auto x: s3){
        for(auto y : s1){
            ll val=x+y;
            if(val%2==0 && s2.count(val/2))ans++;
        }
    }
    ll ansi=n1*n2*n3;
    ansi-=ans;
    cout<<ansi;
}

Measured memory_bytes: 3712
package main

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

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

func strToInt(str string) []int {
	var hotels []int
	for _, s := range strings.Split(str, " ") {
		num, _ := strconv.Atoi(s)
		hotels = append(hotels, num)
	}
	return hotels
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	n, _ := strconv.Atoi(nextLine(sc))

	viewableCount := 1
	hotels := strToInt(nextLine(sc))
	maxHeight := hotels[0]
	for i := 1; i < n; i++ {
		if hotels[i] >= maxHeight {
			maxHeight = hotels[i]
			viewableCount++
		}
	}
	fmt.Println(viewableCount)
}


Measured memory_bytes: 640
from sys import stdin,stdout
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
# n=int(stdin.readline())
def dfs(src):
    global sz
    vis[src]=1
    sz+=1
    for neigh in g[src]:
        if not vis[neigh]:
            dfs(neigh)

n,eg=list(map(int,stdin.readline().split()))
g=defaultdict(list)
for i in range(eg):
    A,B=map(int,stdin.readline().split())
    g[A]+=[B]
    g[B]+=[A]
vis=[0]*(n+1);ans=0
for node in range(1,n+1):
    if not vis[node]:
        sz=0
        dfs(node)
        ans=max(ans,sz)
print(ans)

Measured memory_bytes: 219444
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n; cin >> n;
    int a, b, c, d; cin >> a >> b >> c >> d;
    string s; cin >> s;
    if (c < d) {
        // c < dの場合は b〜dとa〜cに2連続石がなければOK
        FOR(i, b, d-3) {
            if ((s[i] == '#') && (s[i+1] == '#')) {
                cout << "No" << endl;
                return 0;
            }
        }
        FOR(i, a, c-3) {
            if ((s[i] == '#') && (s[i+1] == '#')) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    } else {
        // a < b < d < c
        // まずはbがdまでいけるか確認しつつ、途中で前後が白になるマスがあるか確認
        bool f = false;
        FOR(i, b-1, d-3) {
            if ((s[i] == '#') && (s[i+1] == '#')) {
                cout << "No" << endl;
                return 0;
            }
        }
        // [b, d] を中心として、3連続で白になるマスがあるか確認
        FOR(i, b-1, d-1) {
            if ((s[i-1] == '.') && (s[i] == '.') && (s[i+1] == '.')) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3744
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        x: usize, y: usize, a: usize, b: usize, c: usize,
        p: [i64; a],
        q: [i64; b],
        r: [i64; c],
    }
    let (mut p, mut q, mut r) = (p, q, r);
    p.sort(); p.reverse();
    q.sort(); q.reverse();
    r.sort(); r.reverse();
    let mut tot: i64 = 0;
    let mut que = BinaryHeap::new();
    for i in 0..x {
        que.push(-p[i]);
        tot += p[i];
    }
    for i in 0..y {
        que.push(-q[i]);
        tot += q[i];
    }
    for &r in &r {
        let x = -que.pop().unwrap();
        if x < r {
            tot += r - x;
            que.push(-r);
        } else {
            break;
        }
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 16636
#include<stdio.h>
int main(void){
    int a=0,i;
    char s[3];
    scanf("%s",s);
    for(i=0;i<3;i++){
        a+=(s[i]=='o')?100:0;
    }
    printf("%d\n",700+a);
	return 0;		
}

Measured memory_bytes: 128
let () =
  let a,b,c = Scanf.sscanf (read_line()) "%d %d %d" (fun a b c -> a,b,c) in
  let rec find_divisors divisor n =
    if divisor > b then n
    else
      begin
        if c mod divisor = 0 then find_divisors (divisor + 1) (n + 1)
        else find_divisors (divisor + 1) n
      end
  in
  print_int (find_divisors a 0);
  print_string "\n"
;;


Measured memory_bytes: 2440
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int
int main() {
  int n, m;
  std::cin >> n >> m;
  int maxl=0, minr=n;
  for(int i=0; i < m; i++) {
    int l, r;
    std::cin >> l >> r;
    if(maxl < l) maxl = l;
    if(minr > r) minr = r;
  }
  if(minr < maxl) {
    std::cout << 0 << std::endl;
  } else {
    std::cout<< minr - maxl + 1 << std::endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 20;


/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define policy tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/


void solve(int t)
{

	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll p = 0;
	ll q = n - 1;

	ll ans = 0;
	while (p < q)
	{
		if (s[p] == 'R') p++;
		if (s[q] == 'W') q--;

		if (s[p] == 'W' and s[q] == 'R')
		{
			p++;
			q--;
			ans++;
		}

	}

	cout << ans << endl;


}

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



	int t = 1;
	//cin >> t;


	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    if (S.length() <= K) {
        cout << S << endl;
        return 0;
    }
    cout << S.substr (0, K) + "..." << endl;
    return 0;
}


Measured memory_bytes: 3604
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		MyInput in = new MyInput();
    int N = in.nextInt();
    double[] blcost = new double[N];
    String str = new String();
    long ans = 1;

    str = in.next();
    in.next();

    String[] bls = str.split("");
    String lastr = "";

    int stin = 1;
    boolean ty = false;
    ans *= 3;
    if(N > 1) {
        if(N > 2 ) {
            if(bls[0].equals(bls[1])) {
                ans *= 2;
                stin += 1;
                ty = true;
            }
        }
    }

    for(int i = stin; i < N ; i++) {
        if(i != N - 1 && bls[i].equals(bls[i+1])) {
            ans *= 2;
            if(ty) {
                ans = ans * 3 / 2;
            }
            i++;
            ty = true;
        } else {
            if(!ty) {
                ans *= 2;
            }
            ty = false;
        }
        if(ans > 1000000007) ans %= 1000000007;
    }
    if(ans > 1000000007) ans %= 1000000007;
    System.out.println(ans);

	  }
}

class MyInput {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr= 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		}else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch(IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	public int readByte() { 
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <=126;
	}

	private void skipUnprintable() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if(!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if(b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true) {
			if('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			}else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

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



Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

using PII = pair<int, int>;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};

int h, w;
vector<string> board;

int inside(int y, int x) {
	if (0 <= y && y < h && 0 <= x && x < w) {
		return true;
	} else {
		return false;
	}
}

int calc(int sy, int sx, int gy, int gx) {
	vector<vector<int>> walk(h, vector<int>(w, -1));

	if (sy == gy && sx == gx) {
		return 0;
	}

	queue<PII> que;
	walk[sy][sx] = 0;
	que.push(make_pair(sy, sx));

	int y, x, ny, nx;
	while (!que.empty()) {
		auto p = que.front();
		que.pop();
		y = p.first;
		x = p.second;

		int n_walk = walk[y][x];

		if (y == gy && x == gx) {
			return n_walk;
		}

		for (int i = 0; i < 4; i++) {
			ny = y + dy[i];
			nx = x + dx[i];

			if (!inside(ny, nx)) {
				continue;
			}
			if (board[ny][nx] == '#') {
				continue;
			}
			if (walk[ny][nx] != -1) {
				continue;
			}

			walk[ny][nx] = n_walk + 1;
			que.push(make_pair(ny, nx));
		}

	}


	return 1e6;
}

int main() {
	cin >> h >> w;

	board.assign(h, "");

	for (int i = 0; i < h; i++) {
		cin >> board[i];
	}


	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (board[i][j] == '#') {
				continue;
			}

			for (int k = 0; k < h; k++) {
				for (int l = 0; l < w; l++) {
					if (board[k][l] == '#') {
						continue;
					}

					int tmp = calc(i, j, k, l);
					if (tmp > ans) {
						ans = tmp;
						// printf("%2d %2d -> %2d %2d: %d\n", i, j, k, l, tmp);
					}
				}
			}
		}
	}

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


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,j,k) for (int i = j; i <= k; i++)
#define dow(i,j,k) for (int i = j; i >= k; i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef pair<int, int> pi;
typedef long long ll;

ll a, b, c, d;
int q;

int main() {
	scanf("%d", &q);
	while (q--) {
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		ll k = (max(a, b) - 1) / (min(a, b) + 1) + 1;
		ll l = 0, r = a;
		while (l < r) {
			int ma = (l + r + 1) >> 1;
			int mb = max(0ll, (ma - 1) / k);
			if (b - mb <= (a - ma + 1) * k) l = ma;
			else r = ma - 1;
		}
		ll t = l + max(0ll, (l - 1) / k);
		for (c; c <= min(t, d); c++) putchar(c % (k + 1)? 'A' : 'B');
		for (; c <= d; c++) putchar((a + b + 1 - c) % (k + 1)? 'B': 'A');
		puts("");
	}
}
		
		
		
			
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

Measured memory_bytes: 384
use proconio::input;

fn main() {
    input! {
        n: usize,
        p: [f64; n],
    };

    let mut dp = vec![vec![0_f64; n + 1]; n + 1];
    dp[0][0] = 1_f64;
    for i in 0..n {
        for j in 0..n {
            dp[i + 1][j] += (1_f64 - p[i]) * dp[i][j];
            dp[i + 1][j + 1] += p[i] * dp[i][j];
        }
    }
    let mut ans = 0_f64;
    for (i, &a_i) in dp[n].iter().enumerate() {
        if i > n / 2 {
            ans += a_i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 72584
#include<iostream>

using namespace std;

int main( )
{	
    int n;
    int maxProfit = 1-1000000000;
    int Rj, Ri = 2000000000, t;
   
    cin>>n;
    for( int i=0; i<n; i++ ) {
    	cin>>Rj;
    	t = Rj - Ri;
    	if( maxProfit < t ) {
       		maxProfit = t;
       	}
       	if( Rj < Ri ) {
    		Ri = Rj;
    	}
    }
    cout<<maxProfit<<endl;
	
	return 0;
}

Measured memory_bytes: 1164
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

X=II()
if X<=599:
  print(8)
elif X<=799:
  print(7)
elif X<=999:
  print(6)
elif X<=1199:
  print(5)
elif X<=1399:
  print(4)
elif X<=1599:
  print(3)
elif X<=1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9188
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0) break;
        for(int i=0; i<H; i++){
            for(int a=0; a<W; a++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    
}


Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int n; cin >> n;
    vector<string> s;
    map<string, int> m;
    rep(i, n){
        string str;
        cin >> str;
        vector<char> c;
        rep(j, 10){
            c.push_back(str[j]);
        }
        sort(c.begin(), c.end());
        string moji ="";
        rep(j, c.size()) moji += c[j];
        s.push_back(moji);
        m[moji] ++;
    }

    ll ans = 0;
    for(auto& p: m){
        ll num = p.second;
        ans += num * (num-1) / 2;
    }
    cout << ans<< endl;



    return 0;
}


Measured memory_bytes: 13556
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;

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

     while(scanf("%d%d%d",&a,&b,&c) != EOF)
     {
         if(a == b) printf("%d\n",c);
         else if(a == c) printf("%d\n",b);
         else printf("%d\n",a);
     }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int N;
  cin >> N;
  int T, A;
  cin >> T >> A;

  int ans = 0;
  int min_v = INT_MAX;
  for (int i = 1; i <= N; i++) {
    int H;
    cin >> H;

    int d = (T * 1000 - H * 6) - A * 1000;
    if (d < 0)
      d = -d;
    if (min_v > d) {
      min_v = d;
      ans = i;
    }
  }

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

Measured memory_bytes: 256
package main
 
import "fmt"
 
func main() {
  var l,r,d int
  fmt.Scan(&l,&r,&d)
  answer := (r/d - (l-1) / d)
  if (l==r && r==d) {
      fmt.Println(1)
  } else {
    fmt.Println(answer)
  }
}


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

#define REP(i,j) for(int i=1;i<=j;i++)

char maze[21][21];
int max_step,step[21][21];
bool visited[21][21];
int dx[5]= {0,1,-1,0,0};
int dy[5]= {0,0,0,1,-1};

struct node {
	int x,y;
} note;
queue<node> q;

int main() {
	int x,y;
	scanf("%d%d",&x,&y);
	REP(i,x) {
		REP(j,y) {
			cin>>maze[i][j];
		}
	}
	REP(i,x) {
		REP(j,y) {
			memset(step,0,sizeof(step));
			memset(visited,0,sizeof(visited));
			if(maze[i][j]=='#')
			continue;
			q.push(node {i,j});
			visited[i][j]=true;
			while(!q.empty()) {
				node u=q.front();
				q.pop();
				int X=u.x;
				int Y=u.y;
				REP(k,4) {
					int xx=X+dx[k];
					int yy=Y+dy[k];
					if(maze[xx][yy]=='.'&&!visited[xx][yy]) {
						q.push(node {xx,yy});
						step[xx][yy]=step[X][Y]+1;
						max_step=max(max_step,step[xx][yy]);
						visited[xx][yy]=true;
					}
				}
			}
		}
	}
	printf("%d",max_step);
	return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int f[309][309],C[309][309],S[309][309];
int main(){
  int n,m,mod;
  scanf("%d%d%d",&n,&m,&mod);
  for(int i=0;i<=n;i++)
    for(int j=0;j<=i;j++)
      C[i][j]=(j==0||j==i)?1:(C[i-1][j-1]+C[i-1][j])%mod;
  for(int i=0;i<=m;i++) f[1][i]=1;
  for(int i=2;i<=n+1;i++){
    for(int j=m;j>=0;j--) S[i-1][j]=(S[i-1][j+1]+f[i-1][j])%mod;
    for(int j=0;j<=m;j++)
      for(int k=1;k<i;k++)
	f[i][j]=(1ll*f[i-k][j]*C[i-2][k-1]%mod*S[k][j+1]+f[i][j])%mod;
  }
  printf("%d",f[n+1][0]);
  return 0;
}


Measured memory_bytes: 1280
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
const int inf {int(1e9)};
signed main() {
  int N, T;
  cin >> N >> T;

  int ans{inf};
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;

    if (t <= T) ans = min(c, ans);
  }

  if (ans != inf) {
    cout << ans << endl;
  } else {
    cout << "TLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def main():
  k = int(input())
  #s = input()
  #s = input().split()
  #a,b = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  print((k//2)*((k+1)//2))
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(true){
        int a=scan.nextInt();
        int b=scan.nextInt();
        int c=scan.nextInt();
        if(a==-1 &&b==-1 && c==-1)break;
        if(a==-1 || b==-1)System.out.println("F"); 
        else if(a+b>=80)System.out.println("A"); 
        else if(a+b>=65)System.out.println("B");
        else if(a+b>=50)System.out.println("C");
        else if(a+b>=30){
            if(c>=50)System.out.println("C");
            else System.out.println("D");
        }
        else System.out.println("F");
        }
        scan.close();
        return;
    }
}


Measured memory_bytes: 26364