akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define REV(x) (reverse(x.begin(),x.end()))

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

	int N;
	cin >> N;
	int D[13] = {};

	FOR(i,0,N){
		int d;
		cin >> d;
		D[d]++;
		if(D[d]==3){
			cout << 0 << endl;
			return 0;
		}
		if(D[12]==2){
			cout << 0 << endl;
		}
		if(d==0){
			cout << 0 << endl;
			return 0;
		}
	}

	vector<int> time,tp,pattern;
	time.push_back(12);//takahashi
	FOR(i,1,12){
		if(D[i]==2){
			time.push_back(12-i);
			time.push_back(12+i);
		}else if(D[i]==1){
			pattern.push_back(i);
		}
	}
	if(D[12]==1){
		time.push_back(0);
	}

	int ans = 0;
	FOR(i,0,(1<<(pattern.size()))){
		tp = time;
		FOR(j,0,pattern.size()){
			if(i&(1<<j)){
				tp.push_back(12-pattern[j]);
			}else{
				tp.push_back(12+pattern[j]);
			}
		}
		sort(tp.begin(),tp.end());
		int ansp = 100000;
		FOR(j,0,tp.size()-1){
			ansp = min(ansp,abs(tp[j]-tp[j+1]));
		}
		if(tp[0]==0){
			ansp = min(ansp,abs(24-tp[tp.size()-1]));
		}
		ansp = min(ansp,abs(tp[0]+24-tp[tp.size()-1]));
		ans = max(ans,ansp);
	}
	cout << ans << endl;
}
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//

Measured memory_bytes: 256
class Solution:
    def solve(self, K: int) -> int:

        li = [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]

        return li[K-1]


if __name__ == '__main__':

    # standard input
    S = int(input())

    # solve
    solution = Solution()
    print(solution.solve(S))


Measured memory_bytes: 3060
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque
from functools import wraps
import time

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

R = intinput()
print(2*R*3.1415)


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

int main() {
	for (;;) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		for (int k = 0; k < b; k++) {
			cout << "#";
		}
		for (int m = 0; m < a - 2; m++) {
			cout << endl;
			cout << "#";
			for (int j = 0; j < b - 2; j++) {
				cout << ".";
			}
			cout << "#";
		}
			cout << endl;
		for (int l = 0; l < b; l++) {
			cout << "#";
		}
		cout << endl;
		cout << endl;
	}
}


Measured memory_bytes: 3084
#include <stdio.h>


int main()
{
  int n[100],a,i,b,k=0,c=0,flag=1;
  scanf("%d",&a);
  for(i=0;i<a;i++) scanf("%d",&n[i]);
  while(flag)
    {
      flag = 0;
      for(b=a-1;b>=1;b--)
	{
	  if(n[b]<n[b-1])
	    {
	      k=n[b];
	      n[b]=n[b-1];
	      n[b-1]=k;
	      flag = 1;
	      c++;
	    }
	}
    }
  for(i=0;i<a-1;i++) printf("%d ",n[i]);
  printf("%d\n",n[i]);
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>

int gcd(int ,int);

int x = 0;
int y = 0;
int res = 0;

int main()
{
  scanf("%d %d",&x,&y);

  if(x > y) res = gcd(x,y);

  else res = gcd(y,x);
   

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

  return 0;
  
}

int gcd(int x,int y)
{
  if(y != 0) return gcd(y,x%y);

  else return x;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

struct Edge {
	ll to;
    ll cost;
};

struct edge {
    ll from;
    ll to;
    ll cost;
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define mp make_pair
#define pb push_back
/***** define constant start *******/
const int MAX = 10000000;
const ll MOD = 998244353;
const double PI = 3.1415926535897932;
const ll INF = 1LL << 60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/****** define constant end ********/

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;
}

void debug_out() { std::cout << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

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

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0)
        res += m;
    return res;
}
// a^n mod を計算する
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;
}
// mod. m での a の逆元 a^{-1} を計算する
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 variable start ******/
ll k;
/******* define variable end *******/
int solve() {
	cin >> k;
	REP(i, k){
		cout << "ACL";
	}
	cout << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define PRINT_ARRAY_H(a) REPALL(__i,a) {cout<<a[__i]<<(__i != a.size()-1 ? " " : "");} newline;
#define e1 first
#define e2 second
#define newline putchar('\n')
#define cspace ' '
#define sspace " "
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    ll n, m, l, r, k, a, b, c, d, ans = 0ll;
    string s, t;
    cin>>l>>r>>d;
    cout<<(r/d - (l-1)/d)<<endl;

    return 0;
}


