akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;

int main(){
  string s; ll k;
  cin>>s>>k;
  if(s.size()==1){
    cout<<k/2<<endl;
    return 0;
  }
  vector<char> a;
  vector<ll> b;
  char bef='#'; ll cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=bef){
      if(cnt>0){
	a.push_back(bef);
	b.push_back(cnt);
      }
      cnt=0;
      bef=s[i];
    }
    cnt++;
  }
  if(cnt>0){
	a.push_back(bef);
	b.push_back(cnt);
      }
  if(s[0]==s[s.size()-1]){
    if(b.size()==1){
      cout<<k*(ll)s.size()/2<<endl;
    }
    else{
      ll ans=0;
      for(int i=1;i<b.size()-1;i++){
	ans+=b[i]/2;
      }
      ans*=k;
      ans+=(b[0]+b.back())/2*(k-1);
      ans+=b[0]/2;
      ans+=b.back()/2;
      cout<<ans<<endl;
    }
  }
  else{
    ll ans=0;
    for(auto t:b)ans+=t/2;
    ans*=k;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A,B,C,D;
  scanf("%d%d%d",&A,&B,&C);
  if(A >= B && A >= C){
    D = A*10 + B + C;
  }else if(B >= A && B >= C){
    D = B*10 + A + C;
  }else if(C >= A && C >= B){
    D = C*10 + A + B;
  }
  printf("%d",D);
}
 


  
  

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

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

using namespace std;

bool ispali(int a){
	string s=to_string(a);
	int n=s.length();
	rep(i,n) if(s[i]!=s[n-i-1]) return false;
	return true;
}

int main(){
	int a,b; cin>>a>>b;
	int ans=0;
	for(int i=a;i<=b;i++) if(ispali(i)) ans++;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s[12];
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=0;i<h;i++)
        cin>>s[i];
    int ans=1e9;
    for(int u=0;u<(1<<(h-1));u++){
        int x=__builtin_popcount(u);
        int r[x+1]={0};
        int flag=1;
        int cnt=x;
        for(int j=0;j<w;j++){
            int c[x+1]={0};
            int p=0;
            int mx=0;
            for(int i=0;i<h;i++){
                c[p]+=s[i][j]-'0';
                mx=max(mx,c[p]);
                if(u&(1<<i)) p++;
            }
            if(mx>k) {flag=0;break;}
            mx=0;
            for(int i=0;i<=x;i++){
                mx=max(mx,r[i]+c[i]);
            }
            if(mx>k) {memset(r,0,sizeof(r));cnt++;}
            for(int i=0;i<=x;i++) r[i]+=c[i];
        }
        	if(flag) ans=min(ans,cnt);
	    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define N 100001
const ll INF=1e15+7;
ll n,ans[N],a[N],k=0;

int main(){
	cin>>n;
	FOR(i,0,n){
		cin>>a[i];
	}
	FOR(i,0,n-1){
		k+=abs(a[i]-a[i+1]);
	}
	k+=abs(a[0]);
	k+=abs(a[n-1]);
	FOR(i,1,n-1){
		ans[i]=k-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
	}
	ans[0]=k-abs(a[0])-abs(a[0]-a[1])+abs(a[1]);
	ans[n-1]=k-abs(a[n-1]-a[n-2])-abs(a[n-1])+abs(a[n-2]);
	FOR(i,0,n){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 2816
k = int(input())

c = []


# for k in range(k + 1):
#     n = c[k]
#     m = n % 10
#     for i in range(-1, 2):
#         if 0 <= m + i <= 9:
#             c.append(n * 10 + m + i)

def lunlun(d, num):
    if d > 10:
        return

    c.append(num)

    m = num % 10
    for i in range(-1, 2):
        if 0 <= m + i <= 9:
            lunlun(d + 1, num * 10 + m + i)


for i in range(1, 10):
    lunlun(1, i)

c.sort()
print(c[k - 1])


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, a, b; cin >> n >> a >> b;

    ll t = a + b;

//    bool over = false;
//
//    ll p = 0;
//    for (ll i = 0; i < 1000; ++i) {
//        p += t;
//        if (n < p) {
//            over = true;
//            break;
//        }
//    }

//    if (over) {
        ll v = n / t;

        ll p = n % t;

        ll sum = a * v + min(p, a);

        cout << sum << endl;
        return 0;
//    } else {
//        cout << a * 1000 << endl;
//        return 0;
//    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;
using ll=long long;


int main() {
  int n; cin  >> n;
  vector<ll> as;
  as.pb(0);

  rep(i,n){
    int a;
    cin >> a;
    as.pb(as[i]+a);
  }

  sort(ALL(as));

  ll ans=0;
  ll c = 0;

  rep(i,n){
    if(as.at(i)==as.at(i+1)) c++;
    else {ans += c*(c+1)/2;c = 0;}
  } 
  ans += c*(c+1)/2;
  cout << ans;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll t,x=0,y=0;
    cin>>t;
    for(int i=0; i<t; i++)
    {
        ll a,b;
        cin>>a>>b;
        if(!i)
            x=a,y=b;
        else
        {
            ll dx=x/a;
            ll dy=y/b;
            if(x%a)
                dx++;
            if(y%b)
                dy++;
            ll mx=max(dx,dy);
            x=mx*a;
            y=mx*b;
        }

    }

    cout<<x+y<<endl;

    return 0;
}


Measured memory_bytes: 3628
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))

a1_a2 = c1[0] - c2[0]
a2_a3 = c2[0] - c3[0]
b1_b2 = c1[0] - c1[1]
b2_b3 = c1[1] - c1[2]

cnt = 0
if a1_a2 == c1[1]-c2[1] == c1[2]-c2[2]:
    cnt += 1
if a2_a3 == c2[1]-c3[1] == c2[2]-c3[2]:
    cnt += 1
if b1_b2 == c2[0]-c2[1] == c3[0]-c3[1]:
    cnt += 1
if b2_b3 == c2[1]-c2[2] == c3[1]-c3[2]:
    cnt += 1

if cnt == 4:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<int>vec(n);
  while(true){
    int l=0,r=n;
    cout << 0 << endl;
    string s;
    cin >> s;
    if(s[0]=='V')return 0;
    else if(s[0]=='M')vec[0]=1;
    else vec[0]=0;
    
    while(true){
      int m=(r+l)/2;
      cout << m << endl;
      string t;
      cin >> t;
      if(t[0]=='V')return 0;
      else if(t[0]=='M')vec[m]=1;
      else vec[m]=0;
      
      if((m-l)%2^vec[m]==vec[l])l=m;
      else r=m;
    }
    
  }
  return 0;     
}


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

