akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long mp[305][305],n,m,l;
void floyd(){
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                mp[i][j]=min(mp[i][j],mp[i][k]+mp[k][j]);
            }
        }
    }
}
int main(){
    cin>>n>>m>>l;
    memset(mp,0x3f,sizeof(mp));
    for(long long i=1;i<=n;i++){
        mp[i][i]=0;
    }
    for(long long i=1;i<=m;i++){
        int x,y,z;
        cin>>x>>y>>z;
        mp[x][y]=z;
        mp[y][x]=z;
    }
    floyd();
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(mp[i][j]>l) mp[i][j]=1e17;
            else mp[i][j]=1;
        }
    }
    floyd();
    long long q;
    cin>>q;
    while(q--){
        long long s,t;
        cin>>s>>t;
        if(mp[s][t]>=1e17) cout<<-1<<endl;
        else cout<<mp[s][t]-1<<endl;
    }
}

Measured memory_bytes: 1280
h,w=map(int,input().split())
d=[['.']*(w+2) for j in range(h+2)]
for hh in range(h):
  moji=input()
  for ww in range(w):
    d[hh+1][ww+1]=moji[ww]
for k in range(1,h+1):
  for l in range(1,w+1):
    if d[k][l]=='#' and all(aa=='.' for aa in [d[k-1][l],d[k+1][l],d[k][l-1],d[k][l+1]]):
      print('No')
      exit()
print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int aty[n+1][4];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=3;j++)
            cin>>aty[i][j];
    long dp[n+1][4];
    for(int i=1;i<=3;i++)
        dp[1][i]=aty[1][i];
    for(int day=2;day<=n;day++)
    {
         dp[day][1]=max(dp[day-1][2]+aty[day][1],dp[day-1][3]+aty[day][1]);
         dp[day][2]=max(dp[day-1][1]+aty[day][2],dp[day-1][3]+aty[day][2]);
         dp[day][3]=max(dp[day-1][2]+aty[day][3],dp[day-1][1]+aty[day][3]);
    }

    long m=dp[n][1];
    for(int i=2;i<=3;i++)
        m=max(m,dp[n][i]);
    cout<<m<<endl;
    return 0;
}


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

#define ll long long int
#define pb push_back
#define BOLT               \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);
#define endl "\n"

int main()
{
  BOLT;
// #ifndef ONLINE_JUDGE

//   // For getting input from input.txt file
//   freopen("input.txt", "r", stdin);

//   // Printing the Output to output.txt file
//   freopen("output.txt", "w", stdout);

// #endif
    ll n;
    cin >> n;
    ll sum=0;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    ll j=0;
    while(j<n-1)
    {
      if(a[j+1]<a[j])
        {sum+=a[j]-a[j+1]; a[j+1]=a[j];}
      j++;
    }
    cout<<sum; 
}


Measured memory_bytes: 5204
#include<stdio.h>
int main(void){
  int N,M,i,wa=0,day;
  int A[10000];
  scanf("%d",&N);
  scanf("%d",&M);
  for(i=0;i<M;i++){
    scanf("%d",&A[i]);
    wa=wa+A[i];}
  day=N-wa;
  if(day>=0)
    printf("%d",day);
  else
    puts("-1");
return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << " ";
    }
    cout << endl;
};

int main() {
    int n, q, tmp, C = 0;
    cin >> n;
    map<int, bool> S;
    rep(i, n) {
        cin >> tmp;
        S.insert(make_pair(tmp, 1));
    }
    cin >> q;
    rep(i, q) {
        cin >> tmp;
        if(S.count(tmp))
            C++;
    }
    cout << C << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  string s;
  cin >> s;
  int k=0;
  for(int i=0; i<n; i++){
      a[n-1-i] = s.at(i) - '0';
      k += a[n-1-i];
      //cout << a[n-1-i] << endl;
  }
  //cout << a[0] << " " << k << endl;
  //return 0;
  vector<int> p(n); //k+1
  vector<int> q(n); //k-1
  p[0]=1;
  q[0]=1;
  for(int i=1; i<n; i++) p[i] = (p[i-1]*2)%(k+1);
  if(k-1>0){
      for(int i=1; i<n; i++) q[i] = (q[i-1]*2)%(k-1);
  }
  int xp=0;
  int xq=0;
  for(int i=0; i<n; i++){
      xp += p[i]*a[i];
      xp %= (k+1);
  }
  if(k-1>0){
      for(int i=0; i<n; i++){
          xq += q[i]*a[i];
          xq %= (k-1);
        }
    }
for(int i=0; i<n; i++){
    int s=1;
    //cout << a[n-1-i] << endl;
    if(a[n-1-i]==0){
        int y=(xp+p[n-1-i])%(k+1);
        //cout << "y " <<  y << endl;
        while(y>0){
            //cout << i << " " << y << endl;
             y %= __builtin_popcountll(y);
             s++;
        }
        cout  << s << endl;
    } else {
        if(k==1){
            cout << 0 << endl;
            continue;
        }
        int y=(xq+(k-1)-q[n-1-i])%(k-1);
        while(y>0){
            //cout << i << " " << y << endl;
             y %= __builtin_popcountll(y);
             s++;
        }
        cout << s << endl;
    }
    }




}

Measured memory_bytes: 6016
A,B,C = map(int,input().split())
if (A+B+C)%2 == 0:
    candidates = [i for i in range(0,151,6)]
