akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	double a, b, angleC;
	scanf("%lf %lf %lf", &a, &b, &angleC);
	angleC = angleC * M_PI / 180;
	double h = b * sin(angleC);
	double S = a * h / 2;
	double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(angleC));
	printf("%.8lf %.8lf %.8lf", S, L, h);

	return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    int x;
    cin >> x;

    if (x >= 30) cout <<"Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6;
const double PI = acos(-1.0);
#define Test ll tesnum;tesnum = read();while(tesnum--)
ll read();
int a[N];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    ll ans = 0;
    for(int i = 1; i <= k; i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return "BT7274", NULL;
}

inline ll read() {
    ll hcy = 0, dia = 1;char boluo = getchar();
    while (!isdigit(boluo)) {if (boluo == '-')dia = -1;boluo = getchar();}
    while (isdigit(boluo)) {hcy = hcy * 10 + boluo - '0';boluo = getchar();}
    return hcy * dia;
}

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

using namespace std;

vector<bool> Sieve(int n)
{
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;

    for (int i = 2; i <= n; i += 1) {
        if (!is_prime[i]) {
            continue;
        }
        for (long long int j = 1LL * i * i; j <= n; j += i) {
            is_prime[j] = false;
        }
    }
    return is_prime;
}

bool IsOdd(const vector<bool> &is_prime, int num)
{
    return is_prime[num] && is_prime[(num + 1) / 2];
}

vector<int> OddCount(int n)
{
    auto is_prime = Sieve(n);
    vector<int> odds(n + 1, 0);

    for (int i = 2; i <= n; i += 1) {
        odds[i] = odds[i - 1];
        odds[i] += (IsOdd(is_prime, i) ? 1 : 0);
    }
    return odds;
}

