akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int happ[n][3],dp[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
			cin>>happ[i][j];
	}
	dp[0][0]=happ[0][0];
	dp[0][1]=happ[0][1];
	dp[0][2]=happ[0][2];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(j==0) dp[i][j]=happ[i][j]+max(dp[i-1][j+1],dp[i-1][j+2]);
			else if(j==1) dp[i][j]=happ[i][j]+max(dp[i-1][j+1],dp[i-1][j-1]);
			else dp[i][j]=happ[i][j]+max(dp[i-1][j-1],dp[i-1][j-2]);
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

func readLine(r *bufio.Reader) []byte {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := r.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return buf
}

func main() {
	r := bufio.NewReaderSize(os.Stdin, 200100)

	s := readLine(r)

	S := 0
	T := 0
	for i := len(s) - 1; i >= 0; i-- {
		if s[i] == 'S' {
			if T == 0 {
				S++
			} else {
				T--
			}
		} else {
			T++
		}
	}
	out(T + S)
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String args[]) {
		TreeSet<Integer> result = new TreeSet<>();
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		result.add(a+b);
		result.add(a-b);
		result.add(a*b);
		
		System.out.println(result.last());
	}
}

Measured memory_bytes: 23252
import itertools
import copy

h,w,k = list(map(int, input().split()))
lst = [None for i in range(h)]
for i in range(h):
    lst[i] = list(input())
ans = 0

H = list(itertools.product([0,1],repeat=h))
W = list(itertools.product([0,1],repeat=w))

for i in H:
    for j in W:
        lst_test = copy.deepcopy(lst)
        for I in range(h):
            if i[I]==1:
                for a in range(w):
                    lst_test[I][a] = "R"
        for J in range(w):
            if j[J]==1:
                for a in lst_test:
                    a[J] = "R"
        # print(i,j)
        # print(lst_test)
        count = 0
        for a in lst_test:
            for b in a:
                if b=="#":
                    count += 1
        if count == k:
            ans += 1

print(ans)


Measured memory_bytes: 9248
#include <iostream>
#define MAXN 501
using namespace std;
typedef struct{
	int x;
	int y;
}Friends;
int n,m,ans;
Friends fri[10001];
int student[MAXN];

void check(int number, int count){
	if(count>=3)return;
	for(int i=0;i<m;i++){
		if(fri[i].x==number){
			student[fri[i].y]=1;
			check(fri[i].y,count+1);
		}else if(fri[i].y==number){
			student[fri[i].x]=1;
			check(fri[i].x,count+1);
		}
	}
	return;
}


