akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define fi first
#define se second

const int N = 200100;
const int Q = 1000100;

using namespace std;

int n;
string s[N];
int G;
int t[Q][26];
int f[Q];
bool good[Q][26];

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n;
        vector < int > ord;
        for(int i = 1; i <= n; i++){
                cin >> s[i];
                reverse(s[i].begin(), s[i].end());
                ord.push_back(i);
        }
        sort(ord.begin(), ord.end(), [&](int x, int y){
                return s[x].size() < s[y].size();
        });
        long long res = 0;
        for(int i: ord){
                int cur = 0;
                for(int h = 0; h < 26; h++){
                        good[s[i].size()][h] = false;
                }
                for(int j = s[i].size() - 1; j >= 0; j--){
                        for(int h = 0; h < 26; h++){
                                good[j][h] = good[j + 1][h];
                        }
                        good[j][s[i][j] - 'a'] = true;
                }
                for(int j = 0, g; j < s[i].size(); j++){
                        for(int h = 0; h < 26; h++){
                                if(good[j][h] && t[cur][h]){
                                        res += f[t[cur][h]];
                                }
                        }
                        g = s[i][j] - 'a';
                        if(!t[cur][g]){
                                t[cur][g] = ++G;
                        }
                        cur = t[cur][g];
                }
                f[cur] += 1;
        }
        cout << res << "\n";
}


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

