akhauriyash/Code-Regression huggingface dataset:
require 'matrix'

until (num = $<.gets.to_i).zero?
  circles = Array.new(num) do
    x, y, r = $<.gets.split.map(&:to_r)
    [Vector[x, y], r]
  end
  
  $<.gets.to_i.times do
    tx, ty, sx, sy = $<.gets.split.map(&:to_r)
    ta  = Vector[tx, ty]
    oni = Vector[sx, sy]
    v = ta - oni
    n = Vector[v[1], -v[0]].normalize
    f = circles.map do |o, r|
      pos1 = (oni - o).norm < r
      pos2 = (ta  - o).norm < r
      if pos1 and pos2
        false
      elsif !pos1 and !pos2
        s, t = Matrix.columns([v, -n]).lup.solve(o - oni).to_a
        s.between?(0, 1) and t.abs <= r
      else
        true
      end
    end.any?
    puts f ? "Safe" : "Danger"
  end
end


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

using namespace std;

int main()
{
    long long int k,n,c=0,d;
    cin>>k>>n;
    long long int a[n],i,b[n-1];
    for(i=0;i<n;i++)
        cin>>a[i];
    d=k-a[n-1]+a[0];
    for(i=0;i<n-1;i++)
        b[i]=a[i+1]-a[i];
        sort(b,b+(n-1));
        if(b[n-2]>d)
            b[n-2]=d;
        for(i=0;i<n-1;i++)
            c=c+b[i];
        cout<<c;
    return 0;

}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	
	cin >> s;
	sort(s.begin(),s.end());
	if(s == "abc") cout << "Yes\n";
	else			cout <<"No\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

int cnt[1000*2][1000*2][2] = {};
int ru[1000*2+1][1000*2+1][2] = {};

void solve() {
    int n,K;
    cin >> n >> K;
    int x,y;
    char c;
    REP(i,0,n) {
        cin >> x >> y >> c;
        cnt[x%(2*K)][y%(2*K)][c == 'W']++;
    }
    REP(i,0,2*K) REP(j,0,2*K) REP(k,0,2) ru[i+1][j+1][k] = ru[i+1][j][k] + cnt[i][j][k];
    REP(j,0,2*K) REP(i,0,2*K) REP(k,0,2) ru[i+1][j+1][k] += ru[i][j+1][k];
    int ans = 0;
    REP(i,0,K) REP(j,0,K) {
        int b = 0, w = 0;
        b += ru[i][j][0];
        b += ru[i+K][j+K][0] - ru[i][j+K][0] - ru[i+K][j][0] + ru[i][j][0];
        b += ru[2*K][2*K][0] - ru[i+K][2*K][0] - ru[2*K][j+K][0] + ru[i+K][j+K][0];
        b += ru[i][2*K][0] - ru[i][j+K][0];
        b += ru[2*K][j][0] - ru[i+K][j][0];
        w += ru[i][j][1];
        w += ru[i+K][j+K][1] - ru[i][j+K][1] - ru[i+K][j][1] + ru[i][j][1];
        w += ru[2*K][2*K][1] - ru[i+K][2*K][1] - ru[2*K][j+K][1] + ru[i+K][j+K][1];
        w += ru[i][2*K][1] - ru[i][j+K][1];
        w += ru[2*K][j][1] - ru[i+K][j][1];
        w = ru[2*K][2*K][1] - w;
        ans = max({ans, b + w, ru[2*K][2*K][0] - b + ru[2*K][2*K][1] - w});
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 62720
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N, vector<string> & S){
    ll ct = 0;
    rep(B,N){
        ll judge = 0;
        vector<string> T(N);
        rep(i,N) rep(j,N) T[i].pb(S[i][(j+B)%N]);
        rep(i,N) rep(j,N) if(T[i][j] == T[j][i]) judge++;
        
        if(judge == N*N) ct++;
    }
    return N*ct;
}

int main(){
    ll N; cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S[i];
    pr(solve(N,S));
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	if(a+b>=10){
		cout << "error" << endl;
    }else{
		cout << a+b << endl;
    }
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, x0) = readLine()!!.split(" ").map(String::toInt)
    val x = readLine()!!.split(" ").map(String::toInt).map{abs(x0 - it)}.reduce{a, b -> gcd(a,b)}

    print(x)
}

tailrec fun gcd(a: Int, b: Int): Int{
    if(b == 0) return a
    return gcd(b, a%b)
}

fun abs(n: Int): Int {
    return if(n>0) n else -n
}

Measured memory_bytes: 50188
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

double L,A,B,C;