else:
    candidates = [i for i in range(3,154,6)]
for i in candidates:
    x = i/3
    if A<= x and B<= x and C<=x and ((x-A)+(x-B)+(x-C))%2==0:
        print(int((i-(A+B+C))/2))
        break

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n int
	fmt.Scan(&n)
	sum := int64(0)
	maxv := -1000000
	minv := 1000000
	var x int
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		maxv = max(maxv, x)
		minv = min(minv, x)
		sum += int64(x)
	}
	fmt.Println(minv, maxv, sum)
}



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

#define INX(x) (cin >> x)
#define INXV(vec, cnt) for(ll i; i < cnt; i++) INX(vec[i])
#define OUTX(x) (cout << x << endl)
#define OUTXV(vec) for(ll i; i < (ll)vec.size(); i++) OUTX(vec[i])

#define ADD emplace_back
#define MP make_pair


int main()
{
    ll N;
    INX(N);
    
    ll mod = N % 10;
    string result;
    if(mod == 3)
    {
        result = "bon";
    }
    else if(mod == 2 || mod == 4 || mod == 5 || mod == 7 || mod == 9)
    {
        result = "hon";
    }
    else
    {
        result = "pon";
    }
    OUTX(result);
    

    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<math.h>

using namespace std;
int n,tt=0;
void go(int m)
{
	if (m > 100)return ;
	if (m == n)
	{
		tt = 1;
		return;
	}
	go (m + 4);
	go (m + 7);
}
int main()
{
	tt = 0;
	scanf("%d", &n);
	go(0);
	if (tt == 1)printf("Yes");
	else printf("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
 int a,b,c,d,e,f;
  a=N/1000;
  b=(N%1000)/100;
  c=(N-1000*a-100*b)/10;
  d=N-1000*a-100*b-10*c;
 if(a == b && b==c){
 cout<<"Yes"<<endl;
   
 }
 else if(b==c && c==d){
   cout<<"Yes"<<endl;
 }
  else{
  cout<<"No"<<endl;
  }
    
}

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

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

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(n, vector<int> (m));
    auto dp = v;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            char x;
            cin >> x;
            if (x == '.') {
                v[i][j] = 1;
            }
        }
    }
    dp[n - 1][m - 1] = 1 - v[n - 1][m - 1];
    for (int i = m - 2; i >= 0; --i) {
        if (v[n - 1][i] || !v[n - 1][i + 1]) {
            dp[n - 1][i] = dp[n - 1][i + 1];
        } else {
            dp[n - 1][i] = dp[n - 1][i + 1] + 1;
        }
    }
    for (int i = n - 2; i >= 0; --i) {
        if (v[i][m - 1] || !v[i + 1][m - 1]) {
            dp[i][m - 1] = dp[i + 1][m - 1];
        } else {
            dp[i][m - 1] = dp[i + 1][m - 1] + 1;
        }
    }
    for (int i = n - 2; i >= 0; --i) {
        for (int j = m - 2; j >= 0; --j) {
            dp[i][j] = n + m + 1;
            if (!v[i + 1][j] || v[i][j]) {
                dp[i][j] = dp[i + 1][j];
            } else {
                dp[i][j] = dp[i + 1][j] + 1;
            }

            if (!v[i][j + 1] || v[i][j]) {
                dp[i][j] = min(dp[i][j], dp[i][j + 1]);
            } else {
                dp[i][j] = min(dp[i][j], dp[i][j + 1] + 1);
            }
        }
    }
 /*   for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cout << dp[i][j] << ' ';
        }
        cout << '\n';
    }*/
 cout << dp[0][0];
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>K>>H>>W;
	vector<long long int>v(N+1);
	for(int i=0;i<=N;i++)cin>>v[i];
	vector<long long int>dif(N+1);
	for(int i=0;i<N;i++){
		dif[i]=v[i+1]-v[i];
	}
	long long int ans=0;
	for(int i=0;i<N;i++){
		if(dif[i]>0)ans-=H*dif[i];
		else ans-=W*dif[i];
	}
	vector<long long int>ret;
	for(int i=0;i<K;i++){
		cin>>L>>R>>M;
		L--;
		if(dif[L]>0)ans+=H*dif[L];
		else ans+=W*dif[L];
		if(R<N){
			if(dif[R]>0)ans+=H*dif[R];
			else ans+=W*dif[R];
		}
		dif[L]+=M;
		dif[R]-=M;
		if(dif[L]>0)ans-=H*dif[L];
		else ans-=W*dif[L];
		if(R<N){
			if(dif[R]>0)ans-=H*dif[R];
			else ans-=W*dif[R];
		}
		ret.push_back(ans);
	}
	for(auto i:ret)cout<<i<<endl;
	return 0;
}


Measured memory_bytes: 8124
#include <bits/stdc++.h>
using namespace std;
int main(){

  int n,k;
  cin >> n >> k;
  vector<vector<int>> okashi(n,vector<int>(0));
  
  for(int i=0; i<k;i++){
  
    int d=0;
    cin >> d;
    
    for(int j=0;j<d; j++){
      int h;
      cin >> h;
      okashi.at(h-1).push_back(k);
    }
  }
  
  int count=0;
  
  for(int i=0; i<n; i++){
    if(okashi.at(i).size()==0) count+=1;
  }
  
  cout << count << endl;
    
}

