akhauriyash/Code-Regression huggingface dataset:
k = int(input())

import math

ans = 0
ans += 0.5*k*(k+1)
# print(ans)

for a in range(1, k):
    for b in range(a+1,k+1):
        n = math.gcd(a, b)
        ans += n*6
        for c in range(b+1, k+1):
            if c != b:
                ans += math.gcd(n, c)*6

# for i in range(1, k-1):
#     for j in range(i+1, k):
#         for k in range(j+1, k+1):
#             d = math.gcd(i, j)
#             ans += math.gcd(d, k)*6

print(int(ans))

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

using namespace std;
typedef long long ll;
typedef pair< ll , string > P;



int main(){
	ll n,m;
	ll ac = 0;
	ll wa = 0;
	cin >> n >> m;
	
	vector < bool > rlt( n , 0 );
	vector < int > pena( n, 0 );
	rep( i , m ){ 
		int p;
		string s;
		cin >> p >> s;
		
		p--;
		if( rlt.at( p ) == 1) continue;
		
		if( s =="AC"){
			rlt.at( p ) = 1;
		}
		else{
			pena.at( p )++;
		}
	}
	rep( i , n ){
		ac += rlt[ i ];
		
		if(rlt[ i ]){
		wa += pena[ i ];
		}
	}
	cout << ac << " " << wa;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
string s,t;
void input()
{
      cin>>s>>t;
}
void result()
{
    t.pop_back();
    if(s==t){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}
int main()
{
    input();
    result();
    return 0;
}


Measured memory_bytes: 3608
program making_palindrome
  implicit none
  integer(8), parameter :: inf = 1e18
  integer :: n, i, l
  character(20) :: s(50, 0:1) = ''
  integer(8) :: c(50) = 0, m(50, 21, 0:1) = 0, x = inf
  logical :: u(50, 21, 0:1) = .false.
  read(*,*) n
  do i = 1, n
    read(*,*) s(i, 0), c(i)
    l = len_trim(s(i, 0))
    s(i, 1)(1:l) = reverse(s(i, 0)(1:l))
  end do
  do i = 1, n
    x = min(x, solve(i, 1, 0) + c(i))
  end do
  write(*,'(i0)') merge(x, -1_8, x < inf)
contains
  function reverse(s) result(res)
    character(*), intent(in) :: s
    character(len_trim(s)) :: res
    integer :: n, i
    n = len_trim(s)
    do i = 1, n
      res(i:i) = s(n - i + 1:n - i + 1)
    end do
  end
  recursive integer(8) function solve(i, j, k) result(res)
    integer, intent(in) :: i, j, k
    integer :: l, r, t, l1, l2, h
    logical :: f
    res = m(i, j, k)
    if (u(i, j, k)) return
    u(i, j, k) = .true.
    m(i, j, k) = inf
    l = j
    r = len_trim(s(i, k))
    f = .true.
    do while (l < r)
      if (s(i, k)(l:l) /= s(i, k)(r:r)) then
        f = .false.
        exit
      end if
      l = l + 1
      r = r - 1
    end do
    if (f) then
      m(i, j, k) = 0
      res = 0
      return
    end if
    l1 = len_trim(s(i, k))
    h = xor(k, 1)
    do t = 1, n
      l = j
      r = 1
      l2 = len_trim(s(t, 1 - k))
      do while (l <= l1 .and. r <= l2)
        if (s(i, k)(l:l) /= s(t, h)(r:r)) exit
        l = l + 1
        r = r + 1
      end do
      if (l == l1 + 1) then
        m(i, j, k) = min(m(i, j, k), solve(t, r, h) + c(t))
      end if
      if (r == l2 + 1) then
        m(i, j, k) = min(m(i, j, k), solve(i, l, k) + c(t))
      end if
    end do
    res = m(i, j, k)
  end
end program making_palindrome

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

#define uint        unsigned int
#define ld          long double
#define int         long long
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        400005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int md = 998244353;

/*const int mod = 998244353;
int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}
*/


signed main()
{
    showoff;
    int n,k;
    cin >> n >> k;
    vector<int>v(n+5);
    FOR(i,0,n)cin >> v[i];
    int ans = 0;
    RFOR(i,50,-1){
    int cnt = 0;
    FOR(j,0,n){
        if(v[j]&(1LL<<i))++cnt;
    }
    if(cnt < (n+1)/2){
        if(ans+(1LL<<i) <= k)ans += (1LL<<i);
    }
    }
    int tot = 0;
    FOR(i,0,n)tot += ans^v[i];
    cout << tot << "\n";
    return 0;
}
//*->for large size of matrix take int not long long ......


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
#include<stack>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define MAX 100000
typedef long long ll;
int main(){
	//連結リストを作る
	int n,m;	//user_num, relation
	cin >> n>>m;
	vector<int> G[n];

	int a,b;
	rep(i,m){
	cin >> a>>b;
	G[a].push_back(b);
	G[b].push_back(a);
	}

	//色を塗っていく
	//初期化。全て0
	int color[MAX] = {};
	int id = 1;

	rep(i,n){
	if(!color[i]) {
	
	stack<int> S;
	S.push(i);	
	color[i] = id;

	while(!S.empty()){
	int v = S.top(); S.pop();

	rep(j,G[v].size()){
	int u = G[v][j];
	if(!color[u]){
	color[u] = id;
	S.push(u);
	}
	}
	}
	}
	id++;
	}	
	
	int q,c,d;
	cin >> q;
	rep(i,q){
	cin >> c >> d;

	if (color[c]==color[d]){
	cout << "yes" << endl;
	}
	else
	cout << "no" << endl;
	}
	return 0;
}



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

int dp[201][201], d, n, t[201], a[201], b[201], c[201], mx = 0;

int abs(int x, int y)
{
	if (x >= y) return x - y;
	else return y - x;
}

int main()
{
	cin >> d >> n;
	for (int i = 1; i <= d; i++){
		cin >> t[i];
	}
	for (int i = 1; i <= n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	memset(dp, -1, sizeof dp);

	for (int i = 1; i <= n; i++){
		if (a[i] <= t[1] && t[1] <= b[i]){
			dp[1][i] = 0;
		}
	}

	//dp
	for (int today = 2; today <= d; today++){
		for (int n2 = 1; n2 <= n; n2++){
			for (int n1 = 1; n1 <= n; n1++){
				if (dp[today - 1][n1] == -1) continue;
				if (a[n2] > t[today] || t[today] > b[n2]) continue;
				dp[today][n2] = max(dp[today][n2], dp[today - 1][n1] + abs(c[n1], c[n2]));
			}
		}
	}

	for (int i = 1; i < n; i++){
		mx = max(dp[d][i], mx);
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 1328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    map<string,int> mp;
    int t;
    cin>>t;
    while(t--)
    {
        string ch;
        cin>>ch;
        mp[ch]++;
    }
    cout<<"AC"<<" x "<<mp["AC"]<<endl;
    cout<<"WA"<<" x "<<mp["WA"]<<endl;
    cout<<"TLE"<<" x "<<mp["TLE"]<<endl;
    cout<<"RE"<<" x "<<mp["RE"]<<endl;

    return 0;
}


Measured memory_bytes: 3636
import random


d = int(input())
c = list(map(int,input().split()))
s = []

class field:
    def __init__(self):
        self.ans = [-1 for i in range(365)]
        self.last = [-1 for i in range(26)]


    def score_day(self,day,type):
        inc = s[day][type]
        dec = 0
        for i in range(26):
            dec += c[i]*(day-self.last[i])

        return  inc-dec


for i in range(d):
    arr = list(map(int,input().split()))
    s.append(arr)

best_score = 0
alloc = []

F = field()
ans = 0
good = []
childs = 50
for day in range(d):
    if day == 0:
        tp_scores = []
        for j in range(25):
            prob = j
            befl = F.last[prob]
            F.last[prob] = day
            sc = F.score_day(day, prob)
            tp_scores.append([-sc, j,F.last.copy(),str(j)])

            F.last[prob] = befl

        tp_scores.sort()
        good = tp_scores
    else:
        tp_scores = []
        for i in range(min(childs,len(good))):
            befs = good[i][0]
            befp = good[i][1]
            befl = good[i][2]
            befa = good[i][3]
            F.last = befl
            for j in range(25):
                prob = j
                bt = F.last[prob]
                F.last[prob] = day
                sc = F.score_day(day,prob)
                tp_scores.append([befs-sc,j,F.last.copy(),befa+","+str(j)])

                F.last[prob] = bt

        tp_scores.sort()
        good = tp_scores[:childs]

# print(good[0])


# for g in good:
#     tp = 0
#     root = list(map(int,g[-1].split(",")))
#     F = field()
#     for i in range(len(root)):
#         F.ans[i] = root[i]
#         F.last[root[i]] = i
#         tp += F.score_day(i,root[i])
#     print(root,tp)

# print("bestscore:"+str(best_score))

root = map(int,good[0][-1].split(","))

for r in root:
    print(r+1)


Measured memory_bytes: 187860
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> a(n);
    for (int &x : a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
        sum += a[i];
    }
    cout << (a[n - 1] < sum ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int n, w;
		cin >> n >> w;
		ll dp[n + 1][w + 1], wt[n + 1], val[n + 1];
		for (int i = 0; i < n; i++) cin >> wt[i + 1] >> val[i + 1];
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= w; j++) {
				if (i == 0 || j == 0) dp[i][j] = 0;
				else if (wt[i] > j) dp[i][j] = dp[i - 1][j];
				else dp[i][j] = max(val[i] + dp[i - 1][j - wt[i]], dp[i - 1][j]);
			}
		}
		cout << dp[n][w] << '\n';
	}
	return 0;
}

Measured memory_bytes: 82504
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t; using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define v(t,n) vector<t> n
void _din() {} void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void vsortg(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }
template <typename T>inline void vsortl(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> inline T nmax(T f1, T f2) { return max(f1, f2); }
template <typename T, typename ... Args> inline T nmax(T first, Args ... rest) { return nmax(first, nmax(rest...)); }
template <typename T> inline T nmin(T f1, T f2) { return min(f1, f2); }
template <typename T, typename ... Args> inline T nmin(T first, Args ... rest) { return nmin(first, nmin(rest...)); }
// ==================================================
int main()
{
	din(int, x);

	dout(x == 3 || x == 5 || x == 7 ? "YES" : "NO");
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int MOD = 998244353;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll fact[200005];
ll invFact[200005];

ll C(ll n, ll r){
	if(r > n) return 0;
	ll ret = fact[n];
	ret = ((ret * invFact[n - r]) + MOD) % MOD;
	ret = ((ret * invFact[r]) + MOD) % MOD;
	return ret;
}

ll mypow(ll a, ll p){
	if(p == 0) return 1;
	if(p == 1) return (a % MOD);
	if(p & 1) return ((a % MOD) * (mypow(a, p - 1) % MOD)) % MOD;
	ll x = mypow(a, p / 2) % MOD;
	return (x * x) % MOD;
}

ll inv(ll base){
	return mypow(base, MOD - 2);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, m, k;
	cin >> n >> m >> k;
	fact[0] = 1;
	invFact[0] = 1;
	for(ll i = 1; i < 200005; i++){
		fact[i] = (1LL * fact[i - 1] * i) % MOD;
		invFact[i] = inv(fact[i]);
	}
	//mypow(m - 1, n - 1) * mypow(m, i) for i in range(1, k + 2)
	ll ans = 0;
	for(ll i = 0; i <= k; i++){
		ans += (m * (mypow(m - 1, n - i - 1) * C(n - 1, n - i - 1) % MOD) % MOD);
		ans %= MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n;
vector<lint> a;
vector<lint> sum;
lint memo[401][401];

lint solve(int left, int right){
    if(left + 1 == right){
        return 0;
    }
    if(memo[left][right] >= 0){
        return memo[left][right];
    }
    lint res = LLINF;
    for(int mid = left + 1 ; mid < right ; ++mid){
        res = min(res, solve(left, mid) + solve(mid, right));
    }
    res += sum[right] - sum[left];
    return memo[left][right] = res;
}

int main(){
    cin >> n;
    a.resize(n);
    rep(i, n){
        cin >> a[i];
    }
    sum.resize(n + 1);
    sum[0] = 0;
    REP(i, 1, n + 1){
        sum[i] = sum[i - 1] + a[i - 1];
    }
    fill(memo[0], memo[401], -1);
    lint ans = solve(0, n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define pr(x) cout<<#x<<" "<<x;
#define pl(x) cout<<#x<<" "<<x<<endl;
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_set>
using namespace std;
map <string, int> dp;
int direction[4] = { 1, -1, 4, -4 };
void bfs(){
    queue <string >que;
    que.push("01234567");
    dp["01234567"] = 0;
    while(que.size()){
        string now = que.front();
        que.pop();
        int index = 0;
        for(int i = 0;i<8;i++){
            if(now[i] =='0'){
                index = i;
                break;
            }
        }
        for(int i =0;i<4;i++){
            int n = index + direction[i];
            if(n>=0&&n<8&&!(index==3&&i==0)&&!(index==4&&i==1)){
                string next = now;
                swap(next[n],next[index]);
                if(dp.find(next)==dp.end()){
                    dp[next] = dp[now]+1;
                    que.push(next);
                }
            }
        }
    }

}



int main(){
    bfs();
	string line = "00000000";
	int base[8];
	while (cin>>base[0]>>base[1]>>base[2]>>base[3]>>base[4]>>base[5]>>base[6]>>base[7])
	{
		for(int i=0;i<8;i++){
            line[i] = base[i]+'0';
		}

		cout << dp[line] << endl;
	}

	return 0;


}

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

int main() {
	int n, m;
	cin >> n >> m;
	int n_arr[100][100] = { 0 };
	int m_arr[100] = { 0 };
	int sum[100] = { 0 };

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> n_arr[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> m_arr[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			sum[i] += n_arr[i][j] * m_arr[j];
		}
		cout << sum[i] << endl;
	}
}




Measured memory_bytes: 3128
def get_score(enemy_hand):
    return {"r": P, "s": R, "p": S}[enemy_hand]


N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

enemy_hands = [[] for _ in range(K)]
for i in range(N):
    enemy_hands[i % K].append(T[i])

score = 0
for hands in enemy_hands:
    succession = {"r": [], "s": [], "p": []}
    current = hands[0]
    streak = 0
    for hand in hands:
        if hand == current:
            streak += 1
        else:
            succession[current].append(streak)
            streak = 1
            current = hand
    else:
        succession[current].append(streak)
    for k, v in succession.items():
        for streak in v:
            score += ((streak + 1) // 2) * get_score(k)

print(score)


Measured memory_bytes: 13436
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#define md double
#define LL long long
using namespace std;
const int N=1e6;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int str[N];
int nxt[N][27],ST[N][21];
int main()
{
	int n=0,i,m,t,l,r;char c;
	while ((c=getchar())<'a'||'z'<c);
	while ('a'<=c&&c<='z') str[++n]=c-'a',c=getchar();
	for (i=n;i;i--) {
		nxt[i][str[i]]=i+1;
		for (t=str[i];t<26;t++) nxt[i][t+1]=nxt[nxt[i][t]][t];
		for (t=0;t<str[i];t++) nxt[i][t]=nxt[nxt[i][26]][t];
		ST[i][0]=nxt[i][26];
	}
	for (t=0;t<20;t++) for (i=n-(1<<(t+1))+1;i>0;i--) ST[i][t+1]=ST[ST[i][t]][t];
	m=gi();
	while (m--) {
		l=gi(),r=gi()+1;
		for (t=0;ST[l][t]&&ST[l][t]<=r;t++);
		while (--t>=0) if (ST[l][t]&&ST[l][t]<=r) l=ST[l][t];
		puts(l==r?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 100992
#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;}
*/

const ll MOD = 1000000007;
const ll INF = 9999999999;

bool check(int N, string S, vector<int> &A){
  // Sは動物の回答結果、Aは各々が何の動物か。
  // A.at(0)とA.at(N-1)は予め決定されている。
  for (int i=0; i<N-2; i++){
    int pre = A.at((N+i-1)%N), next = -1;
    char c = S.at(i);
    if (A.at(i) == 1){
      if (c=='o') next = pre;
      else next = 1-pre;
    }else{
      if (c=='o') next = 1-pre;
      else next = pre;
    }
    A.at(i+1) = next;
  }
  // N-2まで全部埋まった。あとはN-2マンとN-1マンの回答の整合性を確認する
  for (int i=N-2; i<=N-1; i++){
    int pre = A.at(i-1), next = -1;
    char c = S.at(i);
    if (A.at(i) == 1){
      if (c=='o') next = pre;
      else next = 1-pre;
    }else{
      if (c=='o') next = 1-pre;
      else next = pre;
    }
    if (A.at((i+1)%N) != next) return false;
  }
  return true;
}

int main() {
  int N; cin >>N;
  string S; cin >>S;
  vector<int> A(N, -1); // i番目の動物の種類を格納。羊：1、狼：0、未決定：-1
  bool ok = false;
  for (int i=0; i<4; i++){
    A.at(0) = i/2, A.at(N-1) = i%2;
    // 00, 01, 10, 11の四通りある
    ok = check(N, S, A);
    if (ok) break;
    A.assign(N, -1);
  }
  if (ok){
    for (int i=0; i<N; i++){
      if (A.at(i) == 1) cout <<"S";
      else cout <<"W";
    }
    cout <<endl;
  }else{
    cout <<-1 <<endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(){
    int n,m,c;cin>>n>>m>>c;
    cout<<max(0,c-(n-m))<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;


int main()
{
	long N;
	cin >> N;
	
	long A[N];
	for(long n = 0; n < N; n++){
		cin >> A[n];
	}
	
	bool can = true;
	long ans = 0;
	while(can){
		for(long i = 0; i < N; i++){
			if(A[i] % 2 == 0) A[i] /= 2;
			else can = false;
		}
		ans++;
	} 	

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,K;
long mod=1e9+7;
long F[4040],I[4040];
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long H(long a,long b)
{
	if(a==0&&b==0)return 1;
	if(a+b-1<0||a-1<0||b<0||a+b-1<b)return 0;
	return F[a+b-1]*I[a-1]%mod*I[b]%mod;
}
main()
{
	F[0]=1;
	for(int i=1;i<4040;i++)F[i]=F[i-1]*i%mod;
	I[4039]=power(F[4039],mod-2);
	for(int i=4039;i--;)I[i]=I[i+1]*(i+1)%mod;
	cin>>N>>K;
	for(int i=1;i<=K;i++)
	{
		long ans=0;
		for(int x=0;x<=N-K;x++)
		{
			ans=(ans+(N-K-x-i+1<0?0:H(i,K-i)*H(i-1,N-K-x-i+1)%mod*(x+1)%mod))%mod;
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main()
{
    cin>>s>>t;
    int ans=0;
    int l=s.length();
    for(int i=0;i<l;i++){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3852
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    //(A*x/B)-A*(x/B)
    int A,B,N;
    cin>>A>>B>>N;
    if(B-1>N) cout<<(A*N/B)-A*(N/B)<<endl;
    else cout<<(A*(B-1)/B)-A*((B-1)/B)<<endl;
    return 0;
    for(int i=1;i<100;i++){
        cout<<(A*i/B)-A*(i/B)<<endl;
    }
    /* 5 7 4
0
1
2
2
3
4
0
0
1
2
2
3
4
0*/
}


Measured memory_bytes: 3188
#include <stdio.h>
#define MAX 101
#define INFINITY 1048576
#define WHITE -1
#define GRAY 0
#define BLACK 1
#define true 1

int serch(int);

int M[MAX][MAX];

int main(){
  int n,i,j,x,y;

  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      scanf("%d",&M[i][j]);
      if(M[i][j]==-1) M[i][j]=INFINITY;
    }
  }
  printf("%d\n",serch(n));
  return 0;
}

int serch(int n){
  int u, v, min, i, j, d[MAX], p[MAX], c[MAX], sum = 0;

  for(i = 1; i <= n; i++){
    c[i] = WHITE;
    d[i] = INFINITY;
    p[i] = -1;
  }
  p[1] = -1;
  d[1] = 0;

  while(true){
    min = INFINITY;
    u = -1;
    for(i = 1; i <= n; i++){
      if(min > d[i] && c[i] != BLACK){
        u = i;
        min = d[i];
      }
    }
    if(u == -1) break;
    c[u] = BLACK;
    for(v= 1; v <= n; v++) {
      if(c[v] != BLACK && M[u][v] != INFINITY){
        if(d[v] > M[u][v]) {
          d[v] = M[u][v];
          p[v] = u;
          c[v] = GRAY;
        }
      }
    }
  }
  for(i = 1; i <= n; i++){
    sum += d[i];
  }
  return sum;
}



Measured memory_bytes: 2088
#include<bits/stdc++.h>
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
typedef long long ll;
inline int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}

inline void file(){
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
}

using namespace std;
const int maxn=1e5+10;
ll a[maxn],b[maxn];

int main(){
	//file();
	ll k,n,h;
	//scanf("%lld%lld",&n,&h);
	cin>>n>>h;
	for(register int i=1;i<=n;++i)
		cin>>a[i]>>b[i];

	sort(a+1,a+n+1);
	for(register int i=1;i<=n;++i)
		b[i]=max(b[i],a[n]);
	sort(b+1,b+n+1);

	ll ovo=0;
	for(register int i=n;i>=1;--i){
		ovo+=b[i];
		if(ovo>=h){
			printf("%lld",n-i+1);
			return 0;
		}
	}
	int ans=n;
	ans+=(h-ovo)/a[n];
	if((h-ovo)%a[n] > 0)
		++ans;
	cout<<ans;
	return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>

using namespace std;
int main() {
    int N,M,i,t;
    vector<int> nums;
    cin>>N>>M;
    for(i=0;i<M;i++){
        cin>>t;
        nums.push_back(t);
    }
    sort(nums.begin(),nums.end());
    vector<int> dp(M);
    for(i=0;i<M-1;i++){
        dp[i]=nums[i+1]-nums[i];
    }
    sort(dp.begin(),dp.end(),greater<int>());
    int ans=0;
    for(i=N-1;i<M;i++){
        ans+=dp[i];
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int main(){
    int n;
    long long result = 0;
    string s;
    long long r = 0, g = 0, b = 0;
    cin >> n >> s;
    for(auto c:s){
        if(c == 'R')r++;
        else if(c == 'G')g++;
        else b++;
    }
    for(int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            if(s[i] != s[j]){
                int k = 2 * j - i;
                if(k >= n|| s[i] == s[k] || s[j] == s[k]) continue;
                result++;
            }
        }
    }

    cout << r * g * b - result << endl;
    return 0;
}


Measured memory_bytes: 3628
// CODE © by 𝕌𝕥𝕜𝕒𝕣𝕤𝕙 𝔾𝕒𝕣𝕘
// Copying or sharing of this code without permission of the Author is strictly prohibited!!!
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Speed ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define endl "\n"
int arr[1001][1001], dp[1001][1001];
const int mod = 1e9 + 7;
int f(int i, int j, int n, int m) {
	// cout << "at " << i << " " << j << "avl is " << arr[i][j] << endl;
	if (i == n - 1 && j == m - 1) {return 1;}
	if (i == n || i < 0 || j == m || j < 0 || arr[i][j] == -1)return 0;
	int ans = 0;
	if (i < n - 1 && dp[i + 1][j] != -1)ans = (ans + dp[i + 1][j]) % mod;
	else if (i < n - 1) {dp[i + 1][j] = f(i + 1, j, n, m); ans = (ans + dp[i + 1][j]) % mod;}
	if (j < m - 1 && dp[i][j + 1] != -1)ans = (ans + dp[i][j + 1]) % mod;
	else if (j < m - 1) {dp[i][j + 1] = f(i, j + 1, n, m); ans = (ans + dp[i][j + 1]) % mod;}
	return ans;
}
signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif
	int a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0, t = 0, n = 0, q = 0, m;
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < m; j++)arr[i][j] = (s[j] == '.' ? 0 : -1);
	}
	// arr[n - 2][m - 1] = 1; arr[n - 1][m - 2] = 1;
	cout << f(0, 0, n, m);
}

Measured memory_bytes: 19320
h, w = map(int, input().split())
array = [input() for i in range(h)]


def delete(array):
    for i in range(len(array) - 1, -1, -1):
        if ''.join(list(set(list(array[i])))) == '.':
            del array[i]

delete(array)
array = list(map(list, zip(*array)))
delete(array)
array = list(map(list, zip(*array)))

for i in range(len(array)):
    print (''.join(array[i]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

void solve(){
    while(1){
        ll h;cin>>h;
        if(h==0)return;

        vvl a(h,vl(5));
        rep(i,h)rep(j,5)cin>>a[i][j];
        ll ans=0;
        while(1){
            ll tmp=0;
            rep(i,h)rep(j,5){
                if(a[i][j]==0)continue;
                ll k=j;
                while(k<4&&a[i][k+1]==a[i][j])k++;
                if(k-j>=2){
                    tmp+=a[i][j]*(k-j+1);
                    fore(l,j,k)a[i][l]=0;
                }
                j=k;
            }
            if(tmp==0)break;
            ans+=tmp;
            rep(i,5){
                ll idx=h-1;
                rrep(j,h){
                    if(a[j][i]){
                        if(j!=idx){
                            a[idx][i]=a[j][i];
                            a[j][i]=0;
                        }
                        idx--;
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
}

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



Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        String str = scn.next();
        int q = scn.nextInt();

        for(int i=0;i<q;i++){
            String order = scn.next();
            if(order.equals("print")){
                int a = scn.nextInt();
                int b = scn.nextInt();

                System.out.println(str.substring(a,b+1));
            }
            if(order.equals("reverse")){
                int a = scn.nextInt();
                int b = scn.nextInt();

                StringBuffer reverse = new StringBuffer(str.substring(a,b+1));
                String nre1 = str.substring(0,a);
                String nre2 = str.substring(b+1,str.length());
                String re = reverse.reverse().toString();

                str = nre1 + re + nre2;

            }
            if(order.equals("replace")){
                int a = scn.nextInt();
                int b = scn.nextInt();
                String rep = scn.next();

                String nre1 = str.substring(0,a);
                String nre2 = str.substring(b+1,str.length());

                str = nre1 + rep + nre2;

            }


        }


        scn.close();
    }

}


Measured memory_bytes: 29992
/************************************************************************/
/****															*********/
/****                          Writer:孙~~                      *********/
/****                            Lang:C++                       *********/
/****                          Status:Unknow                    *********/
/****															*********/
/************************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
#define debug(...) if(debug) printf(__VA_ARGS__)
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=100005;
const bool debug=false;

int dp[SIZE];
vector<int> mp[SIZE];
int dig[SIZE];

int n;

void visit(int p,int f){
	int s=0,cnt=0;
	for(int i=0;i<mp[p].size();i++){
		int u=mp[p][i];
		if(u==f) continue;
		visit(u,p);
		if(dp[u]==0) cnt++;
		s+=dp[u];
	}
//	if(p==1) debug("%d\n",leave);
	dp[p]=s+max(0,cnt-1);
}

int main(){
	scanf("%d",&n);
	for(int a,b,i=0;i<n-1;i++){
		scanf("%d",&a);
		scanf("%d",&b);
		mp[a].push_back(b);
		mp[b].push_back(a);
		dig[a]++;
		dig[b]++;
	}
	int root=-1,mx=0;
	for(int i=0;i<n;i++){
		if(dig[i]>mx) root=i,mx=dig[i];
	}
	if(mx<=2){
		puts("1");
		return 0;
	}
	visit(root,-1);
	for(int i=0;i<n;i++) debug("%d ",dp[i]);
	debug("\n");
	printf("%d\n",dp[root]);
	return 0;
}


Measured memory_bytes: 12544
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	string s; int y, m, d;
	while (cin >> s, s != "#") {
		cin >> y >> m >> d;
		d += m * 100;
		if (y > 31 ||(y == 31 && d > 500)) cout << "? " << y - 30;
		else cout << "HEISEI " << y;
		cout << ' ' << m << ' ' << d % 100 << endl;
	}
}


Measured memory_bytes: 3240
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		String S = in.nextLine();
		char[] chars = S.toCharArray();
		
		char c0 = chars[0];
		char c1 = chars[1];
		char c2 = chars[2];
		char c3 = chars[3];
		
		if(c0==c1&&c2==c3&&c0!=c2) {
			System.out.println("Yes");
		}else if(c0==c2&&c1==c3&&c0!=c1) {
			System.out.println("Yes");
		}else if(c0==c3&&c1==c2&&c0!=c1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		in.close();
	}
}


Measured memory_bytes: 23764
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] a = new int[h];
        int[] b = new int[w];
        HashMap<Long, Integer> c = new HashMap<>();
        
        for(int i=0; i<m; i++){
            int y = Integer.parseInt(sc.next())-1;
            int x = Integer.parseInt(sc.next())-1;
            a[y]++;
            b[x]++;
            long key = ((long)y<<32)+x;
            c.put(key, c.getOrDefault(key, 0)+1);
        }
        
        //bをソートするべき？
        long[] d = new long[w];
        for(int i=0; i<w; i++){
            d[i] = ((long)b[i]<<32) + i;
        }
        Arrays.sort(d);
        for(int i=0; i<w/2; i++){
            long tmp = d[i];
            d[i] = d[w-i-1];
            d[w-i-1] = tmp;
        }
        
        int max = 0;
        for(int i=0; i<w; i++){
            if((d[0]>>32) != (d[i]>>32)){
                break;
            }
            max++;
        }
        
        //System.out.println(max);
        
        long ans = 0;
        
        for(int i=0; i<h; i++){
            for(int j=0; j<max; j++){
                long res = (d[j]>>32) + a[i];
                if(res <= ans){
                    break;
                }
                long key = ((long)i<<32) + (int)d[j];
                if(c.getOrDefault(key, 0) > 0){
                    res--;
                }
                ans = Math.max(ans, res);
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 93352
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	p := make(permutation, 0)
	p.dfs(0, n, 0, make([]int, n))
	for _, aa := range p {
		for i := 0; i < n; i++ {
			if i > 0 {
				fmt.Fprint(writer, " ")
			}
			fmt.Fprint(writer, aa[i])
		}
		fmt.Fprintln(writer, "")
	}
}

type permutation [][]int

func (p *permutation) dfs(i, n int, used uint32, aa []int) {
	if i == n {
		a := make([]int, n)
		for j := 0; j < n; j++ {
			a[j] = aa[j]
		}
		*p = append(*p, a)
		return
	}
	for j := 0; j < n; j++ {
		if used>>uint(j)&1 == 1 {
			continue
		}
		aa[i] = j + 1
		p.dfs(i+1, n, used|(1<<uint(j)), aa)
	}
}



Measured memory_bytes: 74904
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;

using ll=long long;

template <typename T>
T in(){
    T x;
    cin >> x;
    return x;
}

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

main(){
    string s=in<string>(),t=in<string>();
    cout << t << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int i,j,num;
	
	while(scanf("%d",&n)&&n!=0){
		num=0;
		for(i=1;i*i<n;i++){
			if(n%i==0) num=num+i+n/i;
		}
		num-=n;
		if(num==n){
			printf("perfect number\n");
		}
		else if(num>n){
			printf("abundant number\n");
		}
		else {
			printf("deficient number\n");
		}
	}
	return 0 ;
}

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

int v[105];

int main(){
    int n, m, x;
    cin >> n >> m >> x;

    for(int i = 0; i < m; i++){
        int t;
        cin >> t;
        v[t] = 1;
    }

    int c1, c2;

    c1 = 0;
    int a = x;
    while(a < n){
        c1 += v[a+1];
        a++;
    }

    c2 = 0;
    a = x;
    while(a > 0){
        c2 += v[a-1];
        a--;
    }

    printf("%d\n", min(c1,c2));
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  sort(a,a+n);
  ll p=0; //the first positive index of a
  while(a[p]<=0)p++;
  if(n==2){
    cout << a[1]-a[0] << endl;
    cout << a[1] << ' ' << a[0] << endl;
    return 0;
  }
  if(p==0){
    int ans=0;
    rep(i,n){
      if(i==0)ans-=a[i];
      else ans+=a[i];
    }
    cout << ans << endl;
    for(int i=1;i<n-1;i++){
      cout << a[0] << ' ' << a[i] << endl;
      a[0]-=a[i];
    }
    cout << a[n-1] << ' ' << a[0] << endl;
    return 0;
  }
  if(p==n){
    ll ans=0;
    rep(i,n){
      if(i==n-1)ans+=a[i];
      else ans-=a[i];
    }
    cout << ans << endl;
    for(int i=0;i<n-1;i++){
      cout << a[n-1] << ' ' << a[i] << endl;
      a[n-1]-=a[i];
    }
    return 0;
  }
  ll ans=0;
  rep(i,n){
    if(a[i]<0)ans-=a[i];
    else ans+=a[i];
  }
  cout << ans << endl;
  for(int i=p;i<n-1;i++){
    cout << a[0] << ' ' << a[i] << endl;
    a[0]-=a[i];
  }
  for(int i=1;i<p;i++){
    cout << a[n-1] << ' ' << a[i] << endl;
    a[n-1]-=a[i];
  }
  cout << a[n-1] << ' ' << a[0] << endl;
return 0;}

Measured memory_bytes: 2688
//https://atcoder.jp/contests/abc052/tasks/arc067_a
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

//Ｏ(√n)
//素因数分解(map<int,int>を引数とする)
map<int, int> prime_factor(int n, map<int, int> res){
	for (int i = 2; i * i <= n; i++){
		if (n % i == 0){
			while (n % i == 0){
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}

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

	int N;
	cin >> N;
	map<int, int> m;
	
	for (int i = 2; i <= N; i++) {
		m = prime_factor(i, m);
	}

	int ans = 1;

	for (auto tmp:m){
		ans *= tmp.second + 1;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> a(N),b(N),c(N);
    rep(i,N) cin>>a[i]>>b[i]>>c[i];

    vector<vector<int>> dp(N,vector<int>(3,0));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i=1; i<N; i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
    }

    int ans = max({dp[N-1][0], dp[N-1][1], dp[N-1][2]});
    cout << ans << endl;
}


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

#define ll long long int 
#define ull unsigned long long
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i)) 
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



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

int main()
{
	_fastio
	string s,t;
	cin>>s>>t;
	bool flag=true;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
			flag=false;
	}
	if(flag)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	scanInit()

	n := nextInt()
	l := make([]int, 2*n)

	for i := 0; i < 2*n; i++ {
		l[i] = nextInt()
	}
	sort.Ints(l)

	gusum := 0
	for i := 2*n - 1; i > 0; i -= 2 {
		gusum += l[i-1]
	}

	fmt.Println(gusum)
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1800
from math import gcd
k = int(input())
d = 0
for a in range(1, k+1):
    for b in range(a+1, k+1):
        for c in range(b+1, k+1):
            d += 6*gcd(a, gcd(b, c))

for a in range(1, k+1):
    for b in range(a+1, k+1):
        d += 6*gcd(a,b)

for a in range(1, k+1):
    d += a
print(d)

Measured memory_bytes: 9112
//print a Rectangle

#include<stdio.h>

int main()
{
	int i,j,k,a[100][2],count;

	i=0;	

	while(1){			//a[i][0]:hight a[i][1]:wide

		start:
		scanf("%d %d",&a[i][0],&a[i][1]);
		if ( a[i][0]>300 || a[i][1]>300)
			goto start;


		if(a[i][0]==0 && a[i][1]==0)
			break;

		i++;
	
	}
	
	count=i;
		
	for(i=0;i<count;i++){
		for(j=0;j<a[i][0];j++){
			
			if(j%2==1){
				for(k=0;k<a[i][1];k++){
					if(k%2==1)
						printf("#");
					else							
						printf(".");
				}
			}else{
				for(k=0;k<a[i][1];k++){
					if(k%2==1)
						printf(".");
					else							
						printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}
	

Measured memory_bytes: 572
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;

}

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b>>c>>d>>e>>k;
  
  if(e-a <= k){
   cout << "Yay!" <<endl;
  }
  else{
   cout << ":("<<endl; 
  }
  
  
}

Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let d = v[0];
	let n = v[1];
	match d {
		0 => {
			if n == 100 {
				println!("101");
			}else{
				println!("{}", n);
			}
		},
		1 => {
			if n == 100 {
				println!("10100");
			}else{
				println!("{}", 100*n);
			}
		},
		2 => {
			if n == 100 {
				println!("1010000");
			}else{
				println!("{}", 10000*n);
			}
		}
		_ => (),
	}
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, max=0, sum=0;
	int h[100];
	
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> h[i];
		if(h[i]>=max) {
			sum++; 
			max = h[i];
		}
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 256
import bisect
n,m = map(int,input().split())

def c(x):
    x += 1000000
    x = list(str(x))
    del x[0]
    return x

x = [[] for i in range(n)]
jkl = []

for i in range(m):
    p,y = map(int,input().split())
    x[p-1].append(y)
    jkl.append([p,y])
for i in range(n):
    x[i].sort()

for i in range(m):
    p = jkl[i][0]
    y = jkl[i][1]
    k = bisect.bisect(x[p-1],y)
    ass = ''
    r = c(p)
    q = c(k)
    for i in range(6):
        ass += r[i]
    for i in range(6):
        ass += q[i]
    print(ass)

Measured memory_bytes: 32760
#include<bits/stdc++.h>
using namespace std;
#define M 1000000000
typedef long long int ll;

int main(){

	int a, b, k;
	cin >> k >> a >> b;
	if(a%k == 0 || b%k == 0)
		cout << "OK\n";
	else if(a/k == b/k)
		cout << "NG\n";
	else
		cout << "OK\n";

	return 0;
}

Measured memory_bytes: 3632
n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    n = max((t+ti-1)//ti, (a+ai-1)//ai)
    t = n*ti
    a = n*ai
print(t+a)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

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

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N;
  cin >> N;
  string s, t;
  cin >> s >> t;

  string ans = "";
  REP(i,N){
    ans += s[i];
    ans += t[i];
  }
  cout << ans << "\n";
  return 0;
}


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

int main() {
  int A,B,MAX;
  cin >>  A >> B;
 MAX = A+B;
 if(MAX <(A-B)){
  MAX =A-B;
}if(MAX < A*B){
  MAX = A*B;
}
cout << MAX << endl;
return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

h, w = gets.split.map(&:to_i)
c = []
h.times do
  c.push gets.chomp.split('')
end

d = Array.new(h) { Array.new(w) { -1 } }
d[0][0] = 1
q = []

count_b = 0

0.upto(h - 1) do |i|
  0.upto(w - 1) do |j|
    if c[i][j] == '#'
      count_b += 1
    end
  end
end

p = [0, 0]
max = 0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
flag = false
loop do
  xx = p[0]
  yy = p[1]
  0.upto(3) do |i|
    x = xx + dx[i]
    y = yy + dy[i]
    if x == h - 1 && y == w - 1
      flag = true
      max += 1
      break
    end
    next if x.negative? || x > h - 1 || y.negative? || w - 1 < y || d[x][y] >= 0

    next if c[x][y] != '.'

    q.push([x, y])
    count = d[xx][yy] + 1
    max = count if max < count
    d[x][y] = count
  end
  break if flag

  if q.empty?
    puts '-1'
    exit
  end

  p = q.shift
end
puts h * w - max - count_b


Measured memory_bytes: 1916