akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n; cin >> n;
  
  vector<int> cnt(100000);
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    cnt[a]++;
  }
  
  int ans = 0;
  for (int i = 1; i < 100000; i++) {
    ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	auto c = minmax({in(), in(), in()});
	outl(c.first, ' ', c.second);
}


Measured memory_bytes: 2628
a=input()
b=list(map(int,input().split()))
i=list(map(int,input().split()))
j=list(map(int,input().split()))
k=0
for c in b:
    k+=i[c-1]
    d=b.index(c)
    if not d==0 and b[d-1]==c-1:
        k+=j[c-2]
        
print(k)



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

int h = 0;
int w = 0;
char cloud = 0;
bool c_data[120][120] = {0};
int sec_mem[120][120] = {0};
int inf = 100000000;
void solve()
{
  for (int sec = 1; sec <= w; sec++)
  {
    for (int j = w; j >= 0; j--)
    {
      for (int i = 0; i < h; i++)
      {
        c_data[i][j] = c_data[i][j-1];
        if (c_data[i][j]) sec_mem[i][j] = min(sec, sec_mem[i][j]);
      }
    }
  }
}

int main()
{
  cin >> h >> w;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> cloud;
      if (cloud == '.')
      {
        c_data[i][j] = false;
        sec_mem[i][j] = inf;
      }
      else if (cloud == 'c')
      {
        c_data[i][j] = true;
        sec_mem[i][j] = 0;
      }
    }
  }
  solve();
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if (j != 0) printf(" ");
      if (sec_mem[i][j] == inf) sec_mem[i][j] = -1;
      printf("%d", sec_mem[i][j]);
    }
    puts("");
  }
  return 0;
}



Measured memory_bytes: 3260
from collections import deque
import sys
input=sys.stdin.readline
a,b=map(int,input().split())
e=[[]for i in range(a)]

for i in range(a-1):
  c1,c2=map(int,input().split())
  e[c1-1].append(c2-1)
  e[c2-1].append(c1-1)

g=[[]for i in range(a)]
f=deque([(0,-1)])
ans=[0 for _ in range(a)]
for i in range(b):
  ten,p=map(int,input().split())
  ans[ten-1]+=p
i=0
while len(f)!=0:
  i,fr=f.pop()
  for j in e[i]:
    if j==fr:
      continue
    else:
      ans[j]+=ans[i]
      f.append((j,i)) 
print(*ans)

    
  

  
  


Measured memory_bytes: 75000
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <tuple>
#include <numeric>
#include <sstream>
#include <cassert>
template<class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template<class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}

using namespace std;