int main(){
	while(1){
		cin >> n>>m;
		if(n==0&&m==0)break;
		for(int i=1;i<=n;i++){
			student[i]=0;
		}
		for(int i=0;i<m;i++){
			cin>>fri[i].x>>fri[i].y;
		}
		student[1]=1;
		check(1,1);

		ans=0;
		for(int i=2;i<=n;i++){
			if(student[i]==1){
				ans++;
				//cout <<i<<" ";
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    int n;
    cin >> n;
    cout << (n/2)*((n+1)/2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	string S;
	int a[4] = {};
	cin >> S;
	rep(i,S.size()) {
		if(S[i] == 'N')
			a[0] = 1;
		else if(S[i] == 'S')
			a[1] = 1;
		else if(S[i] == 'W')
			a[2] = 1;
		else
			a[3] = 1;
	}
	if((a[0] ^ a[1]) | (a[2] ^ a[3]))
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;
int main()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> W;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		W.push_back(temp);
	}

	ll kotae = 2*(abs(W[0])+abs(W[n-1]));
	ll temp = 0;
	for (int i = 0; i < n - k + 1; i++) {
		if (W[i] * W[i + k - 1] > 0) {
			temp=(abs(W[i])>abs(W[i + k - 1]))? abs(W[i]): abs(W[i + k - 1]);
		}
		else {
			int min = (abs(W[i]) < abs(W[i + k - 1])) ? abs(W[i]) : abs(W[i + k - 1]);
			temp = abs(W[i]) + abs(W[i + k - 1]) + min;
		}
		kotae = (kotae < temp) ? kotae : temp;
	}

	cout << kotae << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main() {
  // input
  int a, b, c;
  cin >> a >> b >> c;

  int res = a*c;
  int ans;
  if (res<=b){ //お金を十分持っている場合
    ans = c;
  }else{
    ans = b/a;
  }

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


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


M = 10**9+7
n = int(input())
p = list(map(int, input().split()))
g1 = [None]*(n+10)
v = 1
g1[0] = 1
for i in range(1,len(g1)):
    v *= i
    v %= M
    g1[i] = v
    
def init(bit, values):
    for i,v in enumerate(values):
        add(bit,i+1,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i&(-i)
    return res

#ai += x(logN)
def add(bit,i,x):
    if i==0:
        raise RuntimeError
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return


index = [i for i,num in enumerate(p) if num==0]
used = [False]*n
for i in range(n):
    if p[i]>0:
        used[p[i]-1] = True
nl = []
for i in range(n):
    if not used[i]:
        nl.append(i+1)
nl.sort()
scores = [0]*(n+1) # scores[i]: nlのうちiより大きいものの個数
v = len(nl)
cur = 0
for i in range(1,n+1):
    if nl and cur<len(nl) and nl[cur]<i:
#     if nl and nl[cur]<i:
        cur += 1
        v -= 1
    scores[i] = v
ans = 0
bit = [0]*(n+1)
s = set(index)
val = 0
pp = len(index) # 欠損の個数
ss = sum(nl)
num = 0
inv2 = pow(2, M-2, M)
for i in range(n):
    if i in s:
        ans += (g1[pp-1] * (ss - pp - val - pp*(num)*inv2)) * g1[n-i-1]
        num += 1
    else:
        ans += (g1[pp] * (p[i]-query(bit, p[i])-1) - g1[pp-1]*num*(len(nl)-scores[p[i]])) * g1[n-i-1]
        add(bit, p[i], 1)
        val += scores[p[i]]
    ans %= M
#     print(ans, val)
print((ans + g1[pp])%M)

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

using namespace std;

const int N = 1e5 + 5;

struct Point {
    int x, y, num, type, type_bracket;

    Point (int x = 0, int y = 0, int num = 0, int type = 0, int type_bracket = 0) {
        this->x = x;
        this->y = y;
        this->num = num;
        this->type = type;
        this->type_bracket = type_bracket;
    }
} a[2 * N];

int r, c, n;
bool used[N];

bool check (int x, int y) {
    return x == 0 || x == r || y == 0 || y == c;
}

int enc (int x, int y) {
    if (x == 0) return y;
    if (y == c) return c + x;
    if (x == r) return c + r + (c - y);
    if (y == 0) return c + r + c + (r - x);
    return (int)1e9;
}

bool cmp (Point a, Point b) {
    return a.num < b.num;
}

int main(){
    scanf("%d %d %d", &r, &c, &n);
    for (int i = 1; i <= n; i++) {
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

        int num = enc(x1, y1);
        int num2 = enc(x2, y2);
        a[i * 2 - 1] = Point(x1, y1, num, i, 1);
        a[i * 2] = Point(x2, y2, num2, i, 2);
    }

    memset(used, 0, sizeof(used));
    for (int i = 1; i <= n; i++) if (check(a[i * 2 - 1].x, a[i * 2 - 1].y) && check(a[i * 2].x, a[i * 2].y)) used[i] = true;

    vector <Point> v;
    for (int i = 1; i <= 2 * n; i++) if (used[(i + 1) / 2]) v.push_back(a[i]);

    sort(v.begin(), v.end(), cmp);
    stack <int> st;
    memset(used, 0, sizeof(used));

    for (auto i: v) {
        if (!used[i.type]) {
            st.push(i.type);
            used[i.type] = true;
        }
        else {
            if (st.empty() || st.top() != i.type) return !printf("NO");
            st.pop();
            used[i.type] = false;
        }
    }

    printf("YES");
    return 0;
}


Measured memory_bytes: 11248
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 998244353
//#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=3050;
//↑templete
long long GCD(long long a,long long b){
	if(b==0)
		return a;
	else
		return GCD(b,a%b);
}
signed main(){
    int K;
    cin>>K;
    ll ans=0;
    for(int a=1;a<=K;a++){
        for(int b=1;b<=K;b++){
            for(int c=1;c<=K;c++){
                ans+=GCD(a, GCD(b, c));
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

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

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

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


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long
int dp[5005][5005];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; string s; cin >> n >> s;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = n - 1; j >= 0; j--) {
			if (s[i] != s[j])dp[i][j] = 0;
			else dp[i][j] = dp[i + 1][j + 1] + 1;
		}
	}
	int ans = 0;
	rep(i, n)rep(j, n) {
		if (i >= j)continue;
		int now = min(dp[i][j], j - i);
		chmax(ans, now);
	}
	COUT(ans);
	return 0;
}

Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int t[60];
signed main()
{
    int n;
    string x;
    cin >> n;
    vector<string> s(n);
    int c = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i] >> t[i];
        c += t[i];
    }
    cin >> x;
    int cnt=0;
    for (int i = 0; i < n; i++)
    {
        
        if (s[i] == x)
        {
            cnt += t[i];
            break;
        }
        else
            cnt += t[i];
    }
    cout << c-cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
constexpr auto maxn=500005;
long long f[maxn];
int g[maxn];
int main() {
	string s;
	cin >> s;
	long long sum=0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '<')
			f[i + 1] = max(f[i + 1], f[i] + 1);
	}
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == '>')
			f[i] = max(f[i], f[i+1] + 1);
	}
	for (int i = 0; i <= s.size(); i++) {
		sum += f[i];
	}
	return cout << sum << endl, 0;
}

Measured memory_bytes: 4740
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

const int MX=100005;

int main()
{
    int r,g,b,k;
    cin>> r >> g >> b >> k;
    while(k && g<=r) k--,g<<=1;
    while(k && b<=g) k--,b<<=1;
    if(r<g && g<b) cout<< "Yes" <<endl;
    else cout<< "No" <<endl;
    return 0;
}

Measured memory_bytes: 3632
import java.math.BigDecimal;
import java.util.Scanner;

//Solution:

public class Main {  
  public static void main(String[] args) {
        Scanner f = new Scanner(System.in);
        // fill in the dictionary with the initial value
         while(true) {
            int num = f.nextInt();
            if(num == 0) break;
            BigDecimal[] entries = new BigDecimal[num];
            BigDecimal sum = new BigDecimal(0);
            BigDecimal std = new BigDecimal(0);
            for (int i = 0; i < num; i++) {
                BigDecimal temp = new BigDecimal(f.nextInt());
                entries[i] = temp;
                sum = sum.add(temp);
            }
            BigDecimal average = sum.divide(new BigDecimal(num),6, BigDecimal.ROUND_HALF_UP);
            for (int i = 0; i < num; i++) {
                std = std.add(entries[i].subtract(average).pow(2));
            }
            System.out.println(Math.sqrt(std.divide(new BigDecimal(num),6, BigDecimal.ROUND_HALF_UP).doubleValue()));
        }
    }
}


Measured memory_bytes: 32824
#include<cstdio>
#include<map>
using namespace std;

const int N_MAX = 3e5;
int n;
int cnt[N_MAX + 1], sum[N_MAX + 1], mul[N_MAX + 1], ans[N_MAX + 1];
map<int, int> m;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        m[a]++;
    }

    for (auto &i : m) cnt[i.second]++;
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + cnt[i];
        mul[i] = mul[i - 1] + cnt[i] * i;
    }
    for (int i = n; i >= 1; i--) {
        int a = sum[n] - sum[i - 1] + mul[i - 1] / i;
        for (int j = a; j >= 1 && ans[j] == 0; j--) ans[j] = i;
    }

    for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 18432
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint ans = 0;
	vector<lint>V(100009);
	rep(i, N) {
		V[A[i]]++;
	}
	rep(i, N) {
		ans += A[i];
	}
	lint Q;
	cin >> Q;
	rep(i, Q) {
		lint B, C;
		cin >> B >> C;
		ans += V[B] * (C - B);
		V[C] += V[B];
		V[B] = 0;
		cout << ans << endl;
	}
}