long long a, b, c;

int main() {
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    if (c <= a + b) cout << c + b << endl;
    else if (c >= a + b + 1) cout << a + b + b + 1 << endl;
    else cout << a + b + b << endl;
    return 0;
}

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

using namespace std;

int main()
{
	cin.sync_with_stdio(false);
	char a, b;
	cin >> a >> b;
	//atcodeer is honest.
	if (a == b) {
		cout << 'H' << endl;
	}
	else {
		cout << 'D' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

  map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }
int main(){
 ll n,m ;cin>>n>>m ;
 map<ll,ll> ord = factor(m) ;
 mint ans=1 ;
 combination c(200000) ;
 for(auto u:ord){
   ll a = u.se ;
   mint now =  c(a+n-1,n-1) ;
   ans= ans*now ;
 }
    cout<<ans<<endl;
    return 0;
  }
   

Measured memory_bytes: 6408
#include<bits/stdc++.h>
using namespace std;
int a[200000+100];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i=k;i<n;++i)
        if(a[i]>a[i-k])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 4408
import java.util.Scanner;

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

        while (sc.hasNext()) {
            String s = sc.next();
            int cnt = 0;

            for (int i = 1; i < s.length(); i++) {
                char a = s.charAt(i);
                char b = s.charAt(i - 1);
                if ( a != b ) {
                    cnt++;
                }
            }
            System.out.println(cnt);
        }
    }
}


Measured memory_bytes: 23788
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	const string ret[2] = {"First", "Second"};

	int no;
	if(s.front() == s.back())
		if(s.size()%2 == 0)
			no = 0;
		else
			no = 1;
	else
		if(s.size()%2 == 0)
			no = 1;
		else
			no = 0;

	cout << ret[no] << endl;

	return 0;
}


Measured memory_bytes: 512
h, w = gets.split.map(&:to_i)

def min_diff(h, w)
  min_diff = h * w
  # pattern 1
  if h % 3 == 0
    return 0
  else
    min_diff = [min_diff, w].min
  end

  # pattern 2
  1.upto(h-1).each do |hh|
    if w.even?
      diff = (hh * w - (h - hh) * (w / 2)).abs
      min_diff = [min_diff, diff].min
    else
      areas = [hh * w, (h - hh) * (w - 1) / 2, (h - hh) * (w + 1)/ 2]
      diff = areas.max - areas.min
      min_diff = [min_diff, diff].min
    end
  end

  min_diff