Measured memory_bytes: 3628
program zigzag
  implicit none
  integer :: n, v(100000) = 0, o(100000,2) = 0, e(100000,2) = 0, i, m
  read(*,*) n
  read(*,*) v(1:n)
  do i = 1, 100000
    o(i,2) = i
    e(i,2) = i
  end do
  do i = 1, n, 2
    o(v(i),1) = o(v(i),1)+1
  end do
  do i = 2, n, 2
    e(v(i),1) = e(v(i),1)+1
  end do
  call merge_sort(o)
  call merge_sort(e)
  if (o(1,2) == e(1,2)) then
    m = max(o(1,1)+e(2,1),o(2,1)+e(1,1))
  else
    m = o(1,1)+e(1,1)
  end if
  write(*,'(i0)') n-m
contains
  subroutine merge_sort(a)
    integer, intent(inout) :: a(:,:)
    integer :: n, m, l, i, u
    n = size(a,1)
    m = n
    l = 1
    do while (m > 1)
      do i = 1, m/2
        u = min(2*i*l,n)
        call merger(a(2*(i-1)*l+1:(2*i-1)*l,:),a((2*i-1)*l+1:u,:))
      end do
      l = 2*l
      m = (m+1)/2
    end do
  end
  subroutine merger(a1,a2)
    integer, intent(inout) :: a1(:,:), a2(:,:)
    integer :: a(size(a1,1)+size(a2,1),size(a1,2))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(a1,1)
    n2 = size(a2,1)
    do while (i1 <= n1 .and. i2 <= n2)
      if (a1(i1,1) >= a2(i2,1)) then
        a(i1+i2-1,:) = a1(i1,:)
        i1 = i1+1
      else
        a(i1+i2-1,:) = a2(i2,:)
        i2 = i2+1
       end if
    end do
    if (i1 <= n1) then
      a(i1+i2-1:n1+n2,:) = a1(i1:n1,:)
    else
      a(i1+i2-1:n1+n2,:) = a2(i2:n2,:)
    end if
    a1 = a(1:n1,:)
    a2 = a(n1+1:n1+n2,:)
  end
end program zigzag

Measured memory_bytes: 3704
from collections import deque
N = input()
A = [[] for i in range(N)]
for i in range(N-1):
	a2,b2,c2 = map(int, raw_input().split())
	A[a2-1].append([b2-1,c2])
	A[b2-1].append([a2-1,c2])
A2 = [-1]*N
A2[0] = 0
q = deque([0])
while q:
	c = q.popleft()
	l = A2[c]
	for c0,c1 in A[c]:
		if(A2[c0] != -1):
			continue
		else:
			A2[c0] = (l + c1)%2
			q.append(c0)
for t in A2:
	print(t)

Measured memory_bytes: 47336
#include<stdio.h>
int main()
{
  int x[10000],y[10000],i,count=0;
  int a[3000];
  for (i=1; i<=3000; i++) {
    scanf("%d %d" ,&x[i] ,&y[i]);
    if (x[i]==0 && y[i]==0) { break;
    }
    count++;
  }
  for (i=1; i<=count; i++) {
    if (x[i]<y[i]) {
      printf("%d %d\n",x[i],y[i]);
    }  else {
      printf("%d %d\n",y[i],x[i]);
    }
  }

  return 0;
}

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

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

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

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector <vector<int>>;
using vvll = vector <vector<ll>>;

#define inf(T) (numeric_limits<T>::max() / 2)
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;


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

    for (;;) {
        int m; cin >> m;
        if (m == 0) break;

        int a, b; cin >> a >> b;
        vi s(m);
        REP(i, m) cin >> s[i];

        int ma = 0, maxId = -1;
        FOR(i, a-1, b) {
            if (ma <= s[i] - s[i+1]) {
                ma = s[i] - s[i+1];
                maxId = i;
            }
        }
        cout << maxId + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)

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

ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

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

  vector<int> a(n);
  ll tmp;
  ll ans;
  cin>>ans;

  r(i,n-1){
    cin>>tmp;
    ans=lcm(ans,tmp);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

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

	string s, t;
	cin >> s >> t;
	int i = 0, j = 0;
	while(i != s.size() && j != t.size()){
		cout << s[i++] << t[j++];
	}
	while(i != s.size())cout << s[i++];
	while(j != t.size())cout << t[j++];
	return 0;
}
// Write Here



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long int
#define inf 1000000000000000
int function(int h,int n,int arr[][2],int memo[])
{
	if(h<=0)
	  return 0;
	if(memo[h]!=-1)
	  return memo[h];
	else
	{
		int val=inf;
		int j;
		for(j=0;j<n;j++)
		{
			int x=arr[j][1]+function(h-arr[j][0],n,arr,memo);
			val=min(val,x);
		}
		memo[h]=val;
		return memo[h];
	}
}
int32_t main()
{
	int h,n;
	cin>>h>>n;
	int memo[h+1];
	int j;
	for(j=0;j<=h;j++)
	  memo[j]=-1;
	int arr[n][2];
	for(j=0;j<n;j++)
	  cin>>arr[j][0]>>arr[j][1];
	int answer=function(h,n,arr,memo);
	cout<<answer<<endl;
}


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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    while(n > 1000) {
        n -= 1000;
    }
    cout << 1000 - n << endl;
    return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b){
  if (a > b) return a = b, true; else return false;
}

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