Measured memory_bytes: 3620
def divide(n):
	divisors = []
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n//i)
	return divisors

n = int(input())
if n < 105:
	print (0)
	exit()
ans = []
for i in range(105,n+1):
	if i % 2 == 0:
		continue
	s = divide(i)
	if len(s) == 8:
		ans.append(i)

print(len(ans))

Measured memory_bytes: 3064
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

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

void Main(){
    ll N, K;
    cin >> N >> K;
    vec<ll> h(N);
    REP(i, N){
        cin >> h[i];
    }
    sort(ALL(h));
    ll mn = LONG_LONG_MAX;
    REP(i, N-K+1){
        chmin(mn, abs(h[i]-h[i+K-1]));
    }
    cout << mn << el;
}



Measured memory_bytes: 1024
program strings_of_impurity
  implicit none
  character(100000) :: s, t
  integer :: n, m, i, j, k, idx(26) = -1, nxt(100000,26) = 0
  integer(8) :: ans = 0_8
  read(*,*) s
  read(*,*) t
  n = len_trim(s)
  m = len_trim(t)
    do i = n, 1, -1
    j = ord(s(i:i))
    idx(j) = n+i
  end do
  do i = 1, m
    j = ord(t(i:i))
    if (idx(j) < 0) then
      write(*,'(i0)') -1
      stop
    end if
  end do
  do i = n, 1, -1
    k = ord(s(i:i))
    do j = 1, 26
      if (idx(j) < 0) cycle
      nxt(i,j) = idx(j)-i
    end do
    idx(k) = i
    if (s(i:i) == t(1:1)) ans = int(i,8)
  end do
  do i = 2, m
    j = int(mod(ans-1_8,int(n,8)),4)+1
    ans = ans+int(nxt(j,ord(t(i:i))),8)
  end do
  write(*,'(i0)') ans
contains
  integer function ord(s)
    character(1), intent(in) :: s
    ord = ichar(s)-96
  end
end program strings_of_impurity

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

int main() {
 int N, M;
 cin >> N >> M;
  
 double sum = 0;
 int count = 0;
  
vector<int> A(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
  sum += A.at(i);
}
  
double L = 4 * M;
for (int i = 0; i < N; i++) {
  if (A.at(i) >= sum / L){
   count++;
  }
}
  
  
if (count >= M){
cout << "Yes" << endl;
}
  
else{
cout << "No" << endl;
}

}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
using namespace std;

int main()
{
	set<int> s;
	int N; scanf ("%d",&N); while (N--){
		int x; 
		scanf ("%d",&x);
		if (s.count(x)) s.erase(x);
		else s.insert(x);
	}
	printf ("%d\n",s.size());

	return 0;
}

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

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    x = max(a, x);
  }
  for(int i = 0; i < m; i++){
    int b;
    cin >> b;
    y = min(b, y);
  }
  if(y - x > 0)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}


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

int main() {
    int64_t X, Y;
    cin >> X >> Y;
    int64_t ans = 0;
    ans += max(100000 * (4 - X), (int64_t)0);
    ans += max(100000 * (4 - Y), (int64_t)0);
    if (X == 1 && Y == 1) {
        ans += 400000;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int n,m,sum[100005],sum2[100005];
char s[100005];
int main() {
	n=_; m=_;
	scanf("%s",s+1);
	for( int i=1;i<=n;i++ ) 
		sum[i]=sum[i-1]+(s[i]=='A'&&s[i+1]=='C'),
		sum2[i]=sum2[i-1]+(s[i]=='C'&&s[i-1]=='A');
	while( m-- ) {
		int l=_,r=_;
		cout<<sum2[r]-sum[l-1]<<"\n";
	}
}

Measured memory_bytes: 1664
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using mint = modint1000000007;

string s = "ACL", ans = "";
int n;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        ans += s;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string s, tmp;
  int k;
  cin >> s >> k;
  vector<string> v;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 1; j <= k; j++) {
      tmp = s.substr(i, j);
      // if (tmp.size() >= j)
      v.push_back(tmp);
    }
  }

  set<string> setvec(v.begin(), v.end());
  vector<string> v2(setvec.begin(), setvec.end());
  cout << v2.at(k - 1) << endl;

}

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