end

puts [min_diff(h, w), min_diff(w, h)].min

Measured memory_bytes: 3836
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
s = input()
t = input()

tmp = ''
for i in range(N+1):
    tmp = s[0:i] + t
    if tmp[:N] == s and tmp[-N:] == t:
        break
print(len(tmp))



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  REP(i, n) cin >> h[i];

  sort(ALL(h));
  ll ret = INF;
  REP(i, n-k+1) chmin(ret, h[i+k-1] - h[i]);
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1024
L, R = map(int, input().split())

ans = 2020

if (R-L) >= 2018:
    print(0)
else:
    X = list(range(L, R+1))
    for i in X[:len(X)-1]:
        for j in X[1:]:
            a = ((i%2019)*(j%2019))%2019
            if ans > a:
                ans = a
    print(ans)
    


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=44;
int n,a[N][N],b[N][N][N];
ll f[N][N][N],ans;
char s[N];
ll dfs(int l,int m,int r){
	if(l==m && m==r) return 1;
	if(b[l][m][r]) return f[l][m][r];
	b[l][m][r]=1;
	FOR(i,l,m-1)FOR(j,m+1,r)if(a[i][j])FOR(p,i,m-1)FOR(q,m+1,j)
		f[l][m][r]+=dfs(l,i,p)*dfs(p+1,m,q-1)*dfs(q,j,r);
	return f[l][m][r];
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);n*=2;
	FOR(i,1,n){
		scanf("%s",s+1);
		FOR(j,1,n) a[i][j]=s[j]^48;
	}
	FOR(i,2,n)if(a[1][i]) ans+=dfs(2,i,n);
	cout<<ans<<'\n';
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if(m1 != m2)cout << "1" << endl;
	else cout << "0" << endl;

	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1000000007
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}*/

