akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string.h>
#define Max 100005
#define LL long long
using namespace std;
int main()
{
    int  n,k;
    scanf("%d%d",&n,&k);
    if(n%k==0)
		printf("0\n");
	else
		printf("1\n");
    return 0;
}


Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
int n,k,a[100005];
bool flag[2];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	if(k>a[n-1]){
		cout<<"IMPOSSIBLE";
		return 0;
	}
	for(int i=0;i<n;i++){
		if(a[i]==k){
			cout<<"POSSIBLE";
			return 0; 
		}
	}
	for(int i=0;i<n-1;i++){
		if(a[i+1]!=a[i] && (a[i+1]-k)%(a[i+1]-a[i])==0){
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

def main():
    data = list(input())

    if data[0] == data[1] or data[1] == data[2] or data[2] == data[3]:
        print('Bad')
    else:
        print('Good')


if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

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

int N, M;
vector<string> c;
vector<vector<bool>> g;
vector<bool> used;

void dfs(int sx, int sy) {
  used[sx * M + sy] = true;
  for (int i = 0; i < 4; ++i) {
    int tx = sx + dx[i];
    int ty = sy + dy[i];
    if (0 <= tx && tx < N && 0 <= ty && ty < M) {
      if (used[tx * M + ty]) continue;
      if (c[tx][ty] == '.') dfs(tx, ty);
    }
  }
}

bool check() {
  used = vector<bool>(N * M, false);
  dfs(0, 0);
  for (auto&& p : vector<P>{{N - 1, 0}, {N - 1, M - 1}, {0, M - 1}}) {
    if (!used[p.first * M + p.second]) return false;
  }
  return true;
}

bool solve() {
  if (!check()) return false;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      if (i == N - 1 && j == 0) continue;
      if (i == N - 1 && j == M - 1) continue;
      if (i == 0 && j == M - 1) continue;
      if (c[i][j] == '#') continue;

      c[i][j] = '#';
      if (!check()) return false;
      c[i][j] = '.';
    }
  }
  return true;
}

int main() {
  while (cin >> N >> M, N) {
    c = vector<string>(N);
    for (int i = 0; i < N; ++i) cin >> c[i];
    cout << ( (solve()) ? "YES" : "NO" ) << endl;
  }
  return 0;
}



Measured memory_bytes: 3396
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#include <cmath>
#include <string.h>
#include <memory.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <bitset>

#define F first
#define S second
#define MP make_pair

typedef long long ll;

using namespace std;

int const PI = acos(-1);
int dx[] = { 0, 1, 0, -1 };
int dy[] = { 1, 0, -1, 0 };

long long gcd(long long a, long long b) {
	return b == 0 ? a : gcd(b, a % b);
}

long long lcm(long long a, long long b) {
	return a * (b / gcd(a, b));
}

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	
	if(s1[s1.length() - 1] == s2[0] && s2[s2.length() - 1] == s3[0])
	  cout << "YES" << endl;
	else
	  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n, d; cin >> n >> d;
  ll ans = 0;
  rep(i, n)
  {
    ll x, y;
    cin >> x >> y;
    if(x * x + y * y <= d * d) ans++;
  }
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(4); //高精度少数表示
  Main();
  return 0;
}


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

using namespace std;
typedef long long ll;

#define pf printf
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define REPSZ(i,v) REP(i,SZ(v))
#define pll pair <ll, ll>

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

ll n,m;
vector<ll> arr[2];

void print(vector <ll> &v){cout << v.size() << endl;for(int i = 0; i < v.size(); i++){pf("%lld ", v[i]);}pf("\n");}
void print(vector <pll> &v){ cout << v.size() << endl; for(int i = 0; i < v.size(); i++){pf("%lld %lld\n", v[i].first, v[i].second);}}
void print(set<ll> s){set <ll> :: iterator itr;for (itr = s.begin(); itr != s.end(); ++itr){cout << *itr << " ";}cout << endl;}
void print(double d){cout << fixed << setprecision(10) << d << endl;}

void from_file(void){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);}

/* ------------------main section-------------! */

void solve() {
    
}


