akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
qs = [input().split() for i in range(Q)]

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
    def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr)

bits = [BinaryIndexedTree(N+1) for i in range(26)]
for i,c in enumerate(S):
    ci = ord(c) - ord('a')
    bits[ci].add(i,1)
now = list(S)

for a,b,c in qs:
    if a=='1':
        b = int(b)
        pi = ord(now[b-1]) - ord('a')
        bits[pi].add(b-1, -1)
        ci = ord(c) - ord('a')
        bits[ci].add(b-1, 1)
        now[b-1] = c
    else:
        b,c = int(b),int(c)
        cnt = 0
        for i in range(26):
            cnt += int(bits[i].sum(b-1,c) > 0)
        print(cnt)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> G[101010];
    int in[101010] = {0};
    int dp[101010] = {0};
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        in[y]++;
        G[x].push_back(y);
    }
    queue<int> que;
    vector<int> T;

    rep(i, n) if(in[i] == 0) que.push(i);
    while(que.size()) {
        int v = que.front(); que.pop();
        T.push_back(v);
        for (auto nxt: G[v]) {
            in[nxt]--;
            if(in[nxt] == 0) que.push(nxt);
        }
    }
    for (int v : T) {
        for (int nxt : G[v]){
            dp[nxt] = max(dp[nxt], dp[v] + 1);
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string s;
  cin>>s;
  string check="AC";
  int count=0;
  if(s.at(0)!='A')check="WA";
  if(isupper(s.at(1))!=0||isupper(s.at(s.size()-1)))check="WA";
  for(int i=2;i<s.size()-1;++i){
     if(isupper(s.at(i))==0&&s.at(i)!='C')check=="WA";
     if(s.at(i)=='C')count++;
  }//for
  if(count!=1)check="WA";
  cout<<check<<endl;
}//main()

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define int long long
#define all(x) (x).begin(), (x).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define inf INT64_MAX
#define eb emplace_back
#define pii pair<int, pair<int, int>>

using namespace std;

int h, w, sh, sw, fh, fw, dis[1005][1005], vis[1005][1005] = {};
char maze[1005][1005];
pair<int, int> nxt[] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
void solve()
{
    cin >> h >> w;
    cin >> sh >> sw >> fh >> fw;
    sh--, sw--, fh--, fw--;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
            cin >> maze[i][j], dis[i][j] = inf;
    }
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push({0, {sh, sw}});
    dis[sh][sw] = 0;
    while (!pq.empty())
    {
        auto src = pq.top();
        pq.pop();
        for (int i = 0; i < 4; i++)
        {
            if ((src.ss.ff + nxt[i].ff >= 0 and src.ss.ff + nxt[i].ff < h) and (src.ss.ss + nxt[i].ss >= 0 and src.ss.ss + nxt[i].ss < w))
            {
                if (maze[src.ss.ff + nxt[i].ff][src.ss.ss + nxt[i].ss] == '.')
                {
                    if (src.ff < dis[src.ss.ff + nxt[i].ff][src.ss.ss + nxt[i].ss])
                    {
                        pq.push({src.ff, {src.ss.ff + nxt[i].ff, src.ss.ss + nxt[i].ss}});
                        dis[src.ss.ff + nxt[i].ff][src.ss.ss + nxt[i].ss] = src.ff;
                    }
                }
            }
        }
        for (int i = max((int)0, src.ss.ff - 2); i <= min(h - 1, src.ss.ff + 2); i++)
        {
            for (int j = max((int)0, src.ss.ss - 2); j <= min(w - 1, src.ss.ss + 2); j++)
            {
                if (maze[i][j] == '.')
                {
                    if (src.ff + 1 < dis[i][j])
                    {
                        dis[i][j] = src.ff + 1;
                        pq.push({src.ff + 1, {i, j}});
                    }
                }
            }
        }
    }
    cout << (dis[fh][fw] != inf ? dis[fh][fw] : -1);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;
    // cin >> t;
    // while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 12656
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int g=a[0],mx=a[0];
    for(int i=1;i<n;i++){
        g=gcd(g,a[i]);
        mx=max(a[i],mx);
    }
    if(k%g==0&&mx>=k)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

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


int main(void) {

    ll n; cin>>n;
    cout<<n<<":";
    map<ll,ll> mp;
    ll i;
    for (i = 2; i*i <= n; ++i) {
        if(n%i==0){
            while (n%i==0){
                n /= i;
                mp[i]++;
            }
        }
        if(n==1) break;
    }
    if(n!=1) mp[n]++;

    for(auto it : mp){
        for (int i = 0; i < it.second; ++i) {
            cout<<" "<<it.first;
        }
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define lol        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define SIZE        1000005
#define debug(x)        cerr << #x << " = " << x << endl;

using namespace std;

void MOD(ll &x)
{
	if (x >= lol) x -= lol;
	if (x < 0) x += lol;
}


void solve()
{
	ll n, m;
	cin>>n>>m;
	if(n==1)
	{
	    n=3;
	}
	if(m==1)
	{
	    m=3;
	}
	cout<<(n-2)*(m-2)<<endl;
	
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin>>n;
	vector<long long> a(n);
	ll ans=0;
	for(int i=0;i<n;++i) cin>>a[i];

	ll mx=a[0];
	for(int i=1;i<n;++i)
	{
		ans+=max(0ll,mx-a[i]);
		mx=max(a[i],mx);
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
int a[27],b[27];
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int a=0,b=0;
    for(int i=1;i<n;++i)
        if(s[i]=='E')
            b++;
    int minn=b;
    for(int i=1;i<n;++i)
    {
        if(s[i]=='E')
            b--;
        if(s[i-1]=='W')
            a++;
        minn=min(minn,a+b);
    }
    cout<<minn;
    return 0;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int n = S.length();
    for(int i=0; i<n; i++) {
        if(S[i] != T[i]) {
            cout << "No";
            exit(0);
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
int n,ans;
int a[100010];
 int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	for (int i=1;i<=n;++i)
		if (mp[a[i]]) mp[a[i]]=0;
		else mp[a[i]]=1;
	for (int i=1;i<=n;++i)
		if (mp[a[i]]) ++ans,mp[a[i]]=0;
	printf("%d",ans);
}

Measured memory_bytes: 5376
a = [int(i) for i in input().split()]
b = [(int(i)+1)/2 for i in input().split()]

he = sum(b[:a[1]])
maxer = he
for i in range(a[0] - a[1]):
    he -= b[i]
    he += b[i + a[1]]
    maxer = max(he, maxer)

print(maxer)

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main()
{
  ll N, M; cin >> N >> M;
  vector<ll> H(N);
  REP(i, N) cin >> H.at(i);

  vector<ll> A(M);
  vector<ll> B(M);
  REP(i, M) {
    cin >> A.at(i) >> B.at(i);
  }

  vector<ll> ANS(N, 1);
  REP(i, M) {
    ll a_ = A.at(i) - 1;
    ll b_ = B.at(i) - 1;

    if (H.at(a_) < H.at(b_)) {
      ANS.at(a_) = 0;
    } else if (H.at(a_) == H.at(b_)) {
      ANS.at(a_) = 0;
      ANS.at(b_) = 0;
    } else {
      ANS.at(b_) = 0;
    }
  }
  cout << SUM(ANS) << endl;
  return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//for (ll ii = 1; ii <= 100; ii++) {
	ll n ;//= ii ;
	cin >> n;
	//n--;
	vl bits(13, 0);
	ll dd = 1;
	ll cl = 0;
	while (dd <= n) {
		dd = dd * 26LL;
		cl++;
	}
	cl--;
	//cout << cl << "\n";
	int f = 0;
	for (ll i = cl; i >= 0; i--) {
		ll j = 1;
		for (ll k = 1; k <= i; k++)
			j = j * 26LL;
		ll cnt = 0;
		//f = 1;
		while (n >= j && cnt <= 25) {
			n = n - j;
			cnt++;
		}
		bits[i] = cnt;
		//cout << i << " " << cnt << "\n";
	}
	for (ll i = 0; i < cl; i++) {
		if (bits[i] <= 0) {
			bits[i] += 26;
			bits[i + 1]--;
		}
	}
	string s = "";
	for (ll i = cl; i >= 0; i--) {
		if (bits[i] <= 0)
			continue;
		//cout << bits[i] << "\n";
		s = s + (char)('a' + bits[i] - 1);
	}
	cout << s << "\n";
	//cout << 26 * 25 << "\n";
}//



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

int main(){
  int n,y;
  cin >> n >> y;
  int a=-1;
  int b=-1;
  int c=-1;
  
  for(int i=0;i<=n;i++){
    for(int j=0;j+i<=n;j++){
      if(10000*i+5000*j+1000*(n-i-j)==y){
        a=i;
        b=j;
        c=n-i-j;
      }
    }
  }
  
  cout << a << " " << b << " " << c << endl;
}
  
  

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner093
{
    public class ABC093C
    {
        public static void Main(string[] args)
        {
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = nums[0];
            int b = nums[1];
            int c = nums[2];

            int cnt = 0;
            while(a != b || b != c || a != c)
            {
                if(a > b && a > c)
                {
                    b++;
                    c++;
                }
                else if(b > c && b > a)
                {
                    a++;
                    c++;
                }
                else if(c > a && c > b)
                {
                    a++;
                    b++;
                }
                else if(a < b)
                {
                    a += 2;
                }
                else if(b < a)
                {
                    b += 2;
                }
                else
                {
                    c += 2;
                }
                cnt++;
            }
            
            Console.WriteLine(cnt);
        }
    }
}

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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long int n, m, sum = 0;
    cin >> n >> m;
    long int x[m], b[m-1];
    
    if(m == 1){
        puts("0");
        return 0;
    }
    
    for(int i=0; i<m; i++){
        cin >> x[i];
    }
    
    sort(x, x+m);
    for(int i=0; i<m-1; i++){
        b[i] = (x[i] < x[i+1])? x[i+1]-x[i] : x[i]-x[i+1];
    }
    sort(b, b+m-1);
    
    for(int i=0; i<m-n; i++){
        sum += b[i];
    }
    
    printf("%ld\n", sum);
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
bitset<61> bs;
bool memoo[61][2][2];
long long memo[61][2][2];
int maxbit = 0;
long long func(int ind, int bad, int left){
    if (ind > maxbit){
        return (bad == 0 && left == 0);
    }
    if (memoo[ind][bad][left]){
        return memo[ind][bad][left];
    }
    int cur = bs[ind];
    long long res = 0;
    for (int i=0; i<=1; i++){
        for (int j=0; j<=i; j++){
            int newbad = bad;
            int mybit = (i+j+left)%2;
            int rem = (i+j+left)/2;
            if (mybit > cur){
                newbad = 1;
            }else if (mybit < cur){
                newbad = 0;
            }
            res += func(ind+1, newbad, rem);
            res %= mod;
        }
    }
    memoo[ind][bad][left] = true;
    memo[ind][bad][left] = res;
    return res;
}
int main ()
{
  prep();
  long long n;
  cin >> n;
  bitset<61> bb(n);
  bs = bb;
  for (int i=0; i<61; i++){
      if (bs[i]){
          maxbit = i;
      }
  }
  cout << func(0, 0, 0);
  return 0; 
}


Measured memory_bytes: 256
a,b,x = [int(i) for i in input().split(" ")]
answer = 0
if (b-a)<x:
    answer+=(a%x==0)or(b%x==0)
elif a==0:
    answer+=b//x+1
else:
    answer+=b//x-a//x+(a%x==0)

print(int(answer))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;

int main(){

    int a,b;
    cin>>a>>b;
    cout<<abs(a-b)<<endl;

    return 0;
}


Measured memory_bytes: 3104
import math
n=int(input())
a=list(map(int, input().split()))
alist=[]
gcd1=a[0]
for i in range(0,n):
  gcd1=math.gcd(gcd1,a[i])
  alist.append(gcd1)
blist=[]
gcd2=a[n-1]
for i in range(n-1,-1,-1):
  gcd2=math.gcd(gcd2,a[i])
  blist.append(gcd2)
clist=[alist[n-2],blist[n-2]]
for i in range(n-2):
  clist.append(math.gcd(alist[i],blist[n-i-3]))
print(max(clist))

Measured memory_bytes: 24980
def read_input():
    n = int(input())
    xlist = list(map(int, input().split()))
    return n, xlist


def get_median(s, ignore):
    l = len(s)
    if ignore < l/2:
        return s[int((l+1)/2)]
    else:
        return s[int((l-1)/2)]

def submit():
    n, xlist = read_input()

    xlist = [(x, i) for i, x in enumerate(xlist)]
    xlist.sort(key=lambda x: x[0])

    pos_dic = {}
    for i, x in enumerate(xlist):
        pos_dic[x[1]] = i

    for i in range(n):
        target = pos_dic[i]
        print(get_median(xlist, target)[0])




if __name__ == '__main__':
    submit()


Measured memory_bytes: 58512
#include <bits/stdc++.h>
#define ll      long long int
#define INF2    ((ll)1e18)
#define pii     pair<ll,ll>
#define x       first
#define y       second
#define vi      vector<ll>
#define pb      push_back
#define sz(a)   (ll)((a).size())
#define all(x)  (x).begin(), (x).end()
#define FIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
template<typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p){os<<"("<<p.x<<","<<p.y<<") "; return os;}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){for(auto i: v) os<<i<<" "; return os;}

const ll mxN = 1e5;
const ll mod = 1e9+7;

int main(){
    FIO;
	//freopen("input.txt", "r", stdin);
	ll a, b, c, k;
	cin>>a>>b>>c>>k;
	if(k%2==0) cout<<a-b;
	else cout<<b-a;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	vector<int64_t> vs(n); for (auto& v : vs) { cin >> v;  }

	sort(vs.begin(), vs.end());

	int ans = 0;
	FOR_LT(i, 0, n) {
		FOR_LT(j, i + 1, n) {
			FOR_LT(k, j + 1, n) {
				int64_t a = vs[i];
				int64_t b = vs[j];
				int64_t c = vs[k];
				if (a == b || b == c || c == a) continue;

				if (a + b > c) ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

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

		for (int i = 0; i <= N; i += 4) {
			for (int j = 0; j <= N; j += 7) {
				if (N == i + j) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23764
import java.util.*;

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

    String s = sc.nextLine();

    for(int i = 0; i < s.length(); i++){
      if(Character.isUpperCase(s.charAt(i))){
        String tmp = String.valueOf(s.charAt(i)).toLowerCase();
        sb.append(tmp);
      } else if(Character.isLowerCase(s.charAt(i))){
        String tmp = String.valueOf(s.charAt(i)).toUpperCase();
        sb.append(tmp);
      } else {
        String tmp = String.valueOf(s.charAt(i));
        sb.append(tmp);
      }
    }

    String ans = sb.toString();
    System.out.println(ans);
  }
}



Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
/*
A:ABC丼
B:ARCカレー
C:AGCパスタ
D:APCラーメン
E:ATCハンバーグ
*/
int main(){
    unordered_map<int, int> un_mp;
    unordered_map<int, int> un_rmp;
    pair<int, int> p=make_pair(0,0);
    int n, t=0;
    for(int i=0; i<5; ++i){
        cin >> n;
        un_mp[i]=n;
        (un_mp[i]%10==0) ? (un_rmp[i]=0):(un_rmp[i]=10-(un_mp[i]%10));
        if(p.second<un_rmp[i]){
            p.first= i;
            p.second = un_rmp[i];
        }
    }
    for(int i=0; i<5; ++i){
        if(i==p.first) {
            continue;
        }else{
            t+=(un_mp[i]+un_rmp[i]);
        }
    }
    t+=un_mp[p.first];
    cout << t << endl;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall as f
def main():
  n,m,l,*t=map(int,open(0).read().split())
  d=[[0]*(n+1)for _ in'_'*(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  print('\n'.join(map(str,map(int,[d[i]for i in zip(*[iter(t[m*3+1:])]*2)]))))
main()

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (b-a <= 0) cout << "delicious" << endl;
  else {
    if (b-a >= x+1) cout << "dangerous" << endl; 
    if (b-a < x+1) cout << "safe" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const int N = 1e7 + 9;

int check[N];
vector<int> prim;

void crivo(){
   for(int i = 1; i < N ;i++) {
      for(int j = 1; i*j < N; j++) {
         check[i*j]++;
      }
   }
}

signed main(){
   IOS;
   crivo();
   int n; cin >> n;
   int ans = 0;
   for(int i = 1; i <= n; i++) ans += i * (check[i]);
   cout << ans << "\n";
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, D;
int X[20][20];

bool can(int i, int j){
    int sum = 0;

    for(int k=0;k<D;++k){
        int diff = X[i][k] - X[j][k];
        sum += diff * diff;
    }

    int sq = std::sqrt(sum);
    return sq * sq == sum;
}

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

    std::cin >> N >> D;

    for(int i=0;i<N;++i){
        for(int j=0;j<D;++j){
            std::cin >> X[i][j];
        }
    }

    int cnt = 0;

    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            if(can(i, j)){
                cnt += 1;
            }
        }
    }

    std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int main() {
    ll x[4];
    rep(i, 4) cin >> x[i];

    ll ans = -(ll)INF * (ll)INF;

    rep(i, 2) {
        REP(j, 2, 4) {
            ans = max(ans, x[i] * x[j]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
#!/mnt/c/Users/moiki/bash/env/bin/python
# N,M = map(int, input().split())
L = int(input())
A = [int(input()) for _ in  range(L)]


DP = [0] * 5
for i in range(L):
    r0 = A[i]
    r1 = (A[i] + 1) % 2

    if A[i] == 0:
        r2 = 2
    else:
        r2 = A[i] % 2

    for i,r in zip(range(4,-1,-1), [r0,r2,r1,r2,r0]):
        DP[i] = min(DP[:i+1]) + r
        # print(DP)

print(min(DP))
    


Measured memory_bytes: 61656
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

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

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

int n, c;
vector<int> a, b;

int f(int a){
    a = (a & 0x5555) + ((a & 0xAAAA) >> 1);
    a = (a & 0x3333) + ((a & 0xCCCC) >> 2);
    a = (a & 0x0F0F) + ((a & 0xF0F0) >> 4);
    a = (a & 0x00FF) + ((a & 0xFF00) >> 8);
    return a;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        cin >> n >> c;
        if(n == 0 && c == 0) break;
        a.assign(n, 0);
        b.assign(c, 0);
        REP(i, n) REP(j, 16) {
            int x; cin >> x;
            if(j != 0) a[i] <<= 1;
            a[i] += x;
        }
        REP(i, c) REP(j, 16) {
            int x; cin >> x;
            if(j != 0) b[i] <<= 1;
            b[i] += x;
        }

        vector<vector<int>> dp(35, vector<int>((1<<16), -1));
        dp[0][a[0]] = 0;
        REP(i, n){
            for(int mask = 0; mask < (1 << 16); mask++){
                if(dp[i][mask] != -1){
                    int m = mask | a[i];
                    REP(j, c){
                        int andnum = m & b[j];
                        int notandnum = m & ~b[j];
                        dp[i+1][notandnum] = max(dp[i+1][notandnum], dp[i][mask] + f(andnum));
                    }
                }
            }
        }

        int ans = 0;
        REP(i, (1 << 16)){
            ans = max(ans, dp[n][i]);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 12360
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int N;
vector< int > cnt;

void poyo() {
	cnt.assign(1001, 0);
	for_(i,1,1000) {
		int sum = i;
		
		for_(j,i + 1,1000) {
			sum += j;
			if (sum > 1000) break;
			++cnt[sum];
		}
	}
}

void solve() {
	cout << cnt[N] << endl;
}

int main() {
	poyo();
	while (cin >> N, N) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define BOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    
    
    
    int n;
    while(cin>>n){
        int ans=0;
    REP(i,10)REP(j,10)REP(k,10)REP(l,10){
        if(i+j+k+l==n)ans++;
    }
    
        
    cout<<ans<<endl;
    
    }
    
    return 0;
}

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

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

  vector<vector<int64_t>> x(3, vector<int64_t>(n));
  for (int i = 0; i < n; ++i) {
    cin >> x[0][i] >> x[1][i] >> x[2][i];
  }

  int64_t ans = -1001001001001001ll;
  for (int bit = 0; bit < 8; ++bit) {
    vector<int64_t> v(n);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < 3; ++j) {
        v[i] += (bit & (1 << j) ? -1 : 1) * x[j][i];
      }
    }

    sort(v.rbegin(), v.rend());
    ans = max(ans, (int64_t)accumulate(v.begin(), v.begin() + m, 0ll));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==1)	a=14;
	if(b==1)	b=14;
	if(a>b)		printf("Alice\n");
	else if(a<b)	printf("Bob\n");
	else 	printf("Draw\n"); 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}
const int maxn = 2e5 + 7;
ll BIT[maxn];
vi a(maxn), h(maxn);
ll query(int x, int n) {
	ll ret = 0;
	while (x > 0) {
		ret = max(BIT[x], ret);
		x -= (x & -x);
	}
	return ret;
}
void sum(int x, int n, ll k) {
	while (x <= n) {
		BIT[x] = max(k, BIT[x]);
		x += (x & -x);
	}
}
void solve() {
	int n;
	cin >> n;
	rep(i, 0, n)cin >> h[i];
	rep(i, 0, n)cin >> a[i];
	ll ans = 0, dp;
	rep(i, 0, n) {
		// trace(i, a[i], h[i], query(h[i], n))
		dp = query(h[i], n) + a[i];
		// trace(dp)
		ans = max(ans, dp);
		sum(h[i], n, dp);
	}
	cout << ans;
}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 6408
from collections import deque

X, Y, A, B, C = map(int, input().split())
 
p = deque(sorted(list(map(int,input().split())))[-X:])
q = deque(sorted(list(map(int,input().split())))[-Y:])
r = sorted(list(map(int,input().split())), reverse=True)
 
for i in r:
    p_min = p[0]
    q_min = q[0]
 
    if p_min > i and q_min > i:
        break
 
    p_min_diff = i - p_min
    q_min_diff = i - q_min
 
    if p_min_diff >= q_min_diff and p_min_diff > 0:
        p.popleft()
        p.append(i)
    elif q_min_diff >= p_min_diff and q_min_diff > 0:
        q.popleft()
        q.append(i)
 
print(sum(p) + sum(q))

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

int main () {

    int N;
    cin >> N;

    double v[N];
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    sort(v, v + N);

    double ans = (v[0] + v[1])/2;
    for (int i = 2; i < N; i++) {
        ans = (ans + v[i])/2;
    }
    printf("%.8lf\n", ans);

    return 0;
}


Measured memory_bytes: 256
N = int(input())
def prime_table(n):
    list = [True for _ in range(n+1)]
    for i in range(2,int(n**0.5)+1):
        if list[i]:
            j = i*2
            while j<=n:
                list[j] = False
                j += i
    table = [i for i in range(n+1) if list[i] and i>=2]
    return table

table = prime_table(55555)
table_ = []
for i in range(len(table)):
    if table[i]%5==1:
        table_.append(table[i])
for i in range(N):
    print(table_[i],end=' ')
print('')

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    cout<<(n<=k)<<endl;
}


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

using namespace std;

int fun(int x)
{
	int i=0;
	while(x%2==0)
	{
		i++;
		x/=2;
	}
	return i;
}
int main()
{
	int n;
	cin>>n;
	int max=0;
	int maxi=1;
	for(int i=2;i<=n;i+=2)
	{
		int k=fun(i);
		if( k>max) 
		{
			max = k;
			maxi= i;
		}
	}
	cout<<maxi;
}

Measured memory_bytes: 256
n,k=gets.split.map &:to_i
as=gets.split.map &:to_i
k.times{
  imos=Array.new(n,0)
  as.each_with_index do |a,i|
    min=[i-a,0].max
    max=[i+a+1,n].min
    imos[min] += 1
    imos[max] -= 1 if max<n
  end
  1.upto(n-1){|i|imos[i] += imos[i-1]}
  as=imos
  break if as.all?{|a|a==n}
  }
puts as.join(" ")

Measured memory_bytes: 80692
#include <algorithm>
#include <iostream>
#include <vector>

#include <stdlib.h>

using namespace std;

#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define SORT(x) sort((x).begin(),(x).end())

#define INF 2000000000000

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main()
{
	int W[10] = {0};
	int K[10] = {0};
	
	vector<int> Wv = {90,11,52,23};
	vector<int> Kv = {90,11,52,23};
	
	rep(i,0,10){
		cin >> W[i];
	}
	
	rep(i,0,10){
		cin >> K[i];
	}
	
	qsort(W, 10, sizeof(int), compare_int);
	qsort(K, 10, sizeof(int), compare_int);
	
	cout << W[7] + W[8] + W[9] << " ";
	cout << K[7] + K[8] + K[9] << endl;
	
	/*
	for(auto a : W){
		cout << a << endl;
	}
	*/
	
}

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

int main() {
	long n,k=1;
	cin>>n;
	vector<long>v(n);
	for(int i=0;i<n;i++)cin>>v.at(i);
	sort(v.begin(),v.end());
	
	for(int i=0;i<n-1;i++){
		if(v.at(i)!=v.at(i+1)){
			k++;
		}
	}
	if(k%2==0){
		cout<<k-1<<endl;
	}
	else{
	cout<<k<<endl;	
	}
	
	
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int32 C, N;
bool c[1000][1000] = {}, ok[500][500] = {};

int32 tov(int32 x){
	return min(x, N-x-1);
}

bool ok_mass(int32 y, int32 x){
	return (c[y][x] == c[y][N-x-1] && c[y][x] == c[N-y-1][x] && c[y][x] == c[N-y-1][N-x-1]);
}

int main(void){
	int32 out = 0;
	cin >> C >> N;
	REP(i, N){
		string s;
		cin >> s;
		REP(j, N){
			c[i][j] = s[j]-'0';
		}
	}
	REP(i, N/2){
		REP(j, N/2){
			if(ok_mass(i, j))
				ok[i][j] = 1;
			else
				out++;
		}
	}
	int32 cnt = out == 0;
	REP(i, C-1){
		int32 D;
		cin >> D;
		REP(j, D){
			int32 y, x;
			cin >> y >> x; y--; x--;
			c[y][x] ^= 1;
			if(!ok[tov(y)][tov(x)]){
				if(ok_mass(tov(y), tov(x))){
					out--;
					ok[tov(y)][tov(x)] = 1;
				}
			}else{
				ok[tov(y)][tov(x)] = 0;
				out++;
			}
		}
		if(out == 0) cnt++;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 4436
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define INF 1e9
using ll = std::int64_t;

template <class T>
bool chmax(T &a, const T &b);
template <class T>
bool chmin(T &a, const T &b);
//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b);
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb);
//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str);
//素数判定
bool is_prime(std::int64_t n);
// 約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n);
// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n);

//10^9 + 7
#define yojo 1000000007
#define MAX_NUM 200001


void Main()
{
  int n, m;
  cin >> n >> m;
  map<int, int> count;

  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    count[a]++;
    count[b]++;
  }
  
  for (int i = 1; i < n + 1; i++)
  {
    std::cout << count[i] << std::endl;
  }
  

  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

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;
}

//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//最大公約数安全版
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str)
{
  std::vector<std::pair<char, std::int64_t>> data;
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return data;
}

//素数判定
bool is_prime(std::int64_t n)
{
  for (std::int64_t i = 0; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      return false;
    }
  }

  return n != 1;
}

//約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n)
{
  std::vector<std::int64_t> res;
  for (int i = 0; i < n; i++)
  {
    if (n % i == 0)
    {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  return res;
}

// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n)
{
  std::map<std::int64_t, std::int64_t> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1)
  {
    res[n] = 1;
  }

  return res;
}

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

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

vector<ll> cnt(1000, 0);
vector<int> prime;

void isP(){
	prime.push_back(2);
	for (int i = 3; i < 1000; i++) {
		bool flag = true;
		for (int j = 2; j*j <= i; j++) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) prime.push_back(i);
	}
}

int N;


void f(int n) {
	for (long long i = n; i <= N; i *= n) {
		cnt[n] += N / i;
	}
}

int main() {
	isP();
	cin >> N;
	for (int i = 0; prime[i]<=N; i++) {
		f(prime[i]);
    if (prime[i] == prime.back()) {
      // prime[i]がprimeの最後の要素のとき、prime[i + 1]をすると範囲外アクセスになる
      break;
    }
	}

	ll res = 1;
	for (int i = 0; prime[i]<=N; i++) {
		res = res * (cnt[prime[i]] + 1) % (1000000000 + 7);
    if (prime[i] == prime.back()) {
      // prime[i]がprimeの最後の要素のとき、prime[i + 1]をすると範囲外アクセスになる
      break;
    }
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

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

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

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

signed main() {
  int n;
  string s[3];

  cin >> n;
  rep(i, 0, 3) cin >> s[i];
  int ans = 0;
  rep(i, 0, n) {
    map<int, int> mp;
    int db = 0;
    rep(j, 0, 3) {
      if(mp[s[j][i]]) db++;
      else mp[s[j][i]] = true;
    }
    ans += 2 - db;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

const int Maxn = 52;

string S, T;
string res;

bool Restore(int pos, string &tmp)
{
	tmp = S;
	for (int i = 0; i < T.length(); i++)
		if (S[pos + i] != '?' && S[pos + i] != T[i]) return false;
		else tmp[pos + i] = T[i];
	for (int i = 0; i < tmp.length(); i++)
		if (tmp[i] == '?') tmp[i] = 'a';
	return true;
}

int main()
{
	cin >> S >> T;
	string tmp;
	for (int i = 0; i + T.length() <= S.length(); i++)
		if (Restore(i, tmp))
			if (res == "" || tmp < res) res = tmp;
	if (res == "") printf("UNRESTORABLE\n");
	else printf("%s\n", res.c_str());
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC117_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var raw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = raw[0];
            var M = raw[1];
            var X = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .OrderBy(x => x)
                .ToArray();

            var dis = new int[M - 1];
            for (int i = 0; i < M - 1; i++)
            {
                dis[i] = X[i + 1] - X[i];
            }

            dis = dis.OrderBy(x => x).ToArray();

            var ans = dis.Take(dis.Length - (N - 1)).Sum();

            Console.WriteLine(ans);
        }
    }
}


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

int main(){
    int n, cards[n];
    cin >> n;
    for(int i=0; i<n; i++) cin >> cards[i];
    sort(cards, cards+n, greater<int>());

    int alice = 0;
    int bob = 0;
    for(int i=0; i<n; i++){
        if(i%2 == 0) alice += cards[i];
        else bob += cards[i];
    }

    int ans = alice - bob;
    cout << ans << endl;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=5e5+10;
int n;
int a,b,T;
int main(){
    ios::sync_with_stdio(false);
    cin>>a>>b>>T;
    cout<<T/a*b;
    return 0;
}
//x+y-a*c1==a*c2;
//x+y=a*2-x;


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int ans=0;
int dp[2000000][2];
void Main(){
    string S;cin>>S;
    int n=S.size();
    dp[0][0]=0;
    dp[0][1]=1;
    For(i,0,n){
        int keta=S[i]-'0';
        dp[i+1][0]=min(dp[i][0]+keta,dp[i][1]+(10-keta));
        dp[i+1][1]=min(dp[i][0]+keta+1,dp[i][1]+(9-keta));
    }
    ans=dp[n][0];
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  
  if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0))
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
function Main(input) {
  const numbers = input.split(' ').map(n => Number(n));
  const a = numbers[0];
  const b = numbers[1];
  if(a % 3 === 0 || b % 3 === 0 || (a + b) % 3 === 0) {
    console.log('Possible');
  } else {
    console.log('Impossible')
  }
}

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

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

int main() {
  int a;
  long long b, n;
  cin >> a >> b >> n;
  long long ans = 0;
  long long l = (a * n / b);
  long long r = a * (n / b);
  long long tmp = n / b;
  long long amari = n % b;
  l = (a * (n - 1)) / b;
  r = a * ((n - 1) / b);
  ans = l - r;

  l = (a * (min(b - 1, n)) / b);
  r = a * (min(n, (b - 1)) / b);
  ans = max(ans, l - r);
  l = (a * n) / b;
  r = a * (n / b);
  ans = max(ans, l - r);
  cout << ans;
  return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

vector<int>E[200000];
int in[200000];
int dp[200000];

int main(){
	int n,m;scanf("%d%d",&n,&m);
	rep(i,m){
		int x,y;scanf("%d%d",&x,&y);x--;y--;
		E[x].push_back(y);
		in[y]++;
	}
	queue<int>que;
	rep(i,n){
		if(!in[i]){
			que.push(i);
		}
	}
	while(!que.empty()){
		int p=que.front();que.pop();
		for(int u:E[p]){
			dp[u]=max(dp[u],dp[p]+1);
			in[u]--;
			if(!in[u])que.push(u);
		}
	}
	cout<<*max_element(dp,dp+n)<<endl;
}

Measured memory_bytes: 8832
#include<stdio.h>
int main() {
	int x;
	int h, m, s;
	scanf("%d", &x);
	h = x / 3600;
	m = (x - h * 3600) / 60;
	s = x - h * 3600 - m * 60;
	printf("%d:%d:%d\n", h, m, s);
}


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

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

fn main() {
    let n: u32 = read();
    let calc = n*n*n;
    println!("{}",calc);
}



Measured memory_bytes: 5028
#include <iostream>
#include <vector>
#define LIM 3000010

using namespace std;

int step[LIM]={0};

int rec(int n){
	
	if(n==1)
		return 0;
	else if(step[n] != 0)
		return step[n];
	
	if(n%2)//odd
		return step[n] = rec(n*3+1)+1;
	else//even
		return step[n] = rec(n/2)+1;
}

int main(){

	int n;
	
	while(cin>>n, n){
		cout << rec(n) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3352
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;
using pr  = pair<int, int>;

const ll MOD = 998244353;

int main()
{

	int X, N;
	cin >> X >> N;

	int ans = -1;
	vec ch(200);
	for (int i = 0; i < N; ++i)
	{
		int p; cin >> p;
		ch[p] = 1;
	}

	for(int i=0;i<200;++i)
	{
		if (ch[i]) { continue; }

		if (abs(i - X) < abs(ans - X))
		{
			ans = i;
		}
		else if (abs(i - X) == abs(ans - X))
		{
			ans = min(i, ans);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use feature qw/say/;

my ($N, $L) = split(/\s+/, <STDIN>);
my @S = map { <STDIN> } (1..$N);
chomp $_ for @S;
say join('', sort { $a cmp $b } @S);

Measured memory_bytes: 768