//To compute x^y under modulo m
ll power(ll x,ll y){
    if(y==0)return 1;
    ll p=power(x,y/2)%mod;
    p=(p*p)%mod;
    return(y%2==0)?p:(x*p)%mod;
}
/*
bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2; p*p<=n; p++)
        if (prime[p] == true)
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
ll n,k;
ll a[100005];
ll fact[100005];
ll invfact[100005];

ll nCr(ll x,ll y){
	if(y>x)return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
void fac(){
	fact[0]=1;
	fact[1]=1;
	rep(i,2,100003){
		fact[i]=fact[i-1]*i;
		fact[i]=fact[i]%mod;
	}
}
void invfac(){
	invfact[100002]=power(fact[100002],mod-2);
	repd(i,100001,0){
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]=invfact[i]%mod;
	}
}
void precal(){
	fac();
	invfac();	
}
ll minsum(){
	ll ans=0;
	rep(i,0,n-k+1){		
		ans+=(a[i]*nCr(n-i-1,k-1))%mod;
		ans+=mod;
		ans%=mod;
		ans+=mod;
		ans%=mod;
	}
	return ans;
}
ll maxsum(){
	ll ans=0;
	rep(i,k-1,n){
		ans+=a[i]*nCr(i,k-1);
		ans%=mod;
		ans+=mod;
		ans%=mod;
	}
	return ans;
}
int solve(){
	precal();
    cin>>n>>k;
	rep(i,0,n)cin>>a[i];
    if(k==1){
		cout<<"0"<<endl;
    	return 0;
	}
    sort(a,a+n);
    ll s=minsum();
    ll a=maxsum();
    //cout<<a<<" "<<s<<endl;
 	cout<<((a-s)+mod)%mod<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


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

from collections import OrderedDict
pairs = OrderedDict()

for k in range(1, N+1):
    first = int(str(k)[0])
    last = int(str(k)[-1])
    if (first, last) in pairs:
        pairs[(first, last)] += 1
    else:
        pairs[(first, last)] = 1

cnt = 0
for i in range(1, 10):
    for j in range(1, 10):
        if (i, j) in pairs and (j, i) in pairs:
            cnt += (pairs[(i, j)] * pairs[(j, i)])

print(cnt)

Measured memory_bytes: 3316
S = input()

A,B = int(S[:2]),int(S[2:])

if A<=12 and B<=12 and A>0 and B>0:
    print("AMBIGUOUS")
elif A<=12 and A>0:
    print("MMYY")
elif B<=12 and B>0:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
using System;

public class AtCoderC
{
    static void Main()
    {
        int n;
        int m;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            m = int.Parse(words[1]);
        }

        int left = 1;
        int right = n;
        for (int i = 0; i < m; i++)
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            int l = int.Parse(words[0]);
            int r = int.Parse(words[1]);
            left = Math.Max(l, left);
            right = Math.Min(r, right);
        }

        if (right < left)
        {
            Console.WriteLine(0);
            return;
        }

        Console.WriteLine(right - left + 1);
    }
}

Measured memory_bytes: 15176
#include<iostream>
using namespace std;
int main() {
	int n, d, x; cin >> n >> d >> x;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		x += (d - 1) / a + 1;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin>>n;
    int m[100001]; rep(i,100001) m[i] = 1<<30;
    m[0]=0;

    rep(i, n+1){
        m[i+1] = min(m[i+1], m[i]+1);
        int k=6;
        while(k<=n && i+k<=100000){
            m[i+k] = min(m[i+k], m[i]+1);
            k*=6;
        }
        k=9;
        while(k<=n && i+k<=100000){
            m[i+k] = min(m[i+k], m[i]+1);
            k*=9;
        }
    }

    cout << m[n] << endl;


    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k;                                      //k=123 
    cin>>k;
    long a,b,c;
    a=k/50+50;     //要特别处理的数的大小           a=123/50+50 = 2+50=52
    b=k%50;       //要特别处理的数的个数            b=123%50=23
    c=a-b-1;      //正常相等的数值                  c=52-23-1=28
    int x[55]={0};
    int xx=0;
    cout<<50<<endl;
    for(int i=0;i<50;i++)
    {
        if(i<b)
        {
            if(i==0)
            cout<<a;
            else
            cout<<" "<<a;
            x[xx]=a;
        }
        else
        {
            if(i==0)
            cout<<c;
            else 
            cout<<" "<<c;
            x[xx]=c;
        }
        xx++; 
    }
    cout<<endl;
 /*   int mmax;
    int index=0;
    cout<<"变化之后"<<endl;
    int s=123;
    while(s--)
    {
    	mmax=-1;
    	for(int j=0;j<50;j++)
    	{
    		if(x[j]>mmax)
    		{
    			mmax=x[j];
    			index=j;
			}
		}
		for(int j=0;j<50;j++)
		{
			if(index==j)
			{
				x[index]-=50;
			}
			else
			{
				x[j]++;
			}
		}
	}
	for(int i=0;i<xx;i++)
	{
		cout<<x[i]<<" ";
	 } */
    return 0;
}//   23+28=51;23个2加上22个1 55，  27个51 （23次）
//27 
//23个52  第22次后 还剩一个52+22，前面的都 -50+21=23  之后的 +22 = 50
//第23次后   前23个都变成了 24， 后27个变成了 51
//第27次后    后27个51 变成了 51-50+26 =27  前23个 24+27=51 
//所以经过50次之后  前23个52变成了51 ，后27个28 变成了27 
//第100次后   前23个变成了50，后27个变成26
//第23次后   前23个变成了22，后27变成了49 


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<ctime>
#define ll long long
#define pr(x) cerr<<#x<<"="<<x<<endl
using namespace std;
int g[1000000],n,m,vis[1000000],i,size,o,p;
struct node
{
	int to,next;
}e[1000000];
void add(int o,int p)
{
	e[++size].to=p;
	e[size].next=g[o];
	g[o]=size;
}
bool dfs(int x,int t)
{
	if(t==3) return false;
	if (x==n) return true;
	for (int i=g[x];i;i=e[i].next)
	{
		int y=e[i].to;
		if(vis[y]) continue;
		if (dfs(y,t+1)) return true;
	}
	return false;
}
int main ()
{
	vis[1]=1;
	scanf ("%d %d",&n,&m);
	for (i=1;i<=m;i++)
	{
		scanf("%d %d",&o,&p);
		add(o,p);
	}
	if (dfs(1,0)) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 7936
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = string_to_int(inputs[0])

    ret = 0.0
    for i in range(1, N+1):
        score = i
        count = 1
        tmp = 1.0 / N
        while score < K:
            score *= 2
            count += 1
            tmp *= 0.5
        ret += tmp

    return ret


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int rate;
    cin>>rate;
    if(rate<1200)
    {
        s = "ABC";
    }
    else if(rate<2800)
    {
        s = "ARC";
    }
    else
    {
        s = "AGC";
    }
    cout<<s<<'\n';
}

Measured memory_bytes: 3640
' Imports System.Collections.Generic
' Imports System.Globalization
' Imports System.IO
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim N, A, B As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        N = arr(0) : A = arr(1) : B = arr(2)
        Console.WriteLine(Math.min(N * A, B))
        Return
    End Sub
End Class

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