void run() {
    fastio;
    ll n, Y;
    cin >> n >> Y;
    REP(x,n+1)
    {
        for(int y = 0; y+x <= n; y++)
        {
            int z = n-(x+y);
            if(x*10000 + y*5000 + z*1000 == Y){
                cout << x << " " << y << " " << z << endl;
                return;
            }
            if(x*10000 + y*5000 + z*1000 == Y) break;
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    
}


int main() {
    #ifndef ONLINE_JUDGE
        from_file();
    #endif
    run();
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int x;
    cin >> x;
    int ans = 1;
    for(int i=2;i<x;i++){
        int z=i;
        for(int j=1;j<x/2;j++){
            z = z * i;
            if(z<=x && ans < z){
                ans = z;
            }
        }
    }
    cout << ans << endl;
}


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

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

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

void slove(int n){
	vector<int> v(86400);
	rep(i, 86400) v[i] = 0;//?????????
	rep(i, n){
		string s, e;
		cin >> s >> e;
		//?§???°?????????
		int start = 36000 * (s[0] - '0') + 3600 * (s[1] - '0') 
					+ 600 * (s[3] - '0') + 60 * (s[4] - '0')
					+ 10 * (s[6] - '0') + 1 * (s[7] - '0');
		int end = 36000 * (e[0] - '0') + 3600 * (e[1] - '0') 
					+ 600 * (e[3] - '0') + 60 * (e[4] - '0')
					+ 10 * (e[6] - '0') + 1 * (e[7] - '0');
		//printf("%d %d\n", start, end);
		for (int j = start; j < end ; ++j) v[j]++;//???????????????
	}
	int ans;

	/*
	rep(i, 86400){
		ans = max(ans, v[i]);
	}
	*/
	sort(all(v));
	reverse(all(v));
	printf("%d\n", v[0]);
	return;
}
int main(void){
	rep(i, 100000000){
		int n; scanf("%d", &n);
		if(n == 0) break;
		slove(n);
	}
	return 0;
}

Measured memory_bytes: 3484
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    const int max_time = 1e5 + 1;
    int n, C; cin >> n >> C;
    vector<vector<int>> table(C, vector<int>(max_time, 0));
    rep(i, n) {
        int s, t, c; cin >> s >> t >> c;
        --c;
        table[c][s]++; table[c][t + 1]--;
    }

    rep(i, C) {
        rep(j, max_time) {
            table[i][j + 1] += table[i][j];
        }
    }

    int ans = 0;
    rep(j, max_time) {
        int cnt = 0;
        rep(i, C) {
            if (table[i][j]) ++cnt;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 12664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)    \
    vl v;               \
    rep(i, n)           \
    {                   \
        ll x;           \
        cin >> x;       \
        v.push_back(x); \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
#include <cstdint>

template <std::uint_fast64_t Modulus>
class modint
{
    using u64 = std::uint_fast64_t;

public:
    u64 a;

    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept
    {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept
    {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept
    {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept
    {
        return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept
    {
        a += rhs.a;
        if (a >= Modulus)
        {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept
    {
        if (a < rhs.a)
        {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept
    {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept
    {
        u64 exp = Modulus - 2;
        while (exp)
        {
            if (exp % 2)
            {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

using mint = modint<MOD>;
int main()
{
    cin>>n;
    inputv(A,n);
    vector<mint> B(n),C(n);
    rep(i,n-1){
        B[i]=A[n-i-1]-A[n-i-2];
    }
  mint k=0;
  rep(i,n-1){
    k+=B[i];
    C[i]=k;
  }
    mint T=1,K=0,P=0,Q;
    rep(i,n-1){
        T*=(i+1);
    }
  
  Q=T;

    rep(i,n-1){
      P+=T/(i+1);
      K+=P*B[n-2-i];
    }

    cout<<K.a<<endl;
}

Measured memory_bytes: 2676
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <string>
#include <iostream>
#include <bitset>
#define PII pair <int, int>
#define PPI pair <PII, int>
#define x first
#define y second
#define M 200010

using namespace std;

char ch[200010];

int n;

int Lf[200010], Ri[200010];

int main() {
    scanf("%d", &n);
    scanf("%s", ch + 1), n = strlen(ch + 1);
    for(int i = 1; i <= n; i++) Lf[i] = Lf[i - 1] + (ch[i] == '#');
    for(int i = n; i >= 1; i--) Ri[i] = Ri[i + 1] + (ch[i] == '.');
    int ans = n;
    for(int i = 1; i <= n + 1; i++)
        ans = min(ans, Lf[i - 1] + Ri[i]);
    printf("%d\n", ans);
}

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

#define LL long long

LL n,ki,ka,mid,y,ans,ac,cc,a[100100],b[100100],c[100100];

LL fa(LL y){
    ki=-1;
    ka=n;
    while(ka-ki>1){
    	mid=(ki+ka)/2;
    	if(a[mid]>=y){
    		ka=mid;
    	}else ki=mid;
    }
    return ki+1;
}
LL fc(LL y){
    ki=-1;
    ka=n; 
    while(ka-ki>1){
    	mid=(ki+ka)/2;
    	if(c[mid]>=y){
    		ka=mid;
    	}else ki=mid;
    }
    return n-ka;
}
     
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    for(int i=0;i<n;i++){
    	cin>>b[i];
    }
    for(int i=0;i<n;i++){
    	cin>>c[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    ans=0;
    for(int i=0;i<n;i++){
    	y=b[i];
    	ac=fa(y);
        cc=fc(y+1);
    	ans=ans+(ac*cc);
    }
    cout<<ans<<endl;
}

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

int main(void){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i< n; ++i){
		cin >> a[i];
	}
	for(int i = 0; i < 30; ++i){
		for(int j = 0; j < n; ++j){
			if(a[j]%2==1){
				cout << i << endl;
				return 0;
			}
			a[j] /= 2;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, m;
    int in, im;
    cin >> n >> m;
    in = max(n - 2, 0);
    im = max(m - 2, 0);
    if (n == 1 && m == 1)
    {
        cout << '1' << endl;
    }
    else if (n == 1)
    {
        cout << im << endl;
    }
    else if (m == 1)
    {
        cout << in << endl;
    }
    else
    {
        cout << (long long)in * im << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define int long long
#define ve vector<int>
#define mod 1000000007
#define eb emplace_back
#define inf ((long long) 1e18 )
#define all(x) (x).begin(),(x).end()
#define debug(x) cout << '>' << #x << ':' << x << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug2(x,y) cout << '>' << #x <<" = "<< x <<" & "<< #y <<" = "<< y << '\n';
#define fileIO freopen("input.txt", "r", stdin); freopen("output2.txt", "w", stdout);
using namespace std;
const int N = 1e6 + 7;

int32_t main()
{
	IOS
#ifndef ONLINE_JUDGE
	fileIO
#endif
	int t;
	t = 1;
	while (t--) {
		int x;
      	cin >> x;
      	if(x >= 30)
          	cout << "Yes\n";
      	else
          	cout << "No\n";
	}
	return 0;
}


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

int main() {
  long long A,B,C,D,E,N;
  cin >> N >> A >> B >> C >> D >> E;
  long long k=min(min(min(min(A,B),C),D),E);
  cout << 5+(N-1)/k << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
  
class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringBuilder out = new StringBuilder();
    static ArrayDeque<Integer> li = new ArrayDeque<Integer>();
  
    public static void main(String[] Args) throws IOException {
        int n = Integer.parseInt(br.readLine());
        String in;
        int key;
        for(int i=0; i<n; i++) {
            in = br.readLine();
            if(in.charAt(0) == 'i') {
                key = Integer.parseInt(in.substring(7));
                li.addFirst(key);
            } else if(in.charAt(6) == 'F') {
                li.removeFirst();
            } else if(in.charAt(6) == 'L') {
                li.removeLast();
            } else {
                key = Integer.parseInt(in.substring(7));
                li.remove((Integer) key);
            }
        }
        out.append(li.poll());
        for(int num : li) {
            out.append(' ').append(num);
        }
        out.append('\n');
        System.out.print(out);
    }
  
}

Measured memory_bytes: 124584
import sys
import math

N = int(input())

if N < 105:
    print(0)
    sys.exit()

odd_num = 105
result = 0

while odd_num <= N:
    divisor_count = 0
    for i in range(1, odd_num + 1):
        if odd_num % i == 0:
            divisor_count += 1

    if divisor_count == 8:
        result += 1
        
    odd_num += 2

print(result)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		solve(scanner);
		scanner.close();
	}
	
	public static void solve(Scanner scanner) {
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
	}
}


Measured memory_bytes: 20692
# -*- coding:utf-8 -*-
"""解説
https://www.youtube.com/watch?v=L8grWxBlIZ4

PDFに書いてある実装をする。

....#.
..#...
.#..#.

それぞれのマスについて、

・左マスを照らせる個数: L[i][j]
・右マスを照らせる個数: R[i][j]
・上マスを照らせる個数: U[i][j]
・下マスを照らせる個数: D[i][j]

をそれぞれ計算する。

左マスを照らす漸化式L[i][j]は、

・i行j列に障害物がある場合はL[i][j] = 0
・そうでないとき、j=1ならば、L[i][j] = 1
・そうでないとき、j>1ならば、L[i][j] = L[i][j-1] + 1

求める答えは、L[i][j]+R[i][j]+U[i][j]+D[i][j]-3 の最大値


計算量はO(HW)。

H,W = 2000なので、O(HW)はO(4*10**6)。 Pythonでこの計算量は無理だろと思って実装を諦めたが、いけるっぽい。認識を改めた。というかPyPyもあるし。

と思ったら普通に無理だった。

numpyを使ったらfor文を一個減らせる。計算量が減ったかどうかは内部処理によるので知らんけどACした。結論：numpyの行列計算は速い。

"""
import numpy as np

def solve():
    H, W = list(map(int, input().split()))
    grid = []
    for i in range(H):
        grid.append(list(input()))
    grid = (np.array(grid) == ".") * 1  # ランプをおける:1, 障害物:0

    L = np.zeros((H,W), dtype=int)
    R = np.zeros((H,W), dtype=int)
    U = np.zeros((H,W), dtype=int)
    D = np.zeros((H,W), dtype=int)
    
    for j in range(W):
        if j == 0:
            L[:, j] = grid[:, j]
        else:
            L[:, j] = (L[:, j-1] + 1) * grid[:, j]
    
    for j in range(W-1, -1, -1):
        if j == W-1:
            R[:, j] = grid[:, j]
        else:
            R[:, j] = (R[:, j+1] + 1) * grid[:, j]

    for i in range(H):
        if i == 0:
            U[i] = grid[i] * 1
        else:
            U[i] = (U[i-1] + 1) * grid[i]
    
    for i in range(H-1, -1, -1):
        if i == H-1:
            D[i] = grid[i]
        else:
            D[i] = (D[i+1] + 1) * grid[i]

    ans = np.max(L+R+U+D-3)
    print(ans)


if __name__ == "__main__":
    solve()


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

int main(void) {
	string N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N.size(); i++) {
		if (N[i] == '2') ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3696
import scala.io.{StdIn => in}
import scala.annotation.tailrec

object Main extends App {
  val Array(_, k) = in.readLine.split(" ").map(_.toInt)
  val a = in.readLine.split(" ").map(_.toInt)
  
  @tailrec
  def gcd(a:Int, b:Int):Int = {
    if(b == 0) a
    else gcd(b, a%b)
  }

  val res = a.reduce( gcd )
  val diff = a.filter(_ >= k).map(_ - k)

  val ans = diff match {
    case d if(d.isEmpty) => "IMPOSSIBLE"
    case d if(d.exists(_ % res == 0)) => "POSSIBLE"
    case _ => "IMPOSSIBLE"
  }

  println(ans)
}

Measured memory_bytes: 42508
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<s.size();i++)
  {
    if((s[i]=='R'||s[i]=='U'||s[i]=='D')&&i%2==0)
      cnt++;
    else if((s[i]=='L'||s[i]=='U'||s[i]=='D')&&i%2==1)cnt++;
  }
  if(cnt==s.size())cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}



Measured memory_bytes: 256
def bubble(n,c):
    for i in range(n):
        ch=True
        for j in range(n-1,i,-1):
            if int(c[j][1])<int(c[j-1][1]):
                c[j],c[j-1]=c[j-1],c[j]
                ch=False
        if ch:
            break
    return c

def selection(n,c):
    for i in range(n-1):
        id=i
        for j in range(i,n):
            if int(c[id][1])>int(c[j][1]):
                id=j
        c[i],c[id]=c[id],c[i]
        
    return c


n=int(input())
c=list(input().split())
c2=c[:]
ba=bubble(n,c2)
print(*ba)
print("Stable")
sa=selection(n,c)
print(*sa)
print("Stable" if sa==ba else "Not stable")


Measured memory_bytes: 5616
//sorting three numbers

#include<iostream>
using namespace std;
int main ()
{
int a,b,c,swap;
cin>>a>>b>>c;
if (a>b){
swap=a;a=b;b=swap;}
if (b>c){
swap=b;b=c;c=swap;}
if (a>b){
swap=a;a=b;b=swap;}
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, K, R, S, P;
    string T, V;
    ll X = 0;
    cin >> N >> K >> R >> S >> P >> T;
    for (int i=0;i<K;i++) {
        switch (T[i]) {
        case 'r':
            V += 'p';
            X += P;
            break;
        case 's':
            V += 'r';
            X += R;
            break;
        case 'p':
            V += 's';
            X += S;
            break;
        default:
            break;
        }
    }
    for (int i=K;i<N;i++) {
        switch (T[i]) {
        case 'r':
            if (V[i-K] == 'p') {
                V += '+'; // + means r or s
            } else {
                if (V[i-K] == '-') V[i-K] = 's';
                else if (V[i-K] == '*') V[i-K] = 'r';
                V += 'p';
                X += P;
            }
            break;
        case 's':
            if (V[i-K] == 'r') {
                V += '-'; // - means s or p
            } else {
                if (V[i-K] == '+') V[i-K] = 's';
                else if (V[i-K] == '*') V[i-K] = 'p';
                V += 'r';
                X += R;
            }
            break;
        case 'p':
            if (V[i-K] == 's') {
                V += '*'; // * means p or r
            } else {
                if (V[i-K] == '+') V[i-K] = 'r';
                else if (V[i-K] == '-') V[i-K] = 'p';
                V += 's';
                X += S;
            }
            break;
        default:
            break;
        }
    }
    cout << X << endl;

    return 0;
}


Measured memory_bytes: 640
X = int(input())
price = [100, 101, 102, 103, 104, 105]

dp = [False for _ in range(X + 1)]

dp[0] = True
for i in range(1, X + 1):
    for j in range(6):
        if i - price[j] >= 0:
            if dp[i - price[j]]:
                dp[i] = True
                break
    else:
        dp[i] = False

if dp[X]:
    print(1)
else:
    print(0)

Measured memory_bytes: 9776
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int L, R, D;
	cin >> L >> R >> D;

	int ans = 0;
	for (int i = L; i <= R; ++i)
	{
		if (i % D == 0) ans++;
	}

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

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***スニペット***
ifelse, isprime, torad, todeg, lcm, bfs
****************/

//隣接リスト
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    bool flag1=1,flag2=1;
    string s; cin >> s;
    int n=s.size();
    rep(i,0,n){
        if(i%2==0){
            if(s[i]=='R' || s[i]=='U' || s[i]=='D'){
                flag1=1;
            }else{
                flag1=0;
                break;
            }
        }else{
            if(s[i]=='L' || s[i]=='U' || s[i]=='D'){
                flag2=1;
            }else{
                flag2=0;
                break;
            }
        }
    }

    if(flag1&&flag2) cout << "Yes" ENDL;
    else cout << "No" ENDL;
    
    return 0;
}

Measured memory_bytes: 5940
L, R = map(int, input().split())

if R - L > 2019:
    print(0)
else:
    l = L % 2019
    r = R % 2019
    ans = 10000000
    if r > l:
        for i in range(l, r):
            for k in range(i+1, r+1):
                if ans > (i * k) % 2019:
                    ans = (i * k) % 2019
        print(ans)
    else:
        print(0)

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

int main() {
	int p[3], j[2], sum, min=10000;
	cin >> p[0] >> p[1] >> p[2] >> j[0] >> j[1];
	for(int a=0; a<3; a++){
		for(int b=0; b<2; b++){
			sum = p[a] + j[b] - 50;
			if(min>sum) min = sum;
		}
	}
	cout << min << endl;
	return 0;
}


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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

double calc(double a, double b, double t) {
    double rad = t * (M_PI / 180);
    double rad90 = (90 - t) * (M_PI / 180);
    double ret = 0;

    if (a * sin(rad) < b * sin(rad90)) {
        ret = a * a * a * tan(rad) * 0.5 + a / cos(rad) * (b * sin(rad90) - a * sin(rad)) * a;
    } else {
        ret = (b * sin(rad90) / sin(rad)) * b * 0.5 * a;
    }

    return ret;
}

signed main() {
    double a, b, x;
    cin >> a >> b >> x;

    double left = 0;
    double right = 90;

    while (right - left >= 0.0000001) {
        double mid = (right + left) / 2;
        double v = calc(a, b, mid);

        if (v < x) {
            right = mid;
        } else {
            left = mid;
        }
    }
    // double ans = calc(3, 1, 4.2363947991);

    cout << setprecision(10) << left << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
	int N,ans=0,len1,len2,cnt;
	char store[26],str[101];
	cin>>N;
	cin>>store;
	len1=strlen(store);
	for(int i=0;i<N;i++){
		cin>>str;
		len2=strlen(str);
		for(int j=0;j<len2;j++){
			for(int k=1;;k++){
				cnt=0;
				for(int l=0;l<len1;l++){
					//printf("%d %d %d\n",j,k,l);
					if(l*k+j>=len2) goto NEXT;
					if(str[l*k+j]==store[l]) cnt++;
				}
				if(cnt==len1){
					//printf("!!!!\n");
					ans++;
					goto END;
				}
			}
			NEXT:;
		}
		END:;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<endl
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll calc(ll k,ll d) {
  return k*(k+1)/2*d;
}

const ll n=26;
ll c[n],q[444];
ll a[444][n];
set<ll> s[n];

ll solve(ll x,ll y) {
  ll ans=0;
  {
    ans-=a[x][q[x]];
    iter(s[q[x]]) it2=s[q[x]].lower_bound(x);
    iter(s[q[x]]) it1=it2,it3=it2;it1--,it3++;
    ans+=calc(*it2-*it1-1,c[q[x]]);
    ans+=calc(*it3-*it2-1,c[q[x]]);
    ans-=calc(*it3-*it1-1,c[q[x]]);
    s[q[x]].erase(it2);
  }
  {
    q[x]=y;
    s[q[x]].in(x);
    ans+=a[x][q[x]];
    iter(s[q[x]]) it2=s[q[x]].lower_bound(x);
    iter(s[q[x]]) it1=it2,it3=it2;it1--,it3++;
    ans-=calc(*it2-*it1-1,c[q[x]]);
    ans-=calc(*it3-*it2-1,c[q[x]]);
    ans+=calc(*it3-*it1-1,c[q[x]]);
  }
  return ans;
}

         
void Main() {
  srand((unsigned)time(NULL));
  int T;
  R T;
  rep(i,n) R c[i];
  rep(i,T)rep(j,n) R a[i][j];
  rep(i,n) s[i].in(-1),s[i].in(T);
  rep(k,T) {
    ll x=rand()%n;
    q[k]=x;
    s[x].in(k);
  }
  ll ans[T];
  mem(ans);
  clock_t t2=clock();
  for(int tt=0;;tt++) {
    ll e[2][3],sum=0;
    rep(i,2) {
      ll x=rand()%T,y=rand()%n;
      e[i][0]=q[x],e[i][1]=x,e[i][2]=y;
      sum+=solve(x,y);
    }
    if(sum<0) {
      rrep(i,2) {
        int x=e[i][1];
        s[q[x]].erase(x);
        q[x]=e[i][0];
        s[q[x]].in(x);
      }
    } else {
      rep(i,2) ans[e[i][1]]=e[i][2];
    }
    clock_t t3=clock();
    double t4=(double)(t3-t2)/CLOCKS_PER_SEC;
    if(tt>=2&&(double)t3/CLOCKS_PER_SEC+t4*2>1.900) break;
    t2=t3;
  }
  rep(i,T) pr(ans[i]+1);
}

int main(){Main();return 0;}


Measured memory_bytes: 3744
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

int N;
char S;
bool ok;
int main() {
    cin>>N;
    REP(i,0,N){
        cin>>S;
        if(S=='Y') ok=true;
    }
    if(!ok){
        p("Three");
    }else{
        p("Four");
    }

    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

ll gcd(ll a, ll b) {
	if (b > a) {
		swap(a, b);
	}
	ll r = a%b;
	while (r != 0) {
		a = b;
		b = r;
		r = a%b;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return (a / gcd(a, b))*b;
}



int main() {
	ll n;
	int i, j;
	cin >> n;
	vl t(n);
	for (i = 0; i < n; i++) {
		cin >> t[i];
	}
	ll ans = 1;
	for (i = 0; i < n; i++) {
		ans = lcm(ans, t[i]);
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int numTrains [510][510];
int pre [510][510];
int preQuery (int x1, int y1, int x2, int y2) {
  return pre[x2][y2] - pre[x2][y1 - 1] - pre[x1 - 1][y2] + pre[x1 - 1][y1 - 1];
}
int main() {
  int N, M, Q; cin >> N >> M >> Q;
  for(int i = 0; i < M; i++) {
    int L, R; cin >> L >> R;
    numTrains[L][R]++;
  }
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= N; j++) {
      pre[i][j] = pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1] + numTrains[i][j];
    }
  }
  for(int i = 0; i < Q; i++) {
    int p, q; cin >> p >> q;
    cout << preQuery(p, p, q, q) << endl;
  }
}

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

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(std::vector<long long> x)
{
  for (int i = 0; i < 5; i++)
    if (x[i] == 0)
      cout << i + 1 << endl;
}

int main()
{
  cout << setprecision(10);
  std::vector<long long> x(5);
  for (int i = 0; i < 5; i++)
  {
    scanf("%lld", &x[i]);
  }
  solve(std::move(x));
  return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[1000],t[1000];
	int len_s,len_t;
	int cnt,change=1001;

	scanf("%s",s);
	scanf("%s",t);
	len_s = strlen(s);
	len_t = strlen(t);

	for(int i=0;i<len_s - len_t + 1;i++){
		cnt = 0;
		for(int j=i;j<i+len_t;j++){
			if(s[j] != t[j-i]){
				cnt = cnt+1;
			}
		}
		if(cnt < change){
			change = cnt;	
		}
	}
	printf("%d\n",change);
	return 0;
}

Measured memory_bytes: 2112
s = input()
a = [0]
for i in s:
    if i == "<":
        a.append(a[-1] + 1)
    else:
        a.append(0)
b = [0]
for i in reversed(s):
    if i == ">":
        b.append(b[-1] + 1)
    else:
        b.append(0)
b.reverse()

c = [max(i, j) for i, j in zip(a, b)]
print(sum(c))


Measured memory_bytes: 99084
/*
https://abc106.contest.atcoder.jp/
*/

#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
using namespace std;



int main()
{
 	ios::sync_with_stdio(false);
	int N;
	int i,j,k;
	while(cin>>N)
	{
		if(N<105)
		{
			cout<<"0"<<endl;
			continue;
		}
		if(N<135)
		{
			cout<<"1"<<endl;
			continue;
		}
		if(N<165)
		{
			cout<<"2"<<endl;
			continue;
		}
		if(N<189)
		{
			cout<<"3"<<endl;
			continue;
		}
		if(N<195)
		{
			cout<<"4"<<endl;
			continue;
		}
		cout<<"5"<<endl;
		
		
		
		
		
	}
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B_Comparing_Strings.exe B_Comparing_Strings.cpp 
Execute: ./B_Comparing_Strings
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <iomanip>
#include <cstring> 
using namespace std;

int main() { 	
	int a, b;
	cin >> a >> b;
	
	int c_min, c_max; 
	c_min = min(a, b); 
	c_max = max(a, b); 
	
	for(int i = 0; i < c_max; i++) { 
		cout << c_min;  
	} 
	cout << endl; 
	
	return 0; 
} 


Measured memory_bytes: 256
#include <iostream>


int main(void){
	int X, Y;
	std::cin >> X >> Y;

	for(int i = 0; i <= X; i++){
		if(2 * i + 4 * (X - i) == Y){
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	std::cout << "No" << std::endl;

	return 0;
}


Measured memory_bytes: 3568
n, x, y = map(int, input().split())

ans = [0] * n
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        ans[min(j - i, min(abs(i - x) + 1 + abs(y - j),
                           abs(i - y) + 1 + abs(x - j)))] += 1

for x in ans[1:]:
    print(x)


Measured memory_bytes: 3572
import java.util.Scanner;

class Main
{

    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int h1 = sc.nextInt();
        int h2 = sc.nextInt();
        int k1 = sc.nextInt();
        int k2 = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int hiroshi = h1 * a + h2 * b + h1 / 10 * c + h2 / 20 * d;
        int kenjiro = k1 * a + k2 * b + k1 / 10 * c + k2 / 20 * d;

        if (hiroshi > kenjiro) {
            System.out.println("hiroshi");
        } else if (hiroshi < kenjiro) {
            System.out.println("kenjiro");
        } else {
            System.out.println("even");
        }
    }

}



Measured memory_bytes: 26228
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,sum=0;
    int d[55];
    cin>>n;
    for(int i=0;i<n;i++) cin>>d[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++) sum+=d[i]*d[j];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()
    val stack = LinkedList<Char>()
    for (c in s) {
        if (c == 'T') {
            if (stack.lastOrNull() == 'S') {
                stack.removeLast()
            } else {
                stack.addLast(c)
            }
        }  else {
            stack.addLast(c)
        }
    }
    out.println(stack.size)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 43344
#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y, int z){
    int t = min(x, min(y, z));
    int a = 0;
    for(int i = 1; i * i <= t; i++){
        if(t % i == 0){
            int s = t / i;
            if(x % s == 0 && y % s == 0 && z % s == 0) a = max(a, s);
            if(x % i == 0 && y % i == 0 && z % i == 0) a = max(a, i);
        }
    }
    return a;
}
int main(){
    long long K;
    cin >> K;
    long long ans = 0;
    for(int i = 1; i < K + 1; i++){
        for(int j = 1; j < K + 1; j++){
            for(int k = 1; k < K + 1; k++){
                ans += gcd(i, j, k);
            }
        }
    }
    cout << ans << endl;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  int n; cin >> n;
  int v[n]; rep(i,n) cin >> v[i];
  sort(v, v+n);
  double res = v[0];
  REP(i, 1, n){
    res = (res + v[i]) / 2.0;
  }
  printf("%.6lf", res);
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    int n,q;
    string s;

    cin >> n >> q >> s;
    
    int count[n] = {0};
    FOR(i, n-1){
        count[i+1] = count[i] + (s.substr(i, 2) == "AC");
    }

    int v1,v2;
    FOR(i, q){
        cin >> v1 >> v2;
        cout << count[v2 -1] - count[v1-1] << endl;
    }

    return 0;
}


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

int main(){
  int N, num = 0, voted = 1, win = 1, ans = 0 ;
  cin >> N ;
  string name[N] ;
  for(int i=0;i<N;i++){
    cin >> name[i] ;
  }  
  sort(name, name+N) ;
  for(int i=0;i<(N-1);i++){
    if(name[i]==name[i+1]){
      voted++ ;
      win = max(win, voted) ;
    }  
    else voted = 1 ;
  }  
  if(win == 1){
    for(int i=0;i<N;i++){
      cout << name[i] << endl ;
    }  
  }
  else{
    voted = 1 ;
    for(int i=0;i<(N-1);i++){
      if(name[i]==name[i+1]){
        voted++ ;
        if(voted == win){
          cout << name[i] << endl ;
        }  
      }  
      else voted = 1 ;
    }  
  }  
  return 0 ;
}

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

int main() {
	string S;
	cin >> S;
	int ans=1000;
	for (int i = 0; i < S.size() - 2; i++) {
		int diff;
		diff = 753 - stoi(S.substr(i, 3));
		ans = min(ans, abs(diff));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  string S;
  cin >> S;
  int a{};
  for (int i = 0, n = S.size(); i != n; ++i ) {
    a += (i%2 == (S[i]-'0'));
  }
  cout << min(a,(int)S.size()-a) << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[][] A = new long[N][N];
		long[][] a = new long[N][N];
		for(int i=0; i<N; i++) {
			for(int j=0; j<N; j++) {
				long temp = sc.nextLong();
				A[i][j] = temp;
				a[i][j] = temp;
			}
		}
		sc.close();
		for(int k=0; k<N; k++) {
			for(int i=0; i<N; i++) {
				for(int j=0; j<N; j++) {
					if(i != j && A[i][k] + A[k][j] < A[i][j]) {
						System.out.println(-1);
						return;
					}
				}
			}
		}
		long ans = 0;
		for(int i=0; i<N; i++) {
			for(int j=0; j<N; j++) {
				boolean flag = true;
				for(int k=0; k<N; k++) {
					if(k!=i && k!=j && a[i][j] == a[i][k]+a[k][j]) {
						flag = false;
						break;
					}
				}
				if(flag) {
					ans += a[i][j];
				}
			}
		}
		System.out.println(ans/2);
	}

}


Measured memory_bytes: 63144
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    if(a[0]!=0) cout << -1 << endl;
    else{
        rep(i,n-1){
            if(a[i+1]-a[i] >= 2){
                ans = -1;
                break;
            }else{
                if(a[i+1]-a[i]==1) ans++;
                else ans += a[i+1];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    double N; cin >> N;
    cout << fixed << setprecision(7) << N*N*M_PI << " " << 2*M_PI*N << endl;

    return 0;
}


Measured memory_bytes: 3276