std::vector<int> Eratosthenes(const int N){
  std::vector<bool> is_prime(N + 1);
  for(int i = 0; i <= N; i++) is_prime[i] = true;
  std::vector<int> P;
  for(int i = 2; i <= N; i++){
    if(is_prime[i]){
      for(int j = 2 * i; j <= N; j += i) is_prime[j] = false;
      P.emplace_back(i);
    }
  }
  return P;
}

bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) if (num % i == 0) return false;
  return true;
}

void solve(){
  ll A, B;
  cin >> A >> B;

  ll gcdab = gcd(A, B);
  vector<int> primes = Eratosthenes(ceil(sqrt(gcdab)));

  int ans = 1;
  for(int p : primes){
    if(gcdab % p == 0){
      ans++;
    }
    while(gcdab % p == 0){
      gcdab /= p;
    }
  }

  if(gcdab != 1)
    ans++;

  cout << ans << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 1020
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (Array(m, nmin, nmax) <- in if m != 0) {
        println(in.take(m).flatten.zipWithIndex.slice(nmin - 1, nmax + 1).foldLeft((0, 0, 0)){
            case ((gap, p0, res), (p1, i)) => if (p0 - p1 >= gap) (p0 - p1, p1, i) else (gap, p1, res)
        }._3)
    }
}

Measured memory_bytes: 80340
n, m = map(int, input().split())
sc = [list(map(int, list(input().split()))) for i in range(m)]

sc.sort()

hantei = [-1] * n
for i in range(m):
    if hantei[sc[i][0] - 1] == -1 or hantei[sc[i][0] - 1] == sc[i][1]:
        hantei[sc[i][0] - 1] = sc[i][1]
    else:
        print("-1")
        exit()

leng = len(hantei)
for i in range(leng):
    if i == 0 and hantei[i] == 0 and leng != 1:
        print("-1")
        exit()
    else:
        if hantei[i] != -1:
            print(hantei[i], end="")
        else:
            if i != 0:
                print("0", end="")
            elif leng == 1:
                print("0")
            else:
                print("1", end="")
              

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

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;}
/*
void chmin(ll a, ll b){if (a>b){a = b; return true;}return false;}
void chmax(ll a, ll b){if (a<b){a = b; return true;}return false;}
*/

int main() {
  int n,k; cin >>n >>k;
  vector<ll> h(n);
  rep(i,n) cin >>h.at(i);

  const ll INF = 9999999999;
  vector<ll> dp(100010,INF);
  dp[0] = 0;

  for (int i=0; i<n; i++){
    for (int j=1; j<=k; j++){
      chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
  }

  cout <<dp[n-1] <<endl;
}

Measured memory_bytes: 1792
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = o.l().sort((a,b)=>a-b);
  for(var l = 0, r = 2*n-1; l < r; l++, r--){
    var f = 1;
    while(l < r){
      if(a[l] + a[r] >= m){f = 0; break;}
      l++;
    }
  }
  r++;
  if(f)r++;
  var ans = 0;
  for(var u = 0, v = 2*(r-n)-1; u < v; u++, v--){
    var t = a[u] + a[v];
    if(ans < t)ans = t;
  }
  for(var u = 2*(r-n), v = 2*n-1; u < v; u++, v--){
    var t = a[u] + a[v];
    t %= m;
    if(ans < t)ans = t;
  }
  return ans;
}

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

const long long INFF = 1e18;

const int MAX_N = 11000;
using TYPE = long long; // ?????¢???????????\??????
vector<pair<int, TYPE> > G[MAX_N];

vector<TYPE> dijkstra(int start){
	vector<TYPE> dist(MAX_N, INFF);
	dist[start] = 0;//dist[i] :=???start->i?????§??????????????¢
	priority_queue<pair<TYPE, int>, vector<pair<TYPE, int> >, greater<pair<TYPE, int> > >  que;
	que.push(make_pair(0, start));
	while(!que.empty()){
		TYPE cost; int u;//????????§???????????£????????? ?????¨?????????
		cost = que.top().first, u = que.top().second;
		que.pop();
		//if(dist[u] < cost) continue;
		for (auto tmp : G[u]){
			int v = tmp.first; TYPE time = tmp.second;//??£??\???????????? ?????????????????§????????????
			if(dist[v] > dist[u] + time){//u->v
				// if(dist[v] != INFF) printf("%f %fa\n", dist[v], dist[u] + time);
				dist[v] = dist[u] + time;
				que.push(make_pair(dist[v], v));
			}
		}
	}
	return dist;
}


int main(void) {
	int n; cin >> n;
	rep(q, n) {
		int u, k; cin >> u >> k;
		vector<int> v(k); vector<long long> c(k);
		rep(i, k) cin >> v[i] >> c[i];
		rep(i, k) G[u].push_back(make_pair(v[i], c[i]));
	}
	auto dist = dijkstra(0);
	rep(i, n) printf("%d %d\n", i, dist[i]);
	return 0;
}

Measured memory_bytes: 12092
import Control.Monad
import Data.List


main :: IO ()
main = do
    [h, w] <- map read . words <$> getLine :: IO [Int]
    lines <- replicateM h getLine
    putStrLn $ replicate (w + 2) '#'
    forM_ lines $ \s -> do
        putStrLn ("#" ++ s ++ "#")
    putStrLn $ replicate (w + 2) '#'