signed main(){
	cin>>L;
	double d=1;
	d*=L/3.0;
	d*=L/3.0;
	d*=L/3.0;
	setdouble(10,d);cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

using namespace __gnu_pbds;
using namespace std;
const int mod = 1e9 + 7;
// const int mod=998244353;
//const int mod=1e9+9;
//const int INF=4e18+10;
const int INF = 4e18 + 10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) \
int n;      \
cin >> n;
#define readv(x, n)   \
vector<int> x(n); \
for (auto &i : x) \
    cin >> i;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template <typename T1, typename T2>
void set_min(T1 &a, T2 b)
{
    a = min(a, (T1)b);
}

int multiply(int a, int b, int in_mod) { return (a * b) % in_mod; }
int mult_identity(int a) { return 1; }


auto power(auto a, int b, int in_mod)
{
    auto prod = mult_identity(a);
    auto mult = a % in_mod;
    while (b != 0)
    {
        if (b % 2)
        {
            prod = multiply(prod, mult, in_mod);
        }
        mult = multiply(mult, mult, in_mod);
        b /= 2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod - 2, in_mod);
}

void  solve()
{

    int n;
    cin>>n;
    readv(a,n);
    int val = 0;
    for(int i= 0;i<n;i++)
    {
        for(int j= i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                vector<int> op;
                op.pb(a[i]);
                op.pb(a[j]);
                op.pb(a[k]);
                sort(all(op));
                if(op[0] !=op[1] && op[1]!=op[2])
                {
                    if(op[0]+op[1]>op[2])
                        val++;
                }
            }

        }
    }

    cout<<val<<endl;

}



signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

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

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<":\n";
        //cout<<"Trip #"<<test<<": ";
        // cout<<endl;
        solve();
        // solveB();

        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


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

vector<ll> f;

