akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    set<int> as(a.begin(), a.end());
    int k = as.size();
    if (k % 2 == 0) {
        cout << k-1 << endl;
    } else {
        cout << k << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
H = LIST()
AB = [LIST() for _ in range(M)]

HH = [1]*N
for i in range(M):
	if H[AB[i][0]-1] > H[AB[i][1]-1]:
		HH[AB[i][1]-1] = 0
	elif H[AB[i][0]-1] < H[AB[i][1]-1]:
		HH[AB[i][0]-1] = 0
	else:
		HH[AB[i][1]-1] = 0
		HH[AB[i][0]-1] = 0


print(sum(HH))

Measured memory_bytes: 33012
import Control.Applicative

type Data = (Int, Int, Int)

type Problem = [Data]

type Result = [String]

judge :: Data -> String

judge (m, f, r)
    | m == -1 || f == -1
        = "F"
        
    | m + f >= 80
        = "A"
        
    | m + f >= 65
        = "B"
        
    | m + f >= 50 || r >= 50
        = "C"
        
    | m + f >= 30
        = "D"
        
    | otherwise
        = "F"

solve :: Problem -> Result

solve xs
    = map judge xs

input :: IO Problem

input
    = return =<< inputProblem []
    
inputProblem :: Problem -> IO Problem

inputProblem xs
    = do
        [m, f, r] <- map read.words <$> getLine
        if (m, f, r) /= (-1, -1, -1)
            then inputProblem $ xs ++ [(m, f, r)]
            else return xs
            
output :: Result -> String

output xs
    = concat $ map (++ "\n") xs
    
main :: IO ()

main
    = putStr.output =<< solve <$> input

Measured memory_bytes: 4088
#include<stdio.h>
int main(){
long long int n,a,b,c,d;
scanf("%lld", &n);
  
  a=n*(n+1)/2;
  c=n/3*(1+n/3)*3/2;
  d=n/5*(1+n/5)*5/2;
  b=n/15*(1+n/15)*15/2;

printf("%lld\n",a+b-c-d);
return 0;
}


Measured memory_bytes: 1736
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#include<complex>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef complex<double> P;
typedef vector<P> G;
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
P pin(){
	double x,y;
	cin>>x>>y;
	P p(x,y);
	return p;
}
void PIN(P* a,int n){
	rep(i,n)a[i]=pin();
}
double dot(P a,P b){
	return real(conj(a)*b);
}
double cross(P a,P b){
	return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
P projection(L a,P p){
	double t=dot(p-a[0],a[0]-a[1])/norm(a[0]-a[1]);
	return a[0]+t*(a[0]-a[1]);
}
P reflection(L a,P p){
	return p+2.0*(projection(a,p)-p);
}
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P intersect_ls(L a,L b){
	double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
	double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
	return b[0]+(b[1]-b[0])*t1/(t1+t2);
}
double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
  return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
  if (intersectLS(l, s)) return 0;
  return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
double area(const G& g){
    double S =0;
    for(int i =0;i <g.size();i++){
        S +=(cross(g[i],g[(i+1)%g.size()]));
    }
    return abs(S/2.0);
}
int main(){
	int n;
	cin>>n;
	G g(n);
	PIN(&g[0],n);
	double S=area(g);
	printf("%.1f\n",S);
}

Measured memory_bytes: 1252
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int X=sc.nextInt();
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=B-A;
        if(A>=B){
            System.out.println("delicious");
        }else if(X>=C){
            System.out.println("safe");
        }else{
            System.out.println("dangerous");
        }

        }
        
        
    }