Measured memory_bytes: 1404
#include <iostream>

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;
int main(){
    const long long INF = 1LL << 60;
    long long dp[100010];
    int n;
    cin >> n;
    int *h = (int *)calloc(n, sizeof(int));
    for(int i=0;i<n;++i){
        cin >> h[i];
    }

    for(int i=0;i<100010;++i) dp[i] = INF;
    dp[0] = 0;

    for(int i=0;i<n;++i){
        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1)chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << "\n";
}

Measured memory_bytes: 1408
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int alpha = sc.next().charAt(0);
        if ((int) 'a' <= alpha && alpha <= (int) 'z') System.out.println("a");
        if ((int) 'A' <= alpha && alpha <= (int) 'Z') System.out.println("A");
    } 
}

Measured memory_bytes: 27004
N = int(input())
ABc = 0
Ac = 0
Bc = 0
j = 0
for i in range(N):
	s = input()
	ABc += s.count("AB")
	if s[0] == "B":
		Bc += 1
	if s[-1] == "A":
		Ac += 1
	if s[0] == "B" and s[-1] == "A":
		j += 1

if Ac == Bc and Bc == j:
	if j == 0:
		print(ABc)
	else:
		print(ABc + Ac - 1)
else:
	print(ABc + min(Ac, Bc))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long ll;
typedef unsigned long long llu;

