akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, m = LI()
    a = LI()
    a.sort()
    if len(a) != len(set(a)):
        print(0)
        return
    b = LI()
    b.sort()
    if len(b) != len(set(b)):
        print(0)
        return
    ans = 1
    for i in range(n * m, 0, -1):
        x = bisect_left(a, i)
        y = bisect_left(b, i)
        if x == n or y == m:
            print(0)
            return
        ansx = 1 if a[x] == i else n - x 
        ansy = 1 if b[y] == i else m - y
        f = a[x] == i or b[y] == i
        ans *= (ansx * ansy - (n * m - i if not f else 0)) % mod
        ans %= mod
    print(ans)

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 44092
a, b = map(int, input().split())

grid = []
for i in range(50):
    line = ['#'] * 100
    grid.append(line)

for i in range(50):
    line = ['.'] * 100
    grid.append(line)

count = 0
for y in range(0, 50, 2):
    for x in range(0, 100, 2):
        if count == a - 1:
            break
        grid[y][x] = '.'
        count += 1
    if count == a - 1:
        break

count = 0
for y in range(51, 100, 2):
    for x in range(0, 100, 2):
        if count == b-1:
            break
        grid[y][x] = '#'
        count += 1
    if count == b - 1:
        break

print(100, 100)
for line in grid:
    print(''.join(line))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	ll ans = 0;
	for (int a = 1; a <= N; ++a) {
		if ((-2 * a) % K) continue;
		int b = -a % K;
		b += K;
		ll tot = N / K;
		if (N % K >= b) ++tot;
		ans += tot * tot;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int H[1000000], W[1000000];

int main(){

	for (int a = 0; a < 1000000; a++){


		cin >> H[a] ;
		cin >> W[a];

		if (H[a] == 0 && W[a] == 0)break;



		for (int n = 0; n < H[a]; n++){
		for (int n=0; n < W[a]; n++){
			cout << "#";
		}cout << endl;               }


		cout << endl;


	}









	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;
 
priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;
 
int A[MAXN];
char S[MAXN];
 
bool visited[MAXN];
 
vector<int> val;
vector<int> permu;
 
void dfs(int here)
{
    visited[here] = true;
    val.push_back(here);
    permu.push_back(A[here]);
 
    int there;
 
    for(int i=0;i<graph[here].size();i++)
    {
        there = graph[here][i];
        if(visited[there])continue;
        dfs(there);
    }
    return;
}
 
int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cin>>n>>m;
 
    for(int i=1;i<=n;i++)
        cin>>A[i];
 
    graph = vector<vector<int> > (n+1);
 
    for(int i=0;i<m;i++){
        cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
 
    int sz;
    int R = 0;
 
    for(int i=1;i<=n;i++){
        if(visited[i])continue;
        val.clear();
        permu.clear();
        dfs(i);
 
        sz = val.size();
 
        sort(val.begin(),val.end());
        sort(permu.begin(),permu.end());
 
        R = 0;
        for(int i=0;i<sz;i++){
            while(R<sz&&permu[R]<val[i])R++;
            if(R==sz||permu[R]>val[i])continue;
            cnt++;
        }
    }
 
    cout<<cnt<<"\n";
 
    return 0;
}

Measured memory_bytes: 9132
import itertools
n = input()
l = len(n)
ans = 0
for ope in itertools.product("_+", repeat = l - 1):
    num = n[0]
    for i in range(l - 1):
        if ope[i] == "+":
            num += n[i + 1]
        else:
            ans += int(num)
            num = n[i + 1]
    ans += int(num)
print(ans)

Measured memory_bytes: 9100
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	xn := make([]float64, n)
	yn := make([]float64, n)
	for i := range xn {
		fmt.Scan(&xn[i])
	}
	for i := range yn {
		fmt.Scan(&yn[i])
	}
	var D1, D2, D3, Di float64
	for i := 0; i < n; i++ {
		d := xn[i] - yn[i]
		D1 += math.Abs(d)
		D2 += d * d
		D3 += math.Abs(d * d * d)
		if Di < math.Abs(d) {
			Di = math.Abs(d)
		}
	}
	fmt.Printf("%f\n%f\n%f\n%f\n", D1, math.Sqrt(D2), math.Cbrt(D3), Di)
}



Measured memory_bytes: 1204
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int M=1e9+7;
const int inf=INT64_MAX;
int factt(int n){
    int ans=1;
    for(int i=1;i<=n;i++){
        ans*=i;
        ans=ans%M;
    }
    return ans;
}
int max(int a,int b,int c){
    return max(a,max(b,c));
}
int min(int a,int b,int c){
    return min(a,min(b,c));
}
int fspow(int x,int y){
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return ((ans*ans)%M);
    return (x*((ans*ans)%M))%M;
}
int gcd(int x,int y){
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x){
    int ans=0;
    while(x>=1){
        ans++;
        x/=2;
    }
    return ans;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
   //  cin>>t;
    //int tmp=t;
    while(t--){
        int n;
        cin>>n;
        int ans=fspow(10,n)-((2*fspow(9,n))%M)+fspow(8,n)+M;
        cout<<ans%M<<"\n";
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    int arr[n];
    vector<int> dp(n, INT_MAX);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
		for(int j = i + 1; j <= i + k; j++) {
			if(j < n)
				dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
		}
	}
	cout << dp[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
from collections import deque

n, q = map(int, input().split())
G = [deque([]) for _ in range(n)]
S = [0] * n
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
for i in range(q):
    p, x = map(int, input().split())
    S[p - 1] += x

ans = [-1] * n

def dfs(v):
    ans[v] = S[v]
    stack = [v]
    while stack:
        x = stack[-1]
        if len(G[x]) > 0:
            w = G[x].popleft()
            if ans[w] == -1:
                ans[w] = ans[x] + S[w]
                stack.append(w)
        else: stack.pop()

dfs(0)
print(*ans)

Measured memory_bytes: 159484
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    P = [[int(x) for x in input().split()] for _ in range(N)]
    eps = 0.000000001
    minR = 10**10
    if N == 2:
        r = (P[1][0] - P[0][0]) ** 2 + (P[1][1] - P[0][1])** 2
        r = (r ** 0.5) / 2
        print(r)
        return 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            a, b = P[i]
            c, d = P[j]
            x, y = (a + c)/2, (b + d)/2
            rd = (x - a) ** 2 + (y - b) ** 2
            for l in range(N):
                if l != i and l != j:
                    if (P[l][0] - x) ** 2 + (P[l][1] - y) ** 2 - rd > eps: break
            else: minR = min(minR, rd)

            for k in range(j + 1, N):
                if (P[j][1] - P[i][1]) * (P[k][0]-P[j][0]) == (P[j][0] - P[i][0]) * (P[k][1]-P[j][1]): continue

                e, f = P[k]
                if c == a: 
                    y = (d + b) / 2
                    if d == f: x = (d + f) / 2
                    else: x = (e + c) / 2 + ((d + f)/2 - y) * (f - d) / (e - c)
                elif e == c: 
                    y = (d + f ) / 2
                    if d == b: x = (d + b) / 2
                    else: x = (a + c) / 2 + ((b + d)/ 2 - y) * (d - b) / (c - a)
                elif d == b: 
                    x = (a + c) / 2
                    y = (d + f) / 2 + ((e + c)/2 - x) * (e - c) / (f - d)
                elif f == d: 
                    x = (c + e) / 2
                    y = (b + d) / 2 + ((c + a)/2 - x) * (c - a) / (d - b)
                else:
                    x = ((c**2 - a**2) / (2 * (d - b)) - (e ** 2 - c ** 2)/(2 * (f - d)) - (f - b)/2) * ((d - b) * (f - d) / ((c - a)*(f - d) - (e - c) * (d - b)))
                    y = (d + f) / 2 + ((e + c)/2 - x) * (e - c) / (f - d)
                rd = (x - a) ** 2 + (y - b) ** 2
                for l in range(N):
                    if l != i and l != j and l != k:
                        if (P[l][0] - x) ** 2 + (P[l][1] - y) ** 2 - rd > eps: break
                else: minR = min(minR, rd)
    print(minR ** 0.5)

    return 0

if __name__ == "__main__":
    solve()


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


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}



int main() {
    fast();
    ll n,m;cin>>n>>m;
    ll total=0;
    for (int i = 0; i <m ; ++i) {
       ll a;cin>>a;
       total+=a;
    }
    cout<<(n-total<0?-1:n-total);
}

Measured memory_bytes: 3656
from itertools import permutations

def resolve():
    N=int(input())
    P = tuple([int(i) for i in input().split()])
    Q = tuple([int(i) for i in input().split()])

    x = list(permutations(range(1,N+1),N))
    x.sort()
    p =0
    q =0
    for i,v in enumerate(x):
        if P == v:
            
            p = i
        if Q == v:
            
            q = i
    print(abs(p-q))


if __name__ == "__main__":
    resolve()

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int 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>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< 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 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

const int MAXN = 555555;

vl fact(MAXN);
vl rfact(MAXN);

ll mod_pow(ll x, ll p, ll M = MOD) {
  if (p < 0) {
    x = mod_pow(x, M - 2, M);
    p = -p;
  }
  ll a = 1;
  while (p) {
    if (p % 2)
      a = a*x%M;
    x = x*x%M;
    p /= 2;
  }
  return a;
}

ll mod_inverse(ll a, ll M = MOD) {
  return mod_pow(a, M - 2, M);
}

ll nCr(ll n, ll r) {
    ll ans = 1;
    rep (i, r) {
        ans = ans * (n - i) % MOD;
        ans = ans * mod_inverse(r - i) % MOD;
    }
    return ans;
}


void solve() {
    ll n;
    cin >> n;

    ll ans = 0;
    rep (i, 12) {
        int m = n - 5 - i;
        if (m < 0) continue;
        if (m % 2 == 1) continue;
        m /= 2;
        ans += nCr(m + 15, 15) * nCr(11, i) % MOD;
        ans %= MOD;
    }
    cout << ans % MOD << endl;
}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 11736
import collections

h,w,k=map(int,input().split())
sy,sx,gy,gx=map(int,input().split())
sy,sx,gy,gx=sy-1,sx-1,gy-1,gx-1
board=[input() for _ in range(h)]
q=collections.deque()
q.append((sx,sy))
cost=[[10**18]*w for _ in range(h)]
cost[sy][sx]=0
while len(q)!=0:
  x,y=q.popleft()
  c=cost[y][x]
  for i in range(1,k+1):
    if x+i<w and board[y][x+i]=='.' and c<cost[y][x+i]:
      if cost[y][x+i]>c+1:
        cost[y][x+i]=c+1
        q.append((x+i,y))
    else:
      break
  for i in range(1,k+1):
    if x-i>=0 and board[y][x-i]=='.' and c<cost[y][x-i]:
      if cost[y][x-i]>c+1:
        cost[y][x-i]=c+1
        q.append((x-i,y))
    else:
      break
  for i in range(1,k+1):
    if y+i<h and board[y+i][x]=='.' and c<cost[y+i][x]:
      if cost[y+i][x]>c+1:
        cost[y+i][x]=c+1
        q.append((x,y+i))
    else:
      break
  for i in range(1,k+1):
    if y-i>=0 and board[y-i][x]=='.' and c<cost[y-i][x]:
      if cost[y-i][x]>c+1:
        cost[y-i][x]=c+1
        q.append((x,y-i))
    else:
      break
if cost[gy][gx]==10**18:
  print(-1)
else:
  print(cost[gy][gx])

Measured memory_bytes: 98244
#include <iostream>
#include <ctype.h>
#include <string>
#include <sstream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
  string input;
  bool loop = true;
  map<char, int> mp;
  string letters = "abcdefghijklmnopqrstuvwxyz";
  char ch;

  for (int i = 0; i < letters.length(); i++) {
    mp[letters[i]] = 0;
  }

  while (cin >> ch) {
    string input;
    input = ch;
    transform(input.begin(), input.end(), input.begin(), ::tolower);
    int num = mp[input[0]];
    num += 1;
    mp[input[0]] = num;
  }

  for (int i = 0; i < letters.length(); i++) {
    cout << letters[i] << " : " << mp[letters[i]] << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<string, int> msi;
typedef map<int,pair<int,int> > miii;
typedef complex<double> point;
typedef pair<int, ii> iii;
typedef vector<iii> viii;
#define X real()
#define Y imag()
#define FileIn(file) freopen(file".txt", "r", stdin)
#define FileOut(file) freopen(file".txt", "w", stdout)
#define Fill(ar, val) memset(ar, val, sizeof(ar))
#define PI 3.1415926535897932385
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define bit(n) (1<<(n))
#define Last(i) (i & -i)
#define INF 500000000
#define maxN 10000010
#define VISITED 1
#define UNVISITED -1
#define P(p) const point &p
#define L(p0, p1) P(p0), P(p1)
//bool given[100000005];
int main()
{
    ios::sync_with_stdio(0);
    //cin.tie(0);
    //FileIn("in");
    //FileOut("out");
    //memset(given,false,sizeof(given));
    int n;
    int cnt = 0;
    cin>>n;
    long long a;
    map<long long int,int> data;
    map<long long int,int>::iterator it;
    for(int i = 0;i<n;i++)
    {
        cin>>a;
        it = data.find(a);
        if(it==data.end())
        {
            /*if(data[a]==1)
            {
                data[a]=0;
                cnt--;
            }
            else*/
            data[a]=1;
            cnt++;
        }
        else
        {
            data.erase(it);
            cnt--;
        }
    }
    cout<<cnt<<'\n';
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
vector<ll> A;

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

    cin >> N;
    A.resize(N);
    REP(i, N) { cin >> A[i]; }

    vector<ll> ans(N, 0);

    // ans[0] の計算
    REP(i, N) {
        ans[0] += (i % 2 == 0) ? (A[i]) : (-A[i]);
    }
    // ans[0] を元に芋づる式に導出
    for(int i = 1; i < N; ++i) {
        ans[i] = A[i-1] - ans[i-1] / 2;
        ans[i] *= 2;
    }

    REP(i, N) {
        printf("%lld%c", ans[i], (i == N-1) ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0,w=1;char ch=' ';
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') w=-1,ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q*w;
}
const int N=100005;
typedef long long LL;
int n,K;LL a[N],s1[N],s2[N],ans;
int main()
{
	n=read(),K=read();
	for(RI i=1;i<=n;++i) {
		LL x=read();
		s1[i]=s1[i-1]+max(0LL,x),s2[i]=s2[i-1]+x;
	}
	for(RI i=K;i<=n;++i) {
		ans=max(ans,s2[i]-s2[i-K]+s1[i-K]+s1[n]-s1[i]);
		ans=max(ans,s1[i-K]+s1[n]-s1[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
import sys

X,N=map(int, input().split())
if N==0:
    print(X)
    sys.exit()
else:
    p=list(map(int, input().split()))

p=sorted(p)
for i in range(100):
    flag1=0
    flag2=0
    for j in range(len(p)):
        if p[j]==X-i:
            flag1=1
        if p[j]==X+i:
            flag2=1
    if flag1==0:
        print(X-i)
        sys.exit()
    if flag2==0:
        print(X+i)
        sys.exit()


Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    double n, a, b, c, d, e;
    cin>>n>>a>>b>>c>>d>>e;
    long double low=min(a, min(b, min(c, min(d, e))));
    long long int ans = ceil(n/low)+4;
    string hoge = to_string(ans);
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

const int N = 510;

int a[N][N];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int k = 501;
    ll s = ll(H) * W * k;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            a[i][j] = k;
        }
    }
    for (int i = h - 1; i < H; i += h) {
        for (int j = w - 1; j < W; j += w) {
            a[i][j] = -(h * w - 1) * k - 1;
            s += a[i][j] - k;
        }
    }
    if (s > 0) {
        cout << "Yes";
        for (int i = 0; i < H; ++i) {
            cout << '\n';
            for (int j = 0; j < W; ++j) {
                cout << a[i][j] << ' ';
            }
        }
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    int[] skills = new int[n];
    int ds = 0;
    for(int i = 0; i < n; i++){
      skills[i] = sc.nextInt();
      ds += skills[i];
    }
    if(ds >= h){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 48952
#include "bits/stdc++.h"

using namespace std;

#define ll          long long int 
#define inf         (ll)1e17

static const int maxn = 100 + 5;
static const int Max = 1e5 + 5;

ll dp[maxn][Max];
bool memoize[maxn][Max];

int w[maxn], val[maxn];

int N, W;

ll solve(int pos, int make)
{
  if (pos >= N) 
  {
      if (make == 0) return 0;
      return inf;
  }
  ll &ret = dp[pos][make];
  bool &mem = memoize[pos][make];
  if (mem) return ret;
  mem = 1;
  ret = inf;
  if (make - val[pos] >= 0) ret = min(ret, w[pos] + solve(pos+1, make - val[pos]));
  ret = min(ret, solve(pos+1, make));
  return ret;
}
                                      
int main()
{
    scanf("%d %d", &N, &W);
    for (int i = 0; i < N; i++) scanf("%d %d", &w[i], &val[i]);
    for (int make = 100000; make >= 0; make--)
    {
        ll ans = solve(0, make);
        if (ans <= W) 
        {
            printf("%d\n", make);
            break;
        }
    }
}

Measured memory_bytes: 88576
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int x,j,ans,s=9999;
	cin>>x;
	if(x==1){cout<<x;return 0;}
	for(int i=2;i*i<=x;i++){
		for(j=i;j*i<=x;j=j*i){}
		if(x-j<s) s=x-j;
	}
	ans=x-s;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
const int mod=1000000007;
const int INF=1e18;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n1=s.length(),n2=t.length();
    int ans=n2;
    for(int i=0;i<=n1-n2;i++) {
        int tmpans=0;
        for(int j=0;j<n2;j++) {
            if(s[i+j]!=t[j])
                tmpans++;
        }
        ans=min(tmpans,ans);
    }
    cout<<ans<<'\n';
    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
    if(a%7==1){cout<<"fri"<<endl;}
    if(a%7==2){cout<<"sat"<<endl;}
    if(a%7==3){cout<<"sun"<<endl;}
    if(a%7==4){cout<<"mon"<<endl;}
    if(a%7==5){cout<<"tue"<<endl;}
    if(a%7==6){cout<<"wed"<<endl;}
    if(a%7==0){cout<<"thu"<<endl;}
}



Measured memory_bytes: 3116
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const int mod = 100000007;

struct Combination{
    int n;
    vector<vector<int>> dp;

    Combination(int i){
        n = i;
        dp = vector<vector<int>>(n+1, vector<int>(n+1, 0));
        constructTriangle();
    }

    void constructTriangle(){
        dp[0][0] = 1;
        for(int i = 1; i <= n; i++){
            dp[i][0] = dp[i-1][0];
            for(int j = 1; j <= i; j++){
                dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % mod;
            }
        }
    }

    // return aCb
    int getCombination(int a, int b){
        return dp[a][b];
    }
};

int main(){
    Combination comb(1001);

    int r, c, ax, ay, bx, by;
    cin >> r >> c >> ax >> ay >> bx >> by;

    int mind = 1001;
    for(int i = -1; i <= 1; i++){
        for(int j = -1; j <= 1; j++){
            int nx = bx + i*r, ny = by + j*c;
            mind = min(mind, abs(nx-ax) + abs(ny-ay));
        }
    }

    ll ans = 0;
    for(int i = -1; i <= 1; i++){
        for(int j = -1; j <= 1; j++){
            int nx = bx + i*r, ny = by + j*c;
            if(abs(nx-ax)+abs(ny-ay) != mind)   continue;
            int x = abs(nx-ax), y = abs(ny-ay);
            ans += comb.getCombination(x+y, x);
            ans %= mod;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6688
//Allah vorosha
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pb push_back
#define pi acos(-1.0)
#define mod 1000000007

int main() {
    //std::ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //setbuf(stdout, NULL); //for interactive problem
    ll x;
    scanf("%lld",&x);
    if(x==0)
        printf("1\n");
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
lint N, X;

lint rec(lint N, lint X){
  if(N == 0) return 1;
  if(X == 1) return 0;
  lint len = (1LL << N + 1)  - 3;
  lint p =  (1LL << N) - 1;
  if(1 < X && X <= 1 + len) return rec(N - 1, X - 1);
  if(X == 2 + len) return p + 1;
  if(2 + len <= X && X <= 2 * len + 2) return p + 1 + rec(N - 1, X - len - 2);
  if(X == 2 * len + 3) return 2 * p + 1;
}

signed main(){
  cin >> N >> X;
  cout << rec(N, X) << endl;
}

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

#define INF (1<<29)
#define max_n 10000

using namespace std;

struct node_t{

  node_t *pp,*lp,*rp;
  int id,val,mini,minId,lazy;

  node_t(int id,int v):id(id),val(v){
    pp=lp=rp=NULL; lazy=0;
  }

  bool is_root(){
    return !pp || (pp->lp != this && pp->rp != this);
  }
  
  void rotr(){
    node_t *q=pp,*r=q->pp;
    if((q->lp=rp))rp->pp=q;
    rp=q;q->pp=this;
    if((pp=r)){
      if(r->lp==q)r->lp=this;
      if(r->rp==q)r->rp=this;
    }
  }

  void rotl(){
    node_t *q=pp,*r=q->pp;
    if((q->rp=lp))lp->pp=q;
    lp=q;q->pp=this;
    if((pp=r)){
      if(r->lp==q)r->lp=this;
      if(r->rp==q)r->rp=this;
    }
  }

  void splay(){
    while(!is_root()){
      node_t *q=pp;
      if(q->is_root()){
	if(q->lp==this)rotr();
	else rotl();
      } else {
	node_t *r=q->pp;
	if(r->lp==q){
	  if(q->lp==this){q->rotr();rotr();}
	  else {rotl();rotr();}
	} else {
	  if(q->rp==this){q->rotl();rotl();}
	  else {rotr();rotl();}
	}
      }
    }
  }
};

node_t *expose(node_t *x){
  node_t *rp=NULL;
  for(node_t *p=x;p;p=p->pp){
    p->splay();
    p->rp=rp;
    rp=p;
  }
  x->splay();
  //return x;
  return rp;
}

node_t *find_root(node_t *x){
  expose(x);
  while(x->lp)x=x->lp;
  return x;
}

void link(node_t *c,node_t *p){
  expose(c);
  expose(p);
  c->pp=p;
  p->rp=c;
}

node_t *lowestCommonAncestor(node_t *x,node_t* y){
  expose(x);
  return expose(y);
}

node_t *node[100001];

int main(void){
  int n;
  cin >> n;
  
  for(int i=0;i<n;i++)node[i]=new node_t(i,0);
  for(int i=0;i<n;i++){
    int k,t;
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> t;
      link(node[t],node[i]);
    }
  }

  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int u,v;
    cin >> u >> v;
    cout << lowestCommonAncestor(node[u],node[v])->id << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8220
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long K, long[] h) {
    auto sh = h.sort!"a < b";

    return iota(N - K + 1).map!(i => sh[i + K - 1] - sh[i]).reduce!min;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    long[] h = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        h[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, K, h);
    else
        solve(N, K, h).writeln;
}


Measured memory_bytes: 3964
#include<cstdio>
using namespace std;
int main(){

  int n,m;

  scanf("%d",&n);

  while(n != 0){
    
    for(int i=0;i<9;i++){
      scanf("%d",&m);
      n -= m;
    }

    printf("%d\n",n);
    
    scanf("%d",&n);
  }

  return (0);
}

Measured memory_bytes: 2612
#include<iostream>
#include<cmath>
#include<tuple>

using namespace std;

using Point = pair<int, int>;

int H, W, D;
Point A2[90001];
int L[100000];
int R[100000];
int d[90001];

int main()
{
	cin >> H >> W >> D;
	
	for (size_t i = 0; i < H; i++)
	{
		for (size_t j = 0; j < W; j++)
		{
			int a;
			cin >> a;
			A2[a] = make_pair(i, j);
		}
	}

	int Q;
	cin >> Q;

	for (size_t i = 0; i < Q; i++)
	{
		cin >> L[i] >> R[i];
	}

	for (size_t i = D + 1; i <= 90000; i++)
	{
		int x1, y1;
		int x2, y2;
		tie(x1, y1) = A2[i];
		tie(x2, y2) = A2[i - D];
		d[i] = d[i - D] + abs(x1 - x2) + abs(y1 - y2);
	}

	for (size_t i = 0; i < Q; i++)
	{
		int l = L[i];
		int r = R[i];
		int ans = d[r] - d[l];

		cout << ans << "\n";
	}

	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++) cin>>arr[i];
ll sum=round(accumulate(arr,arr+n,0.0)/n);
ll res=0;
for(int i=0;i<n;i++){
    res+=(pow((arr[i]-sum),2));
}
cout<<res<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  string S, T; cin >> S >> T;
  int N, M; cin >> N >> M;
  string C; cin >> C;
  if(C==S) N--;
  else M--;
  cout << N << " " << M << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define ff(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b) 
int toInt(const string &cad){
    int ans = 0;
    fore(i, 0, sz(cad))
        ans = ans * 10 + (cad[i] - '0');
    return ans;
}
int main(){
    //FL;
    fin;
    int n;
    cin >> n;
    int r = n % 100;
    n /= 100;
    int l = n;
    if(1 <= l && l <= 12){
        if(1 <= r && r <= 12)
            cout << "AMBIGUOUS\n";
        else
            cout << "MMYY\n";
    }else{
        if(1 <= r && r <= 12)
            cout << "YYMM\n";
        else
            cout << "NA\n"; 
    }
    time;
    return 0;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int L,R,d;
    int sum=0;
    scanf("%d %d %d",&L,&R,&d);
    for(int i=L;i<=R;i++)
    {
        if(i%d==0)
            sum++;
    }
    printf("%d",sum);
    return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }


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

    ll tmin=0, amin=0;
    rep(i,N){
        ll Ti, Ai; cin >> Ti >> Ai;
        ll g = gcd(Ti, Ai);
        Ti /= g; Ai /= g;
        // printf(" %lld %lld [%lld %lld]", tmin, amin, Ti, Ai);

        ll tmag=1, amag=1;
        if (Ti < tmin) tmag = (tmin+Ti-1)/Ti;
        if (Ai < amin) amag = (amin+Ai-1)/Ai;
        ll mag = max(tmag, amag);
        Ti *= mag; Ai *= mag;
        tmin = Ti; amin = Ai;
        // printf(" Tx%lld, Ax%lld, x=%lld -> %lld %lld\n", tmag,amag,mag, tmin,amin);
    }
    ll ans = tmin + amin;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
    int v;
    color[u] = GRAY;
    d[u] = ++tt;
    for(v = 0;v < n; v++){
        if(M[u][v] == 0) continue;
        if(color[v] == WHITE){
            dfs_visit(v);
        }
    }
    color[u] == BLACK;
    f[u] = ++tt;
}

void dfs(){
    int u;
    
    for(u = 0;u < n;u++) color[u] = WHITE;
    tt = 0;
    
    for(u = 0;u < n;u++){
        if(color[u] == WHITE) dfs_visit(u);
    }
    for(u = 0;u < n;u++){
        printf("%d %d %d\n",u + 1,d[u],f[u]);
    }
}

int main(void){
    int u,v,k,i,j;
    
    scanf("%d", &n);
    for(i = 0;i < n;i++){
        for(j = 0;j < n;j++) M[i][j] = 0;
    }
    
    for(i = 0;i < n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(j = 0;j < k;j++){
            scanf("%d",&v);
            v--;
            M[u][v] = 1;
        }
    }
    
    dfs();
}



Measured memory_bytes: 2100
#include <iostream>

using namespace std;

int main(void)
{
    int ans = 700;
    for(int i = 0; i < 3; ++i)
    {
        char order;
        cin >> order;
        if('o' == order)
            ans += 100;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	int ans;
	ans = N * N * N;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val  k = readInteger()
    var ans = 0L
    for (i in 1L..k) {
        for (j in 1L..k) {
            for (k in 1L..k) {
                ans += gcd(i, gcd(j, k))
            }
        }
    }
    println(ans)
}

/** O(log(n)): n = min(a, b) */
fun gcd(a: Long, b: Long): Long {
    var tmpA = a
    var tmpB = b
    while (tmpB != 0L) {
        val tmp = tmpB
        tmpB = tmpA % tmpB
        tmpA = tmp
    }
    return tmpA
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 34736
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(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 ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long N, std::vector<std::string> S) {
  set<string> s;
  REP(i, N) { s.insert(S[i]); }
  cout << s.size() << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  for (int i = 0; i < N; i++) {
    std::cin >> S[i];
  }
  solve(N, std::move(S));
  return 0;
}


Measured memory_bytes: 19912
#include <bits/stdc++.h>
#define N 205

namespace function_by_Lsk {

// fast io
#define Wt write
#define Wtln(x) (Wt(x), putchar('\n'))
template <typename T> inline void read(T &x) {
	x = 0; bool sgn = false; char ch = getchar();
	while(!isdigit(ch)) (ch == '-') && (sgn = true), ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	if(sgn) x = -x;
}
inline int Rd() { static int x; return read(x), x; }
template <typename T> inline void write(T x) {
	if(x < 0) {
		putchar('-'), write(-x);
	} else {
		if(x > 9) write(x / 10);
		putchar(x % 10 + '0');
	}
}

// cmin / cmax
template <typename T> inline void cmax(T &u, const T v) { if(u < v) u = v; }
template <typename T> inline void cmin(T &u, const T v) { if(u > v) u = v; }

// min / max
template <typename T> inline T max(const T u, const T v) { return u > v ? u : v; }
template <typename T> inline T min(const T u, const T v) { return u < v ? u : v; }

// math
template <typename T> inline T gcd(T u, T v) {
	return v ? gcd(v, u % v) : u;
}
inline long long fpm(long long base, int mi, int _mod) {
	long long res = 1;
	while(mi) {
		if(mi & 1) res = res * base % _mod;
		base = base * base % _mod, mi >>= 1;
	}
	return res;
}

} using namespace function_by_Lsk;

int n, ans;
int G[N][N], val[N];

int main() {
	read(n);
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			char ch = getchar();
			while(ch != '0' && ch != '1') ch = getchar();
			if(ch == '1') G[i][j] = 1;
		}
	}
	for(int i = 1; i <= n; ++i) {
		memset(val, 0, sizeof val);
		val[i] = 1;
		std :: queue<int> que;
		que.push(i);
		while(!que.empty()) {
			int u = que.front(); que.pop();
			for(int j = 1; j <= n; ++j) {
				if(G[u][j]) {
					if(!val[j]) { val[j] = val[u] + 1, que.push(j); }
					else if(abs(val[j] - val[u]) != 1) {
						puts("-1");
						return 0;
					}
				}
			}
		}
		for(int i = 1; i <= n; ++i) if(ans < val[i]) ans = val[i];
	}
	Wtln(ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<vector>
int main()
{
	std::vector<bool>is_prime(50020, true);
	const int root = static_cast<int>(floor(sqrt(50021)));
	for (int i = 0; i <= root - 2; i++)
	{
		if (is_prime[i])
		{
			for (int j = i + 2; (i + 2) * j < 50021; j++)
			{
				is_prime[(i + 2) * j - 2] = false;
			}
		}
	}
	for (int n; std::cin >> n;)
	{
		for (int i = n - 2 - 1;; i--)
		{
			if (is_prime[i])
			{
				std::cout << i + 2 << ' ';
				break;
			}
		}
		for (int i = n - 2 + 1;; i++)
		{
			if (is_prime[i])
			{
				std::cout << i + 2 << std::endl;
				break;
			}
		}
	}
	return 0;
}


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

int main(){
    int n;
    int a[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int j=n-1;j>=0;j--){
        if(j==0){
            cout<<a[j]<<endl;
        }else{
            cout<<a[j]<<" ";
        }
    }
    return 0;
}


Measured memory_bytes: 3088
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    h = int(input())
    w = int(input())
    n = int(input())
    if h>=w:
        print((n-1)//h+1)
    else:
        print((n-1)//w+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
  str S, T;
  cin >> S >> T;

  bool flag = false;

  rep(i,0,sz(S)){
    if(T[0] == S[i]){
      ll t = i;
      rep(j,0,sz(T)){
        if(T[j] != S[t]) break;
        t++;
        if(t == sz(S)) t = 0;
      }
      if(t == i){
        flag = true;
        break;
      }
    }
  }

  if(flag) print("Yes");
  else print("No");


  return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    //static int[] dp;
    //static decimal[,,] dp;
    //static decimal N;
    static void Main(string[] args)
    {
        // 入力
        int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
        int N = input[0];
        int K = input[1];
        int Q = input[2];

        // 参加者iの人の正解数を記録する
        int[] ans = new int[N + 1];
        for (int i = 0; i < Q; i++)
        {
            int a = int.Parse(Console.ReadLine());
            ans[a] += 1;
        }

        for(int i=1; i<=N; i++)
        {
            if(K - (Q-ans[i]) > 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }


}


Measured memory_bytes: 17728
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define check system("pause")
#define all(x) (x).begin(),(x).end()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
const ll mod = 1e9+7;
const int N = 1e6+20;
#define dep(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define mes(p,b) memset(p,b,sizeof(p))
#define sz(x) int(x.size())

int main()
{
  	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int k,a,b;
	cin>>k>>a>>b;
	int ans=0;
	rep(i,a,b){
		if(i%k==0) ans=1;
	}
	if(ans) cout<<"OK";
	else 	cout<<"NG";
	  	return 0;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct data{
	int bit,x,y;
	data(){}
	data(int bb,int yy,int xx){
		bit=bb;
		x=xx;
		y=yy;
	}
	bool operator<(const data &d)const{
		return bit<d.bit;
	}
};

int h,w;
string str[20];
int fie[19][15];
map<data,int> mp;
int bsize=0;
P black[20];
int sx,sy;

int bfs(){
	queue<data> que;
	que.push(data((1<<bsize)-1,sy,sx));
	mp[data((1<<bsize)-1,sy,sx)]=0;
	while(que.size()){
		data d=que.front();
		que.pop();
		for(int i=-1;i<=1;i++){
			for(int j=-1;j<=1;j++){
				if(i==0 && j==0)continue;
				for(int k=0;k<bsize;k++){
					if(d.bit>>k & 1){
						fie[black[k].first][black[k].second]=k+1;
					}else{
						fie[black[k].first][black[k].second]=0;
					}
				}
				int cnt=0;
				int nx=d.x;
				int ny=d.y;
				int nbit=d.bit;
				if(nx+j>=0 && nx+j<w && ny+i>=0 && ny+i<h){
					if(fie[ny+i][nx+j]==0)continue;
					nx+=j;
					ny+=i;
					while(nx>=0 && nx<w && ny>=0 && ny<h){
						if(fie[ny][nx]==0)break;
						nbit-=1<<(fie[ny][nx]-1);
						nx+=j;
						ny+=i;
					}
					if(ny>=h || (ny==h-1 && nx>=0 && nx<=w-1)){
						return mp[data(d.bit,d.y,d.x)]+1;
					}else if(nx>=0 && nx<w && ny>=0 && ny<h){
						if(mp.find(data(nbit,ny,nx))==mp.end()){
							mp[data(nbit,ny,nx)]=mp[data(d.bit,d.y,d.x)]+1;
							que.push(data(nbit,ny,nx));
						}
					}
				}
			}
		}
	}
	return -1;
}

int main(void){
	h=19;
	w=15;
	for(int i=0;i<h;i++){
		cin >> str[i];
		for(int j=0;j<w;j++){
			if(str[i][j]=='X'){
				black[bsize++]=P(i,j);
			}
			if(str[i][j]=='O'){
				sy=i;
				sx=j;
			}
		}
	}
	printf("%d\n",bfs());
	return 0;
}

Measured memory_bytes: 8484
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i64,
        y: i64,
    }

    let y_x2 = y - 2 * x;
    let x4_y = 4 * x - y;
    if y_x2 % 2 == 0 && x4_y % 2 == 0 && y_x2 >= 0 && x4_y >= 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;
ll n,m,v,p;
vector<ll> a;
vector<ll> ruiseki;

ll judge(ll x){
  ll bd = a.at(n-p);
  if(x+p>=v){
    if(bd<=a.at(x)+m) return 1; else return 0;
  }
  if(bd>(a.at(x)+m)) return 0;
  ll rui = ruiseki.at(n-p) - ruiseki.at(x);
  ll votecount = (v-(x+p)) * m;
  ll maximum = (n-p-x) * (a.at(x)+m);
  if((ll)(rui+votecount)>maximum){
    return 0;
  }else{
    return 1;
  }
}

int main(){
  cin >> n >> m >> v >> p;
  a.resize(n,0);
  for(ll i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());

  ruiseki.resize(n,0);
  ruiseki.at(0) = a.at(0);
  for(ll i=1;i<n;i++){
    ruiseki.at(i) = ruiseki.at(i-1) + a.at(i); 
  }
  ll l = -1;
  ll r = n-1;
  ll c = (l+r)/2;
  while(r-l>1){
    if(judge(c) == 1) r=c; else l=c;
    c = (l+r)/2;
  }
  cout << n-r << endl;
}


Measured memory_bytes: 1792