int main(){
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  ans+=(n/k)*(n/k)*(n/k);
  if(k%2==0){
    ans+=((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# データ構造：ヒープ
import heapq
class heapque:
    def __init__(self, *args):
        self.que = []
        for arg in args:
            self.push(arg)
    def push(self, v):
        heapq.heappush(self.que, v)
    def pop(self):
        return heapq.heappop(self.que)

# 定数
INF = float("inf")
MOD = int(1e9 + 7)

# エントリーポイント
def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    a = sorted(A, reverse=True)
    b = sorted(B, reverse=True)
    c = sorted(C, reverse=True)

    asum = lambda x: a[x[0]] + b[x[1]] + c[x[2]]

    z = (0, 0, 0)
    heap = heapque((-asum(z), z))
    used = {z}
    for _ in range(K):
        cur = heap.pop()
        print(-cur[0])

        ai, bi, ci = cur[1]
        ns = ((min(ai + 1, X - 1), bi, ci)
            , (ai, min(bi + 1, Y - 1), ci)
            , (ai, bi, min(ci + 1, Z - 1)))
        for n in ns:
            if n in used: continue
            heap.push((-asum(n), n))
            used |= {n}

main()


Measured memory_bytes: 4676
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
t = inl()
a = inl()
mx = max(t)
if max(a) != mx:
    print(0)
    exit()
for p in range(n):
    if t[p]==mx:
        break
for q in range(n-1,-1,-1):
    if a[q]==mx:
        break
if q<p:
    print(0)
    exit()
prod = 1
prev = -1
for i in range(p):
    if t[i]==prev:
        prod = (prod*prev)%R
    else:
        prev = t[i]
prev = -1
for i in range(n-1,q,-1):
    if a[i]==prev:
        prod = (prod*prev)%R
    else:
        prev = a[i]
print((prod*(mx**max(0,q-p-1)))%R)


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(string, s);
  vector<string> v = {"Sunny", "Cloudy", "Rainy"};
  rep(i, v.size()) if (v[i] == s) {
    out(v[(i + 1) % 3]);
    break;
  }
}


Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//最大化問題最小化問題
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;
}

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N,A,B;
    cin >> N >> A >> B;

    vll X(N);
    REP(i,N) cin >> X[i];

    ll dp[N];
    dp[0]=0;


    //本文
    FOR(i,1,N-1){
        dp[i] = dp[i-1] + min((X[i]-X[i-1])*A,B);
    }
    //出力
    cout << dp[N-1] << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

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

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


int main() {
    ll K;
    cin >> K;
    ll res = 0;
    ll gcd = 0;
    for(int a=1;a<=K;a++){
        for(int b=1;b<=K;b++){
            gcd=GCD(a,b);
            for(int c=1;c<=K;c++){
                res+=GCD(gcd,c);
            }
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 3640
def solve():
    N, *A = map(int, open(0).read().split())

    B = [0] * N
    for i, a in enumerate(A):
        B[i] = a - (i + 1)
    B.sort()

    b = 0
    if N % 2 == 1:
        b = B[N // 2]
    else:
        b = round((B[N // 2] + B[N // 2 - 1]) // 2 + 0.1)

    ans = 0
    for i, a in enumerate(A):
        ans += abs(a - (b + i + 1))
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 25180
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    ll a, b,f=1;
    cin>>a>>b;
    for(int i=1;i<=100000;i++)
    if((i*8)/100==a&&i/10==b){cout<<i;f=0;break;}
    if(f)cout<<-1;
}


Measured memory_bytes: 3640
N = int(input())
AC=0
WA=0
TLE=0
RE=0

for i in range(N):
  S = str(input())
  if S=='AC':
    AC+=1
  elif S=='WA':
    WA+=1
  elif S=='TLE':
    TLE+=1
  elif S=='RE':
    RE+=1

print('AC x '+str(AC))
print('WA x '+str(WA))
print('TLE x '+str(TLE))
print('RE x '+str(RE))

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

int main() {
    int n, sumA = 0, sumB = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end(), greater<int>());

    for (int i = 0; i < n; i++)
    {
        //cout  <<"a "<< a[i] << endl;
        if (i % 2 == 0)
        {
            sumA += a[i];
        }
        else
        {
            sumB += a[i];
        }
        
    }
    cout << sumA - sumB << endl;
}

Measured memory_bytes: 256
from heapq import heappush,heappop
K=int(input())
table=[[] for i in range(K)]
for i in range(K):
    table[i].append([1,(i+1)%K])
    t = (10*i)%K
    if t!=i:
        table[i].append([0,t])
dij=[]
visit=[False]*K
val=[10**9]*K
val[1]=0
heappush(dij,[0,1])
while dij:
    d,x=heappop(dij)
    if val[x]<d:
        continue
    for q,y in table[x]:
        if val[y]>val[x]+q:
            val[y]=val[x]+q
            heappush(dij,[val[y],y])
print(val[0]+1)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


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

    i64 len = 0;
    i64 c = 0;
    i64 p = 1;
    vector<i64> P, C;
    P.pb(p), C.pb(c);
    while (1) {
        len++;
        p *= 26;
        c += p;
        P.pb(p), C.pb(c);
        if (c >= N) break;
    }

    string ans = "";
    RREPS(i, len) {
        if (i > 1) {
            i64 n = N - C[i - 1] - 1;
            i64 d = n / P[i - 1];
            i64 ci = (n - d * P[i - 1]) % 26;
            ans += (ci + 'a');
        } else {
            ans += (N - 1 + 'a');
        }

        N = (N - 1) / 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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



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

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

	vector<ll> sum(n+1);
	sum[0] = 0;
	rep(i, n) {
		sum[i+1] = sum[i] + a[i];
	}

	map<ll,int> cnt;
	rep(i, n + 1) {
		cnt[sum[i]]++;
	}

	ll ans = 0;
	for (auto aa : cnt) {
	  ll b = aa.second;
		ans += b*(b-1)/2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define fs first
#define sc second

ll a[100100];
ll b[100100];
ll m_num[100100];

int n, m;

ll dif(ll x, ll y){
    if(x <= y){
        return y - x;
    }
    else{
        return y + m - x;
    }

}

int main(){
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int aa; cin >> aa;
        a[i] = aa - 1;
    }

    fill(b, b+m+10, 0);
    fill(m_num, m_num+m+10, 0);

    for(int i = 1; i < n; i++){
        int up = dif(a[i-1], a[i]);  //upが0になることはない
        b[a[i]+1] += up - 1;   //m = a[i]からm=a[i]+1にしたときに増える量


        if((a[i-1] + 2) % m == (a[i] + 1) % m){
            continue;
        }
        else if((a[i-1] + 2) < a[i] + 1){
            m_num[a[i-1] + 2]++;
            m_num[(a[i] + 1)]--;
        }
        else if((a[i-1] + 2) > (a[i] + 1)){
            if(a[i-1] == m-1){
                m_num[1]++;
                m_num[(a[i] + 1)]--;
            }
            else{
                m_num[a[i-1] + 2]++;
                m_num[(a[i] + 1)]--;
                m_num[0]++;
            }

        }
    }
    //cout << endl;

    //cout << 0 << " " << m_num[0] << endl;
    for(int i = 1; i < m; i++){
        //cout << i << " " << m_num[i] << endl;
        m_num[i] += m_num[i-1]; //imos
        //cout << m_num[i] << endl;
        //cout << endl;
    }
    //cout << endl;

    ll res = 0;  //m = 0のとき
    for(int i = 1; i < n; i++){
        res += min(dif(a[i-1], a[i]), dif(0, a[i]) + 1);
    }
    ll res_tmp = res;
    for(int m_tmp = 1; m_tmp < m; m_tmp++){
        res_tmp += b[m_tmp];
        res_tmp -= m_num[m_tmp];
        if(res_tmp < 0){
            cout << m_tmp << endl;
            cout << m_num[m_tmp] << endl;
            cout << res_tmp << endl;
            return 0;
        }
        res = min(res, res_tmp);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <map>
#include <algorithm>
#include <math.h>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>
typedef long long ll;
using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll cur=1;
    ll jump=3;
    while (cur<=n) {
        if(cur+jump>n)
            break;
        cur=cur+jump;
        jump+=2;
    }
    cout<<cur;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n, cnt2=0;
  cin >> n;

  for (int i=1; i<=n; i+=2) {
    int cnt1=0;
    for (int j=1; j<=n; j+=2) {
      if (i%j==0) cnt1++;
    }
    if (cnt1==8) cnt2++;
  }

  printf("%d\n", cnt2);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
    void bubbleSort(char a[][3],int n);
    void selectSort(char a[][3],int n);
 
    void sw(char a[],char b[]);
 
    char A[200][3];
    char B[200][3];
 
int main()
{
 
    int n ;
    scanf("%d",&n);
    for(int i= 0;i<n;i++){
        scanf("%s",A[i]);
        strcpy(B[i],A[i]);
    }
 
 
    for(int i= 0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(A[j][1] < A[j-1][1]){
                sw(A[j],A[j-1]);
            }
        }
    }
 
    for(int i = 0;i<n-1;i++){
        int ss = i;
        for(int j=i+1;j<n;j++){
            if(B[j][1]<B[ss][1]){
                ss = j;
            }
        }
        if(ss != i){
            sw(B[ss],B[i]);
        }
    }
 
 
 
 
        for(int i= 0;i<n;i++){
            printf("%s%s",A[i],(i == n-1)? "\n": " ");
            //if(i == n-1) printf("\n");
        }
        printf("Stable\n");
 
        for(int i= 0;i<n;i++){
            printf("%s%s",B[i],(i == n-1)? "\n": " ");
            //if(i == n-1) printf("\n");
        }
 
        int stable = 1;
        for(int i= 0;i<n;i++){
            if(strcmp(A[i],B[i])){
                stable = 0;
            }
        }
        printf("%s\n",stable?"Stable":"Not stable");
 
    return 0;
}
 
    void sw(char a[],char b[]){
        char tmp[3] = "";
        strcpy(tmp,a);
        strcpy(a,b);
        strcpy(b,tmp);
    }
 
 
    void selectSort(char a[][3],int n){
 
    }



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

int main(){
    
    std::string s;
    std::cin >> s;

    for(size_t i = s.size() - 1; i >= 2; i--){
        if(i % 2 == 1) continue;

        if(s.substr(0, i / 2) == s.substr(i / 2, i / 2)){
            std::cout << i << std::endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// Union-Find; 素集合データ構造
class UnionFind {
public:
    vector<long long> parent;
    long long n;
    UnionFind(long long x) :parent(x, -1), n(x){}
    bool unite(long long x, long long y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        parent[x] += parent[y]; parent[y] = x;
        return true; }
    bool same(long long x, long long y){ return find(x) == find(y); }
    long long find(long long x){ return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    long long size(long long x){ return -parent[find(x)]; }
};

int main(){
    Init();
    ll n, m, ans = 0; cin >> n >> m;
    vi p(n);
    UnionFind uf(n);
    rep(i, n){ cin >> p[i]; p[i]--; }

    rep(i, m){
        ll x, y; cin >> x >> y; x--; y--;
        uf.unite(x, y);
    }
    
    rep(i, n) if(uf.same(i, p[i])) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 4648
#include<iostream>
#include<set>
#include<vector>
#include <algorithm>
using namespace std;

int main(){
	int N;
	long long C,K,T;
	cin>>N>>C>>K;
	vector<long long> st;
	for(int i=0;i<N;++i){
		cin>>T;
		st.push_back(T);
	}
	sort(st.begin(),st.end());
	long long ans=1,mi=st[0],count=1;

	for(int i=1;i<N;++i){
//		cout<<st[i]<<endl;
		++count;
		if(st[i]>mi+K||count>C){
//			cout<<"a"<<endl;
			ans++;
			mi=st[i];
			count=1;
		}
	}
	//if(st[N-1]<=mi+K)++ans;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1400
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  3e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n, a[N];

void solve(){
	cin>>n;
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		cin>>a[i];
		if(i%2 == 1 and a[i]%2 == 1) ans++;
	}
	deb1(ans)
}

int main(){
	fastio;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
}

Measured memory_bytes: 3608
# coding: utf-8
# Your code here!
num = input().split()
num1 = int(num[0])
retu = int(num[1])
kazu = 0
hint=[]
for i in range(num1):
    hint.append(i)
while len(hint) >= retu:
    kazu+=1
    hint.pop(0)
print(kazu)


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

using ll = long long int;
using node = pair<int, int>;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, m;
map<node, vector<node>> graph;
int s, t;

map<node, int> path_map;

int ans;

int calc() {
  queue<node> que;
  set<node> visited;

  que.push(node(s, 0));
  path_map[node(s, 0)] = 0;
  visited.insert(node(s, 0));

  while (!que.empty()) {
    node cur_node = que.front(); que.pop();

    int cur_path = path_map[cur_node];

    for (node &next_node: graph[cur_node]) {
      if (visited.find(next_node) != visited.end()) continue;

      que.push(next_node);
      path_map[next_node] = cur_path + 1;
      visited.insert(next_node);
    }
  }

  return (path_map.find(node(t, 0)) == path_map.end()) ? -1 : path_map[node(t, 0)] / 3;
}

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[node(u, 0)].push_back(node(v, 1));
    graph[node(u, 1)].push_back(node(v, 2));
    graph[node(u, 2)].push_back(node(v, 0));
  }

  scanf("%d %d", &s, &t);

  ans = calc();

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

  return 0;
}


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

int main(){
    int a,b,c;
    cin >> a>>b>>c;
    int d;
    d=a-b;
    if(c-d<0){
        cout << 0 <<endl;
    }
    else{
        cout << c-d << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cnt[300002], cnt2[300002], sum[300002];
int main(){
    int n, a;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", &a);
        cnt[a]++;
    }
    for(int i=1;i<=n;i++) cnt2[cnt[i]]++;
    for(int i=1;i<=n;i++) sum[i] = sum[i-1] + cnt2[i]*i;
    for(int i=n-1;i>=1;i--) cnt2[i] += cnt2[i+1];
    for(int k=1;k<=n;k++){
        int ans = 0;
        for(int i=1;i<=n/k;i++){
            int rem = sum[i] + cnt2[i+1]*i;
            if(k*i <= rem) ans = i;
        }
        printf("%d\n", ans);
    }
}

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

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') {
        cout << a + b << endl;
    } else {
        cout << a - b << endl;
    }
    return 0;
}

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

int main(void){
    int n, k;
    cin >> n >> k;
    
    int a[200000] = {0};
    int input;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        a[input]++;
    }
    
    sort(a, a + 200000, greater<int>());
    
    int cnt = 0;
    i = k;
    while(a[i] != 0){
        cnt += a[i];
        i++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n;
  string s;
  cin >> n >> s;

  REP(i, s.size()) {
    s[i] += n;
    if (s[i] > 'Z') s[i] -= ('Z' - 'A' + 1);
  }
  cout << s << endl;
}

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

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int x = 0;
  int y = L;
  
  for (int i = 0; i < R-L+1; i++) {
    if(y % d == 0) {
      x++;
    }
    y++;
  }
  cout << x << endl;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int sum = 0;
	if (abs(A-B) != 0) {
		if (A > B) {
			sum += A * 2 - 1;
		} else {
			sum += B * 2 - 1;
		}
	} else {
		sum += A + B;
	}
	cout << sum << endl;
}


Measured memory_bytes: 384
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<assert.h>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define de_x(x) cout<< #x <<"->debug_val: "<<x<<endl;
#define de_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#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 fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(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;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int _,n,m;
/***********************/
void run(){
}
int main(){
//    for(scanf("%d",&_);_;_--) run();
    string s;
    getline(cin,s);
    int a =0,b=0;
    rep(i,0,s.size()){
        if(s[i] =='A') a++;
        else b++;
    }
    if(a >0 && b> 0) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
//بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ
//لا إله إلا الله محمد رسول الله

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define ll long long
#define pb push_back
#define fr first
#define sc second
#define in freopen("input.txt", "r" , stdin)
#define out freopen("snakes.out", "w", stdout)
using namespace std;

vector <ll> g[100005];
vector<ll> ans;
ll n , m;
ll d[100005];
bool used[100005];
bool used1[100005];
ll an = 0;
void dfs1 (ll v) {
    used1[v] = 1;
    for (int i = 0; i < g[v].size();i++) {
        ll to = g[v][i];
        d[to] = max (d[to], d[v] + 1);
        if (!used1[to])
            dfs1 (to);
    }
}
void dfs (ll v) {
    used[v] = 1;
    for (int i = 0; i < g[v].size(); i++) {
        ll to = g[v][i];
        if (!used[to]) {
            dfs (to);
        }
    }
    ans.pb (v);
}

int main(){
    //in;
    //out;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        ll a , b;
        cin >> a >> b;
        g[a].pb (b);
    }


    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            dfs (i);
        }
    }

    reverse(ans.begin(), ans.end());

    for (int i = 0; i < ans.size(); i++) {
            dfs1 (ans[i]);
    }

    for (int i = 1; i <= n; i++) an = max (an, d[i]);

    cout << an;
}



Measured memory_bytes: 10356
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = a
b = a*2
a1 = 0
a2 = 0
m = 10**9+7
for i in range(n):
    a1 += len([j for j in a[i:] if j < a[i]])
for i in range(2*n):
    a2 += len([j for j in b[i:] if j < b[i]])

ans =((a1*k*(k+1)//2) + ((a2 - 3*a1) * (k-1)*k//2 % m) % m) % m

print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>
#include <cstdint>

using namespace std;

long long beki(int x, int y) {
	if (y == 0) {
		return 1;
	}
	else {
		long long n = 1;
		for (int i = 0; i < y; i++) {
			n *= x;
		}
		return n;
	}
}
int main() {
	long long n;
	cin >> n;
	long long m = n;
	int dig;
	int count = 0;
	vector<int>keta;
	while (n > 0) {
		dig = n % 10;
		keta.push_back(dig);
		n /= 10;
		count++;
		//cout << dig << endl;
	}
	//cout << count << endl;
	long long ans = m;
	for (long long bits = 1; bits < (1 << (count - 1)); bits++) {
		long long tmp = 0;
		for (int i = 0; i < keta.size(); i++) {
			//cout << beki(10,i-tmp) << endl;
			ans += (long long)(keta[i] * beki(10, i - tmp));
			if (bits & (1 << i)) {
				tmp = i + 1;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class ABC_131_B
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int L = int.Parse(input[1]);

        int min = L;
        int max = L + N - 1;

        int sum = 0;
        int eat = 0;

        if (min <= 0 && max >= 0) eat = 0;
        else if (min > 0) eat = min;
        else eat = max;

        for (int i = 0; i < N; i++)
        {
            int v = L + i;
            sum += v;
        }

        Console.WriteLine(sum-eat);
    }
}

Measured memory_bytes: 11092
from collections import deque
import sys

def input():
    return sys.stdin.readline().rstrip()

N = int(input())
li = list(map(int, input().split()))
li.sort()

ans = 1
for i in li:
    ans *= i
    if (ans > int(1e18)):
        print(-1)
        sys.exit(0)

if ans > int(1e18):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 22476
#include <stdio.h>
#include <cctype>

using namespace std;

int ar[100];
int sp = -1;

inline void push(int x){
    sp++;
    ar[sp] = x;
}

inline int pop(){
    sp--;
    return ar[sp+1];
}

int main(int argc, char const* argv[])
{
    int lh,rh,r;
    char op;

    while (EOF != (r = getchar())) {
        if(isspace(r)){
            continue;
        }

        if(isdigit(r)){
            ungetc(r, stdin);
            scanf("%d ", &r);
        }else{
            rh = pop();
            lh = pop();
            switch (r) {
                case '+':
                    r = lh + rh;
                    break;
                case '-':
                    r = lh - rh;
                    break;
                case '*':
                    r = lh * rh;
                    break;
            }
        }
        push(r);
    }

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

    return 0;
}

Measured memory_bytes: 2748
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;

const ll DENOMI = 1000000007LL;

int main()
{
	int n;
	cin >> n;
	auto a = vector<ll>(n + 1);
	auto s = vector<ll>(n + 1);
	for(int i = 1; i < n + 1; ++i){
		cin >> a[i];
		s[i] = (a[i] + s[i - 1]) % DENOMI;
	}
	ll ans = 0LL;
	for(int i = 1; i < n + 1; ++i){
		ans = (ans + a[i] * s[i - 1] % DENOMI) % DENOMI;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6292
package main

import "fmt"

func gcd(a, b int) int {
	if a == 0 {
		return b
	}
	return gcd(b%a, a)
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	var g = gcd(a, b)
	var ret = (a / g) * (b / g) * g
	fmt.Println(ret)
}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MAXN = 55;
int n;
int x[MAXN], y[MAXN];

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

    map<pii, int> freq;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        for (int j = 0; j < i; ++j) {
            int dx = x[i] - x[j];
            int dy = y[i] - y[j];
            ++freq[{dx, dy}];
            ++freq[{-dx, -dy}];
        }
    }

    int ans = n;
    for (auto it : freq) {
        ans = min(ans, n - it.second);
    }

    cout << ans << '\n';

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll ans = 1LL;
	sort(all(a));
	rep(i, n) {
		if(a[i]==0) {
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, n) {
		
		// cout << ans << endl;
		if (ans > 1000000000000000000LL/a[i]) {
			cout << -1 << endl;
			return 0;
		}
		ans *= a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4036
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }


int main() {
    string s; cin >> s;
    for (auto c : s) if (c == '1') cout << 9; else cout << 1;
    cout << endl;
    return 0;
}


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

typedef pair<int, int> P;

int N;
vector<P> A;

int main() {
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        A.push_back(P(a, i));
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; ++i) {
        cout << A[i].second << ' ';
    }
    cout << endl;
    return 0;
}
#endif


Measured memory_bytes: 1780
from collections import defaultdict
from collections import Counter

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

d = defaultdict(int)
c = Counter(arr)

for k, v in c.items():
    d[k] += v

for _ in range(m):
    b, c = map(int, input().split())
    d[c] += b

d = list(d.items())
d.sort(key=lambda x: x[0], reverse=True)

ans = 0
for k, v in d:
    ans += k * min(n, v)
    if n > v:
        n -= v
    else:
        break

print(ans)

Measured memory_bytes: 40188
#include<iostream>
using namespace std;
int t[10][10],u[10][10],ans[10][10],n,flg;
int compute();
void dfs(int);
void change(int,int);
int main(){
  cin>>n;
  while(n--){
    flg=0;
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
	cin>>t[i][j];
	ans[i][j]=0;
      }
    }
    dfs(0);
  }
  return 0;
}
void dfs(int x){
  if(x==10){
    /*
    for(int i=0;i<10;i++)cout<<ans[0][i];
    cout<<endl;
    */
    
    if(compute()){
      for(int i=0;i<10;i++){
	for(int j=0;j<10;j++){
	  if(j)cout<<' ';
	  cout<<ans[i][j];
	}
	cout<<endl;
      }
    }
    
    return;
  }
  ans[0][x]=0;
  dfs(x+1);
  ans[0][x]=1;
  dfs(x+1);
}

int compute(){
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      u[i][j]=t[i][j];
      if(i)ans[i][j]=0;
    }
  }

  for(int i=0;i<10;i++){
    if(ans[0][i])change(0,i);
  }

  for(int i=1;i<10;i++){
    for(int j=0;j<10;j++){
      if(u[i-1][j]){
	ans[i][j]=1;
	change(i,j);
      }
    }
  }
  for(int i=0;i<10;i++){
    if(u[9][i])return 0;
  }
  return 1;
}

void change(int y,int x){
  u[y][x]=!u[y][x];
  if(y>0)u[y-1][x]=!u[y-1][x];
  if(x>0)u[y][x-1]=!u[y][x-1];
  if(y<9)u[y+1][x]=!u[y+1][x];
  if(x<9)u[y][x+1]=!u[y][x+1];
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> p[i];
  }
  int min = 0x7fffffff, count = 0;
  for (int v : p) {
    if (min < v) {
      continue;
    }
    std::swap(min, v);
    ++count;
  }
  std::cout << count << std::endl;
  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b;
  rep(i, 7) {
    cin >> a >> b;
    cout << abs(a - b) << endl;
  }
	return 0;
}


Measured memory_bytes: 3164
import sys
x, y = map(int, input().split())

if (y / x == 2 or y / x== 4):
    print('Yes')
    sys.exit()

b = (y - 2 * x) * 1.0 / 2
a = x - b
if b.is_integer() and 0 < b and 0 < a:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define test() int t; cin>>t; while(t--)
#define ll long long int
int mod = 1e9 + 7;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	int x = ceil(n / 1.08);
	if (floor(x * 1.08) == n)	cout << x << endl;
	else	cout << ":(";
	return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 998244353
#define Mod1(x) (x>=mod?x-mod:x)
#define Mod2(x) (x<0?x+mod:x)
#define maxn 3000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
ll fac[maxn],inv[maxn];
int n,m;
inline ll power(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ans=ans*a%mod;
	return ans;
}
inline ll C(int n,int m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}
inline ll calc(int n,int m,int k)
{
	ll sum=0;
	for(int i=0;i<=n&&i<=k;i++)
		if(!((m-i)&1)&&m>=i)sum=(sum+C(n,i)*C((m-i)/2+n-1,n-1))%mod;
	// writeln(sum);
	return sum;
}
int main()
{
	n=read(); m=read();
	fac[0]=inv[0]=1;
	for(int i=1;i<=n+3*m;i++){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=power(fac[i],mod-2);
	}
	ll ans=(calc(n,3*m,m)-n*(calc(n,m,m)-calc(n-1,m,m)+mod))%mod;
	writeln(Mod2(ans));
	return 0;
}

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

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

    bool ans = 0;
    for (size_t i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
        {
            ans = 1;
        }
    }

    if (ans)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

}


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



 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.in","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,s(1),temp,lim(1e18);
    cin>>n;
    vector<ll> v(n);
    for(auto &it:v)cin>>it;
    sort(v.begin(), v.end());
	if(!v[0])cout<<0;
	else {
		for(auto it:v){
			double p1,p2;
			p1=log10(it);
			p2=log10(s);
			if(p1+p2>18){
				cout<<-1;
				return 0;
			}
			else s*=it;
		}
		if(s<=lim)cout<<s;
		else cout<<-1;
	}


   	
   		
 
 
 
 
 
 
 
	return 0;
}

Measured memory_bytes: 3964
#include<iostream>
using namespace std;
int main()
{
    char ch;
    scanf("%c",&ch);
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u'){
        printf("vowel\n");
    }
    else
    {
        printf("consonant\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)













template <typename T>
void sort(T &x){
    sort(x.begin(), x.end());
}


int main(){
    ll n;
    cin >> n;
    map<string, ll> mp;
    ll ans = 0;
    REP(i, n){
        string s;
        cin >> s;
        sort(s);
        ans += mp[s]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n) {
		string f[100];
		int cnt = 0;
		int left = 0, right = 0;
		for (int i = 0; i < n; i++) cin >> f[i];
		int pastl, pastr;
		for (int i = 0; i < n; i++) {
			//cout << '('<<i<<')' << endl;
			if (i % 2 == 0) { pastl = left; pastr = right; }
			if (f[i] == "lu") {
				left++; 
				//cout <<"left is "<< left << endl;
			}
			if (f[i] == "ld") {
				left--; 
				//cout <<"left is "<< left << endl;
			}
			if (f[i] == "ru") {
				right++;
				//cout <<"right is "<< right << endl;
			}
			if (f[i] == "rd") {
				right--;
				//cout <<"right is "<< right << endl;
			}
			//cout << "check" << endl << "right:" << right << " " << "left:" << left << endl << "pastr:" << pastr << " " << "pastl:" << pastl << endl;
			if (right == left&&right != pastr&&left != pastl&&i % 2 == 1)cnt++;
			//cout << "cnt:" << cnt << endl;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

int main()
{
    int a, b, t, sum=0;
    cin >> a>>b>>t;

    for (int i = 1; i < t+1;i++){
        if(i%a==0){
            sum += b;
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n');

  const n = Number(s[0]);
  const a = s[1].split('');

  let count = 0;
  let cum = [0];

  for (let i = 0; i < n; i++) {
    if (a[i] === 'I') count += 1;
    if (a[i] === 'D') count -= 1;
    
    cum.push(count);
  }

  const ans = Math.max(...cum);

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
typedef long long ll;    
typedef long double ld;  
#define pb push_back     
using namespace std;


int ds(int x){
    if(x){
        return x % 10 + ds(x / 10);
    }
    return 0;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	
    int n, a, b; cin >> n >> a >> b;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        int d = ds(i);
        if(a<=d && d <= b) ans += i;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    AB = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]
    AB.sort()
    pro = 0
    cost = 0
    for a, b in AB:
        if pro + b >= M:
            cost += (M - pro) * a
            break
        pro += b
        cost += a * b
    
    print(cost)


if __name__ == '__main__':
    main()

Measured memory_bytes: 16988
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    vector<long double> x(N), y(N);
    rep(i,N) cin>>x[i]>>y[i];
    long double sum = 0;
    rep(i,N){
        rep(j,i){
            long double dx = abs(x[i] - x[j]), dy = abs(y[i] - y[j]);
            sum += sqrt(dx*dx + dy*dy);
        }
    }
    //cout<<sum<<endl;
    sum *= N - 1;
    ll num = N * (N - 1) / 2;
    //reps(i,1,N + 1) num *= i;
    sum /= num;
    cout<<fixed<<setprecision(10)<<sum<<endl;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", (a + b + 1) / 2);
	
	Please AC;
}


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

int main(){
    int h,w;cin>>h>>w;
    vector<string> a(h);
    for(int i=0;i<h;i++) cin>>a[i];

    vector<bool> row(h,false);
    vector<bool> col(w,false);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)if(a[i][j]=='#'){
            row[i]=true;
            col[j]=true;
        }
    }

    for(int i=0;i<h;i++)if(row[i]){
        for(int j=0;j<w;j++)if(col[j]){
            cout<<a[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256