int main () {
	FIO
	int h,w;
	cin>>h>>w;
	if(h == 1 || w == 1){
		cout<<1;
		return 0;
	}
	int baseceil, basefloor;
	baseceil = ceil(w/2.0); basefloor = (w/2);
	int nceil, nfloor;
	nceil = ceil(h/2.0); nfloor = (h/2);
	ll ans = 1LL*nceil*baseceil + 1LL*nfloor*basefloor;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

K, S = map(int, input().split())

num = 0
for x in range(K+1):
    tmp = min(S-x, K) - max(0, S-K-x)
    if tmp >= 0:
        num += tmp + 1


print(num)

Measured memory_bytes: 12208
n = int(input())
mx = 10**18
arr = list(map(int, input().split()))
arr.sort()
if arr[0] == 0:
    print(0)
else:
    mul = 1
    for i in arr:
        mul *= i
        # print(i, mul)
        if mul > mx:
            print(-1)
            exit(0)
    print(mul)

Measured memory_bytes: 21788
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<utility>
#include<iostream>
using namespace  std;

const int maxn = 105;
int n,p,a = 0,b = 0;

long long slove(int x,int y){
	long long sum = 1;
	for(int i = 1;i <= y;i++) sum = (sum * (x - y + i)) / i;
	return sum;
}

int main(){
	long long sum_a = 0,sum_b = 0,sum = 0;
	scanf("%d %d",&n,&p);
	for(int i = 1;i <= n;i++){
		int x;
		scanf("%d",&x);
		if(x % 2 != 0) a++;
		else b++;
	}
	for(int i = 1;i <= b;i++){
			if(i == b) sum_b++;
			else sum_b += slove(b,i);
	}
	if(p == 0){
		int ans = 2;
		while(ans <= a){
			if(ans == a) sum_a++;
			else{
				sum_a += slove(a,ans);
			}
			ans += 2;
		}
		sum = sum_b + sum_a + sum_b * sum_a + 1;
	}
	else{
		int ans = 1;
		while(ans <= a){
			if(ans == a) sum_a++;
			else{
				sum_a += slove(a,ans);
			}
			ans += 2;
		}
		sum = sum_a + sum_a * sum_b;
	}
	printf("%lld",sum);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int tree[262145];
int leaves;

int leftBound(int i) {
  while (i < leaves)
    i *= 2;
  return i - leaves;
}

int rightBound(int i) {
  while (i < leaves)
    i = i * 2 + 1;
  return i - leaves;
}

void add(int cur, int left, int right, int val) {
  int leftB  = leftBound(cur);
  int rightB = rightBound(cur);

  if (leftB == left && rightB == right) {
    tree[cur] += val;
    return;
  }

  if (right <= rightBound(cur * 2))
    add(cur * 2, left, right, val);
  else if (left >= leftBound(cur * 2 + 1))
    add(cur * 2 + 1, left, right, val);
  else {
    add(cur * 2, left, rightBound(2 * cur), val);
    add(cur * 2 + 1, leftBound(cur * 2 + 1), right, val);
  }
}

void print(int i) {
  int cur = leaves + i;
  int ans = tree[cur];

  while (cur != 1) {
    cur /= 2;
    ans += tree[cur];
  }

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

int main() {
  int n, q, i, command, x, y, z;

  scanf("%d %d", &n, &q);
  
  for (leaves = 1; leaves < n; leaves *= 2);

  //  printf("n: %d, q: %d, leaves: %d\n", n, q, leaves);

  memset(tree, 0, sizeof(tree));

  for (i = 0; i < q; i++) {
    scanf("%d", &command);

    if (command) {
      scanf("%d", &x);
      //  printf("performing print on %d\n", x);
      print(x - 1);
    } else {
      scanf("%d %d %d", &x, &y, &z);
      //printf("performing add on %d, %d, %d\n", x, y, z);
      add(1, x - 1, y - 1, z);
    }
  }
}



Measured memory_bytes: 2800
from collections import deque
n,q = list(map(int, input().split()))
P = deque([[p,int(t)] for p,t in [input().split() for _ in range(n)]])
time = 0
while len(P) > 0:
    pi = P.popleft()
    if pi[1] > q:
        P.append([pi[0],pi[1]-q])
        time += q
    else:
        time += pi[1]
        print(pi[0],time)

Measured memory_bytes: 24688
S=input()
Q=int(input())
Rev=False
a=[]
b=[]
for _ in range(Q):
    q=list(input().split())
    if len(q)==1:
        Rev=not Rev
    else:
        if q[1]=='1':
            if not Rev:
                a.append(q[2])
            else:
                b.append(q[2])
        else:
            if Rev:
                a.append(q[2])
            else:
                b.append(q[2])
S=''.join(a)[::-1]+S+''.join(b)
if Rev:
    S=S[::-1]
print(S)

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


void solve(std::string S){
    for(int i=0;i<S.size();++i)S[i]='x';
    cout<<S<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

bool prime[1000001];
int fact[1000001];
void sieve(){
    memset(prime,false,sizeof(prime));
    for(int i=0;i<=1000000;i++)
        fact[i]=i;
    for(int i=2;i<=1000000;i++){
        if(!prime[i]){
            for(int j=i*i;j<=1000000;j=j+i){
                prime[j]=true;
                fact[j]=i;
            }
        }
    }
}

int divisorSum(int n) 
{ 
    map<int,int>mp;
    while(n!=1){
        mp[fact[n]]++;
        n=n/fact[n];
    }
    int product=1;
    for(auto x:mp){
        product*=(x.S+1);
    }
    return product;
} 
  

int32_t main()
{
    // fast;
    sieve();
    int n;cin>>n;
    int sum=1;

    for(int i=2;i<=n-1;i++){
        sum+=divisorSum(i);
    }

    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 12420
#include <bits/stdc++.h>
#define Would
#define you
#define please
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n-1; i>0; i--)

using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> A(n + 1), B(n);
	rep(i, n + 1) scanf("%d", &A[i]);
	rep(i, n) scanf("%d", &B[i]);

	long long res = 0;
	rep(i, n) {
		long long left = min(A[i], B[i]);
		res += left;
		A[i] -= left;
		B[i] -= left;

		long long right = min(A[i + 1], B[i]);
		res += right;
		A[i + 1] -= right;
	}
	cout << res << endl;
}

int main(void) {
	solve();
	Would you please return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
#define rep(i, n) for(int i=0;i<n;i++) 
int main(){
	ll n;
	cin>>n;
	vector<int> a(n), b(n);
	rep(i, n) cin>>a[i];
	rep(i, n) cin>>b[i];
	ll sa = 0, sb = 0;
	rep(i, n) sa += a[i];
	rep(i, n) sb += b[i];
	if(sa>sb){
		cout<<"No"<<endl;
		return 0;
	}
	ll t = sb-sa;
	rep(i, n){
		if(a[i]<b[i]) 
			t -= (b[i]-a[i]+1)/2;
	}
	if(t<0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <complex>
#include <vector>
#include <algorithm>
#include <cstdio>
#define sq(n) (n)*(n)
  
typedef std::pair<double, double> point_t;
typedef std::pair<point_t, point_t> points_t;
 
double distance_between(const point_t& a, const point_t& b){
	return sq(b.first-a.first)+sq(b.second-a.second);
}
 
double find_closest_brute(const std::vector<point_t>& points,int xl,int xr){
	int siz=xr-xl;
	if (siz < 2) {
		return 1e9;
	}
	auto minDistance = 1e9;
	for (auto i = xl; i < xr-1; ++i) {
		for (auto j = i + 1; j < xr; ++j) {
			auto newDistance = distance_between(points[i], points[j]);
			if (newDistance < minDistance) {
				minDistance = newDistance;
			}
		}
	}
	return minDistance;
}
 
double find_closest_optimized(
	const std::vector<point_t>& xP,
	int xl,int xr,
	const std::vector<point_t>& yP,
	int yl,int yr
){
	int xsiz=xr-xl;
	int ysiz=yr-yl;
	if (xsiz <= 8) {
		return find_closest_brute(xP,xl,xr);
	}
	if(ysiz==0)return 1e9;
	auto xM = xP[xl+xsiz/2].first;
	auto yL = std::vector<point_t>(ysiz);
	int left = -1, right = ysiz;
	for(int i = yl; i < yr; i++){
		if (yP[i].first < xM) yL[++left] = yP[i];
		else                  yL[--right]= yP[i];
	}
	std::reverse(yL.begin()+right,yL.end());
	auto p1 = find_closest_optimized(xP,xl,xl+xsiz/2,yL,0,left+1);
	auto p2 = find_closest_optimized(xP,xl+xsiz/2,xr,yL,left+1,ysiz);
	auto minD = sqrt((p1 < p2) ? p1 : p2);
	auto yS = std::vector<point_t>();
	std::copy_if(std::begin(yP), std::end(yP), std::back_inserter(yS), [&minD, &xM](const point_t& p) {
		return std::abs(xM - p.first) < minD;
	});
	auto result = minD*minD;
	if(yS.size()>=2)
	for (auto i = std::begin(yS); i != (std::end(yS) - 1); ++i) {
		for (auto k = i + 1; k != std::end(yS) &&
		 ((k->second - i->second) < minD); ++k) {
			auto newDistance = distance_between(*k, *i);
			if (newDistance < result) {
				result = newDistance;
			}
		}
	}
	return result;
}
  
int main(){
	std::vector<point_t> points;
	int i=0,n;
	double x,y;
	for(scanf("%d",&n);i<n;i++){
		scanf("%lf%lf",&x,&y);
		points.emplace_back(x,y);
	}
	std::sort(std::begin(points), std::end(points), [](const point_t& a, const point_t& b) {
		return a.first < b.first;
	});
	auto xP = points;
	std::sort(std::begin(points), std::end(points), [](const point_t& a, const point_t& b) {
		return a.second < b.second;
	});
	auto yP = points;
	auto r = find_closest_optimized(xP,0,n,yP,0,n);
	printf("%.9f\n",sqrt(r));
}

Measured memory_bytes: 27944
defmodule Main do
  def main do
    [a, b] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    a = String.to_integer(a)
    b = String.to_integer(b)
    if a >= 10 do 
    IO.puts(b) 
    else 
    IO.puts(b + 100 * (10 - a)) 
    end
  end
end


Measured memory_bytes: 30680
#include<cmath>
#include<iostream>
#include<algorithm>
#include <string>
#include <stdexcept>
using namespace std; 
int main(){
  int a,b,c,d,e;
 	cin >>a;
if(a%2==0) cout <<a;
  else cout <<a*2;
  	
  
}

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

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

struct Edge {
    int src, dst, capacity;
    Edge(int src, int dst, int capacity): src(src), dst(dst), capacity(capacity) {}
};
using Graph = vector<vector<Edge>>;

void add_edge(Graph& graph, int src, int dst, int capacity) {
    graph[src].emplace_back(src, dst, capacity);
    graph[dst].emplace_back(dst, src, 0);
}

int augment(const Graph& graph, const vector<int>& level,
            vector<vector<int>>& flow, vector<int>& progress,
            int sink, int u, int f) {
    if (u == sink) return f;
    int total = 0, i = progress[u];
    for (; i < (int)graph[u].size(); ++i) {
        auto& e = graph[u][i];
        int residue = e.capacity - flow[e.src][e.dst];
        if (residue > 0 && level[e.src] < level[e.dst]) {
            int aug = augment(graph, level, flow, progress, sink, e.dst, min(f - total, residue));
            flow[e.src][e.dst] += aug;
            flow[e.dst][e.src] -= aug;
            total += aug;
            if (total == f) break;
        }
    }
    progress[u] = i;
    return total;
}

int dinic(const Graph& graph, int source, int sink) {
    vector<vector<int>> flow(graph.size(), vector<int>(graph.size()));
    int total = 0;
    for (;;) {
        // construct level graph
        vector<int> level(graph.size(), -1); level[source] = 0;
        queue<int> Q; Q.push(source);
        while (!Q.empty()) {
            int u = Q.front(); Q.pop();
            if (level[sink] != -1 && level[u] > level[sink]) break;
            for (auto& e : graph[u]) {
                if (level[e.dst] == -1 && e.capacity - flow[e.src][e.dst] > 0) {
                    level[e.dst] = level[e.src] + 1;
                    Q.push(e.dst);
                }
            }
        }
        if (level[sink] == -1) return total;

        // push blocking flow
        vector<int> progress(graph.size());
        total += augment(graph, level, flow, progress, sink, source, INT_MAX);
    }
}

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

    int V, E;
    while (cin >> V >> E) {
        Graph graph(V);
        REP(i, E) {
            int u, v, c; cin >> u >> v >> c;
            add_edge(graph, u, v, c);
        }
        cout << dinic(graph, 0, V-1) << '\n';
    }
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int n,f[2100000];
bool c[30][30];

signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>c[i][j];
		}
	}
	f[0]=1;
	for(int i=1;i<(1<<n);i++){
		int x=i,ans=0;
		while(x!=0){
			if(x%2==1) ans++;
			x/=2;
		}
		for(int j=1;j<=n;j++) if((i&(1<<(n-j)))&&c[n-ans+1][j]){
			f[i]+=f[i^(1<<(n-j))];
			if(f[i]>=MOD) f[i]-=MOD;
		}
	}
	cout<<f[(1<<n)-1]<<endl;
	return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.se >b.se);
    }
    else
        return (a.fi<b.fi);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
ll sumofdigit(ll n)
{
    ll c=0,d=0,sum=0,i;
    while(n>0)
    {
        c=n%10;
        sum+=c;
        n/=10;
    }
    return sum;
}
int main()
{
 fast;
     int t=1;
     //cin>>t;
     while(t--)
     {

      long double k,i=0,j=0,c=0,d=0,e=0,f=0,sum=0,g=0,h=0,n,maxi=0;
       ll s;
       cin>>n>>k;
       c=n*k;
       s=c;
       cout<<s<<endl;

      }


}



Measured memory_bytes: 3744
#include <stdio.h>

int main(void)
{
 int x,y,z,r;

 scanf("%d %d",&x,&y);

 if(x<y){
  z=x;
  x=y;
  y=z;
 }

 while(y>0){
  r=x%y;
  x=y;
  y=r;
 }

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

 return 0;

}

Measured memory_bytes: 1844
#include<stdio.h>
using namespace std;

int main(){
    int r,c;
    scanf("%d%d",&r,&c);
    int matrix[101][101]={};
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            scanf("%d",&matrix[i][j]);
            matrix[i][c] += matrix[i][j];
            matrix[r][j] += matrix[i][j];
            matrix[r][c] += matrix[i][j];
        }
    }
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c+1;j++){
            if(j<c){
                printf("%d ",matrix[i][j]);
            }else{
                printf("%d",matrix[i][j]);
            }
        }printf("\n");
    }
}