int main()
{
    constexpr int kMaxNum = 1e5;
    auto odds = OddCount(kMaxNum);

    int tests;
    cin >> tests;

    for (int i = 0; i < tests; i += 1) {
        int left, right;
        cin >> left >> right;
        cout << odds[right] - odds[left - 1] << "\n";
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
	long long a = rng();
    return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r, g, b, n;
    int ans = 0;
    cin >> r >> g >> b >> n;
    for(int i = 0; i <= 3000; ++i)
        for(int j = 0; j <= 3000; ++j)
        {
            int dif = n - i * r - j * g;
            if(dif >= 0 && dif % b == 0)
                ++ans;
        }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;
int len_S, len_T;


int get_nr_diff_chrs(const deque<char> cur_str, const string searched_str)
{
    int res = 0;
    for (int i = 0; i < len_T; ++i)
    {
        res += cur_str[i] != searched_str[i];
    }

    return res;
}


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

    string S, T;
    cin >> S >> T;
    len_S = S.size(), len_T = T.size();
    
    deque<char> cur_str;
    for (const char &chr : S.substr(0, len_T))
    {
        cur_str.emplace_back(chr);
    }
    int ans = get_nr_diff_chrs(cur_str, T);
    for (int i = 1; i + len_T < len_S; ++i)
    {
        cur_str.pop_front();
        cur_str.emplace_back(S[i + len_T - 1]);

        ans = min(ans, get_nr_diff_chrs(cur_str, T));
    }

    cout << ans;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
void A(void);
void B(void);
void C(void);
void D(void);
void E(void);
void F(void);

int main(void){
    B();
}

void A(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

void B(){
    int i,j,n,k,d,a,ans=0;
    cin>>n>>k;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        vec.at(i)=0;
    }
    for(i=0;i<k;i++){
        cin>>d;
        for(j=0;j<d;j++){
            cin>>a;
            vec.at(a-1)++;
        }
    }
    for(i=0;i<n;i++){
        if(vec.at(i)==0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>


using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
  vector<vector<int> > l(n+1);
  list<int> path;
  vector<bool> flg(n+1, false);
  int a, b;
  for (int i =0;i<m;i++){
    cin >> a >> b;
    l[a].push_back(b);
    l[b].push_back(a);
  }
  path.push_back(a);
  path.push_back(b);
  flg[a] = true;
  flg[b] = true;


  while(true){
    int begin = path.front();
    int end = path.back();
    int p = 0;
    bool bre = false;
    for(int i=0;i != l[begin].size();i++){
      if(!flg[l[begin][i]]){
        path.push_front(l[begin][i]);
        flg[l[begin][i]] = true;
        bre = true;
        break;
      }
    }
    l[begin].clear();
    for(int i=0;i != l[end].size();i++){
      if(!flg[l[end][i]]){
        path.push_back(l[end][i]);
        flg[l[end][i]] = true;
        bre = true;
        break;
      }
    }
    l[end].clear();
    if(bre == false) break;
  }

  cout << path.size() << endl;
  list<int>::iterator it = path.begin();
  string sp = "";
  while(it != path.end()){
	  cout << sp << *it;
    sp = " ";
    it++;
  }
  cout << endl;
  
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n, m;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >>n >> m;
	cout << (int)((pow(2, m))*(1900*m+(n-m)*100)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

template<class T> ostream& operator << (ostream &s, vector<T> P) {
    for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; }
    return s;
}
template<class T> 
ostream& operator << (ostream &s, vector<vector<T> > P) {
    for (int i = 0; i < P.size(); ++i) {if(i){s<<endl;} s << P[i]; }
    return s << endl; 
}
signed main(){
    ll N, M; cin >>N>>M;
    vector<ll> S(N), T(M);
    REP(i, N) cin >> S[i];
    REP(i, M) cin >> T[i];
    vector<vector<ll>> dp(N+1, vector<ll>(M+1));
    vector<vector<ll>> sum(N+1, vector<ll>(M+1));
    dp[0][0] = 1;
    sum[0][0] = 1;
    REP(i, N+1) sum[i][0] = 1;
    REP(i, M+1) sum[0][i] = 1;
    REP(i, N){
        REP(j, M){
            if(S[i]==T[j]) dp[i+1][j+1] = sum[i][j];
            else dp[i+1][j+1] = 0;
            dp[i+1][j+1] %= MOD;
            sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + dp[i+1][j+1];
            if(sum[i+1][j+1]<0) sum[i+1][j+1] += MOD;
            sum[i+1][j+1] %= MOD;
        }
    }
    cout << sum[N][M] << endl;
    return 0;
}

Measured memory_bytes: 62976
a, b, C = gets.split.map(&:to_i)
rad = C * Math::PI / 180

h = b * Math.sin(rad)
s = a * h / 2

c =  Math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Math.cos(rad))
l = a + b + c

puts s
puts l
puts h

Measured memory_bytes: 6184
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        s: i32,
        w: i32,
    }
    if s > w {
        println!("safe");
    } else {
        println!("unsafe");
    }
}


Measured memory_bytes: 2148
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <list>
using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	string s; cin >> s;
	int M = s.length();
	vector<int> dp(N + 1);
	dp[0] = 1;
	for (int t = 0; t < N; t++) {
		vector<int> _dp(N + 1);
		for (int x = 0; x <= t; x++) {
			_dp[x + 1] = (_dp[x + 1] + dp[x]) % MOD;
			if (x) _dp[x - 1] = (_dp[x - 1] + dp[x] * 2LL) % MOD;
			else _dp[x] = (_dp[x] + dp[x]) % MOD;
		}
		dp = _dp;
	}
	cout << dp[M] << endl;
}


Measured memory_bytes: 256
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto V = new int[N + 1];
      auto W = new int[N + 1];
      foreach (u; 1 .. N + 1) {
        V[u] = readInt();
        W[u] = readInt();
      }
      const Q = readInt();
      auto X = new int[Q];
      auto L = new int[Q];
      foreach (q; 0 .. Q) {
        X[q] = readInt();
        L[q] = readInt();
      }
      
      alias Entry = Tuple!(int, "w", int, "v");
      auto es = new Entry[1 << 9];
      auto fs = new Entry[1 << 9];
      foreach (q; 0 .. Q) {
        int[] us;
        for (int u = X[q]; u; u >>= 1) {
          us ~= u;
        }
        const usLen = cast(int)(us.length);
        const half = usLen / 2;
        foreach (i; 0 .. half) {
          foreach (h; 0 .. 1 << i) {
            es[h | 1 << i].w = es[h].w + W[us[i]];
            es[h | 1 << i].v = es[h].v + V[us[i]];
          }
          es[0 .. (1 << (i + 1))] = merge(es[0 .. 1 << i], es[1 << i .. (1 << (i + 1))]).array[];
        }
        foreach (i; 0 .. usLen - half) {
          foreach (h; 0 .. 1 << i) {
            fs[h | 1 << i].w = fs[h].w + W[us[half + i]];
            fs[h | 1 << i].v = fs[h].v + V[us[half + i]];
          }
          fs[0 .. (1 << (i + 1))] = merge(fs[0 .. 1 << i], fs[1 << i .. (1 << (i + 1))]).array[];
        }
        int ans;
        int mx;
        for (int g = 0, h = 1 << (usLen - half); h--; ) {
          for (; g < 1 << half && es[g].w + fs[h].w <= L[q]; ++g) {
            chmax(mx, es[g].v);
          }
          if (g > 0) {
            chmax(ans, mx + fs[h].v);
          }
        }
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 12112
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1000000007; /// 1e9+7
const int MAX = 1000005;     /// 1e6+5
ll bigmod(ll n, ll r)
{
    if(r==0) return 1;
    if(r==1) return n;
    if(r%2==0)
    {
        ll ret = bigmod(n, r/2);
        return ((ret%MOD) * (ret%MOD)) % MOD;
    }
    else return ((n%MOD) * (bigmod(n,r-1)%MOD)) % MOD;
}
ll modinverse(ll a){return bigmod(a,MOD-2)%MOD;}
ll lcm(ll a, ll b) {a=abs(a); b=abs(b); return (a/__gcd(a,b))*b;}
ll gcd(ll a, ll b) {a=abs(a); b=abs(b); if(!b) return a; return __gcd(b,a%b);}

ll h, w, a, b;
ll fact[MAX];
ll nCr(ll n, ll r)
{
    ll a=fact[n];
    ll b=(fact[r]*fact[n-r])%MOD;
    return (a*modinverse(b))%MOD;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    fact[0]=1;
    for(ll i=1; i<MAX; i++)
        fact[i]=(fact[i-1]*i)%MOD;
    cin>>h>>w>>a>>b;
    ll ans = 0;
    for(ll i=b+1; i<=w; i++){
        ll tmp = (nCr(h+i-a-2, h-a-1)*nCr(w-i+a-1, w-i))%MOD;
        ans = (ans+tmp)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(void){
    int n,s[1000],i;
    double a,m;
    while(1){
        cin>>n;
        if(!n) 
           break;
        m=a=0;
        for(i=0;i<n;i++){
            cin>>s[i];
            m+=s[i];
        }
        m/=n;
        for(i=0;i<n;i++){
            a+=(s[i]-m)*(s[i]-m);
        }
        a=sqrt(a/n);
        cout<<fixed<<setprecision(6)<<a<<endl;
    }
}


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

int main(void) {
    string S;

    cin >> S;

    if(S == "Sunny")
        cout << "Cloudy" << endl;
    if(S == "Cloudy")
        cout << "Rainy" << endl;
    if(S == "Rainy")
        cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int R, G, B, N; cin >> R >> G >> B >> N;
    int ans = 0;
    for (int r = 0; r <= N; r += R) {
        for (int g = 0; r + g <= N; g += G) {
            int b = N - r - g;
            if (b % B == 0) ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
    int cnt = 0;
    int sta;
    int train[10]={0};
    while(cin >> sta){
        if(sta == 0){
            cnt--;
            cout << train[cnt] << endl;
        }
        else {
            train[cnt] = sta;
            cnt++;
        }
    }
}

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

using namespace std;

void solve() {
    long long k, n; cin >> k >> n;
    vector<long long> vt(n);
    for (int i = 0; i < n; i++)
        cin >> vt[i];
    long long mx = 0, sm = 0;
    for (int i = 0; i + 1 < n; i++) {
        mx = max(mx, vt[i + 1] - vt[i]);
        sm += vt[i + 1] - vt[i];
    }
    sm += k - vt[n - 1] + vt[0];
    mx = max(mx, k - vt[n - 1] + vt[0]);
    cout << sm - mx;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 1792
'''
https://atcoder.jp/contests/abc145/tasks/abc145_c
'''
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    grid = [list(map(int, input().split())) for _ in range(N)]
    res = 0
    for path in permutations(grid, N):
        for i in range(N-1):
            res += ((path[i][0]-path[i+1][0])**2 + (path[i][1]-path[i+1][1])**2)**0.5
    a = 1
    for i in range(2, N+1):
        a *= i
    print(res/a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#define INF 1<<30
#define WHITE 0
#define GRAY 1
#define BLACK 2
int G[101][101];
using namespace std;
int n;

void prim(int *d, int *pi){
    int color[n];
    int u = 0;
    for (int i = 0; i < n; i++){
        d[i] = pi[i] = INF;
        color[i] = WHITE;
    }
    d[0] = 0;
    while (1){
        int mincost = INF;
        for (int i = 0; i < n; i++){
            if (color[i] != BLACK && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }
        if (mincost == INF) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++){
            int w = G[u][v];
            if (w == -1) continue;
            else if (color[v] != BLACK && d[u]+w < d[v]){
                pi[v] = u;
                d[v] = d[u] + w;
            }
        }
    }
}

int main(int argc, char* argv[]) {
    cin >> n;
    int d[n], pi[n], sum = 0;
    int u, k, v, c;

    //initialize
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            G[i][j] = -1;
        }
    }
    //input
    for (int i = 0; i < n; i++){
        cin >> u >> k;
        for (int j = 0; j < k; j++){
            cin >> v >> c;
            G[u][v] = c;
        }
    }
    prim(d, pi);
    for (int i = 0; i < n; i++){
        cout << i << " " << d[i] << endl;
    }
    return 0;
}



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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

ll k;
ll a[100];

int main() {
    cin >> k;
    int n = 50;
    ll x = n - 1 + (k / n) + 1;
    ll cur = n * (x - (n - 1));
    cur = cur - k;
    for (int i = 0; i < n; ++i)
        a[i] = x;
    while (cur--) {
        sort(a, a + n);
        a[n - 1] -= n;
        for (int i = 0; i < n - 1; ++i)
            ++a[i];
    }
    sort(a, a + n);
    cout << n << "\n";
    for (int i = 0; i < n; ++i)
        cout << a[i] << " ";
    cout << "\n";
    return 0;
}




Measured memory_bytes: 256
#include<iostream>

using namespace std;

int bubble_sort(int A[], int n)
{
    int sn = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = n-1; j > 0; j--)
        {
            if (A[j] < A[j-1])
            {
                swap(A[j], A[j-1]);
                sn++;
            }
        }
    }
    return sn;
}

void trace(int A[], int n)
{
    for (int i = 0; i < n; i++)
    {
        if (i)
            cout << ' ';
        cout << A[i];
    }
    cout << endl;
}
int main()
{
    int A[100];
    int n, sn;
    
    cin >> n;
    
    for (int i =0; i < n; i++)
        cin >> A[i];
    
    sn = bubble_sort(A, n);
    
    trace(A,n);
    cout << sn << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

int main(void){
  int N;cin >> N;
  ll max = 0, min = INF;
  int i;REP(i,N){
    ll x;cin >> x;
    if(x>max)max = x;
    if(x<min)min = x;
  }
  cout << max - min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  if(n%111==0)cout<<n<<endl;
  else{
  int k = n/111;
  cout<<(k+1)*111<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
while True:
    a,b = map(int,input().split())
    if a == 0 and b==0:
        break
    for i in range(a):
        if (i+1)%2 == 0:
            for s in range(b):
                if (s+1)%2 == 0:
                    print("#",end='')
                else:
                    print(".",end='')
                if s == b-1:
                    print("")
        else:
            for s in range(b):
                if (s+1)%2 == 0:
                    print(".",end='')
                else:
                    print("#",end='')
                if s == b-1:
                    print("") 
    print("")


Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 29;
const ll INF = 1LL << 61;

int main(){
    int N, M, R;
    cin >> N >> M >> R;
    VI r(R);
    rep(i, R) cin >> r[i];
    rep(i, R) r[i]--;
    VVI dist(N, VI(N, inf));
    rep(i,M){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    rep(k ,N) rep(i, N) rep(j, N){
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
    }

    VI rp(R);
    rep(i, R) rp[i] = i;
    int ans = inf;
    do {
        VI seq(R);
        rep(i,R) seq[rp[i]] = r[i];

        int sum = 0;
        rep(i,R-1){
            int st = seq[i];
            int next = seq[i+1];
            sum += dist[st][next];
        }
        ans = min(ans, sum);
    } while(next_permutation(all(rp)));

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

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  vector<string> T={"AC", "WA", "TLE", "RE"};
  
  vector<int> V(4, 0);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < T.size(); j++) {
      if (S.at(i) == T.at(j)) {
        V.at(j)++;
      }
    }
  }
  
  for (int i = 0; i < T.size(); i++) {
    cout << T.at(i) << " x " << V.at(i) << endl;
  }
}


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

long long N;
vector<pair<long long, long long>>BA;

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		long long a, b;
		cin >> a >> b;
		BA.push_back(make_pair(b, a));
	}
	sort(BA.begin(), BA.end(), greater<pair<long long, long long> >());

	long long cur = BA[0].first;;
	for(long long i = 0; i < N; i++){
		long long duration = BA[i].second;
		long long dead = BA[i].first;
		if(cur > dead){
			cur = dead;
		}
		cur = cur - duration;
	}
	if(cur < 0){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int d[n];
    rep(i,0,n) cin >> d[i];

    int ans;
    rep(x,0,n) rep(y,x+1,n){
       ans += d[x]*d[y];
    }
    
    cout << ans << "\n";
}

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

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

    string s;
    cin >> s;
    vector<int> st;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        st.push_back(s[i]);
        while (st.size() > 1 && st[st.size()-1] != st[st.size()-2]) {
            ans += 2;
            st.pop_back();
            st.pop_back();
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 972
import java.util.*;

class Main {

    static void eraseIsland(char[][] field, int i, int j) {
        field[i][j] = '0';
        if (i < 11 && field[i+1][j] == '1') eraseIsland(field, i+1, j);
        if (j < 11 && field[i][j+1] == '1') eraseIsland(field, i, j+1);
        if (i > 0 && field[i-1][j] == '1') eraseIsland(field, i-1, j);
        if (j > 0 && field[i][j-1] == '1') eraseIsland(field, i, j-1);
    }

    static void solve (char[][] field) {
        int island = 0;

        for(int i = 0; i < 12; i++) {
            for(int j = 0; j < 12; j++) {
                if (field[i][j] == '1') {
                    eraseIsland(field, i, j);
                    island += 1;
                }
            }
        }

        System.out.println(island);
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        char [][] field = new char[12][12];
        
        while(sc.hasNext()) {
            
            for(int i = 0; i < 12; i++) {
                field[i] = sc.nextLine().toCharArray();
            }

            if(sc.hasNext())    sc.nextLine();

            solve(field);

        }



    }
}

Measured memory_bytes: 12000
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    int N = s.size();
    int M = t.size();
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(N == M) {
        cout << (s < t ? "Yes":"No") << endl;
    } else if(N < M) {
        if(s <= t.substr(0,N)) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if(s.substr(0,M) < t) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

using namespace std;

char s[200010];
int main()
{

    int n;
    cin>>n;
    scanf("%s",s);
    int i=0,j=n-1;
    n=0;
    for(;j>i;i++)
    {
       if(s[i]=='R')continue;
        for(;j>i;j--)

               if(s[j]=='R') {n++;j--; break;
           }
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 3912
# -*- coding: utf-8 -*-
"""
B - Ringo's Favorite Numbers
https://abc100.contest.atcoder.jp/tasks/abc100_b

"""
import sys
from sys import stdin
input = stdin.readline

Divs = [[], [], []]
for i in range(1, 1100000):
    num = i
    d = 0
    while num % 100 == 0:
        d += 1
        num //= 100
    if d <= 2:
        Divs[d].append(i)

def solve(D, N):
    return Divs[D][N-1]


def main(args):
    D, N = map(int, input().split())
    ans = solve(D, N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 46452
A=list(input())
for i in range(4):
    A[i]=int(A[i])
for i in range(8):
    x=A[0]
    for j in range(3):
        if (i//(2**j))%2==1:
            x+=A[j+1]
        else:
            x-=A[j+1]
    if x==7:
        print(A[0],end='')
        for j in range(3):
            if (i//(2**j))%2==1:
                print('+',end='')
            else:
                print('-',end='')
            print(A[j+1],end='')
        print('=7')
        break


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=1e5+5;
vector<int> g[N];
ll szs[N], ans[N], below[N], n, M;

void dfs(int u, int p){
	szs[u]=1;below[u]=1;
	for(int v:g[u])if(p!=v){
		dfs(v,u);
		szs[u]+=szs[v];
		below[u]=(below[u]*below[v])%M;
	}
	fore(x,0,SZ(g[u]))if(g[u][x]==p){
		swap(g[u][x],g[u].back());
		g[u].pop_back();
		break;
	}
	below[u]++;
}

void f(int u, ll ant){
	vector<ll> cas = {1}, casr;
	for(int v:g[u])cas.pb(below[v]),casr.pb(below[v]);
	casr.pb(1);
	fore(x,1,SZ(cas))cas[x]=(cas[x]*cas[x-1])%M;
	for(int x=SZ(casr)-2; x>=0; x--)casr[x]=(casr[x]*casr[x+1])%M;
	ans[u] = (ant*casr[0])%M;
	fore(x,0,SZ(g[u]))
		f(g[u][x],(1+((ant*cas[x])%M)*casr[x+1])%M);
}

int main(){FIN;
	cin >> n >> M;
	fore(x,1,n){
		int u,v;cin>>u>>v;u--;v--;
		g[u].pb(v);g[v].pb(u);
	}
	dfs(0,-1);
	f(0,1);
	fore(x,0,n)cout<<ans[x]<<"\n";
}

Measured memory_bytes: 25088
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int N;
	int sum = 0;

	cin >> N;

	vector<int> a(N, 0);

	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum += a[i];
	}

	int v1 = sum / N;
	int v2 = v1 + 1;

	int ans1 = 0;
	int ans2 = 0;

	for (int i = 0; i < N; i++) {
		ans1 += (v1 - a[i]) * (v1 - a[i]);
		ans2 += (v2 - a[i]) * (v2 - a[i]);
	}

	cout << min(ans1, ans2) << endl;

	return 0;
}

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

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

    string s;
    cin >> s;
    int n = s.size();

    const string k = "keyence";
    if(s.substr(0, 7)==k || s.substr(n-7, 7)==k){
        puts("YES");
        return 0;
    }

    rep1(i, 7){
        string l = k.substr(0, i);
        string r = k.substr(i, 7-i);

        // cout << l << " " << r << endl;
        // cout << s.substr(0, i) << " " << s.substr(n-7+i, 7-i) << endl << endl;

        if(s.substr(0, i)==l && s.substr(n-7+i, 7-i)==r){
            puts("YES");
            return 0;
        }
    }

    puts("NO");

    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = (b - a) / 2;
    if ((b-a)%2==1) {
        ans += min(a-1, n-b) + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
  while(1){
    double a[3];
    int b,c;
    cin>>a[0]>>a[1]>>a[2];
    if(a[0]==0&&a[1]==0&&a[2]==0)break;
    sort(a,a+3);
    cin>>b;
    for(int i=0;i<b;i++){
      cin>>c;
      if(c*2>sqrt(pow(a[0],2)+pow(a[1],2)))printf("OK\n");
      else printf("NA\n");
    }
  }
  return 0;
}

Measured memory_bytes: 3080
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    long n, a, b;
    scan(n, a, b);

    if (n == 1) {
        if (a != b) {
            writeln(0);
        }
        else {
            writeln(1);
        }
        return;
    }

    if (a > b) {
        writeln(0);
        return;
    }
    
    auto mn = (n - 1) * a + b;
    auto mx = a + (n - 1) * b;
    auto ans = (mx - mn + 1);
    writeln(ans);
}










int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {writeln(b ? "Yes" : "No");}
void YES(bool b) {writeln(b ? "YES" : "NO");}
T[] readArr(T)() {return readln.split.to!(T[]);}
T[] readArrByLines(T)(int n) {return iota(n).map!(i => readln.chomp.to!T).array;}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    
    long long ans=0;
    for(int i=0;i<n;i++) ans+=a[i]-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        h: i64, w: i64, n: usize,
        sr: i64, sc: i64,
        s: Chars,
        t: Chars,
    }

    let mut left = 1i64;
    let mut right = w;
    if s[n-1] == 'L' {
        left += 1;
    } else if s[n-1] == 'R' {
        right -= 1;
    }

    for i in (0..n-1).rev() {
        if t[i] == 'L' {
            right = min(w, right+1);
        } else if t[i] == 'R' {
            left = max(1, left - 1);
        }
        if s[i] == 'L' {
            left += 1;
        } else if s[i] == 'R' {
            right -= 1;
        }
        if left > right {
            println!("NO");
            return;
        }
    }
    if sc < left || right < sc {
        println!("NO");
        return;
    }

    let mut up = 1i64;
    let mut down = h;
    if s[n-1] == 'U' {
        up += 1;
    } else if s[n-1] == 'D' {
        down -= 1;
    }

    for i in (0..n-1).rev() {
        if t[i] == 'U' {
            down = min(h, down+1);
        } else if t[i] == 'D' {
            up = max(1, up - 1);
        }
        if s[i] == 'U' {
            up += 1;
        } else if s[i] == 'D' {
            down -= 1;
        }
        if up > down {
            println!("NO");
            return;
        }
    }
    if sr < up || down < sr {
        println!("NO");
        return;
    }

    println!("YES");
}


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

int main() {
    long long N;
    cin >> N;
    long long num = 0, tmp = N;
    while (tmp != 0) {
        num += tmp % 10;
        tmp /= 10;
    }
    if (N % num == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

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

	string a,b;
	cin >> a >> b;
	if(b.substr(0,b.size()- 1) == a)
		cout << "Yes";
	else
	{
		cout << "No";
	}
	
	


    return 0;
}

Measured memory_bytes: 3668
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bug() cout << "BUG" << endl ;
#define X first
#define Y second
#define per(how) cout << fixed << setprecision(how)
#define bit(a , b) (a >> b) & 1
#define all(v) v.begin() , v.end()
#define LB(x) (x & -x)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 , MOD = 1e9 + 7 , SQRT = 350 ;
inline void smin(ll &x , ll y) { x = min(x , y) ; }
inline void smax(ll &x , ll y) { x = max(x , y) ; }




int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl ;
	return 0;
}



Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  int a, b;
  readf("%s %s\n", &a, &b);
  auto res = -1;
  foreach (i; 1..max(a, b)*20) {
    auto x = (i * 0.08).to!int;
    auto y = (i * 0.1).to!int;
    if (a == x && b == y) {
      res = i;
      break;
    }
  }
  res.writeln;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int M = Integer.parseInt(sc.get());
		int L = Integer.parseInt(sc.get());
		long INF = 100000000000000000L;


		long[][] map = new long[N][N];
		for (long[] ints : map) {
			Arrays.fill(ints, INF);
		}
		for (int i = 0; i < M; i++) {
			int A = Integer.parseInt(sc.get()) - 1;
			int B = Integer.parseInt(sc.get()) - 1;
			int C = Integer.parseInt(sc.get());
			map[A][B] = C;
			map[B][A] = C;
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					map[j][k] = Math.min(map[j][k], map[j][i] + map[i][k]);
				}
			}
		}


		long[][] count = new long[N][N];
		for (long[] ints : count) {
			Arrays.fill(ints, INF);
		}
		for (int i = 0; i < map.length; i++) {
			long[] city = map[i];
			for (int j = 0; j < city.length; j++) {
				if (city[j] <= L) {
					count[i][j] = 1;
				}
			}
		}

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					count[j][k] = Math.min(count[j][k], count[j][i] + count[i][k]);
				}
			}
		}


		int Q = Integer.parseInt(sc.get());
		for (int i = 0; i < Q; i++) {
			int S = Integer.parseInt(sc.get()) - 1;
			int T = Integer.parseInt(sc.get()) - 1;
			if (count[S][T] >= INF) System.out.println(-1);
			else System.out.println(count[S][T] - 1);
		}
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 51204
# -*- coding: utf-8 -*-

H, W = map(int, input().split())
A = []
for i in range(H):
    row = list(map(int, input().split()))
    assert len(row) == W
    A.append(row)

# 操作の列
ops = []

# 各行について, 奇数を右端に移動
oddrow = []
for r, row in enumerate(A):
    for i in range(len(row) - 1):
        if row[i] % 2 != 0:
            row[i]     -= 1
            row[i + 1] += 1
            ops.append((r, i, r, i+1))
    # 各行に残っている奇数を下に移動
    if r + 1 < H and row[-1] % 2 != 0:
        A[r]    [-1] -= 1
        A[r + 1][-1] += 1
        ops.append((r, W-1, r+1, W-1))

# 出力
print(len(ops))
for op in ops:
    print(' '.join([str(x+1) for x in op]))

Measured memory_bytes: 22440
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon
{

    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] input = Console.ReadLine().Split(' ');
            List<int> nums = new List<int>();
            for (int i = 0; i < input.Count(); ++i)
            {
                nums.Add( int.Parse(input[i]) );
            }
            bool isBonus = false;
            int result = 0;
            for( int i = 0; i < input.Count(); ++i)
            {
                if( nums[i] == i + 1)
                {
                    if (isBonus)
                    {
                        isBonus = false;
                    }
                    else
                    {
                        result++;
                        isBonus = true;
                    }
                   
                }
                else
                {
                    isBonus = false;
                }
            }
            Console.WriteLine(result);
        }
    }

}

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