int gcd() {}

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

	long long s = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 != 0 && i % 5 != 0) {
			s += i;
		}
	}

	cout << s;
	
	return 0;
}
	

Measured memory_bytes: 3624
def main():
    m, n = tuple(map(int, input().split()))
    matrix = [[0 for j in range(n+1)] for i in range(m+1)]
    for i in range(m):
        tmp = list(map(int, input().split()))
        for j in range(n):
            matrix[i][j] = tmp[j]
            matrix[i][n] += tmp[j]
    
    for j in range(n+1):
        for i in range(m):
            matrix[m][j] += matrix[i][j]

    for i in range(m+1):
        for j in range(n):
            print(matrix[i][j], end=' ')
        print(matrix[i][n])

if __name__ == '__main__':
    main()


Measured memory_bytes: 6212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  vector<int64_t> L(N+1);
  L.at(0)=2;
  L.at(1)=1;
  for (int i = 2; i < N+1; i++) {
    L.at(i)=L.at(i-2)+L.at(i-1);
//    cout << "L.at("<<i<<")="<<L.at(i)<<endl;
  }
  cout << L.at(N) <<endl;
}

Measured memory_bytes: 256
import sys
from collections import deque
sys.setrecursionlimit(10**7)
#累積和を木に拡張する
N, Q = map(int, input().split())

graph = [[] for i in range(N)]
score = [0 for _ in range(N)]

def dfs(now, prev):

    for adj in graph[now]:
        if adj == prev:
            continue
        score[adj] += score[now]
        dfs(adj, now)

    return

for i in range(1, N):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

query = [0] * N
for i in range(Q):
    p, x = map(int, input().split())

    score[p-1] += x

dfs(0, -1)

for p in score:
    print(p)


Measured memory_bytes: 233072
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int> p[n];
    int s[n],t[n];
    memset(s,0,sizeof(s));
    memset(t,0,sizeof(t));
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        p[a-1].push_back(b-1);
        p[b-1].push_back(a-1);
    }
    //cout<<p[4].size()<<endl;
    queue<int> que;
    que.push(0);
    s[0]=1;
    while(que.size()){
        int x;
        x=que.front();
        que.pop();
        for(int i=0;i<p[x].size();i++){
            if(s[p[x][i]]==0){
                s[p[x][i]]=s[x]+1;
                que.push(p[x][i]);
            }
        }
    }
    //for(int i=0;i<n;i++)cout<<s[i]<<endl;
    que.push(n-1);
    t[n-1]=1;
    while(que.size()){
        int x;
        x=que.front();
        que.pop();
        for(int i=0;i<p[x].size();i++){
            if(t[p[x][i]]==0){
                t[p[x][i]]=t[x]+1;
                que.push(p[x][i]);
            }
        }
    }
    int ptt=0,pts=0;
    //cout<<"WWWWWW"<<endl;
    for(int i=0;i<n;i++){
        if(s[i]<=t[i])pts++;
        else ptt++;
    }
    //cout<<ptt<<pts<<endl;
    if(ptt>=pts)cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
}


Measured memory_bytes: 6528
S = int(input())

x1,y1 = 0,0
x2 = 10**9
y2 =1
y3,x3 = divmod(-S,x2)
y3 *= -1
for a in [x1,y1,x2,y2,x3,y3]:
	if a == y3:
		print(a)
	else:
		print(a,end=" ")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
struct edge { int to, cost; };
typedef pair<int, int> P;
string s;
signed main() {
	cin >> s;
	int ans = s.size();
	int cnt = 0;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == '1')cnt++;
		}
		else {
			if (s[i] == '0')cnt++;
		}
	}
	ans = min(ans, cnt);
	cnt = 0;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == '0')cnt++;
		}
		else {
			if (s[i] == '1')cnt++;
		}
	}
	cout << min(ans, cnt) << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

Int N,C;