Measured memory_bytes: 2724
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	string s;
	cin >> s;
	vector<pair<ll, ll> > vec;
	vector<ll> num(s.length()+1);
	for (int i = 0; i < s.length();){
		for (int j = i; ; j++){
			if (s[j] != s[j+1]){
				if (s[j] == '<') vec.push_back(make_pair(0, j-i+1));
				else vec.push_back(make_pair(1, j-i+1));
				i += j-i+1;
				break;
			}
		}
	}
	ll ans = 0;
	int vs = vec.size();
	if (vec[0].first == 1) ans += vec[0].second*(vec[0].second+1)/2;
	if (vec[vs-1].first == 0) ans += vec[vs-1].second*(vec[vs-1].second+1)/2;
	for (int i = 0; i < vs-1; i++){
		if (vec[i].first == 0 && vec[i+1].first == 1){
			ll big = max(vec[i].second, vec[i+1].second);
			ll small = min(vec[i].second, vec[i+1].second)-1;
			ans += big*(big+1)/2;
			ans += small*(small+1)/2;
		}
	}
	cout << ans << endl;
 	return 0;
 }

Measured memory_bytes: 10744
n, k = map(int, input().split())
mod = 10**9+7

def power(a, n, mod):
    bi=str(format(n,"b")) #2進数
    res=1
    for i in range(len(bi)):
        res=(res*res) %mod
        if bi[i]=="1":
            res=(res*a) %mod
    return res

