akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
import math
n = int(input())
# largest n is 10**4
m = int(math.sqrt(n)) + 1
d = defaultdict(int)
for i in range(1, m):
    for j in range(1, m):
        for k in range(1, m):
            d[i**2+j**2+k**2+i*j+j*k+k*i] += 1
for i in range(1, n+1):
    print(d[i])

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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  
  if (a%2==0 || b%2==0 || c%2==0)
    cout << 0 << endl;
  
  else
    cout << min(min(a*b,b*c),c*a) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define int long long int
int mod=1e9+7;
#define p_b push_back
#define p_f push_front
#define P_f pop_front
#define P_b pop_back
#define len() length()
#define sz() size()
#define u_b upper_bound
#define l_b lower_bound
#define ins insert
#define str string 
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define db double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define F first
#define S second
#define T third
#define endl "\n"
using namespace std;
typedef map<int,int> Map;
typedef pair<int,int> pr;
typedef vector<int> vec;
const int INF = 1e18;
const int MAX =1e6;
int power(int a,int b)
{   
    if(b==0)
    return 1;
    int num=1;
    int m=mod;
    while(b!=1)
    { 
        if(b%2==0)
        { 
            a*=a;
            a%=m;
            b/=2;
        }
        else
        { 
            num*=a;
            num%=m;
            b--;
        }
        
    }
    return (a*num)%m;
}
void solve()
{
    int l,r,d;
    cin>>l>>r>>d;
    int c=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
        c++;
    }
    cout<<c<<endl;
}
int32_t main()
{    
    fio;
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {   
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
tmp = input().split()
N = int(tmp[0])
K = int(tmp[1])
sunuke = [0]*N

for k in range(K):
    tmp = input().split()
    d = int(tmp[0])
    tmp = input().split()
    for di in range(d):
        A = int(tmp[di])
        sunuke[A-1] = sunuke[A-1] + 1

trick = 0

for s in sunuke:
    if s == 0:
        trick = trick + 1

print(trick)

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

def chk(a,t):
  ans = 0
  x = 0
  for i in a:
    x += i
    if t==True and x<1:
      ans += 1-x
      x = 1
    elif t==False and x>-1:
      ans += x+1
      x = -1
    t=not t
  return ans
print(min(chk(a,True),chk(a,False)))
    
  
  


Measured memory_bytes: 14212
import math
mod = 10**9+7

n,m = map(int,input().split())

m_p = {}
m_t = m
for i in range(2,math.ceil(m**0.5)+1) :
  if m_t%i == 0:
    m_p[i] = 0
    for j in range(10**9) :
      m_p[i] += 1
      m_t //= i
      if m_t%i != 0 :
        break
if m_t != 1 :
  m_p[m_t] = 1
  
ans = 1
for v in m_p.values() :
  # nCr = c1/c2　とおく
  # n = v+(n-1)
  # r = v
  c1 = 1
  # c1 = (v+n-1)*(v-1+n-1)*...*((v-(v-1))+n-1)の計算
  for i in range(v) :
    c1 = c1*(v-i+n-1)%mod
  # 1/c2 = (1/v)*(1/(v-1))*...*(1/1)の計算
  c2 = 1
  for i in range(v) :
    c2 = c2*pow(v-i,mod-2,mod)%mod
  ans *= c1*c2%mod
  ans %= mod
  
print(ans)

Measured memory_bytes: 3064
def monthable? number
  (1..12).include? number
end

s = gets.chomp.to_i
former = s / 100
latter = s % 100

is_former_monthable = monthable? former
is_latter_monthable = monthable? latter

answer =
  case
  when is_former_monthable && is_latter_monthable
    "AMBIGUOUS"
  when is_former_monthable && !is_latter_monthable
    "MMYY"
  when !is_former_monthable && is_latter_monthable
    "YYMM"
  else
    "NA"
  end

puts answer


Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

void print_arr(vector<int> A)
{
    rep (i, 0, A.size())
        if (i != A.size()-1)
            printf("%d ", A[i]);
        else
            printf("%d\n", A[i]);
}

void insertion_sort(int N, vector<int> A)
{
    for (int i = 0; i < N; i++) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 and A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        print_arr(A);
    }
}

int main()
{
    int N; cin >> N;
    vector<int> A(N);
    rep (i, 0, N) cin >> A[i];

    insertion_sort(N, A);
}


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

int main(){
    int k,s;
    cin>>k>>s;
    int ans=0;
    for(int i=0;i<=k;i++){
        for(int  j=0;j<=k;j++){
            int t=s-i-j;
            if(t<=k&&t>=0){ans++;
            }
        }
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n, m = map(int, input().split())
broken = [False] * (n + 1)
for i in range(m):
    a = int(input())
    broken[a] = True
dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    dp[i] %= MOD
    if broken[i]:
        dp[i] = 0
    if i + 1 <= n:
        dp[i+1] += dp[i]
    if i + 2 <= n:
        dp[i+2] += dp[i]
print(dp[n] % MOD)

Measured memory_bytes: 7668
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(3).
01 a              PIC 9(1).
01 b              PIC 9(1).
01 n              PIC 9(1).
01 i              PIC 9(2).
01 ans            PIC X(9).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO a b.
  IF a < b
    MOVE b TO n
  ELSE
    MOVE a TO n
    MOVE b TO a
  END-IF.
  PERFORM VARYING i FROM 1 BY 1 UNTIL n < i
    MOVE a TO ans(i:1)
  END-PERFORM.
  DISPLAY ans(1:n).
  STOP RUN.


Measured memory_bytes: 1144
N=int(input())
i=0
while i<N:
    a,b,c=map(int,input().split())
    if a*a==b*b+c*c or b*b==c*c+a*a or c*c==a*a+b*b:
        print('YES')
    else:
        print('NO')
    i+=1


Measured memory_bytes: 5592
N = int(input())
a = list(map(int,input().split()))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    gcda = gcd(a,b)
    return a*b//gcda
def lcmlist(lista):
    if len(lista) == 1:
        return lista[0]
    else:
        from functools import reduce
        return reduce(lcm,lista)
lcma = lcmlist(a)-1
ans = 0
for i in a:
    ans += lcma%i
print(ans)

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    rep(i,n){
        cin >> to[0][i];
        to[0][i]--;
    }
    rep(i,D-1){
        rep(j,n){
            to[i+1][j] = to[i][to[i][j]];
        }
    }
    int v = 0;
    for(int i = D-1; i >= 0; --i){
        ll l = 1LL<<i;
        if(l <= k){
            v = to[i][v];
            k -= l;
        }
    }
    cout << v + 1 << endl;
    return 0;
}

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

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

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int k; 
	cin >> k; 
	
	int rep7 = 7; 
	int result = -1; 
	for(int i = 1; i <= k+1; i++) {
		if(rep7 % k == 0) {
			result = i; 
			break; 
		}
		rep7 = (10 * rep7) % k; 
		rep7 = (rep7 + 7) % k; 
	}
	
	cout << result << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <map>
#include <iostream>

using namespace std;

int main() {
    long int n, k;
  
    cin >> n >> k;
  
    vector<int> a(n), d(n + 1);
    
    for(long int i=0;i<n;i++)
      cin >> a[i];
  
    for(long int i=0;i<n;i++) {
        d[i + 1] = d[i] + a[i];
        d[i + 1] %= k;
    }
    map<long int,long int> m;
  
    long int ans = 0;
  
    queue<long int> q;

for (long int i=0;i<=n;i++) {
        int t = (d[i] - i) % k;
      
        if (t < 0) t += k;
        
        ans += m[t];
        m[t]++;
        
        q.push(t);
        if (q.size() >= k) {
            m[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
   
}


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

int main() {
    int a, b, x;

    cin >> a;
    cin >> b;
    cin >> x;

    if(x < a) {
        cout << "NO" << endl;
    }
    else if(x - a <= b) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;


int main() {
	int n; cin >> n;
	vector<ll> a(n + 2), b(n + 2);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	bool flag = true;
	for (int i = 0; i < n; i++) flag &= a[i] == b[i];
	if (flag) {
		cout << 0 << endl;
		return 0;
	}
	ll s = 0, ans = 0;
	for (int i = 0; i < n; i++) s += a[i];
	for (int i = 0; i < n; i++) {
		if (a[i] <= b[i]) continue;
		ans = max(ans, s - b[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

vector<int> v[101],ans;
int main(){
    int n;
    while(cin>>n,n){
        rep(i,n+1){
            v[i].clear();
            v[i].pb(i);
        }
        ans.clear();
        int l,u;
        while(cin>>u>>l,u!=0||l!=0){
            int tgl=-2,tgu=-1;
            int cl=-1,cu=-1;
            FOR(i,1,n+1){
                rep(j,v[i].size()){
                    if(v[i][j]==u) cu=j,tgu=i;
                    if(v[i][j]==l) cl=j,tgl=i;
                }
            }
            if(tgu==tgl){
                if(cu<cl){
                    int cur=v[tgl].size();--cur;
                    while(cu!=cur){
                        v[v[tgl][cur]].pb(v[tgl][cur]);
                        v[tgl].pop_back();
                        --cur;
                    }
                    v[tgl].pop_back();v[l].pb(u); 
                }
            }
            else{
                if(cu==0&&cl==-1) continue;
                if(cl==-1) tgl=u;
                int cur=v[tgu].size();--cur;
                while(cu!=cur){
                    v[v[tgu][cur]].pb(v[tgu][cur]);
                    v[tgu].pop_back();
                    --cur;
                }
                v[tgu].pop_back();v[tgl].pb(u);
            }
        }
        FOR(i,1,n+1) ans.pb(v[i].size());
        sort(ans.begin(),ans.end());
        for(auto it:ans)if(it!=0)cout<<it<<endl;
        cout<<"end"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,l,x;
  cin >> N;
  vector<int> data = vector<int>(1, 0);
  l = data.size();
  for (int i = 0; i < N; i++) {
    cin >> x;
    for (int j = 0; j < l; j++) {
      if(data.at(j) == x){
        break;
      }else if(j == l-1){
        data.push_back(x);
      }
    }
    l = data.size();
  }
  cout << l-1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define pb push_back
#define sz size()
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    auto b = a;
    ll res = 0, sum = 0;
    rep(i, n){
        if(a[i] == 0){
            res += sum / 2;
            sum = 0;
        }
        else sum += a[i];
    }
    res += sum / 2;
    cout << res << endl;
}





Measured memory_bytes: 4848
import java.util.*;
import java.util.Map.Entry;
 
 

class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   public static void main(String[] args) {
   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       boolean[] visited2 = new boolean[N*N];
       int[] cntc = new int[N*N];
       int[] first = new int[N];
       int[] weight;
  	   List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
       for(long i=0;i<N*N/2;i++)list.add(new ArrayList<Integer>());
       int deka=0;
       int tmp=0;
       int a=0;
       for(int i=0;i<N;i++) {
           int pre=0;
       	for(int j=0;j<N-1;j++){
       		a=sc.nextInt();
       		deka=Math.min(a-1, i);
       		tmp=deka*N+Math.max(a, i+1)-(deka+2)*(deka+1)/2;
       		if(pre!=0) {
               	list.get(pre).add(tmp);      	
               	visited2[tmp]=true;
               	cntc[tmp]++;
       		} else {
           		first[i]=tmp;
       		}
       		pre=tmp;
       	}
       }
       Arrays.sort(first);
		int max=0;

		LinkedList<Integer> queue = new LinkedList<Integer>();
	    int[] tcnt= new int[N*N];
	    weight=new int[N*N];
		int p=-1;
		for(int i=0;i<first.length;i++) {
			if(p!=first[i]&&visited2[first[i]]==false) {
		       	queue.add(first[i]);
		       	queue.add(1);				
			}
			p=first[i];
       }
		
		int cnt=0;
		boolean[] visited = new boolean[N*N];
   	while(!queue.isEmpty()) {
   		int n = queue.poll();
   		int w = queue.poll();
   		if(w!=1)cnt++;
   		tcnt[n]++;
		if(tcnt[n]<cntc[n])continue;
   		if(visited[n]) {
   			System.out.println(-1);
   			return;
   		}
		weight[n]=w;
		max=Math.max(max, w);
   		for(int i:list.get(n)) {
   			queue.add(i);
   			queue.add(w+1);
   		}
   		visited[n]=true;
   	}
   	
   	if(cnt!=N*(N-2))max=-1;
    System.out.println(max);  	
              		
   }

}

Measured memory_bytes: 289752
#coding: utf-8
STDOUT.sync = true

def gcd(x, y)
  while ((z = x % y) != 0) do
    x = y;
	y = z;
  end
  return y
end

def lcm(x, y)
  return x * y / gcd(x, y)
end


while data = STDIN.gets do
  num = data.split().map!(&:to_i)
  ans_g = gcd(num[0], num[1])
  ans_l = lcm(num[0], num[1])
  printf("%d %d\n", ans_g, ans_l)
end

Measured memory_bytes: 8552
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int N,an;
void dfs(LL v,int mask){
    if(v>N)return;
    if(mask==7)an++;
    dfs(v*10+3,mask|1);
    dfs(v*10+5,mask|2);
    dfs(v*10+7,mask|4);
}
int main(){
    R(N);
    dfs(0,0);
    W(an);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Dijkstra {
  private:
    struct Graph {
        int to, cost;
    };
    const long long INF = 4'000'000'000'000'000'000;
    using P             = pair<long long, int>;
    int V;
    vector<vector<Graph>> G;
    vector<long long> dist;

  public:
    Dijkstra(int vertex) {
        V = vertex;
        G.resize(vertex);
        dist.resize(vertex, INF);
    }
    // 無向グラフの構築
    void undirected_update(int x, int y, int cost) {
        G[x].push_back({y, cost});
        G[y].push_back({x, cost});
    }
    // 有向グラフの構築
    void directed_update(int from, int to, int cost) {
        G[from].push_back({to, cost});
    }

    // start からの最短経路計算
    void calc(int start) {
        priority_queue<P, vector<P>, greater<P>> que;
        dist[start] = 0;
        que.push({0, start});

        while (!que.empty()) {
            auto p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first)
                continue;
            for (int i = 0; i < G[v].size(); i++) {
                auto e = G[v][i];
                if (dist[v] + e.cost < dist[e.to]) {
                    dist[e.to] = dist[v] + e.cost;
                    que.push({dist[e.to], e.to});
                }
            }
        }
    }

    // calc で渡した start からの最短経路を返す
    // 最短経路が存在しないとき -1 を返す
    long long min_dist(int to) { return dist[to] != INF ? dist[to] : -1; }
};

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

    int N;
    cin >> N;
    auto dj = Dijkstra(N);
    REP(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        dj.undirected_update(a, b, c);
    }
    int Q, K;
    cin >> Q >> K;
    dj.calc(K - 1);
    REP(i, Q) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        ll ans = dj.min_dist(x) + dj.min_dist(y);
        std::cout << ans << '\n';
    }

    return 0;
}

Measured memory_bytes: 9460
#include <stdio.h>
#include <stdlib.h>

int top = 0,stack[100];
void push(int);
int pop(void);

int main(){
  int num1,num2;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      push(pop() + pop());
    } else if ( s[0] == '-' ){
      num1 = pop();
      num2 = pop();
      push(num2 - num1);
    } else if ( s[0] == '*' ){
      push(pop() * pop());
    } else {
    push(atoi(s));
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int num){
  top++;
  stack[top] = num;
}

int pop(void){
  top--;
  return stack[top+1];
}



Measured memory_bytes: 2048
N, M = map(int, input().split())

flg = False
for a in range(0, N+1):
    for b in range(0, N-a+1):
        c = N - (a+b)
        S = 10000*a + 5000*b + 1000*c
        if (S == M) and (c >= 0):
            flg = True
            ans_a = a
            ans_b = b
            ans_c = c

if flg == True:
    print(ans_a, ans_b, ans_c)
else:
    print(-1, -1, -1)

Measured memory_bytes: 3064
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(A[K-1])

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, K;
    int rem[30][30];

    while(cin >> H >> W >> K) {
        vector<string> S(H);
        rep(y, H)cin >> S[y];

        ll ans = 0;

        rep(remY, H)rep(remX, W) {
            vector<list<int>> ls(W);
            rep(x, W) {
                rep(y, H) {
                    if(y != remY || x != remX)ls[x].push_back(S[H-1-y][x] - '0');
                }
            }

            vector<list<int>::iterator> its(W);

            int upd = 1;
            ll mul = 1, value = 0;
            while(upd) {
                ll sm = 0;
                upd = 0;
                vi col(W);
                MEM(rem, 0);

                rep(x, W)its[x] = ls[x].begin();

                int row = 0;
                for(; row < H && count(all(col), -1) != W; ++row) {
                    int cur = -1, start = -1, suc = 0;
                    rep(x, W) {
                        if(its[x] == ls[x].end())col[x] = -1;
                        else col[x] = *its[x];
                        if(cur != col[x]) {
                            if(cur != -1 && suc >= K) {
                                FOR(i, start, x)rem[row][i] = 1;
                                upd = 1;
                            }
                            suc = 1;
                            cur = col[x];
                            start = x;
                        } else {
                            suc++;
                        }
                    }

                    if(cur!=-1 && suc >= K) {
                        FOR(i, start, W)rem[row][i] = 1;
                        upd = 1;
                    }
                    rep(x, W) {
                        if(rem[row][x]) {
                            sm += *its[x];
                            its[x] = ls[x].erase(its[x]);
                        } else if(its[x] != ls[x].end()) {
                            its[x]++;
                        }
                    }
                }

                value += sm*mul;

                mul *= 2;
            }

            
            smax(ans, value);
        }
        cout << ans << endl;
    }
}

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

void solve(void)
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> flag(n, -1);
    int cta = 0;
    rep(i, n)
    {
        if (flag[i] == -1)
        {
            flag[i] = cta;
            queue<int> q;
            q.push(i);
            while (!q.empty())
            {
                int nxt = q.front();
                q.pop();
                for (auto j : g[nxt])
                {
                    if (flag[j] == -1)
                        flag[j] = cta, q.push(j);
                }
            }
            cta++;
        }
    }
    cout << *max_element(flag.begin(), flag.end()) << endl;
}
int main(void)
{
    solve();
}


Measured memory_bytes: 8712
import math
N,M = map(int, input().split())
def combinations_count(n,r):
	if n == 0 or n == 1:
		return 0
	elif n == 2:
		return 1
	else: return math.factorial(n) // (math.factorial(n-r)*math.factorial(r))
print(combinations_count(N,2) + combinations_count(M,2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
const int SIZE=5+2*1e5;
const LL INF=1<<30;
int main(){
	int n,x;
	cin >> n >> x;
	if(n==2){
		if(x==2) 
			cout <<"Yes" << endl << 1 << endl <<2 <<endl <<3 << endl;
		else cout <<"No" << endl;			
	}
	else if(x==1 or x==2*n-1) cout << "No" << endl;
	else {
		int now=1;
		int from=x-2,to=x+1;
		cout << "Yes" << endl;
		if(x==2) {from++;to++;}
		REP(i,n-3){
			if(now==from) now=to+1;
			cout << now << endl;
			now++;
		}
		if (x==2) 
			cout << 3 << endl << 2 << endl << 1 << endl << 4 << endl;
		else cout << x-2 << endl << x <<endl << x+1 <<endl << x-1 << endl;
		REP(i,n-2){
			if(now==from) now=to+1;
			cout << now << endl;
			now++;

		}

	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long int ll;

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

  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    int buf;
    cin >> buf;
    A.push_back(buf);
  }

  // x0/2 + x1/2 = a0
  // x1/2 + x2/2 = a1
  // x2/2 + x3/2 = a2
  // x3/2 + x4/2 = a3
  // x4/2 + x0/2 = a4

  // x0 = a0 - a1 + a2 - a3 + a4
  // x1 = a1 - a2 + a3 - a4 + a0
  // x2 = a2 - a3 + a4 - a0 + a1
  // x3 = a3 - a4 + a0 - a1 + a2
  // x4 = a4 - a0 + a1 - a2 + a3
  vector<ll> posSum(1, 0), negSum(1, 0);
  ll pos, neg;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      pos = A[i];
      neg = -A[i];
    }
    else {
      pos = -A[i];
      neg = A[i];
    }
    posSum.push_back(posSum[i] + pos);
    negSum.push_back(negSum[i] + neg);
  }
  vector<ll> rain;
  for (int i = 0; i < N; i++) {
    ll x;
    if (i % 2 == 0) x = negSum[i] + (posSum[N] - posSum[i]);
    else x = posSum[i] + (negSum[N] - negSum[i]);
    rain.push_back(x);
  }

  for(int i = 0; i < rain.size(); i++) {
    cout << rain[i];
    if (i < rain.size()-1) cout << " ";
    else cout << endl;
  }
  return 0;
}


Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1000000000000000;

int main()
{
    int n;
    cin >> n;
    ll a[200003];
    for(int i = 0; i < n; i++) cin >> a[i];
    ll l[200003], r[200003];
    l[0] = l[1] = 0;
    set<P> st;
    for(int i = 2; i <= n; i++){
        l[i] = l[i - 1];
        if(a[i - 2] < a[i - 1]){
            ll b = 0;
            ll s = a[i - 2];
            while(s < a[i - 1]){
                s *= 4;
                b += 2;
            }
            int t = i - 1;
            while(st.size()){
                auto itr = --st.end();
                P p = *itr;
                st.erase(itr);
                if(p.second > b){
                    l[i] += (t - p.first) * b;
                    st.insert(P(p.first, p.second - b));
                    b = 0;
                    t = p.first;
                    break;
                }
                l[i] += (t - p.first) * b;
                t = p.first;
                b -= p.second;
            }
            if(b) l[i] += b * t;
        }
        else{
            ll b = 0;
            ll s = a[i - 1];
            while(s <= a[i - 2]){
                s *= 4;
                b += 2;
            }
            b -= 2;
            if(b) st.insert(P(i - 1, b));
        }
    }
    for(int i = 0; i <= n; i++) l[i] += i;
    st.clear();
    r[n] = r[n - 1] = 0;
    for(int i = n - 2; i >= 0; i--){
        r[i] = r[i + 1];
        if(a[i + 1] < a[i]){
            ll b = 0;
            ll s = a[i + 1];
            while(s < a[i]){
                s *= 4;
                b += 2;
            }
            int t = n - i - 1;
            while(st.size()){
                auto itr = st.begin();
                P p = *itr;
                st.erase(itr);
                if(p.second > b){
                    r[i] += (t - p.first) * b;
                    st.insert(P(p.first, p.second - b));
                    b = 0;
                    t = p.first;
                    break;
                }
                r[i] += (t - p.first) * b;
                t = p.first;
                b -= p.second;
            }
            if(b) r[i] += b * t;
        }
        else{
            ll b = 0;
            ll s = a[i];
            while(s <= a[i + 1]){
                s *= 4;
                b += 2;
            }
            b -= 2;
            if(b) st.insert(P(n - i - 1, b));
        }
    }
    ll ans = INF;
    for(int i = 0; i <= n; i++) ans = min(ans, l[i] + r[i]);
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int x, y;
  cin >> x >> y;

  bool is_yes {false};
  for (auto i = 0;i <= x;++i) {
    if (y == 4*i+2*(x-i)) {
      is_yes = true;
    }
  }
  if (is_yes == true) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	var n string
	switch s {
	case "Sunny":
		n = "Cloudy"
	case "Cloudy":
		n = "Rainy"
	case "Rainy":
		n = "Sunny"
	}
	fmt.Printf("%s\n", n)
}


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

int main() {
  int a, b, c;  
  cin >> a >> b >> c;
  string text = "No";
  if (a == b && a != c){
    text = "Yes";
  }
  if (a == c && b != c){
    text = "Yes";
  }
  if (b == c && a != c){
    text = "Yes";
  }

  cout << text << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;


signed main() {
  int n;
  cin>>n;
  for(int i=1;i<10;i++){
    if(n%i==0&&(n/i)<10){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
  return 0;
}


Measured memory_bytes: 256
while True:
    a, op, b = [x for x in input().split()]
    a, b = int(a), int(b)

    if op == '?':
        break
    if op == '+':
        print(a + b)
    if op == '-':
        print(a - b)
    if op == '*':
        print(a * b)
    if op == '/':
        print(a // b)


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

int n, k;
int a[maxn << 1];

void work()
{
    read(k); read(n);
    for(int i = 0; i < n; i++) read(a[i]);

    for(int i = 0; i < n; i++) a[i + n] = a[i] + k;

    int ans = 1e9;

    for(int i = 0; i < n; i++) ans = min(ans, a[i + n - 1] - a[i]);

    cout <<ans <<endl;
}



int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

int main(){
	int w[10];
	int k[10];
	int ks = 0, ws = 0;
	rep(i, 10) cin >> w[i];
	rep(i, 10) cin >> k[i];
	sort(w, w + 10);
	sort(k, k + 10);
	ws = w[9] + w[8] + w[7];
	ks = k[9] + k[8] + k[7];
	cout << ws << " " << ks << endl;
	return 0;
}

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

char str1[200005], str2[200005];

int main(void)
{
    char a[26] = {0}, b[26] = {0};

    scanf("%s %s", str1, str2);
    for (int i = 0, len = strlen(str1); i < len; i++)
    {
        a[str1[i] - 'a']++;
        b[str2[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++)
    {
        int flag = 0;
        for (int j = 0; j < 26; j++)
        {
            if (a[i] == b[j])
            {
                b[j] = 0;
                flag = 1;
                break;
            }
        }
        if (!flag)
        {
            printf("No\n");
            return 0;
        }
    }

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

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int a, b; 
  	cin >> a >> b;
  	cout << ((b-1)+(a-2))/(a-1) << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin >> a >> b >> c;
    int count = 0;

    if(a==b)    count +=1;
    if(a==c)    count += 1;
    if(b==c)    count += 1;
    if(count == 3){
        cout << 1 << '\n';
    }else if(count == 1){
        cout << 2 << '\n';
    }else{
        cout << 3 << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(NULL);
void solve(){
	ll k;
	cin>>k;
	ll val = 0;
	if(k % 2 == 0){
		cout<<-1;
		return;
	}
	bool flag = true;
	ll i = 1;
	for(; i <= k + 1; i++){
		val = (val * 10 + 7) % k;
		if(val % k == 0){
			flag = false;
			break;
		}
	}
	if(flag == false) cout<<i;
	else cout<<-1;
}
	
int main(){
	solve();
	return 0;
}
	


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
# include <math.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    lli n;
    cin>>n;
    lli a[n];
    for(int i = 0; i < n; i ++)
        cin>>a[i];
    lli ans = 0;
    for(int i = 0; i < n; i ++)
    {
        for(int j = i + 1;  j <  n; j ++)
        {
            ans += a[i] * a[j];
        }
    }
    cout<<ans<<endl;
    return ;
}
/*
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(int argc, char const *argv[])
{
  int n,i,x;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    x = i;
    if (x%3==0 || x%10==3) {
      printf(" %d", i);
    }
    else {
      while (x!=0) {
        x/=10;
        if (x%10==3) {
          printf(" %d", i);
          break;
        }
      }
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n , a;
    cin >> n >> a;
    int x;
    long long int dp[2550][55] ={1};
    long long int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> x;
        for(int j = 2500; j >= 0; j--)
            for(int k =0; k < n; k++)
                if(dp[j][k] && j + x <= 2550)    dp[j + x][k + 1] += dp[j][k];
    }
    for(int i = 1; i < 2550; i++)
        for(int j = 1; j <= n; j++)
            if(i % j == 0 && i / j == a && dp[i][j])    ans += dp[i][j];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
N = int(input())
A = list(map(int, input().split()))
R = [0] * (N + 1)
for i in range(N):
  R[i + 1] += R[i] + A[i]
#print(R)  

ans = 10 ** 15
l, r = 2, 4
for i in range(3, N):#R[:i]とR[i:]に切る
  #R[:l], R[l:i], R[i:r], R[r:]
  #R[l - 1] と R[i - 1] - R[l - 1] の差を考える
  
  while abs(R[i - 1] - 2 * R[l]) <= abs(R[i - 1] - 2 * R[l - 1]):
    l += 1
    
  #R[r - 1] - R [i - 1] と R[N] - R[r - 1] の差を考える  
  while abs(R[N] - 2 * R[r] + R[i - 1]) <= abs(R[N] - 2 * R[r - 1] + R[i - 1]):
    r += 1  
  
  now_max = max(max(R[l - 1], R[i - 1] - R[l - 1]), max(R[r - 1] - R[i - 1], R[N] - R[r - 1]))
  now_min = min(min(R[l - 1], R[i - 1] - R[l - 1]), min(R[r - 1] - R[i - 1], R[N] - R[r - 1]))
  ans = min(ans, now_max - now_min)
  #print(R[l - 1], R[i - 1] - R[l - 1],R[r - 1] - R[i - 1], R[N] - R[r - 1], ans)
print(ans)
    
  
  

Measured memory_bytes: 103824
N = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))
T = sum(t)*2
vt = [min((i/2),((T-i)/2)) for i in range(T+1)]
ts = 0
te = 0
for i,ti in enumerate(t):
    te += ti*2
    vi = v[i]
    for j in range(ts,te):
        vt[j] = min(vt[j],vi)
    for j in range(te,T):
        if vt[j] >= (j-te)/2 + vi:
            vt[j] = (j-te)/2 + vi
        else:
            break
    for j in range(ts-1,-1,-1):
        if vt[j] >= -(j-ts)/2 + vi:
            vt[j] = -(j-ts)/2 + vi
        else:
            break
    ts = te
print(sum(vt)/2)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  ll odd_num = 0;
  ll even_num = 0;
  FOR(i,1,N+1){
    if(i%2==0) even_num++;
    else odd_num++;
  }
  
  printf("%.16lf\n", ((double)odd_num/N));


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int x;
    cin>>x;
    int base=400;
    rep(i,0,10){
        if(x>=base+200*i&&x<=(base+200*i)+199){
            cout<<8-i<<endl;
            return 0;
    }
    }
    return 0;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    uint64_t N, A, B;
    cin >> N >> A >> B;
    if (N <= A) {
        cout << N << endl;
        return 0;
    } if (A == 0) {
        cout << 0 << endl;
        return 0;
    } if (B == 0) {
        cout << N << endl;
        return 0;
    } else {
        uint64_t n = N / (A+B);
        uint64_t n2 = N % (A+B);
        if (n2 > A) n2 = A; 
        uint64_t n3 = A * n + n2;
        cout << n3 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = ns()[::-1]
ans = "YES"

while len(s) > 1:
    if s[:5] == "maerd":
        s = s[5:]
    elif s[:7] == "remaerd":
        s = s[7:]
    elif s[:5] == "esare":
        s = s[5:]
    elif s[:6] == "resare":
        s = s[6:]
    else:
        ans = "NO"
        s = ""

print(ans)

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

#[fastout]
fn main() {
    input! {h: usize, w: usize, s: [String; h]};
    let s: Vec<String> = s;
    let mut v: Vec<Vec<char>> = vec![Vec::new(); h + 2];
    let p_t: bool = true;
    let p_b: bool = true;

    for i in 0..h {
        if i == 0 {
            for _ in 0..w + 2 {
                v[0].push('.');
            }
        }

        v[i + 1].push('.');
        for s_i in s[i].chars() {
            v[i + 1].push(s_i);
        }
        v[i + 1].push('.');

        if i == h - 1 {
            for _ in 0..w + 2 {
                v[i + 2].push('.');
            }
        }
    }

    for row_i in 1..h + 1 {
        for col_i in 1..w + 1 {
            let mut count = 0;

            if v[row_i - 1][col_i] == '#' {
                count += 1;
            }
            if v[row_i + 1][col_i] == '#' {
                count += 1;
            }
            if v[row_i][col_i + 1] == '#' {
                count += 1;
            }
            if v[row_i][col_i - 1] == '#' {
                count += 1;
            }
            if v[row_i - 1][col_i + 1] == '#' {
                count += 1;
            }
            if v[row_i - 1][col_i - 1] == '#' {
                count += 1;
            }
            if v[row_i + 1][col_i + 1] == '#' {
                count += 1;
            }
            if v[row_i + 1][col_i - 1] == '#' {
                count += 1;
            }

            if v[row_i][col_i] == '#' {
                print!("#");
            } else {
                print!("{}", count);
            }
        }
        println!();
    }
}


Measured memory_bytes: 2136
n, m= map(int, input().split())
array = []
ans = 0
for i in range(n):
    l = list(map(int,input().split()))
    for i2 in range(1, l[0]+1):
        array.append(l[i2])

for i in range(m+1):
    if array.count(i)==n:
        ans+=1
        
print(ans)

Measured memory_bytes: 3064
s = int(input())

MOD = 10 ** 9 + 7

fact = [0] * 4400
invfact = [0] * 4400

fact[0] = 1
for i in range(1,4400):
    fact[i] = fact[i-1] * i % MOD

invfact[4400 - 1] = pow(fact[4400 - 1], MOD - 2, MOD)

for i in range(4400-1,0,-1):
    invfact[i-1] = invfact[i] * i % MOD

ans = 0

def nCk(n,k):
    return fact[n] * invfact[k] * invfact[n-k] % MOD

ans = 0
for n in range(1,s):
    if 3 * n > s:break
    ans += nCk(s - 3*n + n - 1, n-1)
    ans %= MOD
print(ans)

Measured memory_bytes: 9376