Int solve(vector<Int> &X,vector<Int> &V) {
    vector<Int> dp(N+1,0);
    Int sum = 0;
    for(int i = 0;i < N;i++) {
        sum += V[i];
        dp[i+1] = max(dp[i],sum-2*X[i]);
    }

    Int ret = 0;
    sum = 0;
    for(int i = N-1;i >= 0;i--) {
        sum += V[i];
        Int res = sum - (C-X[i]) + dp[i];
        ret = max(ret,res);
    }

    return ret;
}

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

    vector<Int> XL(N),VL(N);
    vector<Int> XR(N),VR(N);

    for(int i = 0;i < N;i++) {
        cin>>XL[i]>>VL[i];
        XR[N-i-1] = C-XL[i];
        VR[N-i-1] = VL[i];
    }

    Int ans1 = solve(XL,VL);
    Int ans2 = solve(XR,VR);


    Int ans = max(ans1,ans2);

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, k, p[200010];
int a[200010], b[200010];
signed main() {
	cin >> n >> k;
	int cnt = 0;
	rep(i, n) {
		cin >> p[i];
		if (p[i - 1] < p[i])a[i] = cnt;
		else {
			cnt++;
			a[i] = cnt;
		}
	}
	REP(i, n - 1) {
		if (a[i - 1] == a[i])b[i] = b[i - 1] + 1;
		else b[i] = 0;
	}
	int ma = 0;
	set<int> st;
	rep(i, k) {
		st.insert(p[i]);
		ma = max(ma, b[i]);
	}
	int ans = n - k + 1;
	for (int i = k; i < n; i++) {
		if (b[i] >= k - 1 && ma >= k - 1)ans--;
		else if (p[i - k] == *st.begin()) {
			st.erase(p[i - k]);
			st.insert(p[i]);
			if (p[i] == *st.rbegin())ans--;
		}
		st.erase(p[i - k]);
		st.insert(p[i]);
		ma = max(ma, b[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ldbl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
// constant
const double PI  = acos(-1.0);
const int    MOD = (int)(1e9 + 7);
// DO NOT set INFTY_XXXs constants. They may bring some BUG! Use MAX_XXXs in climit instead.
 
// clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
// debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main() {
    int n, m, q; cin >> n >> m >> q;
    vvi dp(n, vi(n, 0));
    REP (i, m) {
        int l, r; cin >> l >> r;
        dp[l-1][r-1]++;
    }
    FOR (d, 1, n) {
        FOR (p, 0, n-d) {
            int q = p + d;
            dp[p][q] += dp[p][q-1] + dp[p+1][q] - (d >= 2? dp[p+1][q-1] : 0);
        }
    }
    REP (i, q) {
        int a, b; cin >> a >> b;
        cout << dp[a-1][b-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    vector<int> f(100000);
    int n;
    cin >> n;
    for(int x=1; x<=100; x++){
        for(int y=1; y<=100; y++){
            for(int z=1; z<=100; z++){
                f[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }


    for(int i=1; i<=n; i++){
        cout << f[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3716
//#include <bits/stdc++.h>
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
const int mod = 1000000007;

ll gcd(ll a, ll b){return b ? gcd(b,a%b) : a;};//最大公約数
ll lcm(ll a, ll b){return a*b/gcd(a,b);};//最小公倍数
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
//ll a[100000];
//ll dom[100001];

int main(){
  ll N,K;
  cin>>N>>K;
  ll p[N];
  for(int i=0;i<N;i++) cin>>p[i];
  double ans=0.000000000;
  for(int i=0;i<K;i++){
    ans+=(double)(p[i]*(p[i]+1.0000000)/(2.000000*p[i]));
  }
  double tmp=ans;
  for(int i=0;i<N-K;i++){
    tmp-=(double)p[i]*((double)p[i]+1.000000)/(2.0000000*(double)p[i]);
    tmp+=(double)p[i+K]*((double)p[i+K]+1.000000)/(2.0000000*((double)p[i+K])); 
    if(tmp>ans) ans=tmp;
  }
  printf("%.7f",ans);
  return 0;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<cstdio>
#include<cmath>
#define rep( i, a ) for( int i = 0; i != (a); ++i )

const double g = 9.8, EPS = 1e-10;

int N, V, X, Y;
int L[50], B[50], R[50], T[50];

double calc( double vy, double t )
{
	return vy * t - g * t * t / 2;
}

int cmp( double lb, double ub, double a )
{
	return a < lb + EPS ? -1 : a > ub - EPS ? 1 : 0;
}

bool check( double qx, double qy )
{
	double a = g * g / 4, b = g * qy - V * V, c = qx * qx + qy * qy;
	double D = b * b - 4 * a * c;
	if( D < 0 && D > -EPS )
		D = 0;
	if( D < 0 )
		return false;

	for( int d = -1; d != 1; d += 2 )
	{
		double t2 = ( -b + d * sqrt( D ) ) / ( 2 * a );
		if( t2 <= 0 )
			continue;
		double t = sqrt( t2 );
		double vx = qx / t, vy = ( qy + g * t * t / 2 ) / t;

		double yt = calc( vy, X / vx );
		if( yt < Y - EPS )
			continue;

		bool fl = true;
		rep( i, N )
		{
			if( L[i] >= X )
				continue;
			if( R[i] == X && Y <= T[i] && B[i] <= yt )
				fl = false;
			int yL = cmp( B[i], T[i], calc( vy, L[i] / vx ) );
			int yR = cmp( B[i], T[i], calc( vy, R[i] / vx ) );
			int xH = cmp( L[i], R[i], vx * ( vy / g ) );
			int yH = cmp( B[i], T[i], calc( vy, vy / g ) );
			if( xH == 0 && yH >= 0 && yL < 0 )
				fl = false;
			if( yL * yR <= 0 )
				fl = false;
		}

		if( fl )
			return true;
	}

	return false;
}

int main()
{
	scanf( "%d %d %d %d", &N, &V, &X, &Y );
	rep( i, N )
	{
		scanf( "%d %d %d %d", L + i, B + i, R + i, T + i );
		R[i] = std::min( R[i], X );
	}

	bool fl = check( X, Y );
	rep( i, N )
	{
		fl |= check( L[i], T[i] );
		fl |= check( R[i], T[i] );
	}

	puts( fl ? "Yes" : "No" );

	return 0;
}

Measured memory_bytes: 1016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();

		if(op.equals("+")) System.out.println(a+b);
		else System.out.println(a-b);
	}
}

Measured memory_bytes: 24020
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
#define pb push_back
#define fr first
#define sc second

const ll Mod = 1000000007;

int main(){
	static int N,M;
	static string S;
	static int l[3002],r[3002];
	scanf("%d%d",&N,&M);
	cin >> S;
	for(int i = 1 ; i <= M ; i ++){
		scanf("%d%d",&l[i],&r[i]);
	}
	
	static int cnt[3002] = {};
	for(int i = 1 ; i <= N ; i ++){
		cnt[i] = cnt[i-1] + S[i-1]-'0';
	}
	static int R[3002] = {};
	for(int i = 1 ; i <= N ; i ++){
		R[i] = i;
	}
	for(int i = 1 ; i <= M ; i ++){
		for(int j = l[i] ; j <= r[i] ; j ++){
			R[j] = max( R[j] , r[i] );
		}
	}
	
	static ll dp[3002][3002] = {};
	dp[0][0] = 1;
	for(int i = 1 ; i <= N ; i ++){
		if(cnt[R[i]]-R[i]+i <= 0)dp[i][0] = dp[i-1][0];
		for(int j = max(cnt[R[i]]-R[i]+i,1) ; j <= cnt[R[i]] ; j ++){
			dp[i][j] = dp[i-1][j]+dp[i-1][j-1];
			if(dp[i][j] >= Mod)dp[i][j] -= Mod;
		}
	}
	cout << dp[N][cnt[N]] << endl;
}


Measured memory_bytes: 68352
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

s = a+v*t
u = b+w*t
ss = a - v*t
uu = b - w*t

if b >= a:
  if s >= u:
    print ('YES')
  else:
    print ('NO')
else:
  if ss <= uu:
    print ('YES')
  else:
    print ('NO')

Measured memory_bytes: 9100
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end() 
#define x first
#define y second

using namespace std;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}


using namespace std;

typedef long long ll;
template <typename T> using V = vector <T>;

const ll mod = 1e9 + 7;
const int MM = 1e4 + 5, KM = 105;

inline int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}

inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % mod);
}

V <V <ll>> dp(MM, V <ll> (KM, 0));
int K;
void pre() {
	dp[0][0] = 1;
	for(int dig = 1; dig < MM; dig++) {
		for(int cd = 0; cd <= 9; cd++) {
			for(int rem = 0; rem < K; rem++) {
				dp[dig][rem] = add(dp[dig][rem], dp[dig - 1][(rem - cd + 10 * K) % K]);
			}
		}
	}
}
ll ansFor(V <int> &N, int ind, ll rem) {
	if(ind == -1) {
		return rem == 0;
	}
	ll cnt0 = 0;
	for(int d = 0; d < N[ind]; d++) {
		cnt0 = add(cnt0, dp[ind][(-rem - d + 10 * K) % K]);
	}
	ll cnt1 = ansFor(N, ind - 1, (rem + N[ind]) % K);
	return add(cnt0, cnt1);
}

int main() {fio;
	string N;
	cin >> N >> K;
	pre();
	V <int> num(N.size());
	for(int i = 0; i < N.size(); i++) {
		num[N.size() - i - 1] = N[i] - '0';
	}
	ll ans = mod - 1;
	ll rem = 0;
	for(int ind = num.size() - 1; ind >= -1; ind--) {
		if(ind == -1) {
			ans += rem == 0;
			break;
		}
		ll cnt0 = 0;
		for(int d = 0; d < num[ind]; d++) {
			cnt0 = add(cnt0, dp[ind][(-rem - d + 10 * K) % K]);
		}
		ans += cnt0;
		ans %= mod;
		rem = (rem + num[ind]) % K;
	}
	cout << ans;
    return 0;
}

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

using namespace std;

typedef long long int Int;

Int cost[200][200];

int main(void)
{
    Int n,m,r;
    vector<Int> city;

    cin>>n>>m>>r;

    for(int i = 0;i < 200;i++)
	for(int j = 0;j < 200;j++)
	    cost[i][j] = 1e9;

    for(int i = 0;i < 200;i++)
	cost[i][i] = 0;

    for(int i = 0;i < r;i++)
    {
	Int temp;
	cin>>temp;
	temp--;

	city.push_back(temp);
    }

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

    for(int i = 0;i < m;i++)
    {
	int a,b,c;
	cin>>a>>b>>c;
	a--;
	b--;
	cost[a][b] = c;
	cost[b][a] = c;
    }

    Int min_cost = 1e9;

    for(int i = 0;i < n;i++) {
	for(int s = 0;s < n;s++) {
	    for(int e = 0;e < n;e++) {
		cost[s][e] = min(cost[s][e],cost[s][i]+cost[i][e]);
	    }
	}
    }

    do
    {
	Int score = 0;
	for(int i = 0;i < r-1;i++)
	    score += cost[city[i]][city[i+1]];

	min_cost = min(min_cost,score);
    }while(next_permutation(city.begin(),city.end()));

    cout<<min_cost<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main()
{
	int	N;	/* 書類に書かれた整数の個数	*/
	int	A[100];	/* 書類に書かれた整数		*/
	int	index;	/* 配列のインデックス		*/
	int	judge;	/* 入国可能か否か		*/

	scanf("%d", &N);
	for(index = 0; index < N; ++index){
		scanf("%d", &A[index]);
	}
	judge = 1;

	for(index = 0; index < N; ++index){
		if(A[index] % 2 == 0){

			if((A[index] % 3 != 0) && (A[index] % 5 != 0)){
				judge = 0;
			}
		}
	}
	if(judge == 1)
		printf("APPROVED\n");
	else
		printf("DENIED\n");

	return 0;
}

Measured memory_bytes: 128
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int r;
    cin >> r;

    ld res = 2. * acos(-1) * r;
    cout << fixed << setprecision(5) << res ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 3824
class Node

  attr_accessor :to, :cost
  def initialize(to, cost)
    @to = to
    @cost = cost
  end
end

INF = 10 ** 7
# INF = Float::INFINITY

def dijkstra(g, s)

  # inf = 10 ** 12
  inf = INF
  dist = Array.new(g.size, inf)
  dist[s] = 0

  que = []
  que.push( [0, s] )

  while que.any?

    d, v = que.shift
    next if dist[v] < d
    g[v].each do |e|
      next if dist[e.to] != inf# || dist[v] == inf
      dist[e.to] = dist[v] + 1
      que.push( [dist[e.to], e.to ] )
    end
  end
  
  # dist.map!{|d| d == inf ? "INF" : d }
  dist
end

n, m = gets.to_s.split.map{|t|t.to_i}

g = Array.new(n*3){ [] }

m.times do
  u, v = gets.to_s.split.map{|t|t.to_i-1}
  g[3*u+0] << Node.new(3*v+1, 1)
  g[3*u+1] << Node.new(3*v+2, 1)
  g[3*u+2] << Node.new(3*v+0, 1)
end

s, t = gets.to_s.split.map{|i|i.to_i-1}

dist = dijkstra(g, s*3+0)

puts dist[t*3+0] == INF ? -1 : dist[t*3+0]/3

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second

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

    int x;
    cin >> x;
    cout << ((x>=30)?"Yes":"No") << '\n';
}


Measured memory_bytes: 3608
n = int(input())
a = list(map(int, input().split()))
ans = 1000000000

for i in range(n):
    count = 0
    while a[i] % 2 == 0:
        a[i] = a[i]//2
        count += 1
    if ans >= count:
        ans = count
print(ans)

Measured memory_bytes: 3060
import math
import sys

N = int(input())

ans = []
if N == 0:
  print(0)
  sys.exit()

while(N != 0):
  m = N % (-2)
  if m == -1:
    m = 1
  ans.insert(0, str(m))
  N = math.ceil(N / (-2))

print("".join(ans))

Measured memory_bytes: 3064
S = input()
N = len(S)
r = 0
l = 0
ans = 0
while l+r < N:
    if S[l] == S[N-1 - r]:
        l += 1
        r += 1
    else:
        if S[l] == 'x':
            l += 1
            ans += 1
        elif S[N-1 - r] == 'x':
            r += 1
            ans += 1
        else:
            print(-1)
            exit()

print(ans)

Measured memory_bytes: 3316
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let lr = (0..n)
        .map(|_| (sc.read::<i64>(), sc.read::<i64>()))
        .collect::<Vec<_>>();

    let mut left = vec![];
    let mut right = vec![];
    for i in 0..n {
        let (l, r) = lr[i];
        left.push(2 * l);
        right.push(-2 * r);
    }
    left.sort();
    left.reverse();
    right.sort();
    right.reverse();

    let mut max = 0;
    let mut sum = 0;
    for i in 0..n {
        max = cmp::max(max, sum);
        max = cmp::max(max, sum + left[i]);
        max = cmp::max(max, sum + right[i]);
        sum += left[i] + right[i];
    }

    println!("{}", max);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define N 102
ll C(ll a, ll b, ll c)
{
     return a*a + b*b + c*c + a*b + b*c + c*a ;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    map<ll,ll> mp;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            for(int k=1;k<=N;k++){
                ll val=C(i,j,k);
                mp[val]++;
            }
        }
    }
    int n; cin>>n;
    for(int i=1;i<=n;i++) cout<<mp[i]<<endl;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int p[n];
    rep(i,n) cin >> p[i];
    long double pp[1010];

    ll s[1001];
    s[0]=0;
    for(int i=1;i<1001;i++){
        s[i]=s[i-1]+i;
    }
    for(int i=1;i<1001;i++){
        long double d=i;
        pp[i]=(1.0/d)*s[i];
    }


    double ans=0;
    rep(i,k){
        ans+=pp[p[i]];
    }
    double pre=ans;

    for(int i=k;i<n;i++){
        long double save=0;
        save=pre+pp[p[i]];
        save-=pp[p[i-k]];
        if(save>ans) ans=save;
        pre=save;
    }
    printf("%.16lf\n",ans);
    //cout << ans << endl;
    
}

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

typedef long long LL;

int n, v1, v2, v4;

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


    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int a; cin >> a;
        if(a % 4 == 0)
            v4++;
        else if(a % 2 == 0) v2 ++;
        else v1 ++;
    }
    while(v1 > 0)
    {
        if(v4 == 0) break;
        v4 --, v1 --;
    }
    while(v2 > 0)
    {
        if(v4 == 0)break;
        v4 --, v2 --;
    }
    if(v1 == 0 || (v1 == 1 && v2 == 0)) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	while (cin >> n, n) {
		int mi = 100000;
		ll sum = 0;
		int num = 0;
		for (int i = 0; i < n; i++) {
			int k;
			cin >> k;
			if (mi > k && k >= 2)mi = k;
			if (k < 2)sum += k;
			else num++;
		}
		if (mi == 100000)cout << "NA" << endl;
		else cout << sum+ num+1 << endl;
	}
	return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;

int n,i,j,a[100005],pos[100005];
long long fact[100005];

long long mypow(long long a, long long lv){
	if(lv == 0) return 1LL;
	long long tmp = mypow(a, lv / 2);
	tmp = (tmp * tmp) % MOD;
	if(lv & 1)
	tmp = (tmp * a) % MOD;
	return tmp;
}

long long ncr(int x, int y){
	return (((fact[x] * mypow(fact[y], MOD - 2)) % MOD) * mypow(fact[x - y], MOD - 2)) % MOD;
}

int main(){
	scanf("%d", &n);
	
	int siz = 0;
	
	memset(pos, -1, sizeof(pos));
	
	fact[0] = 1LL;
	for(i = 1; i <= n + 1; i++)
	fact[i] = (fact[i - 1] * i) % MOD;
	
	for(i = 0; i < n + 1; i++){
		scanf("%d", &a[i]);
		if(pos[a[i]] != -1){
			siz = pos[a[i]] + n - i;
		}
		pos[a[i]] = i;
	}
	
	for(i = 1; i <= n + 1; i++){
		long long s = ncr(n + 1, i);
		if(i <= siz + 1)
		s = (s - ncr(siz, i - 1) + MOD) % MOD;
		printf("%lld\n", s);
	}
}


Measured memory_bytes: 2816
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
  private static void solve(int n, String[] a) {
    Map<String, Integer> fingerprints = new HashMap<>();
    long counter = 0;
    for (String val: a) {
      int[] count = new int[26];
      for (int i = 0; i < 10; i++) {
        count[val.codePointAt(i) - 97]++;
      }
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < 26; i++) {
        sb.append(count[i]);
      }
      String fingerprint = sb.toString();
      if (fingerprints.containsKey(fingerprint)) {
        counter += fingerprints.get(fingerprint);
      }
      fingerprints.merge(fingerprint, 1, Integer::sum);
    }
    System.out.println(counter);
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] a = new String[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLine();
    }
    sc.close();
    solve(n, a);
  }
}

