akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll ll_inf = ll(1e9) * ll(1e9);

#define REP(i, n) for (ll i = 0; i < (ll)(n); ++i)

int main()
{
    ll H, W;
    cin >> H >> W;
    ll startX, startY, endX, endY;
    cin >> startX >> startY >> endX >> endY;
    startX--, endX--, startY--, endY--;

    vector<vector<char>> s(H, vector<char>(W));
    REP(i, H)
    REP(j, W)
    cin >> s[i][j];

    // 魔法を使った回数
    vector<vector<ll>> cnts(H, vector<ll>(W, ll_inf));
    queue<P> q, visited;
    q.push(P(startX, startY));
    cnts[startX][startY] = 0;

    while (!q.empty() || !visited.empty())
    {
        ll nowX, nowY;
        if (!q.empty())
        {
            nowX = q.front().first;
            nowY = q.front().second;

            visited.push(P(nowX, nowY));
            q.pop();
            REP(i, 4)
            {
                ll nextX = nowX + dx[i];
                ll nextY = nowY + dy[i];
                if (0 <= nextX && nextX <= H - 1 && 0 <= nextY && nextY <= W - 1)
                {
                    if (s[nextX][nextY] == '#')
                        continue;
                    if (cnts[nowX][nowY] < cnts[nextX][nextY])
                    {
                        cnts[nextX][nextY] = cnts[nowX][nowY];
                        q.push(P(nextX, nextY));
                    }
                }
            }
        }
        else
        {
            nowX = visited.front().first, nowY = visited.front().second;
            visited.pop();
            for (ll ix = -2; ix <= 2; ++ix)
            {
                for (ll iy = -2; iy <= 2; ++iy)
                {
                    ll nextX = nowX + ix, nextY = nowY + iy;
                    if (0 <= nextX && nextX <= H - 1 && 0 <= nextY && nextY <= W - 1)
                    {
                        if (s[nextX][nextY] == '#')
                            continue;
                        if (cnts[nowX][nowY] + 1 < cnts[nextX][nextY])
                        {
                            cnts[nextX][nextY] = cnts[nowX][nowY] + 1;
                            q.push(P(nextX, nextY));
                        }
                    }
                }
            }
        }
    }

    if (cnts[endX][endY] == ll_inf)
    {
        cout << -1 << '\n';
    }
    else
    {
        cout << cnts[endX][endY] << '\n';
    }
    return 0;
}

Measured memory_bytes: 12516
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multe int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T s){while(n--)cin >> *s, ++s;}
template<typename T> void write(int n, T s){while(n--)cout << *s << " \n"[n==0], ++s;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
ll n, k;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;	
	if(k == 0)eout(n * n);
	ll res = 0;
	for(int b = k+1;b <= n;++b){
		int o = res;
		for(int l = k, v = b;;v += b, l += b){
			if(v >= n){
				res += max(0ll, n-l+(n%b != 0));
				break;
			}
			else res += v-l;
		}
		// dout(b)<< res-o << '\n';
	}
	cout << res << '\n';
}

Measured memory_bytes: 256
a,b,x = map(int,input().split())
import math

if x <= a **2 * b / 2:
    tan_theta = 2 * x / (a * b ** 2)
    radian = math.atan(tan_theta)
    degrees = 90 - math.degrees(radian)

    print(degrees)
else:
    tan_theta = 2 * b / a - 2 * x / a**3
    radian = math.atan(tan_theta)
    degrees = math.degrees(radian)
    print(degrees)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 