Measured memory_bytes: 4768
N,K,Q = gets.split(' ').map(&:to_i)
points = Array.new(N+1, 0)
Q.times do
  a = gets.to_i
  points[a] += 1
end
(1..N).each do |i|
  puts K - Q + points[i] > 0 ? 'Yes' : 'No'
end


Measured memory_bytes: 3196
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

long long n, k, mons[200005], ans;

int main()
{	
	cin>>n>>k;
	if(k >= n) 
	{
		cout<<0;
		return 0;
	}
	for(int i = 0; i < n; i ++)
		cin>>mons[i];
	sort(mons, mons + n);
	for(int i = 0; i < n - k; i ++) ans += mons[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	final long MOD = (long) (1e9 + 7);
	long[] fac = new long[200000];
	long[] ifac = new long[200000];
	long[] inv = new long[200000];
	{
		fac[0] = ifac[0] = inv[0] = fac[1] = ifac[1] = inv[1] = 1;
		for (int i = 2; i < fac.length; ++i) {
			fac[i] = fac[i - 1] * i % MOD;
		}
		for (int i = 2; i < inv.length; ++i) {
			inv[i] = MOD - (MOD / i) * inv[(int) (MOD % i)] % MOD;
		}
		for (int i = 2; i < ifac.length; ++i) {
			ifac[i] = ifac[i - 1] * inv[i] % MOD;
		}
	}

	long comb(int n, int k) {
		return fac[n] * ifac[k] % MOD * ifac[n - k] % MOD;
	}

	public void run() throws Exception {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		long ans = 1;
		for (int i = 2; i * i <= M; ++i) {
			if (M % i == 0) {
				int cnt = 0;
				while (M % i == 0) {
					++cnt;
					M /= i;
				}
				ans = ans * comb(cnt + N - 1, cnt) % MOD;
			}
		}
		if (M > 1)
			ans = ans * N % MOD;
		System.out.println(ans);
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 27604
import java.util.Scanner;
     
    public class Main {
     
        public static void main(String[] args) {
            @SuppressWarnings("resource")
            Scanner sc = new Scanner(System.in);
            char c = sc.next().toCharArray()[0];
            System.out.println(c >= 'a' ? 'a' : 'A');
        }
     
    }

Measured memory_bytes: 35584
#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  string S;
  cin >> S;
  int ans=0;
  for(int i=0;i<S.size()/2;i++){
    if(S[i] != S[S.size()-i-1]){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

def make_divisors(n):
    divisors = set([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)

    return divisors

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

common_divisors = make_divisors(A) & make_divisors(B)
counter = 0
for cd in common_divisors:
    if is_prime(cd):
        counter += 1
print(counter + 1)

Measured memory_bytes: 5120
N = int(input())

def isPrime(x):
    if x==2: return True
    if x%2==0: return False
    i=3
    while i>0 and i*i<=x:
        if x%i==0: i=-100
        i+=2
    return i>0

P = [p for p in range(2,100) if isPrime(p)]
nP = len(P)

f = [0]*nP

for n in range(1,N+1):
    for ip, p in enumerate(P):
        k = n
        while k%p==0:
            f[ip] += 1
            k//=p

r=0
x = [0]*nP
for i in range(nP):
    x[i]=(x[i]+1)*3-1
    for j in range(nP):
        x[j]=(x[j]+1)*5-1
        for k in range(j,nP):
            x[k]=(x[k]+1)*5-1
            ok=True
            for l in range(nP):
                if x[l] > f[l]:
                    ok = False
                    break
            if ok: r+=1
            x[k]=(x[k]+1)//5-1
        x[j]=(x[j]+1)//5-1
    x[i]=0

print(r)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int k;
  cin >> k;
  int t = 7%k;
  rep(i,k){
    if(t==0){
      cout << i+1 << endl;
      return 0;
    }
    t*=10;
    t+=7;
    t%=k;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,T;
  cin >> N >> T;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int m = A[0];
  vector<int> vec;
  int max_now=A[0];
  for(int i=1; i<N; i++){
    if(m <= A[i]){
      max_now = A[i];
      vec.push_back(max_now - m);
    }else{
      m = A[i];
    }
  }
  sort(vec.begin(),vec.end(),greater<int>());
  int cnt = 0;
  for(int i=0; i<vec.size(); i++){
    if(vec[0] == vec[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    int i;
    for(i=0;i<s2.size();i++){
        cout << s1[i] << s2[i];
    }
    if(s1.size()!=s2.size()){
        cout << s1[i];
    }
    cout << endl;
}



Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int A, B, C;
    cin >> A >> B >> C;
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (A == B && B == C) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    while (true) {
        int na = B / 2 + C / 2;
        int nb = A / 2 + C / 2;
        int nc = A / 2 + B / 2;
        A = na;
        B = nb;
        C = nc;
        ans++;

        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    # 同じ数字3枚引いて1, 2枚になるまで減らす
    for i in cnt.keys():
        if cnt[i] % 2 == 0:
            cnt[i] = 2
        else:
            cnt[i] = 1

    ans = 0
    even_num = [i for i in cnt.keys() if cnt[i] == 2]
    # 2枚ある2種類の数字から3枚引けば1枚ずつにできる
    if len(even_num) % 2 == 0:
        ans = len(cnt)
    else:
        # 2枚ある数字が1種類残ったらそれらと別の数字を引く
        ans = len(cnt) - 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 22712
#include <iostream>
#include <cmath>

using namespace std;
int main(void){
    // Your code here!
    int x(0), y(0), sqr(0), periphery(0);
    cin >> x >> y;
    sqr = x*y;
    periphery=2*x+2*y;
    cout << sqr << " "<<periphery<<endl;
    
    return 0;
}



Measured memory_bytes: 3088
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll i,j;
    ll ans=0;
    for(i=1;i<=n;i++){
    	for(j=0;j<=n;j+=i){
    		if(j+i<=n){
    			ans+=max(0LL,i-k);
    		}
    		else{
    			ans+=max(0LL,n-j+1-k);
    		}
    	}
    }
    if(k==0){
    	ans-=n;
    }
    cout<<ans<<endl;
    return 0;  
    
}



Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;


string[] calc(int p, int q, RedBlackTree!int s) {
	auto r = p%q;
	if(r == 0){
		s.clear();
		return [to!string(p/q), " "];
	}
	if(r in s) {
		s.clear();
		s.insert(r);
		return [to!string(p/q), "^"];
	}
	s.insert(r);
	auto ret = calc(r*10, q, s);

	ret[0] = to!string(p/q) ~ ret[0];
	if(r in s)
		s.clear();
	if(s.empty())
		ret[1] = " " ~ ret[1];
	else
		ret[1] = "^" ~ ret[1];
	return ret;
}

void main() {
	auto s = readln();
	while(!s.empty()) {
		auto t = s.strip().split();
		int p = to!int(t[0]);
		int q = to!int(t[1]);
		auto ans = calc(p*10, q, redBlackTree!int(p%q));
		writeln(ans[0]);
		if(ans[1].back == '^')
			writeln(ans[1]);
		s = readln();
	}
}

Measured memory_bytes: 1516
#include<iostream>
using namespace std;
int main(){
  int n,cnt;
  while(cin >> n){
    cnt=0;
    for(int a=0;a<10;a++){
      for(int b=0;b<10;b++){
	for(int c=0;c<10;c++){
	  for(int d=0;d<10;d++){
	    if(a+b+c+d == n)cnt++;
	  }
	}
      }
    }
    cout << cnt << endl;
  }
}

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



int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int h,w;
  cin>>h>>w;
  int ch,cw,dh,dw;
  cin>>ch>>cw;

  --ch;
  --cw;
  cin>>dh>>dw;

  --dh;
  --dw;
  vector<string> maze(h);
  for(int i=0;i<h;i++){
     cin>>maze[i];
   }

  auto inside= [&](int i, int j){
        return i>=0 && i<h && j>=0 && j<w && maze[i][j]=='.';
  };

  vector<vector<int>> dist(h,vector<int>(w,INT_MAX));
  dist[ch][cw]=0;
  deque<pair<int,int>> que;
  que.emplace_back(make_pair(ch,cw));
  while(!que.empty()){
    auto [i,j]= que.front();
    que.pop_front();

    for(int x= i-2; x<= i+2 ; x++){
        for(int y= j-2; y<= j+2; y++){
            if(inside(x,y)){
                int warp= ((abs(x-i)+ abs(y-j)) != 1);
                int d= dist[i][j]+warp;
                if(d<dist[x][y]){
                    dist[x][y]= d;

                    if(warp)
                        que.emplace_back(make_pair(x,y));
                    else
                        que.emplace_front(make_pair(x,y));
                }
            }
        }
    }
  }
  int ans= dist[dh][dw];
  if(ans==INT_MAX) ans= -1;
  cout<<ans<<endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define ar array
#define endl '\n'
#define all(x) x.begin(), x.end()
#define sz(x) ((long long)x.size())

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

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

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){


}

struct  DATA{
    int l,r,i;
};  
int bit[maxs];
int n,q;

void add(int ind,int val){
    while(ind <= n){
        bit[ind] += val;
        ind += ind&-ind;
    }
}

int get(int ind){
    int sum=0;
    while(ind){
        sum += bit[ind];
        ind -= ind&-ind;
    }
    return sum;
}

void solve(){    

    cin >> n >> q;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    DATA AllQueries[q+1];
    for(int i=1;i<=q;i++){
        cin >> AllQueries[i].l >> AllQueries[i].r;
        AllQueries[i].i = i;
    }
    vector<int> ans(q+1,0);
    sort(AllQueries+1,AllQueries+q+1,[&](DATA A,DATA B)->bool{
        return A.r < B.r;
    });

    int ptr_query=1;
    map<int,int> prev;
    for(int i=1;i<=n;i++){
        if(prev.count(a[i])){
            add(prev[a[i]],-1);
        }
        add(i,1);

        while(ptr_query <= q and i == AllQueries[ptr_query].r){
            int l = AllQueries[ptr_query].l;
            int r = i;
            int ind = AllQueries[ptr_query].i;
            int cur_ans = get(r) - get(l-1);
            ans[ind] = cur_ans;
            ptr_query++;
        }
        prev[a[i]] = i;
    }

    for(int i=1;i<=q;i++){
        cout << ans[i] << endl;
    }

}

int main(){
   
    IOS;
    pre();
    ll T = 1;
    //cin >> T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 38908
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
const int N=2e5+5;
int n,val[N];

namespace utils{
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi();
	lint ans=0;
	for(int l=1,s=0,i=1; i<=n; ++i){
		val[i]=nxi();
		while(s&val[i]) s^=val[l++];
		s|=val[i];
		ans+=i-l+1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4580
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

int main() {
  ll A, B; cin >> A >> B;
  vector<int> X(41);
  X.at(0) = ((B / 2 + B % 2) - (max(0LL, A - 1) / 2 + max(0LL, A - 1) % 2)) % 2;
  rep(i, 1, 41) {
    X.at(i) = (max(B % (1LL << (i + 1)) - ((1LL << i) - 1), 0LL) % 2) ^ (max(max(A - 1, 0LL) % (1LL << (i + 1)) - ((1LL << i) - 1), 0LL) % 2);
  }
  ll ans = 0;
  rep(i, 0, 41) {
    if (X.at(i)) ans += (1LL << i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=l;i<r;i++)
#define rrep(i,l,r) for(ll i=(r)-1;i>=l;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define range(i) i.begin(),i.end()
#define sum(i) accumulate(range(i),0)
struct start { start() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }start;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head, Tail&&... tail) {
	cin >> head;
	in(move(tail)...);
}
template <class T>
inline void out(T t) {
	cout << t << '\n';
}
template <class Head, class... Tail>
inline void out(Head head, Tail... tail) {
	cout << head << ' ';
	out(move(tail)...);
}
template <class T>
inline void out(vector<T> a){
    rep(i,0,a.size()-1)cout<<a[i]<<' ';
    out(a.back());
}


int d,g;
vector<int> p(11),b(11);
int dp(int a,int pnt){
    int min=INF,n;
    rep(i,1,d+1)if(!(a&(1<<i))){
        if(p[i]*i*100>=pnt){
            n=(pnt+i*100-1)/(i*100);
            if(min>n)min=n;
        }
        else{
            int pn=pnt-p[i]*i*100-b[i];
            n=pn>0?p[i]+dp(a+(1<<i),pn):p[i];
            if(min>n)min=n;
        }
    }
    return min;
}
int main() {
    in(d,g);
    rep(i,1,d+1)in(p[i],b[i]);
    out(dp(0,g));
} 









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;


#include <random>

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

    int D;
    cin>>D;
    int c[26];
    int q[D];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    int l[26]{};
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            int la[26];
            rep(_,26){
                la[_]=l[_];
            }
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    la[k]=0;
                }else{
                    la[j]++;
                    a-=la[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                l[y]=0;
            }else{
                l[j]++;
                ans-=l[j]*c[j];
            }
        }
        y++;
        q[i]=y;
    }

    int tr=0;
    std::random_device rnd; 
    while(tr<=100000){
        int g=rnd()%26;
        int h=rnd()%26;
        tr++;
        int ansm=0;
        int r[D];
        rep(i,D){
            if(i==g){
                if(h!=q[i]){
                    r[i]=h;
                }else{
                    r[i]=rnd()%26;
                }

            }else{
                r[i]=q[i];
            }
        }
        int lx[26]{};
        rep(i,D){
            ansm+=s[i][r[i]];
            rep(j,26){
                if(j==r[i]){
                    lx[r[i]]=0;
                }else{
                    lx[j]++;
                    ansm-=lx[j]*c[j];
                }
            }
        }
        if(ansm>ans){
            rep(i,D){
                q[i]=r[i];
            }
            ans=ansm;
        }
    }
    rep(i,D){
        cout << q[i] << endl;
    }

    



}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define PI acos(-1)
#define EPS 1e-12
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bitCount __builtin_popcount
#define forn(i, n) for(i = 0; i < (ll)n; i++)
#define for1(i, n) for(i = 1; i <= (ll)n; i++)
#define forv(i, v) for(i = 0; i < v.size(); i++)
#define forab(i, a, b) for(i = a; i <= (ll)b; i++)
#define Sort(v) sort(v.begin(), v.end())
#define bend(v) v.begin(), v.end()
#define sz(v) v.size()
#define trace(x) cout<<"x = "<<x<<"\n"
#define trace2(x, y) cout<<"x = "<<x<<" y = "<<y<<"\n"
#define trace3(x, y, z) cout<<"x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define trace4(w, x, y, z) cout<<"w = "<<w<<" x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define ln "\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef set<int>::iterator sit;
typedef set<ll>::iterator sllt;
typedef set<char>::iterator sct;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;
typedef multiset<int>::iterator msit;
const int maxn = 1e3+5;
const ll mod = 1e9+7;
const int alphabet = 26;
const int inf = INT_MAX;
const ll linf = 1e18+9;
namespace util{
	inline ll cnm(char ch){ return (ch-'0'); }
	inline ll cap(char ch){ return (ch-'a'); }
	inline void instr(string& s, ll& n){ cin>>s;    n = s.length(); }
	inline void instr(string& s){ cin>>s; }
	template<typename T> T gcd(T a, T b){ if(a==0) return b; return gcd(b%a, a); }
	template<typename T> bool min(T a, T b, T c){
		return  std::min(a, std::min(b, c));
	}
}
using namespace util;

ll a[maxn];
void solve(int tc)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll i, j, k, m, n;
	cin>>n>>k;
	for(i = 0; i < n; i++){
		cin>>a[i];
	}
	sort(a, a+n);
	ll ans = 0;
	for(i = 0; i < k; i++) ans += a[i];
	cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	int i = 1;
	// cin>>t;
	while(i <= t){
		solve(i);
		i++;
	}

	return 0;
}



Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
	
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n;
	static int t[10100];
	scanf("%d", &n);
	rep (i, n - 1)
		scanf("%d", t + i);
	int m = n / 2;

	static int dp1[2][10100], dp2[2][10100];
	const int INF = 1e9;
	rep (i, 2)
		rep (j, n + 1)
			dp1[i][j] = dp2[i][j] = INF;

	dp1[1][0] = 0;
	fill(dp2[1] + 1, dp2[1] + n, t[0]);
	for (int i = 2; i <= m; ++i)
	{
		int* prev1 = dp1[(i + 1) & 1];
		int* cur1 = dp1[i & 1];
		int* prev2 = dp2[(i + 1) & 1];
		int* cur2 = dp2[i & 1];

		cur1[0] = INF;
		for (int j = 1; j <= n; ++j)
		{
			cur1[j] = min(prev1[j - 1], prev2[j - 1] + t[j - 1]);
			cur2[j] = min(cur2[j - 1], cur1[j - 1] + t[j - 1]);
		}
	}

	printf("%d\n", dp2[m & 1][n]);
}	

Measured memory_bytes: 1028
A = input()
B = input()
C = input()
count_A = len(A)-1
count_B = len(B)
count_C = len(C)
card = A[0]
A = A[1:]
while(True):
    if(card == "a"):
        count_A -= 1
        if(count_A == -1):
            print("A")
            break
        card = A[0]
        A = A[1:]
    if(card == "b"):
        count_B -= 1
        if(count_B == -1):
            print("B")
            break
        card = B[0]
        B = B[1:]
    if(card == "c"):
        count_C -= 1
        if(count_C == -1):
            print("C")
            break
        card = C[0]
        C = C[1:]       

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c1, c2, c4, c5, d;
  cin >> a >> b;
  d = 0;
  for (int i = a; i < b + 1; i++) {
    c1 = i % 10;
    c2 = i / 10 % 10;
    c4 = i / 1000 % 10;
    c5 = i / 10000 % 10;
    if (c1 == c5 && c2 == c4) {
      d += 1;
    }
  }
  cout << d << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int h,i,j,w;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0&&w==0) break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(((i+j)/2)*2==i+j){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m,k;
	cin >> n >> m >> k;
	bool is = false;
	for(ll i = 0; i <= n; i++) {
		for(ll j = 0; j <= m; j++) {
			ll curr = i*m+j*n-2*i*j;
			if(curr == k) {
				is = true;
			}
		}
	}
	cout << (is ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon May 11 15:59:37 2020

@author: shinba
"""
from collections import deque

n = int(input())
A = deque(map(int,input().split()))

A.appendleft(0)
A.append(0)

B = []

for i in range(n+1):
    B.append(abs(A[i+1]-A[i]))

s = sum(B)

for i in range(n):
    sub =  B[i] + B[i+1] - abs(A[i+2]-A[i])
    if sub == 0:
        print(s)
    else:
        print(s-sub)
    

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

int main(){
  string s;
  cin >> s;
  int count=0;
  r(i,s.length()){
    if(i==s.length()-1)count++;
    else if(i==s.length()-2&&s[i]==s[i+1]){
      count++;
      break;
    }
    else if(s[i]!=s[i+1]){
      count++;
    }
    else {
      count+=2;
      i+=2;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
import heapq
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    B = [(1, -i) for i in A]
    heapq.heapify(A)
    for _ in range(M):
        b, c = map(int, input().split())
        B.append((b,-c))
    B.sort(key=lambda x: x[1])
    t = 0
    i = 0
    tl = []
    while t < N:
        tl.extend([-B[i][1]] * B[i][0])
        t += B[i][0]
        i += 1
    return sum(tl[:(N)])
print(main())



Measured memory_bytes: 35168