akhauriyash/Code-Regression huggingface dataset:
/***************************************************
 * Problem Name : B - ROT N.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2019-11-24
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    int k;
    cin >> k;
    string str;
    cin >> str;

    for (int i = 0; i < SZ (str); i++) {
        char ch = (str[i] + k);

        if (ch > 'Z') {
            int val = ch - 'Z';
            ch = 'A' + (val - 1);
        }

        str[i] = ch;
    }

    cout << str << "\n";
    return 0;
}


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

using namespace std;

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

typedef vector<int> vi;
typedef long long ll;

void solve() {
  int N;
  cin >> N;
  int cur = 1, ans = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a == cur) {
      cur++;
    } else {
      ans++;
    }
  }
  if (ans < N) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int isPrimeNumber(int target_number);
 
int main ( void ) {
	int target_number = 0;
	int loop = 0;
	int Max_number = 0;
	int number_of_prime_numbers = 0;
	int flag_not_prime_number = 0;
	
	scanf ( "%d", &Max_number );
	for ( loop = 0; loop < Max_number; loop++ ) {
		scanf ( "%d", &target_number );
		flag_not_prime_number = isPrimeNumber(target_number);
		 
		if ( flag_not_prime_number == 0 ) {
			number_of_prime_numbers++;
		}
	}
	printf("%d\n", number_of_prime_numbers);
	return 0;
}

int isPrimeNumber(int target_number)
{
	
	int flag_not_prime_number = 0;
	int divisor = 2;
	
	 
	while ( divisor*divisor <= target_number ) {
		if ( target_number % divisor == 0 ) {
			flag_not_prime_number = 1;
			break;
		}
		divisor++;
	}
	return flag_not_prime_number;
}


Measured memory_bytes: 2056
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
char s[300005];
int sume[300005] = {0};
int sumw[300005] = {0};
int main()
{
	int i, n;
	scanf("%d", &n);
	scanf("%s", s);
	for(i = 0 ; i < n ; i++)
	{
		if(s[i] == 'W')
		{
			sumw[i] = sumw[i - 1] + 1;
		}
		else sumw[i] = sumw[i - 1];
	}
	for(i = n - 1 ; i > 0 ; i--)
	{
		if(s[i] == 'E')
		{
			sume[i] = sume[i + 1] + 1;
		}
		else sume[i] = sume[i + 1];
	}
	int ans = 999999;
	for(i = 0 ; i < n ; i++)
	{
		if(ans > sumw[i - 1] + sume[i + 1])
		{
			ans = sumw[i - 1] + sume[i + 1];
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2816
'''
完全順列(derangement)
モンモール数(Montmort number)
'''

MOD = 10**9+7
N, M = map(int, input().split())

# 片方の順列の総数を求める
ans = 1
for i in range(N):
    ans *= M-i
    ans %= MOD

# M枚からN枚選ぶ完全順列を計算
d2, d1 = 1, M-N
d0 = d1
for i in range(2, N+1):
    # 1がk番目にある
    # 1番目にkがある
    d0 = (i-1)*d2 % MOD
    # 1番目にkがない
    d0 += (M-N+i-1)*d1
    d0 %= MOD
    d2, d1 = d1, d0

print(ans*d0 % MOD)


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

int main() {
    int N;
    cin >> N;
    vector<int> v_list;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        v_list.emplace_back(tmp);
    }
    vector<int> c_list;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        c_list.emplace_back(tmp);
    }
    int max_profit = 0;
    for (int i = 0; i < N; i++) {
        int value = v_list.at(i);
        int cost = c_list.at(i);
        if (value > cost) max_profit += value - cost;
    }
    cout << max_profit << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> vec(3,vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> vec.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> bingo(N);
  for(int i=0; i<N; i++){
    cin >> bingo.at(i);
  }
  for(int k=0; k<N; k++){  
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        if(vec.at(i).at(j) == bingo.at(k)){
          vec.at(i).at(j) = 0;
        }
      }
    }
  }
  int p = 0;
  for(int i=0; i<3; i++){
    if((vec.at(i).at(0) == 0)&&(vec.at(i).at(1) == 0)&&(vec.at(i).at(2) == 0)){
      p++;
    }
  }
  int q=0;
  for(int i=0; i<3; i++){
    if((vec.at(0).at(i) == 0)&&(vec.at(1).at(i) == 0)&&(vec.at(2).at(i) == 0)){
      q++;
    }
  }
  int r=0;
  if((vec.at(0).at(0) == 0)&&(vec.at(1).at(1) == 0)&&(vec.at(2).at(2) == 0)){
    r++;
  }
  int s=0;
  if((vec.at(2).at(0) == 0)&&(vec.at(1).at(1) == 0)&&(vec.at(0).at(2) == 0)){
    s++;
  }
  if((p>0)||(q>0)||(r>0)||(s>0)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  ll n, m;
  cin >> n >> m;
  ll total = 0;
  rep(i, m)
  {
    ll temp;
    cin >> temp;
    total += temp;
  }
  total = n - total;
  if(total < 0) {
    cout << -1 << endl;
  }else{
    cout << total << endl;
  }
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define BR "\n"

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

  ll l0 = 2, l1 = 1, l2 = l1;
  rep0(i, N - 1) {
    l2 = l0 + l1;
    l0 = l1;
    l1 = l2;
  }

  cout << l2 << BR;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
int M=1e9+7;
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[s.length()-1]=='s')
	s+="es";
	else
	s+="s";
	cout<<s;
	return 0;
}

Measured memory_bytes: 3624
import numpy as np
A, B, C, D = map(int, input().split())

def gcd(a,b):
    rem = a % b
    while rem != 0:
        a = b
        b = rem
        rem = a % b
    return b

g = gcd(C, D)
l = (C*D)//g

x = B - ((B//C) + (B//D) - (B//l))
A = A-1
y = A - ((A//C) + (A//D) - (A//l))

print(x - y)

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

int main() {
  int N;
  cin >> N;
  
  vector<int> da(N);
  vector<int> db(N);
  vector<int> dc(N);
  
  for(int i = 0; i< N; i++){
    cin >> da.at(i) >> db.at(i);
    dc.at(i) = da.at(i) - db.at(i);
  }
  
  int cont = 0;
  bool zorome = false;
  
  for(int i = 0; i< N; i++){
    if(dc.at(i) == 0){
      cont++;
    }else{
      cont = 0;
    }
    if(cont == 3){
      zorome = true;
      break;
    }
  }
  
  string ans;
  
  if(zorome){
    ans = "Yes";
  }else{
    ans = "No";
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3628
import sys

N = int(input())
H = list(map(int,input().split()))

for i in range(N-1):
    if H[i+1] == H[i]:
        None
    elif H[i+1] > H[i]:
        H[i+1] = H[i+1]-1
    else:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 14396
#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;

signed main()
{
    int a, b, n;
    cin >> a >> b >> n;
    //xはx%b==b-1となる
    if(n>=b-1){
        int x = b - 1;
        cout << (int)((a * x) / b) - a * (int)(x / b) << endl;
    }
    else{
        int x = n;
        cout << (int)((a * x) / b) - a * (int)(x / b) << endl;
    }

    return 0;
}

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

int main()
{
	long long int lucas[87];
	lucas[0] = 2;
	lucas[1] = 1;
	for (int i = 2; i <= 86; i++) {
		lucas[i] = lucas[i - 1] + lucas[i - 2];
	}
	int a = 0;
	cin >> a;
	cout << lucas[a] << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

bool data[92][92];
int w, h, dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};

int dfs(int y, int x, int d){
  int res = d;
  for(int i=0;i<4;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(data[ny][nx]){
      data[ny][nx] = false;
      res = max(res, dfs(ny, nx, d+1));
      data[ny][nx] = true;
    }
  }
  return res;
}

main(){
  while(scanf("%d %d", &w, &h) && (w|h)){
    for(int i=0;i<=h+1;i++){
      for(int j=0;j<=w+1;j++){
        if(i == 0 || j == 0 || i == h+1 || j == w+1) data[i][j] = 0;
        else scanf("%d", &data[i][j]);
      }
    }
    int ans = 0;
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(data[i][j]) ans = max(ans, dfs(i, j, 0));
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <algorithm>
#include <set>
//#define LOCAL
#define be(n) n.begin(), n.end()
using namespace std;
typedef long long ll;
set<ll>a, b;


int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll n;
cin>>n;
for(ll i=0;i<n;i++){
    ll v;
    cin>>v;
    a.insert(v);
}

ll m;
cin>>m;
for(ll i=0;i<m;i++){
    ll v;
    cin>>v;
    b.insert(v);
}
set<ll>c;
set_intersection(be(a), be(b), inserter(c, c.begin()));
for(set<ll>::iterator it=c.begin();it!=c.end();it++){
    cout<<*it<<endl;
}

#ifdef LOCAL
fin.close();
#endif // LOCAL
}



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

int main(){
string s;
  cin >> s;
  int h = 0;
  int o = 0;
  
  for(int i = 0;i < s.size();i++){
  if(s.at(i) == 'A'){
  h = i;
    break;
  }
  }
  
    for(int i = s.size() - 1;i > 0;i--){
  if(s.at(i) == 'Z'){
  o = i;
    break;
  }
  }
  
  cout << o - h + 1 << endl;
}

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

int main(){
    string S;
    cin >> S;
    int len = S.size();
    int ans = len;
    for (int i = 1; i < len; i++){
        if (S[i - 1] != S[i]){
            ans = min(ans, max(i, len - i));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3752
//A*(priority_queue)
//MD=manhattan direction
#include<iostream>
#include<string>
#include<queue>
#include<set>

using namespace std;

const int N=4;
const int N2=16;

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

int MDT[N2][N2];

class puzzle
{
public:
	int f[N2];
	int space;
	int MD;
	int cost;
	
	bool operator<(const puzzle &p)const
	{
		for(int i=0;i<N2;i++)
		{
			if(f[i]==p.f[i])continue;
			return f[i]<p.f[i];
		}
		return false;
	}
};

class state
{
public:
	puzzle p;
	int est;//estimated
	bool operator<(const state &s)const
	{
		return est>s.est;
	}
};

int getallMD(puzzle p)
{
	int sum=0;
	for(int i=0;i<N2;i++)
	{
		if(p.f[i]==N2)continue;
		sum+=MDT[i][p.f[i]-1];
	}
	return sum;
}

int encode(puzzle s)
{
	int cur=0,enc=0;
	for(int i=0;i<N2;i++)
	{
		if(s.f[i]==N2)
		{
			s.f[i]=0;
			break;
		}
	}
	for(int i=0;i<N2-1;i++)
	{
		cur=s.f[i];
		for(int j=i+1;j<N2;j++)
		{
			if(cur<s.f[j])s.f[j]--;
		}
		(enc+=s.f[i])*=N2-1-i;
	}
	return enc;
}

int astar(puzzle s)
{
	priority_queue<state>PQ;
	s.MD=getallMD(s);
	s.cost=0;
	set<int>V;
	puzzle u,v;
	state initial;
	initial.p=s;
	initial.est=s.MD;;
	PQ.push(initial);
	
	while(!PQ.empty())
	{
		state st=PQ.top();PQ.pop();
		u=st.p;
		if(u.MD==0)return u.cost;
		V.insert(encode(u));
		int sx=u.space/N;
		int sy=u.space%N;
		
		for(int r=0;r<4;r++)
		{
			int tx=sx+dx[r];
			int ty=sy+dy[r];
			if(tx<0||tx>=N||ty<0||ty>=N)continue;
			v=u;
			v.MD-=MDT[tx*N+ty][v.f[tx*N+ty]-1];
			v.MD+=MDT[sx*N+sy][v.f[tx*N+ty]-1];
			swap(v.f[sx*N+sy],v.f[tx*N+ty]);
			v.space=tx*N+ty;
			if(!V.count(encode(v)))
			{
				v.cost++;
				state news;
				news.p=v;
				news.est=v.cost+v.MD;
				PQ.push(news);
			}
		}
	}
	
	return -1;
}

int main()
{
	for(int i=0;i<N2;i++)
	{
		for(int j=0;j<N2;j++)
		{
			MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
		}
	}
	
	puzzle in;
	
	for(int i=0;i<N2;i++)
	{
		cin>>in.f[i];
		if(in.f[i]==0)
		{
			in.f[i]=N2;
			in.space=i;
		}
	}
	
	cout<<astar(in)<<endl;
	
	return 0;
}

Measured memory_bytes: 111416
n = int(input())
a = list(map(int, input().split()))

ans = 0
while True:
    flg = False
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] /= 2
        else:
            flg = True
            break
    if flg:
        break
    ans += 1

print(ans)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;

ll a[200005];

int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int n; cin >> n;
	rep(i, n) cin >> a[i], a[i] -= i + 1;
	
	sort(a, a + n);
	
	ll median = a[n / 2], res = 0;
	rep(i, n) res += abs(a[i] - median);
	
	print(res);
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=100100100;
const int MOD=(int)1e9+7;
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<b; i++)

int main(){
    int n,W;
    cin>>n>>W;
    int value[n],weight[n];
    int dp[n+1][W+1];
    REP(i,n)cin>>value[i]>>weight[i];
    REP(i,W+1)dp[0][i]=0;

    REP(i,n){
        REP(j,W+1){
            if(j>=weight[i]) dp[i+1][j]=max(dp[i][j-weight[i]]+value[i],dp[i][j]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    cout<<dp[n][W]<<endl;
}
    


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

using Int = unsigned long long;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	Int a, b, k;
	std::cin >> a >> b >> k;
	if(k < a){
		std::cout << a - k << ' ' << b << std::endl;
	}else if(k < a + b){
		std::cout << 0 << ' ' << a + b - k << std::endl;
	}else{
		std::cout << "0 0" << std::endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int r = sc.nextInt();
    int c = sc.nextInt();
    int[][] table = new int[r][c];
    int[] sumColumn = new int[c];
    int sumAll = 0;

    for(int i = 0; i < r; i++){
      for(int j = 0; j < c; j++){
        table[i][j] = sc.nextInt();
      }
    }

    for(int i = 0; i < r; i++){
      int sumRow = 0;
      for(int j = 0; j < c; j++){
        System.out.print(table[i][j] + " ");
        sumRow += table[i][j];
      }
      System.out.println(sumRow);
    }

    for(int i = 0; i < c; i++){
      for(int j = 0; j < r; j++){
        sumColumn[i] += table[j][i];
      }
      sumAll += sumColumn[i];
      System.out.print(sumColumn[i] + " ");
    }
    System.out.println(sumAll);

  }
}




Measured memory_bytes: 41480
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn min<T: std::cmp::PartialOrd>(a: T, b: T) -> T {
    if a < b {
        return a;
    } else {
        return b;
    }
}

fn main() {
    let n: usize = read();
    let hi: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut dp = vec![0; n];
    dp[1] = (hi[1] - hi[0]).abs();

    for i in 2..n {
        dp[i] = min(dp[i-2] + (hi[i-2] - hi[i]).abs(), dp[i-1] + (hi[i-1] - hi[i]).abs());
    }

    println!("{}", dp[n-1]);
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    ll n;
    cin >> n;

    map<ll, ll> cnt;
    rep(i, n){
        ll a;
        cin >> a;
        if(cnt.find(a) == cnt.end()) cnt[a] = 0;
        ++ cnt[a];
    }

    bool flag = true;
    for(ll target = n - 1; target >= 0; target -= 2){
        flag = ((target == 0 && cnt[target] == 1) || (target > 0 && cnt[target] == 2)) && flag;
    }

    if(!flag) cout << 0 << endl;
    else {
        ll ans = 1;
        rep(i, n / 2){
            ans = mul_mod(ans, 2, 1e9+7);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5376
#include<iostream> 
#include<climits> 
#include <bitset>
#include<string>
#include<math.h>
#include <cstdlib>
using namespace std ;
int main(){
    int a , b, c ;
    cin >> a >> b >> c ;
    cout << c<<" " << a<<" " << b ;
    return 0 ;
}

Measured memory_bytes: 256
import heapq
t = int(input())
while t:
    t-=1
    n = int(input())
    klr = [list(map(int, input().split())) for i in range(n)]
    klr.sort()
    q = []
    ans = 0
    for i in range(n):
        K = klr[i][0]
        L = klr[i][1]
        R = klr[i][2]
        if L >= R:
            ans += L
            heapq.heappush(q,L-R)
            while len(q) > K:
                dec = heapq.heappop(q)
                ans -= dec
    q = []
    for i in reversed(range(n)):
        K = klr[i][0]
        L = klr[i][1]
        R = klr[i][2]
        if L < R:
            ans += R
            heapq.heappush(q,R-L)
            while len(q) > n-K:
                dec = heapq.heappop(q)
                ans -= dec    
    print(ans)


Measured memory_bytes: 115664
#include<cstdio>
const int maxn=100005,mod=(int)(1e9+7);
int fac[maxn],inv[maxn];
int qpow(int a,int x){
  int ans=1;
  for(;x;x>>=1,a=a*1ll*a%mod)if(x&1)ans=ans*1ll*a%mod;
  return ans;
}
void init(){
  fac[0]=1;
  for(int i=1;i<maxn;++i)fac[i]=fac[i-1]*1ll*i%mod;
  inv[maxn-1]=qpow(fac[maxn-1],mod-2);
  for(int i=maxn-1;i>=1;--i)inv[i-1]=inv[i]*1ll*i%mod;
}
int C(int n,int m){
  if(n<m)return 0;
  return fac[n]*1ll*inv[m]%mod*inv[n-m]%mod;
}
int cnt[maxn];
int a[maxn];
int pos[2],tot=0;
int main(){
  init();
  int n;scanf("%d",&n);
  for(int i=1;i<=n+1;i++)scanf("%d",a+i),cnt[a[i]]++;
  int val=-1;
  for(int i=1;i<=n;++i)if(cnt[i]==2)val=i;
  for(int i=1;i<=n+1;++i){
    if(a[i]==val)pos[tot++]=i;
  }
  int tmp=pos[0]-1+n+1-pos[1];
  for(int i=1;i<=n+1;++i){
    int ans=C(n+1,i);
    ans=(ans-C(tmp,i-1)+mod)%mod;
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 2688
import scala.io.StdIn

object Main extends App {
  val Array(n,m) = StdIn.readLine.split(" ").map(_.toInt)
  val aSum = StdIn.readLine.split(" ").map(_.toInt).sum
  val res = n - aSum
  if (res >= 0) println(res) else println("-1")
}

Measured memory_bytes: 55072
s = input()
a = int(s[:2])
b = int(s[2:])


if 1 <= a <= 12:
    if 1 <= b <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= b <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> v(n);
  for(int i=0;i<m;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++){
      int s;
      cin >> s;
      s--;
      v[s] |= (1<<i);
    }
  }
  int p=0;
  int ans =0;
  for(int i=0;i<m;i++){
    int x;
    cin >> x;
    p |= (x<<i);
  }
  
  for(int bit; bit<(1<<n);bit++){
    int t=0;
    for(int i=0;i<n;i++){
      if(bit>>i&1) {
        t ^= v[i];
      }
    }
    if(t==p) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void 
debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
char s[1005];
int exi[305];
int main(){
  cin>>s;
  int n=strlen(s);
  REP(i,n) exi[s[i]]=1;
  if((exi['N']^exi['S'])==0 && (exi['W']^exi['E'])==0) puts("Yes");
  else puts("No");

  return 0;
}





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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
int main()
{
	int n, k;
	cin>>n>>k;
	int pos;
	rep(i, 0, n)
	{
		int x;
		cin>>x;
	}
	int l = 1;
	int r = n;
	int ans = 0;
	while(l < r)
	{
		l += k;
		l--;
		ans++;
	}
	cout<<ans<<endl;
	
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
bool from1[200050];
bool toN[200050];

int main() {
    //cout.precision(10);
    int N, M;
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        int a, b;
        cin >> a >> b;
        if(a == 1) from1[b] = true;
        if(b == N) toN[a] = true;
    }
    for(int i = 2; i < N; i++) {
        if(from1[i] && toN[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if ((a*b)&1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

ans = []
for i in range(n)[::-1]:
  for j in range(i+1)[::-1]:
    if j+1 == A[j]:
      ans.append(A.pop(j))
      break
      
if len(ans)==n:
  for a in ans[::-1]:
    print(a)
else:
  print(-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
    using namespace std;
    using ll = long long;
    #define pb push_back
    #define eb emplace_back
    #define mp make_pair
    #define ff first
    #define ss second

    void io(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        #ifdef LOCAL
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    ll ans;
    int x;
    const int N = 2e5 + 5;
    int main() {
        io();
        string s;
        int n, p;
        cin >> n >> p;
        cin >> s;
        map <int, int> f;
        if(p == 2) {
            for(int i = 0; i < n; i++) {
                if((s[i] - '0') % 2 == 0) {
                    ans += (i + 1);
                }
            }
            cout << ans;
        }
        else if(p == 5) {
            for(int i = 0; i < n; i++) {
                if(s[i] == '5' || s[i] == '0') {
                    ans += (i + 1);
                }
            }
            cout << ans;
        }
        else {
            reverse(s.begin(), s.end());
            int num = 0;
            f[0] = 1;
            int t = 1;
            for(int i = 0; i < n; i++) {
                num = num + t * (s[i] - '0');
                t = t * 10 % p;
                num = num % p;
                f[num]++;


            }          

            for(auto it : f) {

                    ans += ((1LL * it.second * (it.second - 1)) / 2);

            }
            cout << ans;
        }



    }


Measured memory_bytes: 916
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

bool vis[1000];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

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

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

    while(cin >> n >> k)
    {
		memset(vis,0,sizeof vis);

		for(i = 1; i <= k; i++)
		{
			slld(m);

			for(j = 1; j <= m; j++)
			{
				slld(input);
				vis[input] = 1;
			}
		}

		ans = 0;

		for(i = 1; i <= n; i++)
		{
			ans += (vis[i] == 0);
		}

		cout << ans << '\n';
    }


}





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

int main() {
  ll a = 0;
  ll b = 100;
  ll ans = 0;
  cin >> a;
  while(b <= a){
    b = b * 1.01;
    ans++;
    if(b >= a){
      cout << ans;
      return 0;
    }
  }
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int a[10000001]={0};
    for(long long int i=2;i<=10000000;i++)
    {
        if(a[i]==0)
        {
            a[i]=i;
            for(long long int j=i*i;j<=10000000;j+=i)
            {
                a[j]=i;
            }
        }
    }
    long long int n;
    cin>>n;
    long long int ans=0;
    for(long long int i=1;i<=n;i++)
    {
        long long int temp=1;
        long long int aa=i;
        while(aa!=1)
        {
            long int temp1=a[aa];
            long long int kk=0;
            while(aa%temp1==0)
            {
                kk++;
                aa/=temp1;
            }
            temp=(temp*(kk+1LL));
        }
        ans+=(i*temp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 81756
#include <iostream>
#include <algorithm>

int const MAXN = 100000;

int dp[MAXN+1], N;

int calc(int x) {
  if(x == 0) return 0;
  if(dp[x] > 0) return dp[x];
  int res = calc(x-1) + 1;
  for(int i = 6; i <= x; i*=6) res = std::min(res, calc(x-i)+1);
  for(int i = 9; i <= x; i*=9) res = std::min(res, calc(x-i)+1);
  return dp[x] = res;
}

int main() {
  std::cin >> N;
  std::fill(dp, dp+N+1, 0);
  std::cout << calc(N) << std::endl;
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  string s;
  cin >> s;

  rep(i,s.size()){
    cout << (s[i]!=',' ? s[i] : ' ');
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int a;
  int b;

  cin >> a;
  cin >> b;
  if( a <= 5){
    cout << 0 << endl;
  }else if( a <= 12){
    cout << b/2 << endl;
  }else{
    cout << b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 200005;
const int MXV = 0;
const int MOD = 1e9 + 7;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

LL extgcd(LL a, LL b, LL &x, LL &y)
{
    LL d = a;
    if (b)
    {
        d = extgcd(b, a % b, y, x), y -= (a / b) * x;
    }
    else
        x = 1, y = 0;
    return d;
} // ax+by=1 ax同餘 1 mod b

vector<LL> fac(MXN, 0), invfac(MXN, 0);

LL inv(LL a)
{
    LL x, y, b = MOD;
    extgcd(a, b, x, y);
    while(x >= MOD)
    {
        x -= MOD;
    }
    while(x < 0)
    {
        x += MOD;
    }
    return x;
}

void build()
{
    fac[0] = fac[1] = 1;
    invfac[0] = invfac[1] = 1;
    FOR(i, 2, MXN)
    {
        fac[i] = (fac[i - 1] * i) % MOD;
        invfac[i] = inv(fac[i]);
    }
}

LL C(LL m, LL n)
{
    LL res = fac[m];
    res = (res * invfac[n]) % MOD;
    res = (res * invfac[m - n]) % MOD;
    return res;
}

int main()
{
    IOS;
    build();
    int n, k;
    cin >> n >> k;
    k = min(k, n - 1);
    LL ans = 0;
    FOR(i, 0, k + 1) { ans = (ans + (C(n, i) * C(n - 1, n - i - 1) % MOD)) % MOD; }
    cout << ans << '\n';
}


Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <ctime>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll MOD7 = 1000000007;

ll bpow(ll a, ll d, ll mod) { if (d == 0) return 1; ll t = bpow(a, d / 2, mod); t = (t * t) % mod; if (d & 1) t = (t * a) % mod; return t; }
ll bpow(ll a, ll d) { if (d == 0) return 1; ll t = bpow(a, d / 2); t = (t * t); if (d & 1) t = (t * a); return t; }
ll gcd(ll a, ll b) { while (a && b) if (a > b) a %= b; else b %= a; return a + b; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll C(ll n, ll k) { ll res = 1; for (int i = 1; i <= k; ++i) res = res * (n - k + i) / i; return res; }
ll C(ll n, ll k, ll mod) { ll u = 1, d = 1; for (int i = 2; i <= n; ++i) u = (u * i) % mod; int x = max(k, n - k), z = min(k, n - k); for (int i = 2; i <= x; ++i) { d = (d * i) % mod; if (i <= z) d = (d * i) % mod; } d = bpow(d, mod - 2, mod); ll res = (u * d) % mod; return res; }

ll ans(vector<pair<ll, ll>> v, ll n, ll c)
{
	vector<ll> suf(n);
	suf.back() = 2 * (v.back().first - c) + v.back().second;
	for (int i = n - 2; i >= 0; --i)
		suf[i] = suf[i + 1] + 2 * (v[i].first - v[i + 1].first) + v[i].second;

	for (int i = n - 2; i >= 0; --i)
		suf[i] = max(suf[i + 1], suf[i]);

	ll ans = 0LL;
	if (n > 1)
		ans = max(ans, suf[1] - v[0].first + v[0].second);

	ll cur = v[0].second - v[0].first;
	for (int i = 1; i < n - 1; ++i)
	{
		cur += v[i - 1].first - v[i].first + v[i].second;
		ans = max(max(ans, cur + suf[i + 1]), cur);
	}

	ll sum = 0;
	for (int i = 0; i < n; ++i)
		sum += v[i].second;
	ans = max(max(ans, sum - v.back().first), sum - c + v.front().first);
	return ans;
}

void solve()
{
	ll n, c; cin >> n >> c;
	vector<pair<ll, ll>> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i].first >> v[i].second;

	ll res = ans(v, n, c);
	for (int i = 0; i < n; ++i)
		v[i].first = c - v[i].first;
	reverse(v.begin(), v.end());
	res = max(res, ans(v, n, c));
	cout << res;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 4224
import math


def __sieve(num):
    sieved_set = set()
    for i in range(2, num + 1):
        sieved_set.add(i)

    # エラトステネスの篩法で素数を計算する
    for i in range(2, int(math.sqrt(num)) + 1):
        for j in range(2, num + 1):
            if (j % i == 0) and (j != i) and (j in sieved_set):
                sieved_set.remove(j)

    return sieved_set


def __calc_divisor(num, prime_count_array):
    for prime in prime_count_array:
        count = 0
        temp_divided = num
        while temp_divided % prime == 0:
            count += 1
            temp_divided /= prime
        prime_count_array[prime] += count


n = int(input())

# 素数を計算
primes = __sieve(n)

# N! の各項について、素因数分解する
prime_count_array = {}
for i in primes:
    prime_count_array[i] = 0
for i in range(2, n + 1):
    __calc_divisor(i, prime_count_array)

# 素因数分解結果から約数の個数を計算
divisor_count = 1
for divisor_count_of_prime in prime_count_array.values():
    divisor_count *= (divisor_count_of_prime + 1)

# 出力用に余りを算出
print(divisor_count % (10 ** 9 + 7))


Measured memory_bytes: 3064
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(A,B,K);
    cout << max(A-K,0LL) <<" " << max(B-max(K-A,0LL),0LL) << nn;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
typedef pair<int,int> pii;
const int N=3e5+10;
int h,w,m;
int x[N],y[N];
map<pii,int>mp;
pii row[N],col[N];
int main(void)
{
    sync;
    cin>>h>>w>>m;
    for(int i=0;i<m;++i)
    {
        int x,y;
        cin>>x>>y;
        ++row[x].first;
        row[x].second=x;
        ++col[y].first;
        col[y].second=y;
        mp[{x,y}]=1;
    }
    sort(row,row+h+1);
    reverse(row,row+h+1);
    sort(col,col+w+1);
    reverse(col,col+w+1);
    int mr=row[0].first,mc=col[0].first;
    bool flag=false;
    int res=mr+mc-1;
    for(int i=0;row[i].first==mr;++i)
    {
        for(int j=0;col[j].first==mc;++j)
        {
            if(!mp.count({row[i].second,col[j].second}))
            {
                ++res;
                flag=true;
                break;
            }

        }
        if(flag)
            break;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 21944
s = list(input())
l = [0 for _ in range(len(s))]

for i in range(len(s)-1):
  if s[i] == 'R' and s[i+1] == 'L':
    rc = lc = 1
    if i-1 >= 0 : 
      m = i-1
    
      while s[m] == 'R':
        lc += 1
        if m-1 >= 0 : 
          m -= 1
        else:
          break
    
    if i+2 <=  len(s)-1:
      n = i+2
      
      while s[n] == 'L':
        rc += 1
        if n+1 <= len(s)-1:
          n += 1
        else:
          break

    l[i] = lc//2 + lc% 2 + rc//2
    l[i+1] = rc//2 + rc%2 + lc//2
    
for i in range(len(l)):
  print(l[i], end = ' ')
  

Measured memory_bytes: 5556
N=int(input())
a=[]
for i in range(N):
    a.append(list(map(int,input().split())))

data=[0]*2**N
for i in range(1,2**N):
    res=0
    m=[j for j in range(N) if i>>j&1==1]
    for j in m:
        for k in m:
            res+=a[j][k]
    res//=2
    data[i]=res

dp=[0]*2**N
for i in range(1,2**N):
    res=data[i]
    j=(i-1)&i
    while j>0:
        temp=dp[j]+dp[i-j]
        res=max(res,temp)
        j=(j-1)&i
    dp[i]=res

print(dp[-1])

Measured memory_bytes: 45356
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    vec A(3);
    cin >> A[0] >> A[1] >> A[2];

    ll ans = 0;
    while(1){
        sort(ALL(A));
        if(A[0] == A[2]) drop(ans);
        if(A[2] - A[0] >= 2){
            ++ans;
            A[0] += 2;
        }else if(A[1] != A[2]){
            ++ans;
            ++A[0];
            ++A[1];
        }else{
            ++ans;
            ++A[1];
            ++A[2];
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;


void solve(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll op = a + b;

    ll ans = n/(op) * a;
    ans += min(n%op, a);


    cout << ans << endl;
}


int main(){
    //int t; cin >> t;
    //while(t--) solve();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
int solve(vector <int> A,int n){  
  
   // int n=A.size(); 
  
    sort(A.begin(), A.end());  
  
    int count = 0; 
      
    for( int i = n-1; i >= 1; i--){ 
        int l = 0, r = i-1; 
        while( l < r){ 
            if( A[l] + A[r] > A[i]){ 
                      count += r - l ;  
                r--;   
            } 
            else 
                l++;   
        } 
    } 
    return count;
} 
int main(){ 
  
    int n;
    cin>>n;
    vector<int>vec;
    int x;
    
    for(int i=0;i<n;i++){
    cin>>x;
    vec.push_back(x);
    }
    cout<<solve(vec,n)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=700,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str;
	x[str[0]]++;
	x[str[1]]++;
	x[str[2]]++;
	if(x['a']==1&&x['b']==1&&x['c']==1){cout<<"Yes";}
	else{cout<<"No";}



	cout<<endl;
} 


Measured memory_bytes: 256
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

int N, K, nxt[100005];
vector<int> graf[100005];
int ans = 0;

int dfs(int u){
    int depth = 0;
    for(auto v : graf[u]){
        depth = max(depth, dfs(v));
    }

    if(depth == K-1 && nxt[u]!=1){
        ans++;
        return 0;
    }
    
    return depth+1;
}

int main(){

    ios :: sync_with_stdio(false);
    cin >> N >> K;
    FOR(i,N){
        cin >> nxt[i];
        if(i != 1) graf[nxt[i]].push_back(i);
        else{
            if(nxt[i] != 1) ans++;
            nxt[i] = 1;
        }
    }

    dfs(1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10880