D = [0]*(k+1)
ans = 0
for i in reversed(range(1, k+1)):
    a = k//i
    d = power(a, n, mod)
    j = 1
    while i*j <= k:
        d -= D[i*j]
        j += 1
    D[i] = d
    ans += (d*i)%mod

print(ans%mod)

Measured memory_bytes: 69292
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		HashMap<Integer,Integer> bingo = new HashMap<>();
		for(int i=0;i<9;i++) {
			bingo.put(sc.nextInt(),i);
		}
		int N=sc.nextInt();
		boolean f[]=new boolean[9],an=false;
		Arrays.fill(f, false);
		for(int i=0;i<N;i++) {
			int t=sc.nextInt();
			if(bingo.containsKey(t)) {
				f[bingo.get(t)]=true;
				bingo.remove(t);
			}
		}
		for(int i=0;i<3;i++) {
			boolean t=true;
			for(int j=0;j<3;j++) {
				if(!f[i*3+j]) {
					t=false;
					break;
				}
			}
			if(t) {
				an=true;
				break;
			}
		}
		if(!an) {
			for (int i=0;i<3;i++) {
				boolean t=true;
				for (int j=0;j<3;j++) {
					if (!f[i+j*3]) {
						t=false;
						break;
					}
				}
				if(t){
					an=true;
					break;
				}
			}
		}
		if(!an) {
			boolean t=(f[0]&&f[8]&&f[4])||(f[2]&&f[4]&&f[6]);
			if(t) an=true;
		}
		System.out.println(an?"Yes":"No");
	}
}

Measured memory_bytes: 35636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n;
  cin >> n;
  vector<int> count(100005, 0);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    int at;
    cin >> at;
    count[at]++;
    sum += at;
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    sum += count[b] * (c - b);
    cout << sum << endl;
    count[c] += count[b];
    count[b] = 0;
  }
}


Measured memory_bytes: 3188
N = int(input())
s12 = [list(input()), list(input())]
index = 0
left_block = None
point_dict = {"X": {"X": 2, "Y": 1}, "Y": {"X": 2, "Y": 3}}
point = 1
n3 = 0
n2 = 0
n1 = 0
while True:
    if index >= N:
        break
    if left_block:
        if s12[0][index] == s12[1][index]:
            now_block = "X"
            index += 1
        else:
            now_block = "Y"
            index += 2
        point *= point_dict[now_block][left_block]
        left_block = now_block
    else:
        if s12[0][0] == s12[1][0]:
            left_block = "X"
            index += 1
            point *= 3
        else:
            left_block = "Y"
            index += 2
            point *= 6

print(point % (10**9 + 7))


Measured memory_bytes: 3064
// https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>
using namespace std;
int n;
typedef vector<int> vi;
typedef vector<vi> vii;
#define rep(i, k, n) for (int i = k; i < (int)(n); i++)
int main()
{
    cin >> n;
    vii hs(n, vi(3));
    rep(i, 0, n)
    {
        cin >> hs[i][0] >> hs[i][1] >> hs[i][2];
    }
    vii dp(n, vi(3));
    dp[0][0] = hs[0][0];
    dp[0][1] = hs[0][1];
    dp[0][2] = hs[0][2];
    rep(i, 1, n)
    {
        rep(j, 0, 3)
        {
            dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + hs[i][j];
        }
    }
    int ans = 0;
    rep(i, 0, 3) ans = max(ans, dp[n - 1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 14076