Measured memory_bytes: 131432
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int N;
	cin >> N;
	long long sum = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0 || i % 5 == 0) continue;
		sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<stack>
#include<cmath>
#include<queue>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,j,o,p,r,q,i;
    char s[100],n[100];
   while(~scanf("%s",s))
   {
       a=strlen(s);d=0;j=0;o=0;p=0;r=0;
       b=(a-1)/2;
       c=(a+3)/2;
       q=a-c+1;
       for(i=0;i<a/2;i++)
       {
           if(s[i]!=s[a-i-1])
           {d=1;break;}
       }
       for(i=0;i<b/2;i++)
       {
           if(s[i]!=s[b-i-1])
           {
               j=1;break;
           }
       }
       for(i=c-1;i<a;i++)
       {
           n[p++]=s[i];
       }
       for(i=0;i<q/2;i++)
       {
           if(n[i]!=n[q-i-1])
           {
               r=1;break;
           }
       }
      // for(i=0;i<b;i++)
       // printf("%c",s[i]);
      // printf("%d %d %d",r,j,d);
       if(r==0&&j==0&&d==0)
        printf("Yes\n");
       else
        printf("No\n");

   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b,c;
  char A,B,C;
  cin>>a>>b>>c;
  char d='A'-'a';
  A=a[0]+d;
  B=b[0]+d;
  C=c[0]+d;
  cout<<A<<B<<C;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string s;
   cin >> s;
   if (s[0] == s[2]) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int N;
int A[101];

int main(){

    cin >> N;
    for(int i = 0; i < N; i++)cin >> A[i];
    sort(A, A+N, greater<int>());
    int a = 0;
    int b = 0;

    for(int i = 0; i < N;i++){
        if(i%2 == 0) a += A[i];
        else b += A[i];
    }

    cout << a - b << endl;
    

    return 0;
}


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

#define M 1048576/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long i = 0, j;
  long long k;

  k = getKey(str);
  
  while(1){
    j = (h1(k) + i*h2(k)) % M;
    if(strcmp(H[j], str) == 0){
      return 1;
    }
    else if(strlen(H[j]) == 0 || i >= M){
      return 0;
    }
    
    i++;
  }
}

int insert(char str[]){
 long long i = 0,j;
 long long k;

 k = getKey(str);
 
 while(1){
   j = (h1(k) + i*h2(k)) % M;
   if(strlen(H[j]) == 0){
     strcpy(H[j], str);
     return j;
   }
   else if(i >= M){
     return 0;
   }
   i++;
 }
 
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;
}




Measured memory_bytes: 16128
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

#n = ip()                                     #入力整数1つ
a,b,c,d= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#v=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
for i in range(d-b):
    print("U", end='')
for i in range(c-a):
    print("R", end='')
for i in range(d-b):
    print("D", end='')
for i in range(c-a+1):
    print("L", end='')
for i in range(d-b+1):
    print("U", end='')
for i in range(c-a+1):
    print("R", end='')
print("D", end='')
print("R", end='')
for i in range(d-b+1):
    print("D", end='')
for i in range(c-a+1):
    print("L", end='')
print("U")



Measured memory_bytes: 14388