def main():
    n=int(input())
    a=list(map(int, input().split()))
    pre2 = (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 73741817, 147483634, 294967268, 589934536, 179869065, 359738130, 719476260, 438952513, 877905026, 755810045, 511620083, 23240159, 46480318, 92960636, 185921272, 371842544, 743685088, 487370169, 974740338, 949480669, 898961331, 797922655, 595845303, 191690599, 383381198, 766762396, 533524785, 67049563, 134099126, 268198252, 536396504)
    pre1 = (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976)
    x=[0 for _ in range(61)]
    ans=0
    for i in range(n):
        z=[0 for _ in range(61)]
        y = a[i]
        for k in range(60,-1,-1):
            if y>=pre1[k]:
                y-=pre1[k]
                z[k]+=1
        for j in range(61):
            num = i-x[j]
            if i!=0:
                if z[j]==0:
                    ans=(ans+x[j]*pre2[j])%mod
                else:
                    ans=(ans+num*pre2[j])%mod
            x[j]+=z[j]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 123084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> n;
    vector<ll> list(n), sorted(n);
    rep(i, n){
        cin >> list[i];
        sorted[i] = list[i];
    }
    sort(all(sorted));
    rep(i, n){
        if(list[i] <= sorted[n / 2 - 1]){
            cout << sorted[n / 2] << endl;
        }else{
            cout << sorted[n / 2 - 1] << endl;
        }
    }
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, M; cin >> N >> M;
	vint dp(1<<N, INF);
	dp[0] = 0;
	vint A(M), B(M);
	vint C(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		for (int j = 0; j < B[i]; j++) {
			int c;
			cin >> c; --c;
			C[i] |= (1<<c);
		}
	}

	for (int b = 0; b < (1<<N); b++) {
		if (dp[b] == INF) continue;
		for (int i = 0; i < M; i++) {
			chmin(dp[b|C[i]], dp[b] + A[i]);
		}
	}
	cout << (dp[(1<<N)-1] == INF ? -1 : dp[(1<<N)-1]) << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int main(){
    int n,l;
    scanf("%d%d",&n,&l);
    int lsum=0;
    for(int i=1;i<=n;i++)lsum+=l+i-1;
    if(l>0)lsum-=l;
    if(l+n-1<0)lsum-=l+n-1;
    printf("%d\n",lsum);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Point{

	double x,y;
};


int N,K;
Point point[205];

double calc(double X,double Y){

	vector<double> V;

	for(int i = 0; i < N; i++){

		V.push_back(sqrt((X-point[i].x)*(X-point[i].x)+(Y-point[i].y)*(Y-point[i].y)));
	}

	sort(V.begin(),V.end());

	double ret = 0;
	int count = 0;

	for(int i = N-1; i >= 0; i--){

		ret += V[i];
		count++;

		if(count == K)break;
	}

	return ret;
}

double thirds_searchY(double X){

	double L = -1001,R = 1001;

	for(int loop = 0; loop < 100; loop++){

		double mid1 = (2.0*L+R)/3.0;
		double mid2 = (1.0*L+2.0*R)/3.0;

		if(calc(X,mid1) > calc(X,mid2)){

			L = mid1;
		}else{

			R = mid2;
		}
	}

	return calc(X,(L+R)/2);
}

//Yをsガス
double thirds_searchX(){

	double L = -1001,R = 1001;

	for(int loop = 0; loop < 100; loop++){

		double mid1 = (2.0*L+R)/3.0;
		double mid2 = (1.0*L+2.0*R)/3.0;

		if(thirds_searchY(mid1) > thirds_searchY(mid2)){

			L = mid1;
		}else{

			R = mid2;
		}
	}

	return thirds_searchY((L+R)/2);
}

int main(){

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

	for(int i = 0; i < N; i++){

		scanf("%lf %lf",&point[i].x,&point[i].y);
	}

	printf("%.10lf\n",thirds_searchX());

	return 0;
}



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

int main() {
	int N;
	cin >> N;
	map<string, int> P;
	int mv = 0;
	rep(i, N) {
		string s;
		cin >> s;
		int n = P[s];
		P[s] = n + 1;
		mv = max(mv, P[s]);
	}
	for (auto p : P) {
		if (p.second == mv) cout << p.first << endl;
	}
}

Measured memory_bytes: 25216
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    
    int sum = 0;
    
    if (k <= a) {
      System.out.println(1 * k);
    } else if ((a < k) && (k <= a+ b)) {
      System.out.println(1 * (k - b));
    } else if ((a+b < k) && (k <= a + b + c)) {
      System.out.println(1 * a + -1 * (k -b -a));
    } else {
      System.out.println(1 * a + -1 * (k - a - b));
    }
  }
}

Measured memory_bytes: 35864
import           Control.Applicative
import           Control.Monad
import           Data.List
import           Text.Printf

main :: IO ()
main = do
  n <- readLn
  print $ solve n 100000
    where
      solve::Int->Int->Int
      solve 0 money = money
      solve cur money = solve (cur-1) (money+interest)
        where
          interest = ceiling (0.05 * fromIntegral money / 1000.0) * 1000


Measured memory_bytes: 3760
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<set>
#include<algorithm>
#define ll long long
#define rep(i,a,n) for(ll i=a;i<=n;i++)
#define per(i,a,n) for(ll i=n;i>=a;i--)