Measured memory_bytes: 22612
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int num[200005];
int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&num[i]);
        ans=ans^num[i];
    }
    for(int i=1;i<=n;i++)
    {

        printf("%d ",ans^num[i]);
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 2e5+10;
ll N, K, P[MAX];

ld solve() {
    ll sm = 0;
    REP (i, K) sm += P[i];
    ll max_sum = sm;
    REP (l, N-K) {
        sm += P[l+K] - P[l];
        max_sum = max(max_sum, sm);
    }
    return (max_sum + K) * 1.0l / 2.0;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> P[i];

    cout << fixed << setprecision(9) << solve() << endl;
}

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

int main(){
	int n; scanf("%d",&n);
	int a[n];
	for(int i = 0;i < n;i++) scanf("%d",&a[i]);
	int sum = 0;
	for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			sum += a[i]*a[j];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

#input = sys.stdin.readline

########################################
c = input()
if ord(c) >= 97:
	print("a")
else:
	print("A")










Measured memory_bytes: 9396
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int func(int a, int K)
{
    if(a%K==0) {
        return (a/K);
    }
    else if(a<K) {
        return 0;
    }
    else {
        return func(a-a/K-1, K);
    }
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    ll sum=0;
    int i;
    for(i=0; i<n; i++) {
        int a,K;
        scanf("%d%d", &a, &K);
        while(1) {
            if(a<K) {
                a=0; break;
            }
            int b=a/K;
            int c=a-K*b;
            if(c==0) {
                a=b;
                break;
            }
            else {
                a=a-b-1;
            }
        }
        sum^=a;
    }
    if(sum==0) {
        printf("Aoki\n");
    }
    else {
        printf("Takahashi\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define ll      long long 
#define double      long double
#define pii     pair<int ,int>
#define pld     pair<ld ,ld>
#define all(v)  v.begin(),v.end()
#define F       first
#define S       second
#define mod     1000000007
#define pb      push_back
#define MP      make_pair
#define mset(x) memset(x, 0, sizeof(x));
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf     10000000000000007
#define PI 3.14159265
const int N=300005;
// ll a[N],BIT[N];
// void upd(ll x,ll y)
// {
//     for(;x<N;x+=x&-x)
//         BIT[x]+=y;
// }
// ll get(ll x)
// {
//     ll res=0;
//     for(;x;x-=x&-x)
//         res+=BIT[x];
//     return res;
// }
// void f(ll i,ll l,ll r){
//     ll lo,hi,mid,st,en;
//     lo=0;
//     hi=n-1;
//     st=n;
//     while(lo<=hi){
//         mid=(lo+hi)/2;
//         if(v[mid].F>=l) st=mid,hi=mid-1;
//         else lo=mid+1;
//     }
//     en=-1;
//     while(lo<=hi){
//         mid=(lo+hi)/2;
//         if(v[mid].F<=r) en=mid,lo=mid+1;
//         else hi=mid-1;
//     }
//     for(;st<=en;st++)
//         seg[i].pb(v[st].S);
//     mid=(l+r)/2;
//     f(2*i,l,mid);
//     f(2*i+1,mid+1,r);
// }
// ll g(ll i,ll l,ll r,ll x,ll y){
    
// }
// void run(int t){
//     cin>>n>>q;
//     for(i=0;i<n;i++)cin>>a[i];
//     for(i=0;i<n;i++)
//         v.pb(MP(a[i],i));
    
//     sort(all(v));
//     f(1,1,100000);
//     while(q--){
//         cin>>x>>y;
//         cout<<g(1,1,100000,x,y)<<"\n";
//     }


   


// }
 
void run(int t)
{
    ll x,y;
    set<ll>s;
    s.insert(1);
    s.insert(2);
    s.insert(3);
    cin>>x>>y;
    s.erase(x);
    s.erase(y);
    ll ans=*s.begin();
    cout<<ans;
}
void setup(){
    ios;
    //cout << setprecision(20);
    // #ifndef ONLINE_JUDGE
    // freopen("input", "r", stdin);
    // freopen("output", "w", stdout);
    // #endif
}
 
signed main(){
    setup();
    int tests = 1;
    //cin >> tests;
    for(int i = 1; i <= tests; i++) run(i);
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

N, M, Q = map(int, input().split())

Tss = [[0] * N for i in range(N)]
for i in range(M):
    L, R = map(int, input().split())
    Tss[L - 1][R - 1] += 1

Ass = [list(accumulate(Ts)) for Ts in Tss]

Bss = [[0] * N for i in range(N)]
for j in range(N):
    Bss[N - 1][j] = Ass[N - 1][j]
    for i in reversed(range(N - 1)):
        Bss[i][j] = Bss[i + 1][j] + Ass[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    print(Bss[p - 1][q - 1])


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

int N, S;
int dp[1<<10][500];

int main() {
  while(cin >> N >> S) {
    if(N > 10 || S >= 500) {
      cout << 0 << endl;
      continue;
    }

    fill(dp[0], dp[1<<10], 0);
    dp[0][0] = 1;
    for(int i = 0; i < (1<<10); ++i) {
      int t = __builtin_popcount(i) + 1;
      if(t > N) continue;
      for(int j = 0; j <= S; ++j) {
        if(dp[i][j] == 0) continue;
        for(int k = 0; k < 10; ++k) {
          if(i & (1<<k)) continue;
          int ni = (i | (1<<k));
          int nj = j + k * t;
          if(nj > S) continue;
          dp[ni][nj] += dp[i][j];
        }
      }
    }
    int res = 0;
    for(int i = 0; i < (1<<10); ++i) {
      if(__builtin_popcount(i) == N) {
        res += dp[i][S];
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M;

signed main() {
    cin >> N >> M;
    cout << min(N, M / 2) + (M - 2 * min(N, M / 2)) / 4 << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int X,Y,m[15][17],dp[15][17];

int main(){
	while(cin>>X>>Y&&X){
		rep(i,Y)fill(dp[i],dp[i]+17,0);
		rep(i,Y)rep(j,X){
			cin>>m[i][j+1];
			if(!i&&!m[i][j+1])dp[i][j+1]=1;
		}
		for(int i=1;i<Y;i++)for(int j=1;j<=X;j++){
			if(m[i][j]==0){
				for(int k=-1;k<2;k++)if(m[i-1][j+k]==0)dp[i][j]+=dp[i-1][j+k];
				if(i>1&&m[i-2][j]==2)dp[i][j]+=dp[i-2][j];
				if(i==Y-1&&m[i-1][j]==2)dp[i][j]+=dp[i-1][j];
			}
			if(m[i][j]==1&&i==Y-1&&m[i-1][j]==2)dp[i][j]+=dp[i-1][j];
			if(m[i][j]==2){
				if(m[i-1][j]==0)dp[i][j]=dp[i-1][j];
				if(i>1&&m[i-2][j]==2)dp[i][j]+=dp[i-2][j];
				if(i==Y-1&&m[i-1][j]==2)dp[i][j]+=dp[i-1][j];
			}
		}
		int ans=0;
		rep(i,X)ans+=dp[Y-1][i+1];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e17;
#define int long long


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>ret;
	int ans = INF;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0) {
			int tmp = i + n / i;
			chmin(ans, tmp);
		}
	}
	cout << ans - 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
ll mod_inverse(ll a) {
	ll n = mod - 2;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}
const int N_MAX = 20000001;
ll p[N_MAX], invp[N_MAX];
void init() {
	p[0] = 1;
	rep1(i, N_MAX - 1) {
		p[i] = p[i - 1] * i%mod;
	}
	invp[N_MAX - 1] = mod_inverse(p[N_MAX-1]);
	per(i, N_MAX - 1) {
		invp[i] = invp[i + 1] * (i + 1) % mod;
	}
}
//xCyを求める
ll comb(ll x, ll y) {
	if (x < y || y<0)return 0;
	ll res = p[x];
	(res *= invp[y]) %= mod;
	(res *= invp[x - y]) %= mod;
	return res;
}
ll comb2(ll x, ll y) {
	return p[x] * invp[x - y] % mod;
}
int main() {
	init();
	ll h, w, k; cin >> h >> w >> k;
	ll ans = 0;
	rep1(i, k) {
		ll csum = h * w%mod*comb(h + w - 2, i - 2) % mod*p[i] % mod;
		csum += (i + 1)*comb2(h + w, i) % mod; csum %= mod;
		csum = csum * comb2(h + w - i, k - i) % mod;
		ans = (ans + csum) % mod;
	}
	cout << ans << endl;
	//stop
	return 0;
}

Measured memory_bytes: 313336
# Aそれぞれに対してBを二分探索→M(累積和構成) + NlogM
# Aを昇順、Bを降順に動かす→O(N+M)
import bisect

n, m, k = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

# 累積和を作る
b_cumsum = [0] * (m+1)
for i in range(m):
    b_cumsum[i+1] = b_cumsum[i] + bb[i]

ans = 0
a_sum = 0
b_rest = k

temp = bisect.bisect(b_cumsum, b_rest) - 1
ans = max(ans, temp)

for idx, a in enumerate(aa):
    a_sum += a
    b_rest -= a
    if a_sum > k:
        break
    temp = idx + 1 + bisect.bisect(b_cumsum, b_rest) - 1
    ans = max(ans, temp)

print(ans)


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

int main() {
    string S;
    cin >> S;
    
    int cnt = 0;
    for (int i = 0; i < S.size(); ++i) {
        static string ss, last;
        ss += S[i];
        if (last != ss) {
            last = ss;
            ss.clear();
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int H,W,h,w;
	cin >> H;
	cin >> W;
	cin >> h;
	cin >> w;

	int ans = H * W - (h * W + w * H - w*h);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int A, B, C, X, Y;
	int res = 0;
	cin >> A >> B >> C >> X >> Y;
	if((A+B)>=C*2){
		if(X>=Y){
			if(A>=C*2){
				res = C*2*X;
			}else{
		 		res = C*2*Y + A*(X-Y);
			}
		}else if(B>=C*2){
				res = C*2*Y;
			}else{
				res = C*2*X + B*(Y-X);
		}
	}else{
		res = A*X+B*Y;
	}
	cout << res << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,W;
  cin >> n >> W;
  vector<ll> v(n),w(n);
  for(int i=0;i<n;++i)
    cin >> w[i] >> v[i];
  vector<ll> dp(W+1);
  for(int i=0;i<n;++i)
  {
    for(int weight=W;weight>=0;weight--)
    {
      if(weight+w[i]<=W)
        dp[weight+w[i]]=max(dp[weight+w[i]],dp[weight]+v[i]);
    }
  }
  cout << dp[W] << endl;
}

Measured memory_bytes: 4024
program ddd
implicit none

integer(8) :: n, w, i, j
integer(8),allocatable,dimension(:) :: g, v
integer(8),allocatable,dimension(:,:) :: dp

read*, n, w

allocate(g(n))
allocate(v(n))
allocate(dp(0:w,0:n))
dp=0

do i=1,n
read*, g(i), v(i)
end do

do i=1, n
 do j=0, w
 if(j>=g(i)) then
 dp(j,i)=max(dp(j,i-1),dp(j-g(i),i-1)+v(i))
 else
 dp(j,i)=dp(j,i-1)
 end if
 end do
end do

write(*,'(i0)') dp(w,n)

end program

Measured memory_bytes: 79104
n,k=map(int,input().split())
ls={}
for i in range(n):
  a,b=map(int,input().split())
  if a not in ls:
    ls[a]=b
  else:
    ls[a]+=b
ls=sorted(ls.items())
tmp=0
for i,j in ls:
  tmp+=j
  if k <= tmp:
    print(i)
    exit()

Measured memory_bytes: 14580
from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))
C = Counter(A).most_common()

if len(C) <= K:
    print(0)
    exit()
ans = 0
for c in C[len(C) - 1:K - 1:-1]:
    ans += c[1]
print(ans)


Measured memory_bytes: 44272
/*************************************************************************
  > File Name: kdmc.cpp
  > Author: PumpkinYing
  > Created Time: 2018/11/28 13:45:23
 ************************************************************************/

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define prii pair<int,int>
#define prdd pair<double,double>
#define rep(i,l,r) for(int i = l;i < r;i++)
#define rep_(i,l,r) for(int i = l;i <= r;i++)
typedef long long ll;

const int maxn = 1000010;
char s[maxn];

ll work(char* s,int k) {
	int n = strlen(s);
	ll cntM = 0,cntC = 0;
	ll ret = 0;
	ll tmp = 0;
	for(int i = 0;i < k;i++) {
		if(s[i] == 'M') cntM++;
		else if(s[i] == 'C') {
			cntC++;
			tmp += cntM;
		}
	}
	if(s[0] == 'D') ret += tmp;

	for(int i = 1;i < n;i++) {
		if(i+k-1 < n) {
			if(s[i+k-1] == 'M') cntM++;
			else if(s[i+k-1] == 'C') {
				cntC++;
				tmp += cntM;
			}
		}

		if(s[i-1] == 'M') {
			tmp -= cntC;
			cntM--;
		}
		else if(s[i-1] == 'C') {
			cntC--;
		}

		if(s[i] == 'D') ret += tmp;
	}
	return ret;
}

int main() {
	int n;
	scanf("%d",&n);
	scanf("%s",s);
	int q;
	scanf("%d",&q);
	rep(cou,0,q) {
		int k;
		scanf("%d",&k);
		printf("%lld\n",work(s,k));
	}
	return 0;
}


Measured memory_bytes: 1280
#include <math.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)
#define LLONG_MAX     9223372036854775807i64

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	int N;
	string S;

	cin >> N >> S;

	int ans = 0;
	repr(i, 1, N) {

		string X, Y;
		rep(j, N) {
			if (j < i) X.push_back(S[j]);
			else Y.push_back(S[j]);
		}

		int al1[26] = { 0 }, al2[26] = { 0 };
		rep(j, X.length()) al1[X[j] - 'a']++;
		rep(j, Y.length()) al2[Y[j] - 'a']++;

		int res = 0;
		rep(j, 26) if (al1[j] > 0 && al2[j] > 0) res++;

		ans = max(ans, res);
	}

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

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

using namespace std;

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

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


ll func(ll bottom, int level){
    if(level == 0 && bottom == 1)
        return 1;
    ll total = 4;
    REP(i, level)
        total *= 2;
    total -= 3;

    
    ll half = total / 2 + 1;
    if(bottom == 1)
        return 0;
    else if(bottom < half){
        return func(bottom-1, level-1);
    }
    else if(bottom == half){
        return func(half-2, level-1) + 1;
    }
    else if(bottom < total){
        return func(half-2, level-1) + func(bottom - half, level-1) + 1;
    }
    else{
        return 2 * func(half-2, level-1) + 1;
    }
}
int main() {
    ll n, x;
    cin >> n >> x;

    cout << func(x, n) << endl;

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n;
int a[200005];

int main(){
	n=readint();
	for(int i=1;i<=n;i++) a[i]=readint();
	int cnt=0,now=0;
	for(int i=1;i<=n;i++) if(a[i]&1) cnt++,now^=1;
	if(cnt==n||cnt==0) printf("0\n");
	else if(now==0) printf("%d\n",n-2);
	else printf("%d\n",n-1);
	return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 a, b; scanf("%lld%lld", &a, &b);
	
	std::set<int> st;
	for(i64 i = a; i < std::min(a + 2019 * 2, b + 1); i++) st.insert(i % 2019);
	
	int mi = 1 << 30;
	for(auto i: st) for(auto j: st) if(i < j) mi = std::min(mi, i * j % 2019);
	printf("%d\n", mi);
	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static int[][] math;
	static final int MATH_LENGTH = 10;

	public static void main(String[] args) throws IOException {
		//??????°????????????
		math = new int[10][10];
		int x = 0, y = 0;
		int scale;

		//??\???????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String inputStr = null;
		while (true) {
			inputStr = br.readLine();
			if (inputStr == null || inputStr.isEmpty()) {
				break;
			}
			//??\???????????????","???§??????
			String[] inputSplitStr = inputStr.split(",");
			x = Integer.valueOf(inputSplitStr[0]);
			y = Integer.valueOf(inputSplitStr[1]);
			scale = Integer.valueOf(inputSplitStr[2]);

			// ????????????´????????????????????¨????
			switch (scale) {
			case 1: //????????????´?????°????
				setSmallInk(x, y);
				break;
			case 2: //????????????´?????????
				setMediumInk(x, y);
				break;
			case 3: //????????????´??????§???
				setLargeInk(x, y);
				break;
			}
		}
		//????????????¶?????????????????????¨?????????????????????????????????
		int whiteNumber = 0;
		int mostNumber = 0;
		for (int i = 0; i < MATH_LENGTH; i++) {
			for (int j = 0; j < MATH_LENGTH; j++) {
				if (math[i][j] == 0) {
					whiteNumber++;
				}
				if (mostNumber < math[i][j]) {
					mostNumber = math[i][j];
				}
			}
		}
		System.out.println(whiteNumber);
		System.out.println(mostNumber);
	}

	private static void setSmallInk(int x, int y) {
		math[x][y]++;
		if ((x - 1) >= 0) {
			math[x - 1][y]++;
		}
		if ((y - 1) >= 0) {
			math[x][y - 1]++;
		}
		if (MATH_LENGTH > (x + 1)) {
			math[x + 1][y]++;
		}
		if (MATH_LENGTH > (y + 1)) {
			math[x][y + 1]++;
		}
	}

	private static void setMediumInk(int x, int y) {
		math[x][y]++;
		if ((x - 1) >= 0) {
			math[x - 1][y]++;
			if ((y - 1) >= 0) {
				math[x - 1][y - 1]++;
			}
			if (MATH_LENGTH > (y + 1)) {
				math[x - 1][y + 1]++;
			}
		}
		if ((y - 1) >= 0) {
			math[x][y - 1]++;
		}
		if (MATH_LENGTH > (y + 1)) {
			math[x][y + 1]++;
		}
		if (MATH_LENGTH > (x + 1)) {
			math[x + 1][y]++;
			if ((y - 1) >= 0) {
				math[x + 1][y - 1]++;
			}
			if (MATH_LENGTH > (y + 1)) {
				math[x + 1][y + 1]++;
			}
		}
	}

	private static void setLargeInk(int x, int y) {
		math[x][y]++;
		if ((x - 2) >= 0) {
			math[x - 2][y]++;
		}
		if (MATH_LENGTH > (x + 2)) {
			math[x + 2][y]++;
		}
		if ((y - 2) >= 0) {
			math[x][y - 2]++;
		}
		if (MATH_LENGTH > (y + 2)) {
			math[x][y + 2]++;
		}
		if ((x - 1) >= 0) {
			math[x - 1][y]++;
			if ((y - 1) >= 0) {
				math[x - 1][y - 1]++;
			}
			if (MATH_LENGTH > (y + 1)) {
				math[x - 1][y + 1]++;
			}
		}
		if ((y - 1) >= 0) {
			math[x][y - 1]++;
		}
		if (MATH_LENGTH > (y + 1)) {
			math[x][y + 1]++;
		}
		if (MATH_LENGTH > (x + 1)) {
			math[x + 1][y]++;
			if ((y - 1) >= 0) {
				math[x + 1][y - 1]++;
			}
			if (MATH_LENGTH > (y + 1)) {
				math[x + 1][y + 1]++;
			}
		}
	}
}

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

using namespace std;

int main()
{

    int n,k,p[100005],sum=0;
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>p[i];
    }
    sort(p,p+n);
    for(int i=0;i<k;i++)
    {
        sum += p[i];
    }
    cout<<sum<<endl;

}



Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
int main() {

    int R ;
    scanf("%d",&R);
    double PI = acos(-1);
    double W ;
    W = 2*PI*R ;
    printf("%lf",W);


}


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

ll x;

ll func(ll a)
{
    return a * a * a * a * a;
}

int main()
{
    cin >> x;
    vector<ll> num(200);
    for(ll i = 0; i <= 1000; i++)
    {
        num[i] = func(i);
    }
    //for(int i = 0; i <= 1000; i++) cout << num[i] << " ";
    
    for(int i = 0; i <= 1000; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            if(num[i] + num[j] == x)
            {
                cout << i << " " << -j << endl;
                return 0;
            }
            if(num[i] - num[j] == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
string s;
int flag1=-1,flag2=-1;
int main()
{
//	freopen("1.txt","r",stdin);
	cin>>s;
	int lo=s.length();
	for(int i=0;i<lo;i++)
	{
		if(s[i]=='C')flag1=1;
		if(s[i]=='F'&&flag1==1)flag2=1;
    }
	
	if(flag2==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static class Node {
		int key;
		int value;
		Node(int key, int value){
			this.key = key;
			this.value = value;
		}
		public int getKey() {
			return key;
		}
		public void setKey(int key) {
			this.key = key;
		}
		public int getValue() {
			return value;
		}
		public void setValue(int value) {
			this.value = value;
		}
		
	}
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		
		int[] nums = {a,b,c,d,e};
		int sum = 0;
		int[] arr = new int[5];
		List<Node> list = new ArrayList<Node>();
		for(int i=0; i<nums.length; i++) {
			for(int j=0; j<=9; j++) {
				if((nums[i]+j)%10==0) {
					arr[i] = j;
				}
			}
			Node node = new Node(nums[i], arr[i]);
			list.add(node);
		}
		Collections.sort(list, new Comparator<Node>() {

			@Override
			public int compare(Node o1, Node o2) {
				return o1.getValue()-o2.getValue();
			}
		});

		for(int i=0; i<list.size()-1; i++) {
			sum += list.get(i).getKey()+list.get(i).getValue();
		}
		sum += list.get(4).getKey();
		System.out.println(sum);
    }
}


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

using namespace std;

#define F first
#define S second
#define MP make_pair
#define PB emplace_back
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

const int N = 1e3 + 100;

int a[N], h[N][N], n, m;

bool viz[N][N], in[N][N];

char c[N][N];

bool fix[N][N];

bool exist(int x, int y) {
    return x >= 0 && y >= 0 && x < n && y < m && c[x][y] == '.';
}

bool tam(int x1, int y1, int x2, int y2) {
    return (abs(x1 - x2) + abs(y1 - y2) != 1);
}

int main () {
    IOS;
    cin >> n >> m;
    long long int sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    sx--;
    sy--;
    ex--;
    ey--;
    for(int i = 0 ; i < n ; i++ ) {
        for(int j = 0 ; j < m ; j++ ) {
            cin >> c[i][j];
            h[i][j] = 1e7;
        }
    }
    deque<pair<int,int>>q;
    q.push_back(MP(sx, sy));
    h[sx][sy] = 0;
    while(q.size() > 0) {
        pair<int,int>p=q.front();
        q.pop_front();
        if(fix[p.F][p.S]) continue;
        fix[p.F][p.S] = 1;
        for(int i = -2 ; i <= 2 ; i++ ) {
            for(int j = -2 ; j <= 2 ; j++ ) {
                if(exist(p.F + i, p.S + j)) {
                    bool add = tam(p.F + i, p.S + j, p.F, p.S);
                    if(h[p.F + i][p.S + j] > h[p.F][p.S] + add) {
                        if(add) {
                            h[p.F + i][p.S + j] = h[p.F][p.S] + add;
                            q.push_back(MP(p.F + i,p.S + j));
                        }
                        else {
                            h[p.F + i][p.S + j] = h[p.F][p.S] + add;
                            q.push_front(MP(p.F + i,p.S + j));
                        }
                    }
                }
            }
        }
    }
    if(h[ex][ey] > 1e6+1000) {
        cout << -1 << '\n';
    }
    else cout << h[ex][ey] << '\n';
}


Measured memory_bytes: 10072
n, l = map(int, input().split())

s_list = []
s_list.append(input())

for i in range(n-1):
  s = input()
  for j in range(len(s_list)):
    if s_list[j] >= s:
      s_list.insert(j, s)
      break
    elif j == len(s_list) - 1:
      s_list.append(s)

ans = ''
for i in range(len(s_list)):
  ans += s_list[i] 

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <sstream>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


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

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "{" << p.first << ", " << p.second << "}";
}


int main() {
    int X[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    string s;
    while(getline(cin, s), s != "#"){
        int cnt = 0;
        for (auto &&i : s) cnt += i == '.';
        vector<ll> val{0};
        for (auto &&i : s) {
            if(isdigit(i)) val.back() = val.back()*10+i-'0';
            else val.emplace_back();
        }
        if(val.size() == 3){
            if(val[1] <= 2) val[1] += 12, val[0]--;
            ll x = 365*val[0]+val[0]/4-val[0]/100+val[0]/400+306*(val[1]+1)/10+val[2]-735286;
            vector<int> ans(5);
            ans[4] = x%20; x /= 20;
            ans[3] = x%18; x /= 18;
            ans[2] = x%20; x /= 20;
            ans[1] = x%20; x /= 20;
            ans[0] = x%13;
            printf("%d.%d.%d.%d.%d\n", ans[0], ans[1], ans[2], ans[3], ans[4]);
        }else {
            ll x = val[4]+20*(val[3]+18*(val[2]+20*(val[1]+20*(val[0]))));
            int ok = 2011, ng = 8000;
            while(ng-ok > 1){
                auto mid = (ok+ng)/2;
                if(365*mid+mid/4-mid/100+mid/400-734857 <= x) ok = mid;
                else ng = mid;
            }
            x = x-(365*ok+ok/4-ok/100+ok/400-734857);
            ok++;
            if(ok%4 == 0 && ok%100 != 0 || ok%400 == 0) X[2] = 29;
            else X[2] = 28;
            for (int i = 1; i <= 12; ++i) {
                for (int j = 1; j <= X[i]; ++j) {
                    if(!x) printf("%d.%d.%d\n", ok, i, j);
                    x--;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3276
#define _CRT_SECURE_NO_WARNINGS
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
const ll mod = 1000000007;
const double eps = 1e-6;
const double PI = acos(-1);
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
const int iadd[] = {0, 1, 0, -1}, jadd[] = {1, 0, -1, 0};
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
int n;
int a[maxn];
int cnt[maxn];

void solve(){
	memset(cnt, 0, sizeof(cnt));
	for(int i = 0; i < n; i++) cnt[a[i]]++;
	int ans = cnt[0] + cnt[1];
	for(int i = 1; i < 1e5; i++){
		int u = cnt[i] + cnt[i - 1] + cnt[i + 1];
		ans = max(u, ans);
	}
	printf("%d\n", ans);
}
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	solve();
}



Measured memory_bytes: 1024
from collections import defaultdict

def trial_division(n):

    tmp = int(n ** 0.5) + 1
    for num in range(2, tmp):
        while n % num == 0:
            d[num] += 1
            n //= num
    if n > 1:
        d[n] += 1

    return

N = int(input())

d = defaultdict(int)

for i in range(1, N+1):
    trial_division(i)

a = 0
b = 0
c = 0
x = 0
y = 0

for k, v in d.items():
    if v + 1 >= 3:
        a += 1
    if v + 1 >= 5:
        b += 1
    if v + 1 >= 15:
        c += 1
    if v + 1 >= 25:
        x += 1
    if v + 1 >= 75:
        y += 1

ans = (a-2) * ((b * (b-1)) // 2) + (b-1) * c + x * (a-1) + y
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 10100;
const int maxd = 110;
const ll modd = 1LL * 1e9 + 7;
ll dp[maxn][maxd][2][2];
string x;
ll d;

void solve() {

    dp[0][0][1][1] = 1LL;
    for(int len=0;len<x.length();len++) {
        for(int mod=0;mod<d;mod++) {
            for(int limit=0;limit<2;limit++) {
                for(int leading=0;leading<2;leading++) {
                    if(dp[len][mod][limit][leading] == 0) continue;

                    //cout<<len<<", "<<mod<<", "<<limit<<", "<<leading<<" -> "<<dp[len][mod][limit][leading]<<"\n";

                    if(leading) {
                        dp[len+1][mod][0][1] += dp[len][mod][limit][1];
                        if(limit) {
                            for(int ndigit=1;ndigit<(x[len]-'0');ndigit++) {
                                dp[len+1][(mod+ndigit)%d][0][0] += dp[len][mod][limit][leading];
                                dp[len+1][(mod+ndigit)%d][0][0] %= modd;
                            }
                            dp[len+1][(mod+(x[len]-'0'))%d][1][0] += dp[len][mod][limit][leading];
                            dp[len+1][(mod+(x[len]-'0'))%d][1][0] %= modd;
                        }
                        else {
                            for(int ndigit=1;ndigit<=9;ndigit++) {
                                dp[len+1][(mod+ndigit)%d][0][0] += dp[len][mod][limit][leading];
                                dp[len+1][(mod+ndigit)%d][0][0] %= modd;
                            }
                        }
                    }
                    else {
                        if(limit) {
                            for(int ndigit=0;ndigit<(x[len]-'0');ndigit++) {
                                dp[len+1][(mod+ndigit)%d][0][0] += dp[len][mod][limit][leading];
                                dp[len+1][(mod+ndigit)%d][0][0] %= modd;
                            }
                            dp[len+1][(mod+(x[len]-'0'))%d][1][0] += dp[len][mod][limit][leading];
                            dp[len+1][(mod+(x[len]-'0'))%d][1][0] %= modd;
                        }
                        else {
                            for(int ndigit=0;ndigit<=9;ndigit++) {
                                dp[len+1][(mod+ndigit)%d][0][0] += dp[len][mod][limit][leading];
                                dp[len+1][(mod+ndigit)%d][0][0] %= modd;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<dp[x.length()][0][0][0] + dp[x.length()][0][1][0]<<"\n";
}

int main() {
    cin>>x>>d;
    solve();
    return 0;
}


Measured memory_bytes: 34688
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const int MN = 1e5 + 5, LOG=16;
ll n;
int main() {
    cin >> n;
    for (ll i = ceil(sqrt(n)); i>0;i--) {
        if (n % i == 0) {
            cout << i-1 + ((n/i)-1) << "\n";
            return 0;
        }
    }
}


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

void cin_Ignore(){
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
}

int main(){
    
    string input;
    vector<int> Que(3,0);
    for(int i = 0; i < Que.size(); i++){
        cin >> Que[i]; cin_Ignore;
    }
    
    int count_5 = 0;
    int count_7 = 0;
    for(const auto &fd : Que){
        if(fd == 5)
            count_5++;
        else if(fd == 7)
            count_7++;
    }
    
    if (count_5 == 2 && count_7 == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    
}

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

using namespace std;

long add(const string& numbers, const int& bitsOfPlusPosition);

int main() {
    string numbers;
    cin >> numbers;
    
    long answer = 0;
    for (int bits = 0; bits < (1 << (numbers.size() - 1)); ++bits) {
        answer += add(numbers, bits);
    }
    cout << answer << endl;       
}

long add(const string& numbers, const int& bitsOfPlusPosition) {
    const int DICIMAL_BASE = 10;
    long sum = 0;
    long term = 0;
    for (size_t i = 0U; i < numbers.size(); ++i) {
        term *= DICIMAL_BASE;
        term += numbers.at(i) - '0';
        if (bitsOfPlusPosition & (1 << i) || i == numbers.size() - 1) {
            sum += term;
            term = 0;
        }
    }
    return sum;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n, k;
	while(cin >> n >> k) {
		if(n == 0 && k == 0) break;

		vector<int> v(n);
		rep(i, n) cin >> v[i];

		int l = v[0], a = 0;
		rep(i, k) a += v[i];

		ll ans = a;
		REP(i, k, n) {
			a -= l;
			a += v[i];

			ans = max(ans, (ll)a);
			l = v[i - k + 1];
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1532
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 2e6 + 10;

struct node {
  LL t, e;
  friend bool operator < (node a, node b) {
    if (a.e == b.e) return a.t <= b.t;
    return a.e <= b.e;
  }
} a[maxn];

int main() {
  LL n, ans = 0;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", &a[i].t, &a[i].e);
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if ((ans += a[i].t) > a[i].e) {ans = -1; break;}
  }
  printf("%s\n", ans == -1?"No":"Yes");

  return 0;
}


Measured memory_bytes: 4352