int main()
{
  string S;
  deque< pair< char, int > > data;

  cin >> S;
  data.push_back(make_pair(S[0], 1));
  for(int i = 1; i < S.length(); i++) {
    if(data.back().first == S[i]) data.back().second++;
    else data.push_back(make_pair(S[i], 1));
  }
  int ret = 0;
  for(int i = 2; i < data.size(); i++) {
    if(data[i - 2].first == 'J' && data[i - 1].first == 'O' && data[i].first == 'I') {
      if(data[i - 2].second >= data[i - 1].second && data[i].second >= data[i - 1].second) {
        ret = max(ret, min(data[i - 2].second, min(data[i - 1].second, data[i].second)));
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 10228
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  string n;
  while (getline(cin, n)) {
    string ans = n;
    for (int i = 0; i < 26; i++) {
      if (ans.find("the") != -1 || ans.find("that") != -1 ||
          ans.find("this") != -1)
        break;
      for (int j = 0; j < ans.size(); j++) {
        if (ans[j] == ' ' || ans[j] == '.')
          continue;
        if (ans[j] == 'z')
          ans[j] = 'a';
        else
          ans[j]++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll K,X;
ll i,j,ans;
int main(){
    scanf("%lld%lld", &K, &X);
    K--;
    fornum(i,0,K){
        printf("%lld ", X - K + i);
    }
    printf("%lld ", X);
    fornum(i,0,K){
        printf("%lld ", X + i + 1);
    }

    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int d[110];
    int n, q;
    while(cin >> n >> q, n+q){
        fill(d, d+110, 0);
        for(int i=0; i< n; i++){
            int q;
            cin >> q;
            rep(j, q){
                int r; cin >> r; d[r]++;
            }
        }
        int m = 0, ret = -1;
        rep(i, 110){
            if(q <= d[i] && m < d[i]){ret = i; m = d[i];}
        }
        cout << (ret==-1?0:ret) << endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
#define int long long int
#define mod 1000000007
void dfs(int src,vector<int> adj[],int &here,bool visited[])
{
	if(visited[src])
	   return ;
	else
	{
		visited[src]=true;
		here++;
		for(int x:adj[src])
		   dfs(x,adj,here,visited);
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int j,arr[n];
	for(j=0;j<n;j++)
	   cin>>arr[j];
	int answer=0;
	int sum=0;
	for(j=n-1;j>=0;j--)
	{
		answer+=(sum*arr[j]);
		answer%=mod;
		sum+=arr[j];
		sum%=mod;
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 5212
import java.util.*;
public class Main{


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

		long s  =sc.nextLong();
	 HashSet<String> ss = new HashSet<String>();
		while(s-->0) {
			String as = sc.next();
			ss.add(as);
		}
		System.out.println(ss.size());
	}

}


Measured memory_bytes: 78456
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = a[n - 1];
    if(n == 3) {
        ans += a[n - 2];
        cout << ans << endl;
        return 0;
    }
    if(n == 4) {
        ans += a[n - 3] + a[n - 2];
        cout << ans << endl;
        return 0;
    }
    if(n % 2 == 1) {
        repl(i, 2, n / 2 + 1) {
            ans += 2 * a[n - i];
        }
        ans += a[n - n / 2 - 1];
    }
    else {
        repl(i, 2, n / 2 + 1) {
            ans += 2 * a[n - i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    rep(i, 3)
    {
        if (s.at(i) == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 200005;
int a[MAXN],n;
long long s[2][MAXN];
long long ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",a+i);
		s[0][i]=s[0][i-1]^a[i];
		s[1][i]=s[1][i-1]+a[i];
	}
	int p=1;
	for(int i=1;i<=n;++i){
		while((s[0][i]^s[0][p-1])!=(s[1][i]-s[1][p-1]))++p;
		ans+=i-p+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4096
N,Q = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N-1)]
px = [list(map(int,input().split())) for i in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in px:
    value[p] += x

from collections import deque
todo = deque([(1,0)])
while len(todo) > 0:
    x,parent = todo.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        todo.append((y,x))

answer = ' '.join(map(str,value[1:]))
print(answer)

Measured memory_bytes: 140804
import sys

input = sys.stdin.readline

class uf_tree:
    def __init__(self, n):
        self._size = n
        self.sizes = [1] * n
        self.par = list(range(n))

    def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        self._size -= 1
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.par[y] = x
        self.sizes[x] += self.sizes[y]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self.sizes[self.find(x)]


def com(x):
    return x*(x-1)//2

n, m = map(int, input().split())
AB = [ list(map(int, input().split())) for _ in range(m) ]

ans = []
benri = 0

uf = uf_tree(n+1)

for a, b in AB[::-1]:
    ans += [ com(n) - benri ]    
    if uf.same(a, b):
        continue

    a_benri = com(uf.size(a) )
    b_benri = com(uf.size(b) )

    uf.unite(a, b)
    sum_benri = com( uf.size(a) )
    benri += sum_benri - a_benri - b_benri

print (*ans[::-1], sep="\n")



Measured memory_bytes: 36360
#include<bits/stdc++.h>
using namespace std;
bool a[10000000];
int main() {
  memset(a,1,sizeof(a));
	for(long i =2; i*i<=10000000;++i) {
      if(a[i]==1) {
      	for(long j = 2 ; i*j<=10000000; ++j) 	a[j*i]=0;
      }
    }
  long x;
  cin>>x;
  for(long i=x;i<=10000000;++i) if(a[i]==1) { cout<<i; break; }
  
}


Measured memory_bytes: 9984
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, x, y = na()
x -= 1
y -= 1
anss = [0] * n
for i in range(n):
    for j in range(i+1, n):
        d = min(j-i, 1 + abs(x-i) + abs(j-y))
        anss[d] += 1

for i in range(1, n):
    print(anss[i])


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

template <typename T>
class fenwick_tree {
	const int n;
	vector<T> data;
public:
	fenwick_tree(int n_) : n(n_), data(n + 1) {}
	T find(int p) const {
		T res = 0;
		while (p > 0) {
			res += data[p];
			p -= p & -p;
		}
		return res;
	}
	void add(int p, T val) {
		++p;
		while (p <= n) {
			data[p] += val;
			p += p & -p;
		}
	}
};

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	ll k = (ll)N * (N + 1) / 2;
	int lb = 0, ub = 1e9;
	while (ub - lb > 1) {
		int c = (lb + ub) >> 1;
		vector<int> sum(N + 1); sum[0] = N;
		for (int i = 0; i < N; i++) {
			sum[i + 1] = sum[i] + (a[i] <= c ? 1 : -1);
		}
		ll cnt = 0;
		fenwick_tree<int> ft(N + N + 1);
		for (int i = 0; i <= N; i++) {
			cnt += ft.find(sum[i]);
			ft.add(sum[i], 1);
		}
		(cnt * 2 > k ? ub : lb) = c;
	}
	cout << ub << endl;
	return 0;
}


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

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

 vector<int> vec(N);
 for(int i=0; i<N; i++) cin >> vec.at(i);

 sort(vec.begin(), vec.end());
 reverse(vec.begin(), vec.end());

 int sum=0;

 for(int i=0; i<K; i++) sum+=vec.at(i);

 cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <array>
using namespace std;

#define SZ(a) (int)(a).size()
using ll = long long;

constexpr ll mod = 998244353;

ll powmod(ll b, ll e) {
    ll r = 1;
    while (e != 0) {
        if (e & 1) {
            r = (r * b) % mod;
        }
        b = (b * b) % mod;
        e >>= 1;
    }
    return r;
}

int main() {
    cin.sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> a(n);
    for (int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        a[max(x, y)].emplace_back(min(x, y), c);
    }
    for (auto &b: a) {
        sort(begin(b), end(b));
    }
    array<ll, 2> dp = {1, 0};
    bool pos = true;
    ll s = 0;
    for (int i = 0; i < n; i++) {
        // cerr << s << " " << dp[0] << " " << dp[1] << endl;
        s += i;
        const auto &b = a[i];
        // for (auto p: b) {
        //     cerr << p.first << "," << p.second << " ";
        // }
        // cerr << endl;
        int k;
        for (k = 0; k < SZ(b); ) {
            int l = b[k].first;
            if (l >= i - 2) break;
            int c = 0;
            int p = 0;
            while (k < SZ(b) && b[k].first == l) {
                c++;
                p ^= b[k].second & 1;
                k++;
            }
            if (c == 2 && p != 0) {
                pos = false;
                break;
            }
            s--;
        }
        if (!pos) {
            break;
        }
        array<int, 3> cs = {0, 0, 0};
        array<int, 3> ps = {0, 0, 0};
        for (; k < SZ(b); ) {
            int l = b[k].first;
            int c = 0;
            int p = 0;
            while (k < SZ(b) && b[k].first == l) {
                c++;
                p ^= b[k].second & 1;
                k++;
            }
            cs[i - l] = c;
            ps[i - l] = p;
            if (l != i) {
                s--;
            }
        }
        // cerr << ps[0] << endl;
        array<ll, 2> dp1 = {0, 0};
        for (int j = 0; j < 2; j++) {
            if (cs[0] == 1 && ps[0] != j) continue;
            for (int k = 0; k < 2; k++) {
                if (!(cs[1] == 2 && ps[1] != j ^ k || cs[2] == 2 && ps[2] != k)) {
                    // cerr << i << " " << j << k << endl;
                    dp1[j] += dp[k];
                }
            }
            dp1[j] %= mod;
        }
        swap(dp, dp1);
    }
    if (!pos) {
        puts("0");
        return 0;
    }
    // cerr << s << " " << dp[0] << " " << dp[1] << endl;
    ll ans = powmod(2, s) * (dp[0] + dp[1]) % mod;
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for (int i=0; i<M; i++) {
    cin >> A[i];
  }
  
  int ans = 0;
  int a = 0, b = 0;
  
  for (int c : A) {
    if (c < X) a++;
    else b++;
  }
  ans = min(a, b);
  cout << ans << endl;
      
  
}

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

#define xx first
#define yy second

typedef pair<int, int> pii;
typedef long long LL;

const int N = 1100;
int vis[N];

void div(int x)
{
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0)
        {
            while (x % i == 0)
            {
                vis[i]++;
                x /= i;
            }
        }
    if (x > 1)
        vis[x]++;
}

const int mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        div(i);
    LL res = 1;
    for (int i = 2; i < N; i++)
        (res *= (vis[i] + 1)) %= mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

#define rep0(n) for(int i=0;i<n;i++)
#define rep(n) for(int i=1;i<=n;i++)

double const pi = 3.1415926535;
int const mod = 1000000007;
int const inf = 2147483647;

int yesno(bool flag, string yes, string no) {
	if (flag)cout << yes << endl;
	else cout << no << endl;
	return 0;
}

int printint(int n) {
	cout << n << endl;
	return 0;
}

int prints(string s) {
	cout << s << endl;
	return 0;
}

int main() {

	int x, y;
	cin >> x >> y;
	yesno(x % 500 <= y, "Yes", "No");

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt(),m=sc.nextInt();
        int[] a=new int[200001];
        int[] b=new int[200001];
        HashSet<Integer>[] via=new HashSet[200001];
        if(n==200001||m==200001){
            while (true){
                
            }
        }
        for (int i = 1; i <= 200000; i++) {
            via[i]=new HashSet<>();
        }
        for (int i = 0; i < m; i++) {
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
            via[a[i]].add(b[i]);
            via[b[i]].add(a[i]);
        }
        for (Integer k:via[1]){
            for (Integer l:via[k]){
                if(l==n){
                    out.println("POSSIBLE");
                    exit(0);
                }
            }
        }
        out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 188852
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n + 1);
    for (int i = 1; i <= n; i++) cin >> h[i];
    using vll = vector<long long>;
    vector<vector<vll>> dp(n + 1, vector<vll>(n + 1, vll(k + 1, INF)));
    dp[0][0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int r = 0; r < i; r++) {
            for (int c = 0; c <= k; c++) {
                auto val = dp[i - 1][r][c];
                if (val == INF) continue;
                int cost = max(0, h[i] - h[r]);
                chmin(dp[i][i][c], val + cost);
                if (c < k) chmin(dp[i][r][c + 1], val);
            }
        }
    }
    long long mi = INF;
    for (int r = 0; r <= n; r++) mi = min(mi, dp[n][r][k]);
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 216832
#include <bits/stdc++.h>
using namespace std;
int main(){
  long k,a=0;
  cin >> k;
  vector<long> aaa(10000000);
  aaa[0]=7%k;
  for(long i=1;i<10000000;i++) aaa[i]=aaa[i-1]*10%k;
  for(long i=0;i<10000000;i++) {
    a=(a+aaa[i])%k;
    if(a==0) {
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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

using namespace std;

int arr[26] = {0};

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i)
    {
        arr[s[i] - 'a'] = -1;
    }
    bool help = true;
    char add;
    for(int i = 0; i < 26; ++i)
    {
        if(arr[i] != -1)
        {
            help = false;
            add = 'a' + i;
            break;
        }
    }
    if(!help)
    {
        cout << s + add << endl;
        return 0;
    }
    int uk1, uk2;
    for(int i = 0; i < s.size() - 1; ++i)
    {
        if(s[i] + 1 != s[i + 1] || s[i] - 1 != s[i + 1])
        {
            uk1 = i;
            break;
        }
    }
    arr[s[s.size() - 1] - 'a'] = 0;
    s.erase(s.size() - 1, 1);
    for(int i = s.size() - 1; i >= uk1; --i)
    {
        for(int j = s[i] - 'a'; j < 26; ++j)
        {
            if(arr[j] != -1)
            {
                s[i] = j + 'a';
                cout << s << endl;
                return 0;
            }
        }
        arr[s[i] - 'a'] = 0;
        s.erase(i, 1);
    }
    cout << -1 << endl;
    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

static ll const def=-1LL<<60;
template<class V,int NV> class SegTree_3 {
public:
	vector<V> val, ma;
	SegTree_3(){
		int i;
		val.resize(NV*2,0); ma.resize(NV*2,0);
		FOR(i,NV) val[i+NV]=ma[i+NV]=0;
		for(i=NV-1;i>=1;i--) ma[i]=max(ma[2*i],ma[2*i+1]);
	};
	
	V getval(int x,int y,int l=0,int r=NV,int k=1) {
		if(r<=x || y<=l) return def;
		if(x<=l && r<=y) return ma[k];
		return val[k]+max(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	
	void update(int x,int y, V v,int l=0,int r=NV,int k=1) {
		if(l>=r) return;
		if(x<=l && r<=y) {
			val[k]+=v;
			ma[k]+=v;
		}
		else if(l < y && x < r) {
			update(x,y,v,l,(l+r)/2,k*2);
			update(x,y,v,(l+r)/2,r,k*2+1);
			ma[k]=val[k]+max(ma[k*2],ma[k*2+1]);
		}
	}
};

SegTree_3<ll,1<<20> st;

int N,M;
vector<int> add[202020];
vector<pair<int,int>> del[202020];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>l>>r>>x;
		add[l].push_back(x);
		del[r].push_back({l,x});
	}
	
	ll ma=0;
	for(i=1;i<=N;i++) {
		FORR(a,add[i]) st.update(0,i,a);
		ll v=st.getval(0,i);
		ma=max(ma,v);
		st.update(i,i+1,v);
		FORR(a,del[i]) st.update(0,a.first,-a.second);
	}
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
    ll N, K, Q;
    cin >> N >> K >> Q;
    ll A[Q];
    for (int i = 0; i < Q; i++) {
        cin >> A[i];
        A[i] --;
    }

    vector<ll> points(N, K-Q);
    vector<bool> survived(N, false);

    for (int i = 0; i < Q; i++) {
        points[A[i]] ++;
    }

    for (int i = 0; i < N; i++) {
        if (points[i] > 0) survived[i] = true;
    }

    for (int i = 0; i < N; i++) {
        if (survived[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
a,b,k = [int(x) for x in input().split()] 

def func(x,y):
    x = x//2
    y += x
    return x,y

for i in range(k):
    if i%2 == 0:
        a,b = func(a,b)
    else:
        b,a = func(b,a)

print(a, b)

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

using namespace std;

int main() {
  int n;
  cin>>n;
  
  vector<vector<int>> vec(100, vector<int>(100));
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      vec.at(i).at(j)=(i+1)*(j+1);
    }
  }
  
  
  for(int p=1;p<n+1;p++){
    int ans=0;
    for(int i=0;i<100;i++){
      if(6*(i+1)*(i+1)==p){
        ans-=2;
      }
    }
    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
        if(3*(i+1)*(i+1)+2*(i+1)*(j+1)+(j+1)*(j+1)==p){
          ans+=3;
        }
      }
    }
  for(int i=0;i<100;i++){
    if(6*(i+1)*(i+1)<p){
      continue;
    }
    if((i+1)*(i+1)+2*(i+1)+3>p){
      break;
    }
    for(int j=0;j<i;j++){
      for(int k=0;k<j;k++){
        if(vec.at(i).at(j)+vec.at(i).at(k)+vec.at(j).at(k)+vec.at(i).at(i)+vec.at(j).at(j)+vec.at(k).at(k)==p){
         ans+=6;
              
        }
      }
    }
  }
    cout<<ans<<endl;
  }
}
    
  


Measured memory_bytes: 3640
import java.lang.*;
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int a = input.nextInt();
    int b = input.nextInt();
    
    int na = n * a;
    
    if(na < b) {
      System.out.println(na);
    }
    else {
      System.out.println(b);
    }
    
    return;
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	ll a, b, c, k; cin >> a >> b >> c >> k;
	ll ans = 0;
	ans += min(k, a);
	k -= min(k, a);
	if (k > 0) {
		k -= b;
	}
	if (k > 0) {
		ans -= min(k, c);
	}
	
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3652