using namespace std;
int main()
{
    ll n,m;
    cin>>n>>m;
    ll ans=n/m;
    if(n%m!=0)
        ans++;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int N;

	cin >> N;
	vector<string> s( N );
	for( int i = 0; i < N; i++ ) {
		cin >> s[i];
	}

	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		int pos = s[i].find( "AB" );
		while( pos != string::npos ) {
			ans++;
			pos = s[i].find( "AB", pos + 2 );
		}
	}
	int acnt = 0;
	int bcnt = 0;
	int abcnt = 0;
	for( int i = 0; i < N; i++ ) {
		if( s[i][0] == 'B' && s[i][s[i].size() - 1] != 'A' ) {
			bcnt++;
		}
		if( s[i][s[i].size() - 1] == 'A' && s[i][0] != 'B' ) {
			acnt++;
		}
		if( s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A' ) {
			abcnt++;
		}
	}
	int cnt = 0;
	if( abcnt == 0 ) {
		cnt = min( acnt, bcnt );
	}
	else if( acnt + bcnt > 0 ) {
		cnt = abcnt + min( acnt, bcnt );
	}
	else {
		cnt = abcnt - 1;
	}
	ans += cnt;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0, tmp = 0;
    repf(i,1,n) {
        if (h[i-1] >= h[i]) tmp++;
        else tmp = 0;
        chmax(ans, tmp);
    }
    chmax(ans, tmp);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<tuple<int, int, int, int>> q(Q);

    for(auto &&x: q) {
            cin >> get<0>(x);
            cin >> get<1>(x);
            cin >> get<2>(x);
            cin >> get<3>(x);
    }

    vector<int> a(N, 1);
    ll md = 0;
    while(true) {
        ll d = 0;
        for(auto &&[ai, bi, c, dd]: q) {
            if(a[bi-1] - a[ai-1] == c) d += dd;
        }
        md = max(d, md);
        a[N - 1]++;
        for(int i = N - 1; i >= 0; i--) {
            if(a[i] > M) {
               
                if(i > 0) {
                    a[i - 1]++;
                    for (int j = i; j < N; j++) {
                        a[j] = a[i - 1];
                    }
                } else goto outer_loop;
            } else
                break;
        }
    }
    outer_loop:
    cout << md << endl;
}

Measured memory_bytes: 3552
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>

using namespace std;

int N, K;
int H[100000];
int dp[100000];
int INF = 1000000000;

int main()
{
    // input
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> H[i];
    
    // pre-populate dp table
    for (int i = 0; i < min(K+1, N); ++i){
        dp[i] = abs(H[i]-H[0]);
    }
    
    // execute dp
    for (int i = K+1; i < N; ++i){
        int m = INF;
        for (int j = 1; j < K+1; ++j){
            m = min(m, dp[i-j] + abs(H[i]-H[i-j]));
        }
        dp[i] = m;
    }
    
    cout << dp[N-1] << endl;
    
    return 0;
}

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

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int N; cin >> N;
	struct constraint {
		bool z;
		uint64_t v;
	};
	vector<constraint> rows[2] = {vector<constraint>(N), vector<constraint>(N)};
	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			cin >> rows[d][i].z;
		}
	}

	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			cin >> rows[d][i].v;
		}
	}

	auto id = [](bool z) -> uint64_t { return z ? uint64_t(0) : ~uint64_t(0); };
	auto op = [](bool z, uint64_t a, uint64_t b) -> uint64_t { return z ? (a | b) : (a & b); };

	uint64_t accum[2][2] = {{id(0), id(1)}, {id(0), id(1)}};
	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			for (int z = 0; z < 2; z++) {
				accum[d][z] = op(z, accum[d][z], rows[d][i].v);
			}
		}
	}

	vector<bool> parity[2] = {vector<bool>(N), vector<bool>(N)};
	for (int d = 0; d < 2; d++) {
		bool cur_parity[2] = {true, true};
		for (int i = 0; i < N; i++) {
			parity[d][i] = (cur_parity[rows[d][i].z] ^= 1);
		}
	}

	auto get_cell = [&](int i, int j) -> uint64_t {
		constraint c[2] = {rows[0][i], rows[1][j]};
		if (c[0].z == c[1].z) {
			return op(!c[0].z, c[0].v, c[1].v);
		} else {
			int d = parity[0][i] ^ parity[1][j];
			return op(!c[d].z, c[d].v, op(!c[!d].z, ~accum[!d][c[d].z], c[!d].v));
		}
	};

	vector<vector<uint64_t>> ans(N, vector<uint64_t>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans[i][j] = get_cell(i, j);
		}
	}

	vector<uint64_t> ansVal[2] = {vector<uint64_t>(N), vector<uint64_t>(N)};
	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			ansVal[d][i] = id(rows[d][i].z);
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ansVal[0][i] = op(rows[0][i].z, ansVal[0][i], ans[i][j]);
			ansVal[1][j] = op(rows[1][j].z, ansVal[1][j], ans[i][j]);
		}
	}
	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			if (ansVal[d][i] != rows[d][i].v) {
				cout << -1 << '\n';
				exit(0);
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cout << ans[i][j] << " \n"[j+1==N];
		}
	}

	return 0;
}