int main()
{
  int i;
  int n, h, lh, flg = 0;
  cin >> n;
  for (i = 0; i < n; i++)
  {
    cin >> h;
    if (h > lh)
    {
      lh = h - 1;
    }
    else if (h < lh)
    {
      flg = 1;
    }
  }
  if (flg == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	string s,t,r="UNRESTORABLE";
	cin>>s>>t;
	for(int i=s.size()-1;i>=0;i--){
		if(i+t.size()-1 >= s.size()) continue;
		int j;
		for(j=i;j<i+t.size();j++){
			if(s[j]!='?' && s[j]!=t[j-i]){
				goto fail;
			}
		}
		for(j=i;j<i+t.size();j++){
			s[j] = t[j-i];
		}
		rep(j,s.size()) if(s[j]=='?') s[j]='a';
		cout<<s<<endl;return 0;
		fail:;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdlib>
#include<iostream>
using namespace std;
string a,b;int c;
int main()
{
	cin>>a>>b;a+=b;
	c=atoi(a.c_str());
	if(pow((int)sqrt(c),2)==c)cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 256
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h, w := scanInt(), scanInt()
	n := scanInt()
	a := scanInts(n)
	c := make([]int, h*w)
	p := 0
	for i := 0; i < n; i++ {
		for j := 0; j < a[i]; j++ {
			c[p] = i + 1
			p++
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if i&1 == 1 {
				fmt.Fprint(wr, c[i*w+w-1-j], " ")
			} else {
				fmt.Fprint(wr, c[i*w+j], " ")
			}
		}
		fmt.Fprintln(wr)
	}
}


Measured memory_bytes: 2032