int main() {
	int N;
	int L[15] = { };
	int max = 0;
	int sum = 0;

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> L[i];
		max = (max >= L[i])? max : L[i];
		sum += L[i];
	}

	sum -= max;

	if(sum > max){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[10][10];
void c(){
	for(int i=0;i<=10;i++){
		dp[i][0]=1;
		dp[i][1]=i;
	}
	for(int i=1;i<=10;i++)
		for(int j=1;j<=10;j++){
			dp[i][j]=dp[i-1][j-1]+dp[i-1][j]; 
//			cout<<dp[i][j]<<endl;
		}
}
int main(){
	c(); 
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n-1;i++) sum+=i;
	sum+=dp[n][3];
	cout<<sum*6+n<<endl; 
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

KMIN = 2
KMAX = 10 ** 12 + 1  # Exclusive

def main():
    n = int(input())
    k = []
    k += dividor_of(n - 1)
    for d in dividor_of(n):
        if d < 2:
            continue
        x = n
        while x % d == 0:
            x //= d
        if x % d == 1:
            k.append(d)
    k = sorted(x for x in k if x >= 2)
    print(len(set(k)))

def dividor_of(m):
    res = set()
    for i in range(1, 10 ** 6 + 1):
        if m % i == 0:
            res.add(i)
            res.add(m // i)
        if i ** 2 >= m:
            return sorted(list(res))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3828
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

int dx[] = { 0, 1, 0, -1};
int dy[] = {-1, 0, 1,  0};

int main()
{
  int N;
  std::cin >> N;
  std::unordered_map<std::string, int> m;
  while(N--)
  {
    std::string s;
    std::cin >> s;
    m[s]++;
  }
  std::vector<std::pair<std::string, int>> v;
  v.reserve(m.size());
  for(auto& p: m)
    v.push_back(p);
  std::sort(v.begin(), v.end(), [](auto&& x, auto&& y){ return x.second != y.second ? x.second > y.second : x.first < y.first; });
  std::cout << v[0].first << "\n";
  int cnt = v[0].second;
  for(int i = 1; i < v.size(); ++i)
  {
    if(v[i].second != cnt)
      break;
    std::cout << v[i].first << "\n";
  }
  return 0;
}



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

typedef long long ll;
int n;
ll m1[262144],m2[262144];

int main(){
    scanf("%d",&n);
    vector<ll> ms;
    for(int i=0;i<(1<<n);i++){
        ll a;
        scanf("%lld",&a);
        m1[i]=(a<<(n+1))+i;
        ms.clear();
        ms.push_back(m1[i]);
        for(int d=0;d<n;d++){
            if(i&(1<<d)){
                m1[i]=max(m1[i],m1[i^(1<<d)]);
                ms.push_back(m1[i^(1<<d)]);
                ms.push_back(m2[i^(1<<d)]);
            }
        }
        for(ll x:ms)
            if(x!=m1[i])m2[i]=max(m2[i],x);
    }
    for(int i=1;i<(1<<n);i++){
        ll ans=m1[i]+m2[i];
        for(int d=n-1;d>0;d--){
            if(i&(1<<d)){
                int k=(i^(1<<d))|((1<<d)-1);
                ans=max(ans,m1[k]+m2[k]);
            }
        }
        printf("%lld\n",ans>>(n+1));
    }
}

Measured memory_bytes: 7168
S = input()
N = len(S)
P = 2019

# 余りの累積和
d = [0] * (N+1)
ten = 1
for i in range(N-1, -1, -1):
    a = int(S[i]) * ten % P
    d[i] = (d[i+1] + a) % P 
    ten *= 10
    ten %= P

ans = 0
count = [0] * P
for i in range(N, -1, -1):
    ans += count[d[i]]
    count[d[i]] += 1

print(ans)

Measured memory_bytes: 69800
#include <bits/stdc++.h>
using namespace std;
/*
	Author		zombie462
	Date&Time 	Unknown
*/
#define int long long
#define LL long long
#define uLL unsigned long long
#define LD long double
//#define N 0
//#define M 0
//#define mod 0
//#define G 0
#define reg register
//#pragma GCC optimize("O2")
int read(){
	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 etot=1,ea[N*2],eb[N*2],ec[N],ed[N*2];
void add(int x,int y,int z=0){
	etot++;ea[etot]=y;eb[etot]=ec[x];ec[x]=etot;ed[etot]=z;
}
*/
/*
int gcd(int x,int y){
	if (x%y==0) return y;
	else return gcd(y,x%y);
}
int lcm(int x,int y){
	return x*y/gcd(x,y);
}
int getinv(int x){
	if (x==1) return 1;
	else return (mod-mod/x)*getinv(mod%x)%mod;
}
*/
/*
int inv[G],fac[G];
int C(int n,int m){
	if (n==m) return 1;
	if (n<m) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
void initC(){
	inv[0]=inv[1]=fac[0]=fac[1]=1;
	for (int i=1;i<G;++i) fac[i]=fac[i-1]*i%mod;
	for (int i=1;i<G;++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for (int i=1;i<G;++i) inv[i]=inv[i]*inv[i-1]%mod;
}
*/
#define mod 1000000007
#define N 1010
int d[N],fac[N],inv[N],f[N][N][2];
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);

	int n=read();
	fac[0]=fac[1]=1;
	for (int i=2;i<=n;++i) fac[i]=fac[i-1]*i%mod;
	inv[0]=inv[1]=1;
	for (int i=2;i<=n;++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	int inv2=inv[2];
	for (int i=2;i<=n;++i) inv[i]=inv[i]*inv[i-1]%mod;
	for (int i=1;i<=n;++i) d[i]=read();
	f[0][0][0]=1;
	for (int i=0;i<n;++i){
		for (int j=0;j<=i;++j){
			f[i+1][j][0]=(f[i+1][j][0]+f[i][j][0]*(inv[d[i+1]-1])%mod)%mod;
			f[i+1][j][1]=(f[i+1][j][1]+f[i][j][1]*(inv[d[i+1]-1])%mod)%mod;
			if (d[i+1]<2) continue;
			f[i+1][j+1][0]=(f[i+1][j+1][0]+f[i][j][0]*(inv[d[i+1]-2])%mod)%mod;
			f[i+1][j+1][1]=(f[i+1][j+1][1]+f[i][j][1]*(inv[d[i+1]-2])%mod)%mod;
			if (d[i+1]<3) continue;
			f[i+1][j+1][1]=(f[i+1][j+1][1]+f[i][j][0]*(inv[d[i+1]-3])%mod)%mod;
		}
	}
	int ans=0;
	for (int j=3;j<n;++j) ans=(ans+f[n][j][1]*fac[n-j-1]%mod*fac[j-1]%mod*inv2%mod)%mod;
	if (n>=3) ans=(ans+f[n][n][0]*fac[n-1]%mod*inv2%mod);
	cout<<ans<<endl;
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}
/*
--Some models can copy to use--
Coming soon...
*/


Measured memory_bytes: 4992
#include<stdio.h>

#define MAX 2000000

int H,A[MAX+1];

void maxHeapfy(int );

int main(){
int i;
scanf("%d",&H);

for( i = 1 ; i <= H ; i++ ){

	scanf("%d",&A[i]);

}
for( i = H/2 ; i >= 1 ; i-- ){
	maxHeapfy(i);
}

for( i = 1 ; i <= H ; i++){
	printf(" %d",A[i]);
}
printf("\n");

return 0;

}



void maxHeapfy(int i){

	int  l,r,largest,t;
	l = 2 * i;
	r = 2 * i +1;

	if( l <= H && A[l] > A[i]) largest = l;
	else largest = i;
	if(r <= H && A[r] > A[largest]) largest = r;

	if( largest != i){
		t = A[i];
		A[i] = A[largest];
		A[largest] = t;
		maxHeapfy(largest);
	}

}

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

    int n;
    cin>>n;
    int pre=0;
    int k;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>k;
        if(pre<k)ans+=k-pre;
        pre=k;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
PROGRAM-ID.                      PROGRAM_ID.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 LN           PIC X(13).
    01 N            PIC 9(10).
    01 K            PIC 9(2).
    01 cnt          PIC 9(3).
    01 ans          PIC X(3).
    01 ZS           PIC Z(3)9.
    01 DUMMY        PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT LN.
    UNSTRING LN DELIMITED BY SPACE INTO N K.
    MOVE 1 TO cnt.
    PERFORM UNTIL N < K ** cnt
       ADD 1 TO cnt
    END-PERFORM.
    MOVE cnt TO ZS.
    PERFORM UNANS.
    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
    ZS DELIMITED BY ALL SPACE
    INTO DUMMY ans.


Measured memory_bytes: 636
n,m=map(int,input().split())
w=[0]*n 
v=[0]*n
from collections import Counter
l=[]
for i in range(n):
    a,b=map(int,input().split())
    w[i]=a  
    v[i]=b 
a=min(w)
c=Counter(w)
#print(a)
cnt1=c[a]
#print(c)
v1=[v[i] for i in range(n) if w[i]==a]
v1.sort(reverse=1)
cnt2=c[a+1]
v2=[v[i] for i in range(n) if w[i]==a+1]
cnt3=c[a+2]
v3=[v[i] for i in range(n) if w[i]==a+2]
v2.sort(reverse=1)
v3.sort(reverse=1)
cnt4=c[a+3]
v4=[v[i] for i in range(n) if w[i]==a+3]
v4.sort(reverse=1)
#print(cnt1)
pv1=[0]*(cnt1+1)
pv1[0]=0
for i in range(1,cnt1+1):
    pv1[i]=pv1[i-1]+v1[i-1]
pv2=[0]*(cnt2+1)  
pv2[0]=0
for i in range(1,cnt2+1):
    pv2[i]=pv2[i-1]+v2[i-1]
pv3=[0]*(cnt3+1) 
pv3[0]=0
for i in range(1,cnt3+1):
    pv3[i]=pv3[i-1]+v3[i-1]
ans=0 
pv4=[0]*(cnt4+1)
for i in range(1,cnt4+1):
    pv4[i]=pv4[i-1]+v4[i-1]
for i in range(0,cnt1+1):
    for j in range(0,cnt2+1):
        for k in range(0,cnt3+1):
            for z in range(0,cnt4+1):
                if (i)*a+(j)*(a+1)+(k)*(a+2)+z*(a+3)<=m:
                    ans=max(ans,pv1[i]+pv2[j]+pv3[k]+pv4[z])
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;
const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  string s, t;
  cin >> s >> t;

  for (i = 0; i < 26; i++)
  {
    char c = 'a' + i;
    if (s + c == t)
    {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3552
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n;
        ll x=log2(n);
        ll p=pow(2,x+1);
        cout<<p-1;
    }
    return 0;
}

Measured memory_bytes: 384
use std::collections::HashSet;
fn f(x: usize) -> usize {
    let mut cnt = 0;
    let mut tmp = x;
    while tmp > 0 {
        if tmp % 2 == 0 {
            cnt += 1;
        } else {
            break;
        }
        tmp /= 2;
    }
    cnt
}

fn gcd(x: usize, y: usize) -> usize {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    let a: Vec<usize> = sc.vec::<usize>(n).iter().map(|x| x / 2).collect();
    let b: HashSet<usize> = a.iter().map(|x| f(*x)).collect();
    if b.len() != 1 {
        println!("0");
        return;
    }

    let t = f(a[0]);
    let a: Vec<usize> = a.iter().map(|x| x >> t).collect();
    let m = m >> t;
    let mut lcm = a[0];
    for i in 1..n {
        lcm = lcm / gcd(lcm, a[i]) * a[i];
        if lcm > m {
            println!("0");
            return;
        }
    }
    let m = m / lcm;
    let result = (m + 1) / 2;
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .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: 12668
#include <iostream>
#include <cstdio>
using namespace std;

typedef long long ll;

ll a[100010];
int main()
{
    int x, n;
    while(scanf("%d%d", &n, &x) != EOF)
    {
        ll sum = 0;
        for(int i = 0; i < n; i++)
        {
            scanf("%lld", &a[i]);
            if(a[i] > x)
                {
                    sum += a[i] - x;
                    a[i] = x;
                }
        }
        for(int i = 1; i < n; i++)
        {
            if(a[i] + a[i - 1] > x)
            {
                sum += a[i] - (x - a[i - 1]);
                a[i] = x - a[i - 1];
            }
        }
        printf("%lld\n", sum);
    }
    return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [u64;n],
    }

    p.sort();
    let ans: u64 = p[0..k].iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 2176
S = input()
T = input()

flag = 0

for i in range(len(S)):
	S2 = S[-2:]
	S2 = S[-1] + S[:-1]
	if S2 == T:
		flag = 1
	S = S2
	#print(S2)

if flag == 1:
	print("Yes")
else:
	print("No")

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

const int dx[]={1,-1,0,0},
		  dy[]={0,0,1,-1};

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,sz[N];

char s[N];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	printf("%d\n",a[(n/2)]-a[n/2-1]); 
}



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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        scanf("%d", &a[i]);
    }
    
    long yen = 1000, stock = 0;
    rep(i, n-1) {
        if (a[i] < a[i+1]) {
            stock = yen / a[i];
            yen += (a[i+1] - a[i]) * stock;
            stock = 0;
        }
    }

    printf("%ld\n", yen);
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;
long long n,k,total;
struct matrice
{
    vector < vector<long long>> t;
    matrice()
    {
        t.resize(n, vector<long long>(n));
    }

    matrice operator* (const matrice &b)
    {
        matrice ans = matrice();
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                for(int k=0; k<n; k++)
                {
                    ans.t[i][k] += (t[i][j]*b.t[j][k])%mod;
                    ans.t[i][k] %= mod;
                }
        return ans;
    }
};
int main()
{
    cin>>n>>k;
    vector<vector<long long>> can(n, vector<long long>(n));
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>can[i][j];

    matrice ans = matrice();
    for(int i=0; i<n; i++)
        ans.t[i][i]=1;

    matrice m = matrice();
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            m.t[i][j]=can[i][j];

    while(k)
    {
        if(k%2)
        {
            ans=ans * m;
        }
        m = m*m;
        k/=2;
    }

    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            total += ans.t[i][j];
            total %= mod;
        }

    cout<<total;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


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

    ll n,k;
    cin>>n>>k;
    ll val=1;
    for(ll i=1;i<=n;i++)
    {
        val=val*2;
    }
    if(k>=val)
    {
        cout<<"-1";
        exit(0);
    }
    if(n==1 && k==1)
    {
        cout<<"-1";
        exit(0);
    }
    if(n==1 && k==0)
    {
        cout<<"0 1 1 0";
        exit(0);
    }
    cout<<k<<" ";
    for(ll i=0;i<val;i++)
    {
        if(i==k)
        {
            continue;
        }
        cout<<i<<" ";
    }
    cout<<k<<" ";
    for(ll i=val-1;i>=0;i--)
    {
        if(i==k)
        {
            continue;
        }
        cout<<i<<" ";
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n, k;
map<int, int> a;
vector<int> cnt;
/**********************************************/

int main(){
    cin >> n >> k;
    REP(i, n){
        int x;
        cin >> x;
        a[x]++;
    }
    
    for(auto itr = a.begin(); itr != a.end(); ++itr){
        cnt.pb(itr->second);
    }

    VSORT(cnt);
    int ans = 0;
    int num = cnt.size() - k;
    REP(i, num){
        ans += cnt[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ss string 
int main()

{ 
	ll t,ac=0,wa=0,re=0,tle=0;
	cin >> t;
	for(int i=0;i<t;i++)
	{
		ss s;
		cin >> s;
		if(s[0]=='A')
		{
           ac++;
		}
		 else if(s[0]=='W')
		{
           wa++;
		}
		 else if(s[0]=='T')
		{
           tle++;
		}
		 else if(s[0]=='R')
		{
           re++;
		}
	}
	cout <<"AC x "<< ac <<"\n";
	cout <<"WA x "<< wa <<"\n";
	cout <<"TLE x "<< tle <<"\n";
	cout <<"RE x "<< re <<"\n";
}


Measured memory_bytes: 3584
import java.util.*;

public class Main{
	static final int	dx[]={0,-1,0,1};
	static final int	dy[]={-1,0,1,0};

	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		ArrayList<ArrayList<Integer>>g=new ArrayList<>();
		for(int i=0;i<n;++i)
			g.add(new ArrayList<>(1));
		for(int i=1;i<n;++i) {
			int a=s.nextInt()-1;
			int b=s.nextInt()-1;
			g.get(a).add(b);
			g.get(b).add(a);
		}
		boolean f[]=new boolean[n];

		int root=0;
		{
			f[0]=true;

			ArrayDeque<Integer>q=new ArrayDeque<>();
			q.add(0);
			f[0]=true;
			while(!q.isEmpty()) {
				int i=q.poll();
				for(int j:g.get(i)) {
					if(!f[j]) {
						q.add(j);
						f[j]=true;
					}
				}
				if(q.isEmpty())
					root=i;
			}
			Arrays.fill(f,false);
		}

		int r2 = dfs(g,f,root,1);
		System.err.println(r2);;
		System.out.println(r2%3==2?"Second":"First");
	}

	private static int dfs(ArrayList<ArrayList<Integer>> g,boolean[] f,int i,int d){
		f[i]=true;
		int b=0;
		for(int j:g.get(i)) {
			if(!f[j]) {
				b = Math.max(b,dfs(g,f,j,d+1));
			}
		}
		return b==0?d:b;
	}
}

Measured memory_bytes: 174664
#include<bits/stdc++.h>
using namespace std;
int x,y,n,B;
int main(){
cin>>n>>B>>B;
for(int i=1;i<=n;++i)x=y,cin>>y;
printf("%d",n==1?abs(y-B):max(abs(y-B),abs(x-y)));
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second


void solve(){
	
	int n,k;
	cin>>n>>k;
	int height[n];
	rep(i,0,n)
		cin>>height[i];

	int dp[n];
	dp[0]=0;

	rep(i,1,n){
		dp[i] = 1e18;
		for(int j=1; i-j>=0 && j<=k;j++){
			dp[i] = min(dp[i], dp[i-j] + abs(height[i]-height[i-j]));
		}
	}
	cout<<dp[n-1]<<endl;


}
signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

ll H, W;
int main(void){
    cin >> H >> W;
    if(H > 1 & W > 1)
        cout << H * W / 2 + (H * W) % 2 << endl;
    else{
        cout << 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	int n;
	cin >> n;
	vector<pair<int, string>> inputs;
	REP(i, n) {
		string a;
		int b;
		cin >> a >> b;
		inputs.push_back(mp(b, a));
	}
	sort(ALL(inputs));
	reverse(ALL(inputs));
	map<string, vector<int>> gogo;
	REP(i, inputs.size()) {
		gogo[inputs[i].second].push_back(inputs[i].first);
	}
	int m;
	cin >> m;
	int now = -1;
	REP(i, m) {
		string a;
		cin >> a;
		while (gogo[a].empty() == false && gogo[a].back() <= now) {
			gogo[a].pop_back();
		}
		if (gogo[a].empty()) {
			cout << "No" << endl;
			return;
		}
		now = gogo[a].back();
		gogo[a].pop_back();
	}
	cout << "Yes" << endl;
	return;
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 21700
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

template<typename T> class Weighted_UnionFind
{
public:
    vector<int> par,nrank;
    vector<T> wd;
    int V;
    Weighted_UnionFind(int node_size){
        V = node_size;
        par.resize(V),wd.resize(V,0),nrank.resize(V,0);
        rep(i,V){
            par[i] = i;
        }
    }
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            int parent = find(par[x]);
            wd[x] += wd[par[x]];
            return par[x] = parent;
        }
    }
    T weight(int x){
        find(x);
        return wd[x];
    }
    void unite(int x,int y,T w){
        w += weight(x), w -= weight(y);
        x = find(x),y = find(y);
        if(x == y) return;
    	if(nrank[x] < nrank[y]){
            swap(x,y);
            w = -w;
        }
        nrank[x] += (nrank[x] == nrank[y]);
        par[y] = x;
        wd[y] = w;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    T diff(int x,int y){
        return weight(y)-weight(x);
    }
};


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    Weighted_UnionFind<int> wu(n);
    rep(i,m){
        int l,r,d;
        cin >> l >> r >> d;
        --l,--r;
        if(wu.same(l,r)){
            if(wu.diff(l,r) != d){
                cout << "No\n";
                return 0;
            }
        }else{
            wu.unite(l,r,d);
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(void){
    int n, key; 
    cin>>n;
    vector <int> a(n+1); 
    COMinit();
    rep(i,n+1) cin>>a[i];
    vector <bool>  c(100010) ;
    rep(i,n+1) {if(c[a[i]]) {key = a[i]; break;} else c[a[i]] = true;}
    int l = 0, r = n-1;
    itn cntl=0,cntr = 0;
    
    for(int l = 0;l<n+1;l++){
        if(a[l] == key) break;
        else cntl++;
    }
    for(int r = n;r>=0;r--){
        if(a[r] == key) break;
        else cntr++;
    }

    
    for(int k=1;k<=n+1;k++){
        if(k==1) {cout<<n<<endl; continue;}
        if(k==n+1) {cout<<1<<endl; continue;}
        //cout<<COM(cntr+cntl, k-1)<<endl;
        int tmp = (COM(n+1,k) + MOD - COM(cntr+cntl, k-1))%MOD;
        cout<<tmp%MOD<<endl;
    }
    
}


Measured memory_bytes: 13952
#include <iostream>
#include <algorithm>
using namespace std;
int a[3], k;

int main () {
	for (int i = 0; i < 3; i++) cin >> a[i];
	cin >> k;
	sort (a, a+3);
	for (int i = 0; i < k; i++) a[2]*=2;
	cout << a[0]+a[1]+a[2];






return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, t; cin >> n >> t;
	long long a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	long long mx = 0, vm = 0;
	long long v[n];
	for(int i = n-1; i >= 0; i--){
		mx = max(mx, a[i]);
		v[i] = mx - a[i];
		vm = max(vm, v[i]);
	}
	long long ans = 0;
	for(int i = 0; i < n; i++){
		ans += (vm == v[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
from math import factorial


def combinations_count(n, r):
    if n < 2:
        return 0
    return factorial(n) // (factorial(r) * factorial(n - r))

N, M = list(map(int, input().split(' ')))
N_combinations = combinations_count(N, 2)
M_combinations = combinations_count(M, 2)

print(N_combinations +  M_combinations)

Measured memory_bytes: 3060
n=int(input())
p=[int(j) for j in input().split()]
q=[int(j) for j in input().split()]
l=list(range(1,n+1)[::-1])
import itertools
ll=[]
for x in itertools.permutations(l):
    ll.append(list(x))
ll.sort()
a=0
b=0
c=0
for i in ll:
    if i==p:
        a=c
    if i==q:
        b=c
    c+=1
print(abs(a-b))

Measured memory_bytes: 47836
N = int(input())
A = [int(a) for a in input().split()]
DP = [[None, None] for i in range(N)] 
DP[0] = [A[0], -A[0]]
for i in range(1, N):
    DP[i][0] = max(DP[i-1][0] + A[i], DP[i-1][1] - A[i])
    DP[i][1] = max(DP[i-1][0] - A[i], DP[i-1][1] + A[i])
print(DP[N-1][0])


Measured memory_bytes: 25572
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;
  cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    ans+=i*(n/i)*(1+n/i)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };


int main() {
	vector<int>a(5);
  	rep(i,0,5)cin >> a[i];
  	int k;
  	cin >> k;
  	rep(i,0,5)rep(j,i+1,5){
      if(abs(a[i]-a[j]) > k){
        cout << ":(" << endl;
        return 0;
      }
    }
  	cout << "Yay!" << endl;
  	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int main() {
  while (true) {
    int a, b, c, d, e;
    int na, nb, nc;
    cin >> a >> b >> c >> d >> e;
    if (a == 0) break;
    cin >> na >> nb >> nc;
    int sum = a * na + b * nb + c * nc;
    rep (dd, na + nb + nc + 1) {
      int d2 = dd;
      int aa = na, bb = nb, cc = nc;
      int diff = min(cc, d2);
      cc -= diff;
      d2 -= diff;
      diff = min(bb, d2);
      bb -= diff;
      d2 -= diff;
      diff = min(aa, d2);
      aa -= diff;
      sum = min(sum, max(dd, d) * e + aa * a + bb * b + cc * c);
    }
    cout << sum << endl;
  }
  return 0;
}

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

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

  if (K <= (N-1)*(N-2)/2) {
    // Starを作る
    cout << N-1 + (N-1)*(N-2)/2 - K << endl;
    for (int i=2; i<=N; i++) {
      cout << 1 << " " << i << endl;
    }
    int count = 0;
    for (int i=2; i<=N-1; i++) {
      for (int j=i+1; j<=N; j++) {
        if (count >= (N-1)*(N-2)/2 - K) return 0;
        cout << i << " " << j << endl;
        count++;
      }
    }
  } else {
    cout << -1 << endl;
  }
}


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

using namespace std;

constexpr int INF=1e9+7;

int main()
{
  int n,w;
  cin>>n>>w;
  vector<int>vv(n),wv(n);
  vector<vector<int>>dp(101,vector<int>(10001,INF));
  dp[0][0]=0;
  for(int i=0;i<n;++i){
    cin>>vv[i]>>wv[i];
  }
  for(int i=0;i<n;++i){
    for(int j=0;j<=10000;++j){
      if(j<vv[i]){
        dp[i+1][j]=dp[i][j];
      }else{
        dp[i+1][j]=min(dp[i][j],dp[i][j-vv[i]]+wv[i]);
      }
    }
  }
  int ans=0;
  for(int i=0;i<=10000;++i){
    if(dp[n][i]<=w)ans=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

int w, h, x, y;

int main(){
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(9) << 1.0 * w * h / 2 << ' ' << (2*x == w && 2*y == h);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  
  if((n / 10) == 9 || n - ((n / 10) * 10) == 9) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  int n; cin>> n;
  vector<ll> A(n);
  for(int i = 0;i<n;++i){
    cin >> A[i];
      if(A[i] == 0){
       cout << 0 << endl;
       return 0;
      }
  }
  
    ll ans = 1, max = 1e18; 
      for(ll x : A){
        if(x > max/ans){
          cout << -1 << endl;
          return 0;
        }
        ans *= x;
      }
    cout << ans << endl;
  
  
  
  
  
}


Measured memory_bytes: 4012
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    int n, w;
    cin >> n >> w;

    vector< P > item(n);
    rep(i, n)
    {
        cin >> item[i].second >> item[i].first;
    }

    vector< vs32 > dp(n + 1, vs32(w + 1, 1e9));
    rep (i, w + 1) dp[0][i] = 0;

    rep (i, n)
    {
        rep (j, w + 1)
        {
            if (j - item[i].first < 0)
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                dp[i + 1][j] = MAX(dp[i][j], dp[i][j - item[i].first] + item[i].second);
            }
        }
    }

    cout << dp[n][w] << "\n";
    return 0;
}



Measured memory_bytes: 6772
package main

import (
	"fmt"
)

func main() {
	var n int
	_, _ = fmt.Scanf("%d", &n)

	fmt.Println(answer168A(n))
}

func answer168A(n int) string {
	d := n % 10
	switch d {
	case 0, 1, 6, 8:
		return "pon"
	case 2, 4, 5, 7, 9:
		return "hon"
	case 3:
		return "bon"
	default:
		return "UNKNOWN"
	}
}


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

int main() {
    unsigned long N;
    unsigned long trans[5];
    unsigned long min_trans;
    unsigned long time;
    cin >> N;
    for (int i = 0; i < 5; ++i) {
        cin >> trans[i];
    }

    min_trans = N;
    for (unsigned long& tr : trans) {
        min_trans = min(min_trans, tr);
    }

    time = 4 + N / min_trans;
    if (N % min_trans != 0) time++;
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    ll N  = S.length();
    rep(i, N-1){
        if(S.substr(i, 2)=="AC"){
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int dp[200];//iが一番外の最大値
int h[200];
int r[200];
int m,n;
int max(int a,int b){return a>b?a:b;}
int dfs(int x){
	if(dp[x]!=-1)return dp[x];
	int i;
	int ans=1;
	for(i=0;i<m+n;i++){
		if(h[i]<h[x]&&r[i]<r[x])ans=max(ans,dfs(i)+1);
	}
	return dp[x]=ans;
}
int main(){
	while(1){
	scanf("%d",&m);
	if(m==0)return 0;
	int i;
	for(i=0;i<m;i++)scanf("%d %d",&h[i],&r[i]);
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d %d",&h[i+m],&r[i+m]);
	int ans=1;
	for(i=0;i<m+n;i++)dp[i]=-1;
	for(i=0;i<m+n;i++)ans=max(ans,dfs(i));
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 1028
/*
        --------------              |   /
              |                     |  /
              |                     | /
              |             *       |/          |    |         ------            *
              |                     |           |    |        /      \
              |             |       |\          |    |       |       |\          |
           \  |             |       | \         |    |       |       | \         |
            \ |             |       |  \        |    |        \     /   \        |
             V              |       |   \        \__/|         -----     \       |
        */
        #include <bits/stdc++.h>
        using namespace std;

        #define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
        #define endl '\n'
        #define mem(i,j) memset(i,j,sizeof (i));
        #define F first
        #define S second
        #define pb push_back
        #define mp make_pair
        #define all(a) (a).begin(), (a).end()
        #define bit(s,i) (((s)>>(i))&1LL)
        #define lowbit(x) ((x)&(-(x)))
        #define siz(v) (long long)(v).size()
        typedef int64_t ll;
        typedef uint64_t ull;
        typedef pair<int,int> pii;
        typedef pair<ll, ll> pll;
        const double EPS  = 1e-8;
        const int INF     = 0x3F3F3F3F;
        const int MOD     = 1e9+7;
        const int MAXN    = 2e5+9;
        /*-----------------------------------------------------------------------------------------------------*/

        int dig[100];
        signed main() {
        	EmiliaMyWife

        	int n, m;
        	cin >> n >> m;
        	for(int i = 1; i <= n; i++) dig[i]=-1;
        	for(int i = 0, a, b; i < m; i++) {
        		cin >> a >> b;
        		if(dig[a]!=-1 && dig[a]!=b) return cout << -1, 0;
        		dig[a]=b;
        	}
        	if(dig[1]==0 && n > 1) return cout << -1, 0;
        	for(int i = 1; i <= n; i++) {
        		cout << (dig[i]==-1?(i==1 && n>1):dig[i]);
        	}

        	return 0;
        }


Measured memory_bytes: 256