Measured memory_bytes: 7568
n = int(input())
p = [0] + list(map(float, input().split()))
q = [1 - p[i] for i in range(n + 1)]
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(n + 1):
        dp[i][j] = dp[i - 1][j] * q[i]
        if not j == 0:
            dp[i][j] += dp[i - 1][j - 1] * p[i]
ans = 0
for i in range((n + 1) // 2):
    ans += dp[n][n - i]
print(ans)

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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

bool can(ll x, ll p) {
  while(x % p == 0) {
    x /= p;
  }
  return x % p == 1;
}

double getSum(double x) {
  return x * (x + 1.0) / 2.0;
}

int main() {
  int s; cin >> s;
  map <ll, int> cnt;
  int cur = 1;
  ll val = s;
  while(true) {
    if(cnt.count(val)) {
      print(cur);
      return 0;
    }
    cnt[val] = 1;
    if(val % 2ll == 0) val /= 2ll;
    else val = 3ll * val + 1;
    cur++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

int k;

int main() {
	cin>>k;
	int res = 7%k, ans = 1;
	while(res%k != 0) {
		ans++;
		res = (res*10 + 7)%k;
		if(ans > k) break;
	}
	if(ans > k) cout<<-1<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 3544
from sys import exit, setrecursionlimit, stdin, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *
import operator
import math
from fractions import gcd
from random import randint

setrecursionlimit(10**8)

def input():
  return stdin.readline().strip()

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

MAX = 3 * 10**6
MOD = 998244353

fact = [1] * MAX
for i in range(1, MAX):
  fact[i] = (fact[i-1] * i) % MOD
invfact = [0] * MAX
invfact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(MAX-2, -1, -1):
  invfact[i] = invfact[i+1] * (i+1) % MOD

def comb(n, k):
  return fact[n] * invfact[n-k] * invfact[k] % MOD if 0 <= k <= n else 0

def H(n, k):
  return comb(n+k-1, k-1)

N, M = reads()

ans =0
for k in range(M%2, M+1, 2):
  d = comb(N, k) * (
    H((3 * M - k) // 2, N)
          - k * H((M-k)//2, N)
          - (N-k) * H((M-2-k)//2, N)
    )
  # print(k, d)
  ans = (ans + d) % MOD

print(ans)

Measured memory_bytes: 116424
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll n,ww;
  cin>>n>>ww;
  vector<ll> w(n);
  vector<ll> v(n);
  vector<ll> min_weight(100001,INF);
  vector<ll> old_min_weight(100001,INF);
  rep(i,n){
    cin>>w[i];
    cin>>v[i];
  }
  min_weight[0]=0;
  old_min_weight[0]=0;
  rep(i,n){
    rep(j,100001){
      if(j+v[i] > 100000) continue;
      old_min_weight[j+v[i]] = min(min_weight[j]+w[i],min_weight[j+v[i]]);
    }
    rep(j,100001){
      min_weight[j] = old_min_weight[j];
    }
    rep(j,20){
      //cout << min_weight[j] << " ";
    }
    //cout << endl;
  }
  ll ans=0;
  rep(i,100001){
    if(min_weight[i] <= ww) ans=i;
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int car;
	int a[11];
	int i,s;
	i=0;
	while(scanf("%d",&car)!=EOF){
		if(car!=0){
			a[i]=car;
			i++;
		}
		else {
			i--;
			printf("%d\n",a[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
class PriorityQueue
  def initialize()
    @elements = []
  end
  
  def push(n)
    i = @elements.size
    while i > 0
      p = (i-1) / 2
      break if @elements[p] <= n
      @elements[i] = @elements[p]
      i = p
    end
    @elements[i] = n
  end
  alias :<< :push
  
  def pop
    min = @elements[0]
    n   = @elements.pop
    unless @elements.empty?
      i = 0
      while i * 2 + 1 < @elements.size
        if @elements[i * 2 + 2].nil? or @elements[i * 2 + 1] < @elements[i * 2 + 2]
          buf = i * 2 + 1
        else
          buf = i * 2 + 2
        end
        break if @elements[buf] > n
        @elements[i] = @elements[buf]
        i = buf
      end
      @elements[i] = n
    end
    min
  end
end

def sum(a, n)
  s = Array.new(n+1, 0)
  q = PriorityQueue.new
  
  (0..n-1).each { |i| q << a[i]; s[0] += a[i] }
  n.times do |i|
    q << a[n+i]
    s[i+1] = s[i] + a[n+i] - q.pop
  end
  s
end

N = gets.to_i
a = gets.split.map(&:to_i)

ls = sum(a, N)
rs = sum(a.reverse.map{|x| -x}, N)
puts ls.zip(rs.reverse).map{|x, y| x+y}.max

Measured memory_bytes: 36952
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

string s;

void solve() {
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
	long long n, i;
	long long ans;
	cin >> n;
	for (i = 1; i < 31625; i++)
	{
		if (n < (i * i)) break;
	}
	ans = (i - 1) * (i - 1);
	cout << ans;
	return 0;
}

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

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  vector<vector<int>> edge(n);
  for (int i = 0; i < m; i++) {
    int from, to;
    scanf("%d%d", &from, &to);
    from--, to--;
    edge[from].emplace_back(to);
    edge[to].emplace_back(from);
  }

  for (int i : edge[0]) {
    for (int j : edge[i]) {
      if (j == n-1) {
        printf("POSSIBLE\n");
        return 0;
      }
    }
  }

  printf("IMPOSSIBLE\n");
  return 0;
}

Measured memory_bytes: 12016
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

S = input()

ans = 0
for i in range(len(S)//2):
    if S[i] != S[len(S)-i-1]:
        ans += 1

print(ans)

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

int main()
{
    int N, Y;
    cin >> N >> Y;
    bool ans = false;
    for (int x = 0; x <= N; ++x)
    {
        int y = 0;
        while (true)
        {
            int z = N - x - y;
            if (10000 * x + 5000 * y + 1000 * z == Y)
            {
                ans = true;
                cout << x << " ";
                cout << y << " ";
                cout << z << endl;
                return 0;
            }
            if (x + y == N)
            {
                break;
            }
            ++y;
        }
    }
    if (ans == false)
    {
        cout << "-1 -1 -1" << endl;
    }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int RA[3], RB[3];
	pair<double, int> R[3];
	cin >> RA[0] >> RA[1] >> RA[2] >> RB[0] >> RB[1] >> RB[2];
	rep(i, 3) R[i] = mp(1.0 * RB[i] / RA[i], i);
	sort(R, R + 3);

	int A[3], B[3];
	int K = 0;
	rep(i, 3) {
		A[i] = RA[R[i].second];
		B[i] = RB[R[i].second];
		if (A[i] < B[i]) K++;
	}

	if (K == 3) {
		int saidai = 0;
		rep(i, N + 1) rep(j, N + 1) {
			int nokori = N - i * A[0] - j * A[1];
			if (nokori >= 0) {
				int k = nokori / A[2];
				int amari = nokori % A[2];
				int kari = i * B[0] + j * B[1] + k * B[2] + amari;
				saidai = max(saidai, kari);
			}
		}
		co(saidai);
	}
	else if (K == 2) {
		int saidai = 0;
		rep(j, N + 1) {
			int nokori = N - j * A[1];
			if (nokori >= 0) {
				int k = nokori / A[2];
				int amari = nokori % A[2];
				int kari = j * B[1] + k * B[2] + amari;
				saidai = max(saidai, kari);
			}
		}
		ll kotae = 1ll * saidai / B[0] * A[0] + saidai % B[0];
		co(kotae);
	}
	else if (K == 1) {
		N = N / A[2] * B[2] + N % A[2];
		ll saidai = 0;
		rep(i, N + 1) {
			ll nokori = N - 1ll * i * B[0];
			if (nokori >= 0) {
				ll j = nokori / B[1];
				ll amari = nokori % B[1];
				ll kari = 1ll * i * A[0] + 1ll * j * A[1] + amari;
				saidai = max(saidai, kari);
			}
		}
		co(saidai);
	}
	else {
		int saidai = 0;
		rep(i, N + 1) rep(j, N + 1) {
			int nokori = N - i * B[0] - j * B[1];
			if (nokori >= 0) {
				int k = nokori / B[2];
				int amari = nokori % B[2];
				int kari = i * A[0] + j * A[1] + k * A[2] + amari;
				saidai = max(saidai, kari);
			}
		}
		co(saidai);
	}


	Would you please return 0;
}

Measured memory_bytes: 384
#include <unistd.h>
#include <cstdio>
#include <x86intrin.h>

typedef long long ll;
int mat[3000][3000]; 
ll dp0[3000] __attribute((aligned(32)));

char buf[1048576];
int lim = 0;
int cur = 0;

void refill()
{
    lim = read(STDIN_FILENO, buf, sizeof buf);
    cur = 0;
}

int rd()
{
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return -1;
        } else {
            if (buf[cur] >= '0' && buf[cur] <= '9') break;
            cur++;
        }
    }
    int acc = buf[cur++] - '0';
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return acc;
        } else {
            if (buf[cur] < '0' || buf[cur] > '9') return acc;
            acc = acc * 10 + buf[cur++] - '0';
        }
    }
}

#pragma clang attribute push(__attribute__((target("avx2"))), apply_to=function)
int main(int argc, char **argv)
{
    int rr = rd();
    int cc = rd();
    int k  = rd();

    for (int i = 1; i <= k; i++) {
        int r = rd();
        int c = rd();
        int v = rd();
        mat[r - 1][c - 1] = v;
    }
    for (int y = 0; y < rr; y++) {
        ll work0 = 0, work1 = 0, work2 = 0, work3 = 0;
        ll worka = 0;
        for (int x = 0; x < cc; x++) {
            if (dp0[x] > work0) {
                work0 = dp0[x];
                int v = mat[y][x];

                if (work3 < work2 + v) work3 = work2 + v;
                if (work2 < work1 + v) work2 = work1 + v;
                if (work1 < work0 + v) work1 = work0 + v;

                worka = work3 > work2 ? work3 : work2;
                ll workb = work1 > work0 ? work1 : work0;
                if (workb > worka) worka = workb;

                dp0[x] = worka;
            } else {
                int v = mat[y][x];
                if (v > 0) {
                    if (work3 < work2 + v) work3 = work2 + v;
                    if (work2 < work1 + v) work2 = work1 + v;
                    if (work1 < work0 + v) work1 = work0 + v;

                    worka = work3 > work2 ? work3 : work2;
                    ll workb = work1 > work0 ? work1 : work0;
                    if (workb > worka) worka = workb;
                }
                 dp0[x] = worka;
            }
        }
    }
    std::printf("%lld\n", dp0[cc - 1]);
    return 0;
}
#pragma clang attribute pop

Measured memory_bytes: 39320
#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.at(i);
  }
  sort(d.begin(), d.end());
  
  int count = 0;
  int max = 0;
  for (int i = 0; i < N; i++) {
    if (d.at(i) > max) {
      count++;
      max = d.at(i);
    }
  }
  cout << count << endl;
}


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

int n;
int H[255];

int main()
{
    cin >>n;
    int i;
    for(i=1;i<=n;i++){
        cin>>H[i];
    }
    for(i=1;i<=n;i++){
        cout<<"node "<<i<<": ";
        cout<<"key = "<<H[i]<<", ";
        if(i!=1)cout<<"parent key = "<<H[i/2]<<", ";
        if(i*2<=n)cout<<"left key = "<<H[i*2]<<", ";
        if(i*2+1<=n)cout<<"right key = "<<H[i*2+1]<<", ";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3052
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 f(n: i64) -> i64 {
    n.to_string()
        .chars()
        .map(|c| c.to_digit(10).unwrap() as i64)
        .sum()
}

fn main() {
    let n: i64 = read();
    if n % f(n) == 0 {
        println!("Yes")
    } else {
        println!("No")
    }
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef map<string, int> msi;
typedef pair<int, int> PII;

int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll b_100 = b * 100 + 0.000001;

    cout << (a*b_100/100) << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
const int MaxN = 1e3 + 5;
int n,m,j,k;
int a[MaxN];
int main(){
	while(~scanf("%d%d%d%d",&n,&m,&j,&k)){
int left1 = min(n,m),left2 = min(j,k),right1 = max(n,m),right2 = max(j,k);
left1 = max(left1,left2);
right1 = min(right1,right2);
int ans = right1 - left1;
if(ans > 0)printf("%d\n",ans);
else printf("0\n");
	}
}

Measured memory_bytes: 128
#include       <set>
#include       <map>
#include     <queue>
#include     <cmath>
#include    <cstdio>
#include    <cctype>
#include    <vector>
#include   <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
const double eps = 1e-7;
const int maxn = 105;

ll fast_pow(ll a,ll b,ll mod){
    ll ans = 1;
    while(b){
        if(b&1)
            ans = ans*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return ans;
}

int w[maxn], v[maxn];
int dp[maxn*4][maxn];

int main(){
    int n, W, c;
    scanf("%d%d",&n,&W);
    for(int i=0;i<n;i++)
        scanf("%d%d",&w[i],&v[i]);
    for(int i=1;i<n;i++)
        w[i] -= w[0]-1;
    c = w[0]-1;
    w[0] = 1;
    for(int i=0;i<n;i++)
        for(int j=(i+1)*4;j>=w[i];j--)
            for(int k=1;k<=i+1;k++){
                dp[j][k] = max(dp[j][k],dp[j-w[i]][k-1]+v[i]);
    }
    int ans = 0;
    for(int j=n*4;j>=0;j--)
        for(int k=1;k<=n;k++){
            if(1ll*k*c+j<=W){
                ans = max(ans,dp[j][k]);
            }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size())
	{
		cout << "GREATER" << endl;
		return 0;
	}
	else if (a.size() < b.size())
	{
		cout << "LESS" << endl;
		return 0;
	}
	else
	{
		for (int i = 0; i < a.size(); ++i)
		{
			if (a[i] > b[i])
			{
				cout << "GREATER" << endl;
				return 0;
			}
			else if (a[i] < b[i])
			{
				cout << "LESS" << endl;
				return 0;
			}
		}
	}
	cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,m,lots[50];
  cin >>n>>m;
  for(int i=0; i<50; i++){lots[i] = i+1;}
  while(m--){
    int a,b,c;
    scanf("%d,%d",&a,&b);
    c = lots[a-1];
    lots[a-1] = lots[b-1];
    lots[b-1] = c;
  }
  for(int i=0; i<n; i++){cout <<lots[i]<<endl;}
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    int k = -1;
    for(int i = 2; i*(i-1)/2<= N; i++){
        if(2*N == i*(i-1)) k = i;
    }
    if(k == -1){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        cout << k << endl;
        int s = 2*N/k;
        int mx = 1;
        vector<queue<int>> vq(k);
        for(int i = 0; i < k; i++){
            cout << s << " ";
            if(i == 0){
                for(int j = 0; j < s; j++){
                    vq[i].push(mx);
                    cout << mx << " ";
                    mx++;
                }
                cout << endl;
            } else {
                int cnt = 0;
                for(int j = 0; j < i; j++){
                    cout << vq[j].front() << " ";
                    vq[j].pop();
                    cnt++;
                }
                while(vq[i].size()+cnt < s){
                    vq[i].push(mx);
                    cout << mx << " ";
                    mx++;
                }
                cout << endl;
            }
        }
    }
}



Measured memory_bytes: 1920
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

map<ll, ll> factor(ll n){
    ll tmp = n;
    map<ll, ll> ps;
    for(ll i=2;i*i<=n;i++){
        if(tmp % i)
            continue;
        int cnt = 0;
        while(tmp % i == 0){
            tmp /= i;
            cnt++;
        }
        ps[i] = cnt;
    }
    if(tmp > 1)
        ps[tmp] = 1;
    return ps;
}
int main() {
    ll n;
    cin >> n;
    auto primes = factor(n);

    ll ans = 0;
    for(auto t: primes){
        ll num = t.second;

        ll i = 1;
        while(i*(i+1)/2<=num)
            i++;
        ans += i-1;
    }

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

Measured memory_bytes: 3196
n, d = (int(x) for x in input().split())
ab = []
for _ in range(n):
    t = list(map(int,input().split()))
    ab.append(t)

ans = 0
for i in range(n):
    for j in range(i):
        #print(i , j)
        count = 0
        for k in range(d):
            count += (ab[i][k]-ab[j][k])**2
        if count == int((count)**0.5)**2:
            ans += 1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

int main() {
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    int n, l;
    cin >> n >> l;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < n-1; i++) {
        if (a[i]+a[i+1] >= l) {
            cout << "Possible" << endl;
            for (int j = 0; j < i; j++) {
                cout << j+1 << endl;
            }
            for (int j = n-1; j >= i+1; j--) {
                cout << j << endl;
            }
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int h,w;
/*vector<vector<vector<vector<int>>>> rinsetu;*/

int main(){
  cin>>h>>w;
	vector<string> board(h);
	for(int i = 0; i<h; i++) cin >> board.at(i);
  int rinsetu[h][w][h][w];
 
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
          if(i==k && j==l){
            rinsetu[i][j][k][l] = 0;
            continue;
          }
          rinsetu[i][j][k][l] = 1001001001;
        }
      }
    }
  }
  
  

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      rinsetu[i][j][i][j] = 0;
      if(board.at(i).at(j) == '#') continue;
      if(i!=0) {
        if(board.at(i-1).at(j) == '.'){
          rinsetu[i-1][j][i][j] = 1;
          rinsetu[i][j][i-1][j] = 1;
        }
      }
      if(j!=0){
        if(board.at(i).at(j-1) == '.'){
          rinsetu[i][j-1][i][j] = 1;
          rinsetu[i][j][i][j-1] = 1;
        }
      }
      if(i!=h-1){
        if(board.at(i+1).at(j) == '.'){
          rinsetu[i][j][i+1][j] = 1;
          rinsetu[i+1][j][i][j] = 1;
        }
      }
      if(j!=w-1){
        if(board.at(i).at(j+1) == '.'){
          rinsetu[i][j][i][j+1] = 1;
          rinsetu[i][j+1][i][j] = 1;
        }
      }
    }
  }

  /*for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
          cout << rinsetu[i][j][k][l] << " " ;
        }
      }
      cout << endl;
    }
  }  */
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
          for(int m=0;m<h;m++){
            for(int n=0;n<w;n++){
              rinsetu[k][l][m][n] = min(rinsetu[k][l][m][n] , rinsetu[k][l][i][j] + rinsetu[i][j][m][n]);
            }
          }
        }
      }
    }
  }
   
  /*for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
          cout << rinsetu[i][j][k][l] << " " ;
        }
      }
      cout << endl;
    }
  }*/
  
  
  int ans = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
          //cout << rinsetu[i][j][k][l] << " " ;
          if(rinsetu[i][j][k][l] > 1e7) continue;
          ans = max(ans,rinsetu[i][j][k][l]);
          //cout << rinsetu[i][j][k][l]  << " ";
        }
      }
      //cout << endl;
    }
  }
  
  

  cout << ans << endl;
  


}


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