ll modinv(ll a, ll m) {
	ll b=m, u=1, v=0;
	while(b) {
		ll t=a/b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= m;
	if(u<0)
		u += m;
	return u;
}

ll cmb(int n, int r) {
	ll x,y;

	if(r == 0)
		return 0;
	if(n == r)
		return 1;

	x = f.at(n-1) * modinv(f.at(n-r-1),MOD) % MOD;
	y = f.at(r-1);
	return x * modinv(y,MOD) % MOD;
}

int main() {
	int N,K;
	ll r=0;
	cin >> N >> K;

	vector<int> A(N);
	f.resize(N);

	f.at(0) = 1;
	rep(i,N-1) {
		f.at(i+1) = f.at(i)*(i+2);
		f.at(i+1) %= MOD;
	}
	
	rep(i,N)
		cin >> A.at(i);
	sort(A.begin(), A.end());

	rep(i,N) {
		if(i >= K-1)
			r += A.at(i) * cmb(i,K-1) % MOD;
		if(N-1-i >= K-1)
			r -= A.at(i) * cmb(N-1-i,K-1) % MOD;
		r %= MOD;
	}

	cout << r << endl;
}

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


void solve(long long N, std::vector<std::string> S){
    bool y_flag = false;
    for (int i=0; i<N; i++) {
        if (S[i] == "Y") {
            y_flag = true;
            break;
        }
    }
    if (y_flag) cout << "Four" << endl; else cout << "Three" << endl;
}

// 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(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 3672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                decimal[] input = Array.ConvertAll(Console.ReadLine().Split(' '), decimal.Parse);

                decimal ax = input[0], ay = input[1];
                decimal bx = input[2], by = input[3];
                decimal cx = input[4], cy = input[5];
                decimal dx = input[6], dy = input[7];

                sb.AppendLine((bx - ax) * (dy - cy) == (dx - cx) * (by - ay) ? "YES" : "NO");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9324
# import sys
# input = sys.stdin.readline
import collections
import itertools

def main():
    n, k = input_list()
    res = 0.0
    for v in range(n):
        i = v + 1
        t = 1.0
        ii = i
        while ii < k:
            ii *= 2
            t /= 2.0
        res += t

    res /= n
    print(res)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 67820
S = input()
INF = 10000000000000
T_S = INF
N = len(S)
for i in range(N - 1):
    if S[i] != S[i + 1]:
        T_S = min(T_S, max(i + 1, N - i - 1))
if T_S == INF:
    print(N)
else:
    print(T_S)


Measured memory_bytes: 3188
#include <stdio.h>
#define N 100000
int partition(int *A,int p,int r){
    int x,i,j,t;
    x = A[r];
    i = p-1;
    for(j = p;j < r; j++){
        if(A[j] <= x){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    return i + 1;
}

int main(){
    int i,q;
    int A[N],n;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    
    q = partition(A,0,n - 1);
    
    for(i=0;i<n;i++){
      if(i > 0) printf(" ");
      if(i == q) printf("[");
      printf("%d",A[i]);
      if(i == q) printf("]");
    }
    printf("\n");
  
  return 0;
}



Measured memory_bytes: 2120
from itertools import accumulate
N, M, K = map(int, input().split())
Nlist = [0]+list(map(int, input().split()))
Mlist = [0]+list(map(int, input().split()))
Asum = list(accumulate(Nlist))
Bsum = list(accumulate(Mlist))
count = 0
j = 0
for i in range(N, -1, -1):
    if K >= Asum[i]:
        while Asum[i]+Bsum[j] <= K:
            j += 1
            if j == M+1:
                break
        if count < i+j-1:
            count = i+j-1
    if j == M+1:
        break
print(count)


Measured memory_bytes: 47488
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 10000
int n;
long long a[N+5],b[N+5];
long long max(long long x,long long y) {
	return x > y ? x: y;
}
long long PD(long long p,long long q) {
	return (p+q-1)/q;
}
int main() {
	scanf("%d",&n);
	scanf("%lld %lld",&a[1],&b[1]);
	for(int i=2; i<=n; i++) {
		scanf("%lld %lld",&a[i],&b[i]);
		long long tmp=max(PD(a[i-1],a[i]),PD(b[i-1],b[i]));
		a[i]=a[i]*tmp;
		b[i]=b[i]*tmp;
	}
	printf("%lld",a[n]+b[n]);
}//

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

const int D=60;
const int MAX_N=200005;
int to[D+1][MAX_N];

int main(){
    ll n,k;
    cin >>n>>k;
    for (int i = 0; i < n; ++i) {
        cin >>to[0][i];
        to[0][i]--;
    }
    for (int j = 0; j < D; ++j) {
        for (int i = 0; i < n; ++i) {
            to[j+1][i]=to[j][to[j][i]];
        }
    }
    ll key=0;
    for (int i = D; i >=0; --i) {
        if(k>>i&1){
            key=to[i][key];
        }
    }
    cout <<key+1<<endl;
    return 0;
}

Measured memory_bytes: 51248
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数群
string S, T;
vector<string> vec;

//解法
void solve() {
	if (S.size() < T.size()) {
		cout << "UNRESTORABLE" << endl;
		return;
	}

	int cnt = S.size() - T.size() + 1;
	int cnt2 = T.size();
	rep(i, cnt) {

		bool ichi = true;
		rep(j, cnt2) {
			if (S[i + j] == '?' || S[i + j] == T[j]) {
			}
			else {
				ichi = false;
			}
		}
		if (ichi == true) {
			string S2 = S;
			rep(j, cnt2) {
				S2[i + j] = T[j];
			}
			rep(j, S2.size()) {
				if (S2[j] == '?') S2[j] = 'a';
			}
			vec.emplace_back(S2);
		}

	}
	if (vec.size() == 0) {
		cout << "UNRESTORABLE" << endl;
		return;
	}

	int ans = 0;
	rep(i, vec.size()) {
		if (vec[i] < vec[ans]) ans = i;
	}

	cout << vec[ans] << endl;
	return;
}

int main() {
	//入力
	cin >> S >> T;
	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())
if x>(a*a*b)/2:
  y=2*b-(2*x)/(a*a)
  ans=math.degrees(math.atan(y/a))
else:
  y=(2*x)/(a*b)
  ans=math.degrees(math.atan(b/y))
print(ans)

Measured memory_bytes: 3060
import java.util.*;
 
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long ans = Long.MAX_VALUE;
        for (long i = 1; i*i <= N; i++) {
            if (N%i == 0) {
                long a = i;
                long b = N/i;
                ans = Math.min(ans, a+b-2);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
N,K = map(int, input().split())
num = []
num.append(N)

if N > K:
    s = N // K
    N -= (K * s)
min = N
if K == 1:
    print(0)
else:
    while True:
        if K == 1:
            print(0)
            break
        N = abs(N - K)
        if  (N in num)  == True:
            print(min)
            break
        else:
            num.append(N)
            if N < min:
                min = N


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

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll x, y;
    cin >> x >> y;

    rep(turu, 101)rep(kame, 101){
        if(turu + kame == x && turu*2 + kame*4 == y){
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";
}

Measured memory_bytes: 3636
import sys
input=sys.stdin.readline

def main():
    _ = int(input())
    A = list(map(int, input().split()))
    pre = A[0]
    ans = 1
    state = 0
    for a in A:
        if state == 0:
            if a > pre:
                state = 1
            if a < pre:
                state = -1
        if state == 1:
            if a < pre:
                ans += 1
                state = 0
        elif state == -1:
            if a > pre:
                ans += 1
                state = 0
        pre = a
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14252
N = int(input())
H = list(map(int,input().split()))
ans = 'Yes'
for i in range(N):
    if i==0:
        H[0]-=1
    elif H[i]==H[i-1]:
        continue
    else:
        H[i]-=1
for i in range(1,N):
    if H[i]<H[i-1]:
        ans ='No'
print(ans)
    
    

Measured memory_bytes: 14224
N = int(input())
T = list(map(int,input().split()))
V = list(map(int,input().split()))
v = [0]*(sum(T)*2+1)
t,Ti = 0,0
for i in range(N):
    Ti += T[i]*2
    v[t] = min(v[t],V[i])
    while t < Ti:
        if v[t] < V[i]:
            v[t+1] = v[t]+0.5
        else:
            v[t+1] = min(v[t],V[i])
        t += 1
sumT = sum(T)*2
v[sumT] = 0
t,Ti = sumT,sumT
for i in range(N):
    Ti -= T[N-i-1]*2
    while t > Ti:
        if v[t-1] > v[t]+0.5:
            v[t-1] = v[t]+0.5
        t -= 1
Ans = 0
for i in range(sumT):
    Ans += (v[i]+v[i+1])*0.5/2

print(Ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
const string ok="YES";
const string ng="NO";

string ans = "AKIHABARA";
int main(){
    string s;
    cin>>s;
    int i=0;
    int id=0;
    while(id<ans.size()){
        if(i>=s.size()){
            if(ans[id]=='A'){
                id++;
            }
            else{
                cout<<ng<<endl;return 0;
            }
        }
        else if(s[i]==ans[id]){
            i++;
            id++;
        }
        else if(ans[id]=='A'){
            id++;
        }
        else{
            cout<<ng<<endl;
            return 0;

        }
    }
    if(i==s.size()){
        cout<<ok<<endl;
    }
    else cout<<ng<<endl;
    return 0;
}


Measured memory_bytes: 256
def rren(): return list(map(int, input().split()))
N = int(input())
R = rren()

print(" ".join(map(str, R)))
for i in range(1,N):
    take = R[i]
    j = i-1
    while j >= 0 and R[j] > take:
        R[j+1] = R[j]
        j -= 1
    R[j+1] = take
    print(" ".join(map(str, R)))

Measured memory_bytes: 7748
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC168D
//ABC168C
//ABC168B
int main(void) {
  int n, k, i, cou=0, tmp;
  char s[110];
  scanf("%d %s", &k, s);
  for(i=0; s[i]!='\0'; ++i)
    ; //文字数
  if(i<=k) printf("%s", s);
  else{
    for(i=0; i<k; i++){
      printf("%c", s[i]);
    }
    printf("...");
  }
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int mod=998244353;

int a[3010],dp[3010][3010];

signed main(){
    int n,s;
    cin>>n>>s;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    dp[0][0]=1;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<=s;j++){
            dp[i+1][j]+=2*dp[i][j];
            dp[i+1][j]%=mod;
            if(j+a[i]<=s){
                dp[i+1][j+a[i]]+=dp[i][j];
                dp[i+1][j+a[i]]%=mod;
            }
        }
    }
    
    cout<<dp[n][s]<<endl;
    return 0;
}

Measured memory_bytes: 74164
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

class Program
{
   

    static void Main(string[] args)
    {
        int ko = 0;
        var arr = arrInt();
        int n = arr[0];
        int x = arr[1];
        int t = arr[2];

        if (n % x == 0) ko = n / x;
        else ko = n / x + 1;

        int ans = ko * t;
        Console.WriteLine(ans);
        
    }

   
   

    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt(){return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();}
    static long[] arrLong(){ return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr(){return Console.ReadLine().Split(' ').ToArray();}
    static List<int[]> mapInt(int h)
    {
        List<int[]> mapInt = new List<int[]>();
        for (int i = 0; i < h; i++)
        {
            mapInt.Add(arrInt());
        }
        return mapInt;
    }

    static List<string[]> mapStr(int h)
    {
        List<string[]> mapStr = new List<string[]>();
        for (int i = 0; i < h; i++)
        {
            mapStr.Add(arrStr());
        }
        return mapStr;
    }

    static List<char[]> mapChar(int h)
    {
        List<char[]> mapChar = new List<char[]>();
        for (int i = 0; i < h; i++)
        {
            string s = crS();
            mapChar.Add(s.ToCharArray());
        }
        return mapChar;
    }

    static List<char[]> mapCharCopy(List<char[]> map)
    {
        List<char[]> copyMap = new List<char[]>();
        foreach (var arr in map)
        {
            List<char> list = new List<char>();
            foreach (var ele in arr)
            {
                list.Add(ele);
            }
            copyMap.Add(list.ToArray());
        }
        return copyMap;
    }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    int seven = 0;
    rep(i,k+5){
        seven = (seven * 10 + 7) % k;
        if(seven == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3620
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
d = inpl()
ans = 0
for i in range(N-1):
	for j in range(i+1, N):
		ans += d[i] * d[j]
print(ans)
	

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9188
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for i in range(n):
    left = min(a[i], b[i])
    a[i] -= left
    b[i] -= left
    ans += left

    right = min(a[i + 1], b[i])
    a[i + 1] -= right
    b[i] -= right
    ans += right

print(ans)


Measured memory_bytes: 19116
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = if (a*b) % 2 == 0 { "Even" } else { "Odd" };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",(a-1)*(b-1));
	return 0 ;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fast_input ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long int ll;
int main()
{
    fast_input;
    int n;
    cin>>n;
    int i;
    int a[n];
    for(i=0;i<n;i++)
      cin>>a[i];
    int cnt=0;
    int req=1;
    for(i=0;i<n;i++){
        if(a[i]==req)
          req++;
        else
          cnt++;
    }
    if(cnt==n)
    cout<<-1<<endl;
    else
    cout<<cnt<<endl;
}

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

int n, num[100];
unsigned long long dp[101][21];

int main(){
    scanf("%d", &n);
    for(int x = 0; x < n; x++){
        scanf(" %d", &num[x]);
    }
    dp[0][num[0]] = 1;
    for(int x = 1; x < n-1; x++){
        for(int y = 0; y <= 20; y++){
            if(!dp[x-1][y]) continue;
            if(y + num[x] <= 20) dp[x][y + num[x]] += dp[x-1][y];
            if(y - num[x] >= 0)  dp[x][y - num[x]] += dp[x-1][y];
        }
    }
    printf("%lld\n", dp[n-2][num[n-1]]);
    return 0;
}

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

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

int main() {
  int64_t N;
  int64_t count=0;
  int64_t money=100;
  
  cin >> N;
  
  while(true){
    money*=1.01;
    count++;
    if(money>=N)break;
  }
  cout << count << endl;
      
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		var S = Console.ReadLine();
		string ans = "A";
		if (S=="Sunny") ans = "Cloudy";
		if (S=="Cloudy") ans = "Rainy";
		if (S=="Rainy") ans = "Sunny";
		Console.WriteLine(ans);
		Console.ReadLine();
	}
}

Measured memory_bytes: 11092
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double W = sc.nextInt();
        double H = sc.nextInt();
        double x = sc.nextInt();
        double y = sc.nextInt();
        double S = W*H/2;
      
      if(W==x*2&&H==y*2){System.out.print(S+" "+1);}
      else{System.out.print(S+" "+0);}
      


      
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;

    int total = 1 << N;
    std::vector<int> S(total);
    for (int i=0; i<total; ++i) {
        std::cin >> S[i];
    }
    std::sort(S.begin(), S.end(), std::greater<int>());

    // HPのヒストグラム (HP降順)
    std::vector<int> hp;
    int prev = -1;
    int count = 0;
    for (int i=0; i<total; ++i) {
        if (prev == S[i]) {
            count += 1;
        } else {
            if (count > 0) {
                hp.push_back(count);
            }
            count = 1;
            prev = S[i];
        }
    }
    hp.push_back(count);

    std::vector<int> trees(N+1, 0);
    trees[N] = 1;

    auto findTree = [&]() {
        for (int j=N; j>=0; --j) {
            if (trees[j] > 0) {
                trees[j] -= 1;
                return j;
            }
        }
        return -1;
    };

    bool ok = true;
    for (int i=0; i<hp.size(); ++i) {
        std::vector<int> queue;
        int pop = hp[i];
        for (int ii=0; ii<pop; ++ii) {
            int t = findTree();
            if (t == -1) {
                ok = false; break;
            }
            queue.push_back(t);
        }
        if (!ok) break;
        for (int q=0; q<queue.size(); ++q) {
            for (int t=0; t<queue[q]; ++t) {
                trees[t] += 1;
            }
        }
    }

    std::cout << (ok ? "Yes" : "No") << std::endl;
    return 0;
}

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

int main(){ 
  int n;
  cin >> n;
  int res = 0;
  int cntA = 0, cntB = 0, cntAB = 0;
  rep(i,n) {
    string s;
    cin >> s;
    rep(i,sz(s)-1) {
      if (s[i] == 'A' && s[i+1] == 'B') res++;
    }
    if (s.front() == 'B' && s.back() == 'A') cntAB++;
    else if (s.front() == 'B') cntB++;
    else if (s.back() == 'A') cntA++;
  }
  res += max(cntAB - 1, 0);
  if (cntA > 0 && cntAB > 0) res++, cntA--;
  if (cntB > 0 && cntAB > 0) res++, cntB--;
  res += min(cntA, cntB);
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
H,W=map(int,input().split())
A=[list(input()) for _ in range(H)]
x=0
y=0
flag=1
cnt=0
for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            cnt=cnt+1

if cnt==W+H-1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

vector<double> x;
vector<double> y;

double dist(int i,int j){
    return pow((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]),0.5);
}

int main(){
    double n;
    cin >> n;
    x.resize(n);
    y.resize(n);
    vector<int> v(n);
    double ans=0;
    double fact=1;

    rep(i,n){
        cin >> x[i] >> y[i];
        v[i] = i;
        fact *= i+1;
    }

    do{
        for(int i=0; i<n-1; i++){
            ans+= dist(v[i],v[i+1]);
        }
    }
    while(next_permutation(v.begin(),v.end()));

    cout << fixed << setprecision(10) << ans/fact << endl;
}



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

using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(vr) vr.begin(),vr.end()
const int N=1e5+10;

struct edge {int u,v,w;};
int main()
{
    //freopen("ss.inp","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int L;
    cin>>L;
    int n=1;
    while ((1<<(n-1))<=L) n++;
    n--;
    vector<edge> ans;
    for (int i=1;i<n;i++)
    {
        ans.pb({i,i+1,0});
        ans.pb({i,i+1,1<<(n-i-1)});
    }
    int w=(1<<(n-1));
    for (int i=n-2;i>=0;i--)
        if ((L>>i)&1)
        {
            ans.pb({1,n-i,w});
            w+=(1<<i);
        }
    cout<<n<<" "<<ans.size()<<"\n";
    for (edge x : ans) cout<<x.u<<" "<<x.v<<" "<<x.w<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

const int N=2005;
const int M=4000005;
const int mod=1000000007;

int n,m,ans;
int dp[N][N],fac[M],inv[M];

int quickpow(int x,int y){
	int s=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) s=1ll*s*x%mod;
	return s;
}

void init(int n){
	int i,j;
	fac[0]=inv[0]=1;
	for (i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=quickpow(fac[n],mod-2);
	for (i=n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

int C(int x,int y){
	if (x<y) return 0;
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	if (m==1){
		printf("1\n");
		return 0;
	}
	init(M-5);
	dp[0][0]=1;
	for (i=0;i<=n;i++)
		for (j=0;j<=i;j++) if (dp[i][j]){
			(dp[i][j+1]+=dp[i][j])%=mod;
			(dp[i+1][j]+=1ll*dp[i][j]*C(i*(m-1)+j+m-2,m-2)%mod)%=mod;
		}
	ans=dp[n][n];
	for (i=1;i<=n;i++) ans=1ll*ans*i%mod;
	printf("%d\n",ans); 
	return 0;
} 

Measured memory_bytes: 47232
N,K = map(int,input().split())
a_ls = list(map(int, input().split()))
i_great = [0] * N
i_greatleft = [0] * N 

for i in range(N):
    for j in range(N):
        if a_ls[i] > a_ls[j]:
            i_great[i] += 1
            if i < j:
                i_greatleft[i] += 1
#print(i_great)
#print(i_greatleft)

ans = 0
mod = 10**9+7
K %= mod
times = ((K*(K-1))//2)%mod

for i in range(N):
    #print('------')
    #print(i)
    ans += (K*i_greatleft[i])%mod
    #print(K*i_greatleft[i])
    ans += (times*i_great[i])%mod
    #print(times*i_great[i])
    ans %= mod

print(ans)


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    bool flag = true;
    int cnt = 0;
    while (flag) {
        flag = false;
        for (int i = N-1; i > 0; i--) {
            if (A[i] < A[i-1]) {
                swap(A[i], A[i-1]);
                flag = true;
                cnt++;
            }
        }
    }
    cout << A[0];
    for (int i = 1; i < N; i++) {
        cout << ' ' << A[i];
    }
    cout << endl;

    cout << cnt << endl;

}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
int main()
{
    char a;
    cin >> a;

    if (65 <= a && a <= 90)
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using str = string;

int main(){
  str S; cin >> S;
  str T; cin >> T;
  int ans=0;
  for(int i=0; i<3; i++){
    if(S[i] == T[i]){
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int a=0,b=0;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s.substr(i,1)=="A"){
			a++;
		}else{
			b++;
		}
	}
	if(a==3||b==3){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  ll all=0;
  rep(i,n){ cin>>a[i]; }
  rep(i,n-1){
    all += abs(a[i]-a[i+1]);
  }
  all += abs(a[0])+abs(a[n-1]);
  
  cout << all-abs(a[0])-abs(a[0]-a[1])+abs(0-a[1]) << endl;
  for(int i=1; i<n-1; i++){
    int ans = all-abs(a[i]-a[i+1])-abs(a[i-1]-a[i])+abs(a[i-1]-a[i+1]);
    cout << ans << endl;
  }
  cout << all-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(0-a[n-2]) << endl;
  
  return 0;
}

Measured memory_bytes: 1664
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m,a,b,c,t;
V M(const V &x,const V &y){
	V z(n*n);
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(x[slice(i*n,n,1)]*y[slice(j,n,n)]).sum()%m;
	return z;
}
V E(const V &x,const int n){
	if(n==1)return x;
	if(n&1)return M(E(x,n-1),x);
	V y=E(x,n>>1);
	return M(y,y);
}
V s,x;
void O(const V &r){
	int i=0;
    for(;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	int i;
	s.resize(99);
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		//s.resize(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		x.resize(0);
		x.resize(n*n);
		if(t){
			x[0]=b;
			x[1]=c;
			for(i=1;i<n-1;i++){
				x[i*n+i-1]=a;
				x[i*n+i]=b;
				x[i*n+i+1]=c;
			}
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			O(E(x,t));
		}else{
			for(i=0;i<n;i++)x[i*n+i]=1;
			O(x);
		}
	}
}

Measured memory_bytes: 1080
//url:
//problem name:

#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() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(A > 0 || C > 0) {
        C -= B;
        if(C <= 0) break;
        A -= D;
    } 
    if(A > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3600
n,m = gets.split.map(&:to_i)
ls = m.times.map{gets.split.map(&:to_i)}

a = [ls[0][0],ls[0][1]]

ls.each do |b|
  if a[0] < b[0]
    a[0] = b[0]
  end
  if a[1] > b[1]
    a[1] = b[1]
  end
end

tmp = a[1] - a[0]
if tmp < 0
  puts 0
else
  puts tmp + 1
end


Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
int A[305][305];
int v[305][305];
int main () {
  cin >> N;
  ll sum = 0;
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      cin >> A[i][j];
      sum += A[i][j];
    }
  }
  cerr << sum << endl;
  for(int k = 0; k < N; ++k) {
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
        if (A[i][k] + A[k][j] < A[i][j]) {
          cout << -1 << endl;
          return 0;
        } else if (i != j && i != k && k != j && A[i][k] + A[k][j] == A[i][j] && A[i][j] != 0) {
          // cout << "i, j " << i << ' ' << j << endl;
          v[i][j] = 1;
        }
      }
    }
  }


  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      // cout << "i, j" << i << ' ' << j << endl;
      if (v[i][j] == 1) sum -= A[i][j];
    }
  }
  cout << sum / 2<< endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
//template <typename... T> void read(T& ... t){ ((cin >> t), ...); }
//template <typename... T> void write(T ... t){ ((cout << t), ...); }
//#define int long long
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define size(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ln '\n'
#define space ' '
using LL = long long;
using pii = pair<int,int>;
const int INF = 2e9;
const int NN = 2e3;
const int MOD = 998244353;
namespace Mm{
	inline int _chk(const LL &x){ return (x >= MOD) ? x%MOD : x; }
	inline int mul(const LL &x, const LL &y) { return _chk(x*y); }
	inline int add(const LL &x, const LL &y) { return _chk(x+y); }
	inline int power(const LL &x, const LL &n){ if(n == 0) return 1; int y=power(x, n>>1); y=mul(y,y); return (n&1)?mul(y,x):y; }
	inline int inv(const LL &x){ return power(x, MOD-2); }
	int _fact[2*NN] = {0};
	inline int fact(const int &x){ return (x == 0 ? 1 : (_fact[x] != 0 ? _fact[x] : _fact[x]=mul(x, fact(x-1)))); }
	int _cnk[2*NN+1][2*NN+1] = {0};
	inline int cnk(const int &n, const int &k){ return (n<k) ? 0 : _cnk[n][k]; }
} using namespace Mm;
int n,k;
int dp[NN+1][NN+1];
int nbPairs[2*NN+1];

#define read(a,b) cin>>a>>b
#define write(a,b) cout<<a<<b

int32_t main(){ FAST;
	for(int a=0; a<=2*NN; ++a) for(int b=0; b<=2*NN; ++b){
		if(b > a) _cnk[a][b] = 0;
		else if(b == 0) _cnk[a][b] = 1;
		else _cnk[a][b] = add(_cnk[a-1][b], _cnk[a-1][b-1]);
	}

	read(k,n);
	dp[0][0] = 1;
	for(int i=1; i<=NN; ++i){ // #pairs
		int prefSum = 0;
		for(int j=0; j<=NN; ++j){ // #items to distribute on pairs
			dp[i][j] = add(dp[i-1][j], add(prefSum, prefSum)); // k € [1;j]
			prefSum = add(prefSum, dp[i-1][j]);
		}
	}

	for(int i=1; i<=k; ++i) for(int j=i+1; j<=k; ++j) ++nbPairs[i+j];

	for(int i=2; i<=2*k; ++i){
		int ans = 0;
		int others = k - 2*nbPairs[i];

		if(i&1){
			if(others == 0){
				ans = dp[nbPairs[i]][n];
				write(ans, ln);
				continue;
			}

			for(int giveOthers=0; giveOthers<=n; ++giveOthers){
				int givePairs = n-giveOthers;
				ans = add(ans, mul(dp[nbPairs[i]][givePairs], cnk(others+giveOthers-1, giveOthers)));
			}
		}
		else{
			--others;
			if(others == 0){
				ans = add(dp[nbPairs[i]][n], dp[nbPairs[i]][n-1]);
				write(ans, ln);
				continue;
			}
			
			for(int giveOthers=0; giveOthers<=n; ++giveOthers){
				int givePairs = n-giveOthers;
				ans = add(ans, mul(dp[nbPairs[i]][givePairs], cnk(others+giveOthers-1, giveOthers)));
			}
			for(int giveOthers=0; giveOthers<=n-1; ++giveOthers){
				int givePairs = n-1-giveOthers;
				ans = add(ans, mul(dp[nbPairs[i]][givePairs], cnk(others+giveOthers-1, giveOthers)));
			}
		}

		write(ans, ln);
	}
}

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

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

int INF = 10000000;

int main() {
  int H, W;
  queue<int> que;
  char field[1005][1005];
  int dist[1005][1005];
  for(int i = 0; i < 1005; i++) {
    for(int j = 0; j < 1005; j++) {
      dist[i][j] = INF;
    }
  }
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> field[i][j];
      if(field[i][j] == '#') {
	dist[i][j] = 0;
	que.push(j); que.push(i);
      }
    }
  }

  while(que.size()) {
    int x = que.front(); que.pop();
    int y = que.front(); que.pop();
    for(int i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(0 <= nx && nx < W && 0 <= ny && ny < H && dist[ny][nx] == INF && field[ny][nx] != '#') {
	dist[ny][nx] = dist[y][x] + 1;
	field[ny][nx] = '#';
	que.push(nx); que.push(ny);
      }
    }
  }

  int max_dist = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(dist[i][j] != INF) {
	max_dist = max(max_dist, dist[i][j]);
      }
    }
  }
  cout << max_dist << endl;
  return 0;
}


Measured memory_bytes: 13328
a,b,c = map(int, input().split())
if a == 5 and b == 7 and c == 5:
    print("YES")
elif a == 5 and b == 5 and c == 7:
    print("YES")
elif a == 7 and b == 5 and c == 5:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
//#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<int>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
string s;
int a;
int main()
{
    cin>>a>>s;
    if(a>=3200)
        cout<<s<<endl;
    else
        cout<<"red"<<endl;
}


















Measured memory_bytes: 256
def main():
    A = list( map( int, input().split()))
    A.sort()
    if A[0] == A[1] and A[1] != A[2]:
        print("Yes")
        return
    if A[1] == A[2] and A[1] != A[0]:
        print("Yes")
        return
    print("No")
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N = gets.to_i

puts 8 if N >= 400 && N <= 599
puts 7 if N >= 600 && N <= 799
puts 6 if N >= 800 && N <= 999
puts 5 if N >= 1000 && N <= 1199
puts 4 if N >= 1200 && N <= 1399
puts 3 if N >= 1400 && N <= 1599
puts 2 if N >= 1600 && N <= 1799
puts 1 if N >= 1800 && N <= 1999


Measured memory_bytes: 14392
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var W = Number(inputs[0]);
    var H = Number(inputs[1]);
    var x = Number(inputs[2]);
    var y = Number(inputs[3]);
    var r = Number(inputs[4]);
  var x0 = W - x - r;
  var x1 = W - x + r;
  var y0 = H - y - r;
  var y1 = H - y + r;
  if ((x0 >= 0 && x1 <= W) && (y0 >= 0 && y1 <= H)) {
    console.log('Yes');
  } else {
    console.log('No');
  }
});

process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
int main()
{
    int n;
    cin >> n;
    bool flag = 0;
    if (n < 0) flag ^= 1;
    n = abs(n);
    if (n==0){
        cout << 0 << endl;
        return 0;
    }
    string ans = "";
    while (n > 0){
        ans += to_string(n%2);
        if (flag) n++;
        n >>= 1;
        flag ^= 1;
    }
    reverse(all(ans));
    cout << ans << endl;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int N[10];
main(){
    int a;
    for(int i = 0;i < 3;i++){
        cin >> a;
        N[a-1]++; 
    }
    if(N[4]==2&&N[6]==1)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 384