#define N_MAX 3002
#define ll long long

using namespace std;

const ll MOD = 1e9+7;

int n;

string s;

ll dp[N_MAX][N_MAX];
ll sdp[N_MAX][N_MAX];

int main()
{
    cin >> n;
    cin >> s;
    sdp[1][1] = 1;
    for(int i = 2; i <= n; i++)
        for(int j = 1; j <= i; j++)
        {
            if(s[i - 2] == '<')
                dp[i][j] = sdp[i - 1][j - 1];
            else
                dp[i][j] = (sdp[i - 1][i - 1] - sdp[i - 1][j - 1] + MOD) % MOD;
            sdp[i][j] = sdp[i][j - 1] + dp[i][j];
            if(sdp[i][j] >= MOD)
                sdp[i][j] -= MOD;
        }
    cout << sdp[n][n] << "\n";
    return 0;
}


Measured memory_bytes: 139392
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


ll combination(int n, int r)
{
	//nCr = nC(n-r)を使用して計算量を節約
	if (n - r < r) r = n - r;

	//自明な場合の戻り値
	if (n < 0) return 0;
	if (r < 0) return 0;
	if (r == 0) return 1;
	if (r == 1) return n;

	//組み合わせの数の定義に登場する分母・分子の要素
	vector<int> numerator(r, 0);
	vector<int> denominator(r, 0);

	//初期化
	rep(k, r)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	//分子を分母で割っていく。
	repse(p, 2, r)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				//分子は割り切れる場所までスライド
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	rep(k, r)
	{
		//残りを全部乗算
		if (numerator[k] > 1) result *= numerator[k];
	}

	return result;
}


ll HCOM(int n, int k)
{
    return combination(n + k - 1, k);
}

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

    string A;
    in(A);

    vi count(26);

    for (auto a : A)
    {
        count[a - 'a']++;
    }

    ll ans = HCOM(A.size(), 2);

    rep(i, 26)
    {
        ans -= HCOM(count[i], 2);
    }

    ans += 1;

    outl(ans);

    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ud(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, a, b) for (int i = a, i < b; ++i)
#define rep3(i, n) for (int i = n - 1; i >= 0; ++i)
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

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

void solve(void) {
  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++;
  }
  cout << ans << endl;
}
int main(void) { solve(); }


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mpp make_pair

using namespace std;

const int N=3e5+5;
const ll infi=1e18+5;


int main()
{
	ll h,w,n;
	cin>>h>>w>>n;

	ll val=max(h,w);
	ll calc=n/val;

	if(n%val)
		calc++;
	cout<<calc;
}

Measured memory_bytes: 256