akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	ll a,b,c;
	while(cin>>a>>b>>c){
		a=a%b;
		a*=pow(10,c);
		ll ans=a/b;
		ll  out=0;
		while(ans){
			out+=ans%10;
			ans/=10;
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1200
import java.util.*;

class Main {
	Scanner sc;
	int N;
	int[][] stmt;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		stmt = new int[N][2];
		
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			for (int j = 0; j < A; j++) {
				int x = 1 << (sc.nextInt()-1);
				int y = sc.nextInt();
				stmt[i][y] |= x;
			}
		}
		int max = 0;
		int n = 1 << N;
		for (int b = 0; b < n; b++) {
			int i = 0;
			for (; i < N; i++) {
				if ( (b&(1<<i))==0 ) continue;
				if ((stmt[i][1] & ~b) != 0) break;
				if ((stmt[i][0] & b) != 0) break;
			}
			if (i == N) max = Math.max(max, Integer.bitCount(b));
		}
		
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 23124
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int[][] arr = new int[n][m+1];
    int ans = Integer.MAX_VALUE;


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        for (int i=0; i<n; i++) {
            for (int j=0; j<m+1; j++) {
                arr[i][j] = sc.nextInt();
            }
        }

        dfs("0");
        if (ans == Integer.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }

    }

    void dfs(String s) {
        if (s.length() == n) {
            ans = Math.min(ans, calc(s));
//            System.out.println(s);
        }
        if (s.length() <= n) {
            for (int i=0; i<2; i++) {
                s = s + String.valueOf(i);
                dfs(s);
                s = s.substring(0, s.length()-1);
                if (s.length() == 1 && s.charAt(0) == '0') {
                    dfs("1");
                }
            }
        }
    }

    int calc(String s) {
        int ret = 0;
        int[] p = new int[m];
        for (int i=0; i<n; i++) {
            if (s.charAt(i) == '1') {
                for (int j=0; j<m; j++) {
                    p[j] += arr[i][j+1];
                }
                ret += arr[i][0];
            }
        }
        for (int i=0; i<m; i++) {
            if (p[i] < x) {
                return Integer.MAX_VALUE;
            }
        }
        return ret;
    }
}



Measured memory_bytes: 45468
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  for(int i = 0; i < 10000; i++){
  int za =i*0.08;
  int zb =i*0.1;
  
    
      if(za==A&&zb==B){
        cout << i << endl;
        return 0;
      }

    }
  cout << -1 << endl;
}

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

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

int main() {
    int x, y, asi;
    cin >> x >> y;

    rep(i, x) {
        asi = (2 * (x-i)) + 4 * i;
        if (asi == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, M = map(int, input().split())
    p = [int(i) - 1 for i in input().split()]
    uf = UnionFind(N)
    for _ in range(M):
        x, y = map(lambda i: int(i) - 1, input().split())
        uf.union(x, y)

    count = 0
    for i in range(N):
        if uf.same(i , p[i]):
            count += 1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13940
import sys
input = sys.stdin.readline

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

from collections import Counter
from itertools import accumulate
import bisect

C=Counter(A)

LIST=sorted(C.values())
LEN=len(LIST)
SUM=[0]+list(accumulate(LIST))
MIN=0
MAX=SUM[-1]

for k in range(1,N+1):
    MIN=0
    while MIN!=MAX:
        mid=(MIN+MAX+1)//2
        x=bisect.bisect_right(LIST,mid)

        if SUM[x]+(LEN-x)*mid>=mid*k:
            MIN=mid
        else:
            MAX=mid-1

    print(MIN)


Measured memory_bytes: 44636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
#define int ll
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second
const int MM = 1e7+5;
int n;
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	//freopen("in.txt","r", stdin);
    cin >> n;
    vector<int> div(MM,1);
    for(int i = 2; i<= n; i++){
        for(int j = i; j <= n; j += i)
            div[j]++;
    }

    ll ans = 0;
    for(int i = 1; i <= n;i++){
        ans += (i * div[i]);
    }
    cout << ans << "\n";

}


Measured memory_bytes: 81340
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
result = 0
for a in list(sorted(d.keys(), reverse = True)):
  if a not in d:
    continue
  t = (1 << a.bit_length()) - a
  if t not in d:
    continue
  if a != t:
    if d[a] < d[t]:
      i = d[a]
    else:
      i = d[t]
  else:
    if d[a] == 1:
      continue
    i = d[a] // 2
  result += i  
  if d[a] == i:
    del d[a]
  else:
    d[a] -= i
  if d[t] == i:
    del d[t]
  else:
    d[t] -= i
print(result)


Measured memory_bytes: 44704
#include <bits/stdc++.h>
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
*/
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N){
  string x="";
  while(N--){
    x += 'a'+(N%26);
    N /= 26;
  }
  reverse(all(x));
  cout << x << endl;
}


int main(){
    long long N;
				scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

struct UF{
  vector<int>par,rank;
  UF(int n){
    par.resize(n);
    rank.resize(n,0);
    for(int i=0;i<n;i++)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(rank[x]<rank[y]){
      par[y]=x;
    }
    else{
      par[x]=y;
      if(rank[x]==rank[y]){
        rank[x]++;
      }
    }
  }
  bool isSame(int x,int y){
    return root(x)==root(y);
  }
};

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

  int N,M;
  cin>>N>>M;
  vector<int>X(M),Y(M),Z(M);
  for(int i=0;i<M;i++)cin>>X[i]>>Y[i]>>Z[i];
  for(int i=0;i<M;i++)X[i]--,Y[i]--;
  UF uf(N);
  for(int i=0;i<M;i++){
    uf.unite(X[i],Y[i]);
  }
  set<int>s;
  for(int i=0;i<N;i++){
    s.insert(uf.root(i));
  }
  cout<<s.size()<<endl;
  return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

ll f(ll A) {
    if(A % 4 == 0) return A;
    if(A % 4 == 1) return 1;
    if(A % 4 == 2) return A + 1;
    return 0;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    cout << (f(B) ^ f(A - 1)) << endl; 

    return 0;
}
// 0000 ^ 1100 = 1100
// 1100 ^ 1101 = 0001
// 0001 ^ 1110 = 1111
// 1111 ^ 1111 = 

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
const int N = 100005, mod = 1000000007;
int n, m, ind[N], outd[N], pos[N], sz;
bool vis[N], fl;
struct edge { int y, nex; } g[N * 2];
void init(int x, int y) { g[++ sz] = (edge) { y, pos[x] }, pos[x] = sz; }
int node(int x, int y) {
	return !y ? x : -y;
}
void dfs(int x) {
	vis[x] = 1;
	RepE(i, x) if (!vis[ev]) dfs(ev);
}
int main()
{
	scanf ("%d%d", &m, &n);
	Rep(i, 1, m) {
		int a, b, c, d;
		scanf ("%d%d%d%d", &a, &b, &c, &d);
		int x = node(a, c), y = -node(b, d);
		if (x < 0) x = n + (-x);
		if (y < 0) y = n + (-y);
		ind[y] ++;
		outd[x] ++;
		// cout << x<<" "<<y<<endl;
		init(x, y);
	}
	Rep(i, 1, n) {
		if (ind[i] > outd[i]) fl = 1;
		if (ind[i + n] < outd[i + n]) fl = 1;
	}
//	cout << fl<<endl;
	Rep(i, 1, n * 2) {
		if (ind[i] == outd[i]) continue ;
		if (!vis[i]) dfs(i);
	}
	Rep(i, 1, n * 2) if (ind[i] && !vis[i]) fl = 1;
	puts(fl ? "NO" : "YES");

	return 0;
}

Measured memory_bytes: 1024
input_string = list(input().split())

stack = []
for s in input_string:
  if s == "+":
    a = stack.pop()
    b = stack.pop()
    c = a + b
    stack.append(c)
  elif s == "-":
    a = stack.pop()
    b = stack.pop()
    c = b - a
    stack.append(c)
  elif s == "*":
    a = stack.pop()
    b = stack.pop()
    c = b * a
    stack.append(c)
  else:
    stack.append(float(s))

print(int(stack.pop()))
    


Measured memory_bytes: 5572
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int K = scanner.nextInt();
        
        if(A>=K){
            System.out.println(K);
        }else if(A<K && A+B>=K){
            System.out.println(A);
        }else if(A+B<K){
            System.out.println(A-(K-A-B));
        }

    }
}


Measured memory_bytes: 35696
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int gcd(int x,int y){
	
	if(x%y==0){
		return y;
	}else{
		return gcd(y,x%y);
	}
	
}

int main() {
	
	int N,M;
	cin>>N>>M;
	int A[31];
	fx(31){
		A[x]=0;
	}
	fx(N){
		int a;
		cin>>a;
		fy(a){
			int b;
			cin>>b;
			A[b]++;
		}
	}
		int ans=0;
	fyg(31,1){
		if(A[y]==N){
			ans++;
		}
	}
	ce(ans)
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    ll n,a,b;cin>>n>>a>>b;

    if((b*(n-2))-(a*(n-2))+1<=0){
        cout<<0<<endl;
    }
    else {
        cout<<(b*(n-2))-(a*(n-2))+1<<endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	int N,B, K; cin >>N >> B >> K;
	int ans = K;
	VI A(N);
	for (int i = 0;i < N;i++) cin >> A[i];
	for (int i = 0;i < N;i++) {
		for (int j = 0;;j++) {
			if (j * A[i] + 1 <= B) ans++;
			else break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
A = []
3.times do
  A.push(gets.split.map(&:to_i))
end
N = gets.to_i
A_cleared = [
  [0, 0, 0],
  [0, 0, 0],
  [0, 0, 0]
]

N.times do
  tgt_num = gets.to_i
  3.times do |i|
    3.times do |j|
      if A[i][j] == tgt_num then
        A_cleared[i][j] = 1
      end
    end
  end
end

bingo = 0
3.times do |i|
  bingo += A_cleared[i][0] * A_cleared[i][1] * A_cleared[i][2]
end
3.times do |i|
  bingo += A_cleared[0][i] * A_cleared[1][i] * A_cleared[2][i]
end

bingo += A_cleared[0][0] * A_cleared[1][1] * A_cleared[2][2]
bingo += A_cleared[0][2] * A_cleared[1][1] * A_cleared[2][0]

puts bingo > 0 ? 'Yes' : 'No'


Measured memory_bytes: 1788
s = gets.chomp

ans = 0
len = s.length-1

[0, 1].repeated_permutation(len) do |bit|
  tmp_char = s[0]

  len.times do |i|
    tmp_char += '+' if bit[i] == 1
    tmp_char += s[i+1]
  end

  ans += eval(tmp_char)
end

p ans

Measured memory_bytes: 1916
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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


int main()
{
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  for (ll b = K + 1; b <= N; b++) {
    ll n = N / b;
    ans += n * (b - K);
    if (b*n + K <= N) {
      ans += N - (b*n + K);
      if (K > 0) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main(void) {
  int N; cin >> N;
  string S; cin >> S;
  int K; cin >> K;

  char e = S[K-1];
  for (char s : S) {
    if (s == e) cout << s;
    else cout << '*';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

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


long long power(long long x, long long y, long long p)
{
long long res = 1;


x = x % p;


while (y > 0)
{
if (y & 1)
res = (res*x) % p;


y = y>>1;
x = (x*x) % p;
}
return res;
}

void solve()
{
     ll n,k;
     cin>>n>>k;
     ll i,j;
     ll cnt[k+1];
     clr(cnt);
     for(i=1;i<=k;i++)
     {
        cnt[i]=k/i;
     }
     ll ans[k+1];
     clr(ans);
     for(i=k;i>=1;i--)
     {
        ll tans=power(cnt[i],n,mod);
        for(j=2*i;j<=k;j+=i)
        {
            tans-=ans[j];
            tans%=mod;
            tans+=mod;
            tans%=mod;
        }
        ans[i]=tans;
     }
    ll nos2=0;
    ll res=0;
    for(i=1;i<=k;i++)
    {
      ll tans=ans[i]*i;
      res+=tans;
      res%=mod;      
    }
    res%=mod;
    res+=mod;
    res%=mod;

    cout<<res<<"\n";

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 5220
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();

		}
		print(A);
		sc.close();
		insertionSort(A, N);

	}


	private static void insertionSort(int A[], int N){
		for (int i = 1; i < N ; i++) {
			int v = A[i];
			int j = i - 1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
				A[j + 1] = v;
			}
			print(A);
		}
	}

	static void print(int array[]){
		for (int i = 0; i < array.length; i++) {
			if(i == array.length -1){
				System.out.println(array[i]);
			}else{
				System.out.print(array[i] + " ");
			}
		}
	}
}


Measured memory_bytes: 31284
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[200005];
 
int main(){
    
		ll n,m,x;
		cin>>n>>m>>x;
		vector<vector<ll> >cost;
		for(ll i=1;i<=n;i++){
			vector<ll> k;
			ll o;
			cin>>o;
			k.pb(o);
			for(ll j=1;j<=m;j++){
				cin>>o;
				k.pb(o);
			}
			cost.pb(k);
		}
		ll ans=1e9+7;
		
		for(ll i=0;i<(1ll<<n);i++){
			ll f=1;
			ll buck=0;
			map<ll,ll> req;
			for(ll j=0;j<n;j++){
				if(i&(1ll<<j)){
					buck+=cost[j][0];
					for(ll k=1;k<=m;k++)req[k]+=cost[j][k];
				}
			}
			for(ll j=1;j<=m;j++)if(req[j]<x)f=0;
			if(f)ans=min(ans,buck);
			
		}
		if(ans==1e9+7)cout<<-1;
		else cout<<ans;
		
		
		
	
	
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int k;
	string s;
	cin>>k>>s;

	int count;
	if(k<s.size())count=k;
	else count=s.size();
	for(int i=0;i<count;i++)cout<<s[i];
	if(k<s.size())cout<<"...";
	cout<<endl;

	return 0;
}



Measured memory_bytes: 3628
n = gets.chomp.to_i
p = gets.chomp.split(" ").map(&:to_i)

count = 0
1.upto(n - 2) do |i|
  array = []
  array.push(p[i - 1], p[i], p[i + 1])
  array.sort!
  count += 1 if array[1] == p[i] && array[2] != p[i]
end

puts count


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        char[] c = s.toCharArray();

        if (c[0] == c[1] || c[1] == c[2] || c[2] == c[3]) {
            System.out.println("Bad");
        } else {
            System.out.println("Good");
        }
    }
}

Measured memory_bytes: 22100
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  string S;
  cin >> S;
  const set<char> ACGT = {'A', 'C', 'G', 'T'};
  const int N = S.size();

  size_t answer = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= N - i; j++) {
      const auto sub = S.substr(i, j);
      if (all_of(ALL(sub), [&ACGT](const char &c) {
            return ACGT.find(c) != ACGT.cend();
          })) {
        answer = max(answer, sub.size());
      }
    }
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int n,x;
    int m[110];
    cin >> n >> x;
    rep(i,n) cin >> m[i];
    sort(m,m+n);
    rep(i,n){
        x -= m[i];
    }
    cout << n+x/m[0] << endl;
}


Measured memory_bytes: 256
#! usr/bin/env python
# -*- coding: utf-8 -*-

MAX_C = 2 * 10 ** 5


def main():
    N = int(input())
    C = [int(input()) for i in range(N)]
    MOD = 10 ** 9 + 7

    NC = []
    CNT = [0] * (MAX_C+1)
    dp = [0] * (N+1)
    idx = 0
    while idx < N:
        NC.append(C[idx])
        while idx < N - 1 and C[idx] == C[idx+1]:
            idx += 1
        idx += 1

    dp[0] = 1
    for i in range(len(NC)):
        c = NC[i]
        dp[i] = (dp[i]+CNT[c]) % MOD
        dp[i+1] = (dp[i+1]+dp[i]) % MOD
        CNT[c] = dp[i]

    print(dp[len(NC)]%MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75992
IN = [input() for i in range(1)]
N = int(IN[0])
INP = [input() for i in range(int(N))]
AC = 0
WA = 0
TLE = 0
RE = 0
i = 0

while i < N:
  if INP[i] == "AC":
    AC = AC + 1
    i = i + 1
  elif INP[i] == "WA":
    WA = WA + 1
    i = i + 1
  elif INP[i] == "TLE":
    TLE = TLE + 1
    i = i + 1
  elif INP[i] == "RE":
    RE = RE + 1
    i = i + 1
  else:
    i = i + 1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))
	

Measured memory_bytes: 15964
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int mod=1e9+7;
int n,can[21][21],dp[1<<21];
void add(int& a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>can[i][j];
		dp[0]=1;
	for(int mask=0;mask<(1<<n)-1;mask++)
	{
		int m=__builtin_popcount(mask);
		for(int w=0;w<n;w++)
		{
			if(can[m][w]&&!(mask&(1<<w)))
			{
				int mask2=mask^(1<<w);
				add(dp[mask2],dp[mask]);
			}
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

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

int const N = 2e5 + 7;
int ar[N];
int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> ar[i];

	int x = 0;
	for (int i = 0; i < n; ++i)
		x ^= ar[i];

	bool space = false;
	for (int i = 0; i < n; ++i)
	{	
		if (space) cout << ' ';
		else space = true;

		cout << (x ^ ar[i]);
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll num = N/(A+B);
    ll ans = A*num;
    ll tmp = N-num*(A+B);
    if(tmp>=A){
        ans+=A;
    } else{
        ans+=tmp;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

void getValue(long long s, long long n, long long* maxScore, long long** vals) {

	if (maxScore[s] != -1) {
		return;
	}

	if (__builtin_popcount(s) <= 1) {
		maxScore[s] = 0;
		return;
	}

	// All elements are included
	long long score = 0;
	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j < n; j++) {
			if ((s & (1 << i)) && (s & (1 << j))) {
				score += vals[i][j];
			}
		}
	}
	score /= 2;

	long long b = 0;
	do {
		if (b != 0 && b != s) {
			getValue(b, n, maxScore, vals);
			getValue(s-b, n, maxScore, vals);
			score = max(score, maxScore[b] + maxScore[s-b]);
		}
	} while (b = (b-s)&s);

	maxScore[s] = score;
	return;

}

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

	long long** vals = new long long*[n];
	for (long long i = 0; i < n; i++) {
		vals[i] = new long long[n];
	}

	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j < n; j++) {
			cin >> vals[i][j];
		}
	}

	long long maxScore[(1<<n)];
	for (long long i = 0; i < (1<<n); i++) {
		maxScore[i] = -1;
	}

	getValue((1 << n) - 1, n, maxScore, vals);

	// cout << "-------" << endl;

	// for (long long i = 0; i < (1 << n); i++) {
	// 	cout << maxScore[i] << " ";
	// }
	// cout << endl;

	cout << maxScore[(1 << n) - 1] << endl;

}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int[][] mat = new int[n+1][n+1];
			for(int i = 0 ; i < mat.length -1; i++){
				for(int j = 0 ; j < mat[i].length -1; j++){
					mat[i][j] = sc.nextInt();
					mat[i][mat.length-1] += mat[i][j];
					mat[mat.length-1][j] += mat[i][j];
				}
			}
			for(int i = 0 ;  i < mat.length -1;i++){
				mat[mat.length-1][mat.length-1] += mat[mat.length-1][i];
			}
			for(int i = 0 ; i < mat.length ; i++){
				for(int j = 0 ; j < mat[i].length ;j++){
					if(1 == String.valueOf(mat[i][j]).length()){
						System.out.print("    " + mat[i][j]);
					} else if(2 == String.valueOf(mat[i][j]).length()){
						System.out.print("   " + mat[i][j]);
					} else if(3 == String.valueOf(mat[i][j]).length()){
						System.out.print("  " + mat[i][j]);
					} else if(4 == String.valueOf(mat[i][j]).length()){
						System.out.print(" " + mat[i][j]);
					} else if(5 == String.valueOf(mat[i][j]).length()){
						System.out.print(mat[i][j]);
					}

				}
				System.out.println();
			}
		}
	}

}

Measured memory_bytes: 24024
#include<bits/stdc++.h>
using namespace std ;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define lli long long int
	#define ulli unsigned long long int
	#define ff first
	#define ss second
	#define mp make_pair
	#define pb push_back
	#define pf pop_front()
	#define lb lower_bound
	#define ub upper_bound
	#define bs binary_search
	#define loop(i,a,b) for(lli i=a;i<b;i++)
	#define loopi(i,a,b) for(int i=a;i<b;i++)
	#define all(v) v.begin(), v.end()
	#define mod 1000000007
	#define inf 100000000000000000
	#define lld long double
	#define pll pair<long long int,long long int>
	#define pii pair<int,int>
	#define vll vector<lli>
	#define vii vector<int>
	#define endl '\n'
	#define setp(k, x) fixed << setprecision(k) << (x)
	#define deb(x) cerr << #x << ": " << x << " " << endl;
	#define debug(x) cout << "m here-" <<#x<<" ..."<<"\n";
	#define printa(a,n) for(lli i=0;i<n;i++) cout<<a[i]<<" "; cout<<"\n";
  #define printv(a) for(lli i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<"\n";
	bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) //sort on basis of column //use- sort(vect.begin(), vect.end(),sortcol);
      { return v1[1] < v2[1]; }//[] o based indexing in column
	bool sortpair(const pair<lli, lli> &a, const pair<lli, lli> &b)
			{return a.second < b.second;}


int main ()
{
	// fastio
 	// lli  t;
 	// cin>>t;
 	// while(t--)
 	{
		lli n,i,d,a,b,c,j,k,sum=0;
    double r;
    cin>>r;
    cout<<2*(3.1428)*r<<"\n";

 	}
}


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

using namespace std;

using ll = long long;

// n: number of items, w_i: weight, v_i: value
// maximize value under \sum w <= W
// can choose any number of same-type items
// O(nW)
// DPL_1_C: verified
int main(){
    ll n, W; cin >> n >> W;
    vector<vector<ll> > dp(n + 1, vector<ll>(W + 1));
    vector<ll> v(n + 1), w(n + 1);
    for(int i=1;i<=n;i++) cin >> v[i] >> w[i];
    for(int i=1;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(j < w[i]){
                dp[i][j] = dp[i - 1][j];
            }else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;
}



Measured memory_bytes: 10724
#include<stdio.h>



int main(){
  int i,n,j,a,A[100],c= 0,k;


  
  scanf("%d",&a);

  
  for(i = 0; i < a; i++){
    scanf("%d",&A[i]);
  }


  
  for(i = 0; i < a; i++){

    n = i;
    
    for(j = i; j < a; j++){
      if(A[j] < A[n]) {
          
	n = j;
	
      }
    }
    if(n != i) c++;
    
    k = A[i];
    A[i] = A[n];
    A[n] = k;
    
  }

  
  for(i = 0; i < a; i++){
    printf("%d",A[i]);
    if(i == a -1) break;
    printf(" ");
  }

  
  printf("\n");
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;

    if ( b % a == 0 ) {
        cout << a + b << endl;
    }
    else {
        cout << b - a << endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    char[] chr = str.toCharArray();
    Arrays.sort(chr);
    String ary = String.valueOf(chr);
    System.out.println(ary.equals("abc")?"Yes":"No");
  }
}

Measured memory_bytes: 32492
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  ios::sync_with_stdio(false);
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);

  ll ans=0;
  // fisrt and end
  if(a.at(0)-x>0) {
    ans+=a.at(0)-x;
    a.at(0) = x;
  }
  if(a.at(n-1)-x>0) {
    ans+=a.at(n-1)-x;
    a.at(n-1) = x;
  }

  // ruisekiwa
  vector<ll> sums(n-1);
  rep(i, n-1) sums.at(i) = a.at(i) + a.at(i+1);

  for (int j = 0; j < n-1; ++j) {
    if(sums.at(j)>x){
      ans += sums.at(j)-x;
      if(j!=n-2) sums.at(j+1) -= (sums.at(j)-x);
    }
  }

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

Measured memory_bytes: 1792
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int LOG_N = 60;
const int N = 100005;
long long n, a[N], xorSum = 0;
long long basic[LOG_N];
void insertVector(long long mask){
	for (int i=LOG_N-1;i>=0;--i){
		if (bits(mask, i) == 0) continue;
		if (!basic[i]) {
			basic[i] = mask;
			return;
		}
		else mask ^= basic[i];
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i=1;i<=n;++i){
		cin >> a[i];
		xorSum ^= a[i];
	}
	for(int i=0;i<LOG_N;++i) {
		if (bits(xorSum, i)){
			for(int j=1;j<=n;++j) if (bits(a[j], i)) a[j] -= (1LL << i);
		}
	}
	for(int i=1;i<=n;++i) insertVector(a[i]);
	long long maxXor = 0;
	for(int i=LOG_N-1;i>=0;--i){
		if (!basic[i]) continue;
		if (bits(maxXor, i)) continue;
		maxXor ^= basic[i];
	}
	// cout << maxXor << '\n';
	cout << (maxXor * 2 + xorSum);
}

Measured memory_bytes: 4408
#include <iostream>
#include <string>
#include <sstream>
#include <string.h>
#include <time.h>
#include <cmath>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
char Front(string s){
    char ch;
    ch=s[0];
    return ch;
}
bool print(string s){
    for(int i=0;i<s.size();i++)
        cout<<s[i];
    return true;
}
string ABC(string s){
    string ANS="";
    s=s+" ";int top=0;
    string Ans[s.size()];
    for(int i=0;i<s.size();i++)
        if(s[i]==' ') top++;
        else Ans[top]+=s[i];
    for(int i=0;i<=top-1;i++)
        ANS+=Front(Ans[i]);
    return ANS;
}
int main(){
    string s;
    getline(cin,s);
    print(ABC(s));
    cout<<endl;
    return 0;
}

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

	static Scanner sc = new Scanner(System.in); 
	static int[] intArray = new int[5];
	public static void main(String[] args) {
		read();
		slove();
	}
	static boolean read(){
		int i;
		int value;
		for(i = 0; i < 5; i++){
			value = sc.nextInt();
			intArray[i] = value;
		}
		return true;
	}
	static void slove(){
		java.util.Arrays.sort(intArray);
		int j;
		for(j = 4; j > 0; j--){
			System.out.print(intArray[j] + " ");
		}
		System.out.println(intArray[0]);
	}
}

Measured memory_bytes: 11000
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n, count;
    char ch[100000];
    count = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%s", ch);
    }
    
    int i = 0;
    while(i < n-1){
        if(ch[i] == 'O'){
            if(ch[i+1] == 'X'){
                count++;
                i += 2;
            }
            else i++;
        }
        if(ch[i] == 'X'){
            if(ch[i+1] == 'O'){
                count++;
                i += 2;
            }
            else i++;
        }
        
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 3320
h,w = map(int ,input().split())
l=[list(input().split()) for x in range(h)]
for i in range(h):
    l[i].insert(0,"#")
    l[i].append("#")
print("#"*(w+2))
for i in range(h):
    for j in range(3):
        print(l[i][j],end="")
    print("")    
print("#"*(w+2))

Measured memory_bytes: 3064
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 998244353;
// constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

vector<ll> fact(200010), factinv(200010);

ll mpow(ll b, ll e) {
    ll res = 1;
    while (e) {
        if (e&1) res *= b;
        res %= MOD;
        b *= b;
        b %= MOD;
        e >>= 1;
    }
    return res;
}

void init(void) {
    fact[0] = 1, fact[1] = 1;
    for (int i=2;i<=200010;i++) {
        fact[i] = (fact[i-1]*i) % MOD;
    }
    factinv[0] = 1, factinv[1] = 1;
    for (int i=2;i<=200010;i++) {
        factinv[i] = mpow(fact[i],MOD-2);
    }
}

int main(void) {
    int N, M, K;
    cin >> N >> M >> K;

    init();
    ll res = 0;
    for (int i=0;i<=K;i++) {
        ll t = M;
        t = t * fact[N-1] % MOD;
        t = t * factinv[N-1-i] % MOD;
        t = t * factinv[i] % MOD;
        t = t * mpow(M-1,N-1-i) % MOD;
        res = (res + t) % MOD;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 6292
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b,c;
  cin>>a>>b>>c;
  vector<int>v;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(v.begin(),v.end());
  cout<<v[0]+v[1];

  

}  


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    string S;
    cin >> S;
    string A = S.substr(0, 2);
    string B = S.substr(2, 2);

    if((A == "00" || "13" <= A && A <= "99") && "01" <= B && B <= "12") _PR("YYMM");
    else if("01" <= A && A <= "12" && (B == "00" || "13" <= B && B <= "99")) _PR("MMYY");
    else if("01" <= A && A <= "12" && "01" <= B && B <= "12") _PR("AMBIGUOUS");
    else _PR("NA");

    return 0;
}

/*



*/

Measured memory_bytes: 256
import bisect
import sys
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    S = list(input())

    a_ord = ord('a')
    z_ord = ord('z')

    set_list = [[] for _ in range(z_ord+1)]
    for i in range(N):
        s = S[i]
        set_list[ord(s)].append(i)

    Q = int(input())
    for q in range(Q):
        ipt = input().split()
        if ipt[0] == "1":
            i,c = int(ipt[1]), ipt[2]
            j = ord(S[i-1])

            if j == ord(c): continue
            set_list[j].remove(i-1)
            bisect.insort_left(set_list[ord(c)],i-1)
            S[i-1] = c
            # print(set_list[])

        else:
            l,r = int(ipt[1]), int(ipt[2])
            ans = 0
            # if l == r:
            #     print(1)
            #     continue

            for i in range(a_ord,z_ord+1):
                st = set_list[i]
                if not len(st) > 0: continue

                # print(i,set_list[i])
                l_p = bisect.bisect_left(st,l-1)
                r_p = bisect.bisect_right(st,r-1)

                # print(l-1,r-1,l_p,r_p)
                if l_p < r_p:
                    ans += 1

            # print(ans,"____")
            print(ans)



if __name__ == "__main__":
  main()


Measured memory_bytes: 106880
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define COUT(x) cout << x << endl
#define CIN(x) cin >> x
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define EXIST(s, e) (s.find(e) != s.end())
#define SORT(c) sort(c.begin(), c.end())
#define ERASEUNIQE(v) v.erase(unique(v.begin(), v.end()), v.end())

// conversion
inline int toInt(string s)
{
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x)
{
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
template <class T>
inline T sqr(T x) { return x * x; }

// typedef
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

// container util
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()

// constant
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

int main(int argc, char const *argv[])
{
  int n, m, tmp;
  cin >> n >> m;
  int k[n];
  int ans[30] = {};
  
  for(int i = 0; i < n; i++) {
    cin >> k[i];
    for(int j = 0; j < k[i]; j++) {
      cin >> tmp;
      ans[tmp-1]++;
    }
  }
  tmp = 0;
  for(int l = 0; l < m; l++) {
    if(ans[l] == n) tmp++;
  }
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 256
// Username: WillTheBill
// Time of creation: 2020-09-27 15:06
// Original filename: main.cp.cpp

#include<bits/stdc++.h>
using namespace std;

// shortcuts
#define pb push_back
#define fi first
#define se second

// IO
#define multitest signed __T; cin >> __T; while(__T--)
void _masterread(){}
template<typename T,typename... V>
void _masterread(T& t, V&... v){cin >> t;_masterread(v...);}
#define read(...)_masterread(__VA_ARGS__);
void _masterprint(){cout << endl;}
template<typename T,typename... V>
void _masterprint(T t, V... v){cout << t;if(sizeof...(v)) cout << " ";_masterprint(v...);}
#define print(...)_masterprint(__VA_ARGS__);

// TYPES
// #define int long long

// DEBUG
// colored output???
template <typename T> // start forward declaration
void _print(T t);
template<typename T1,typename T2>
void _print(pair<T1,T2> p);
template<typename T>
void _print(vector<T>v);
template <typename T> // end forward declaration
void _print(T t){cerr<<t;}
template<typename T1,typename T2>
void _print(pair<T1,T2> p){cerr<<"{";_print(p.first);cerr<<", ";_print(p.second);cerr<<"}";}
template<typename T>
void _print(vector<T>v){cerr<<"(";for(unsigned _i=0;_i<v.size();_i++)_print(v[_i]),cerr<<(_i==v.size()-1?"":", ");cerr << ")";}
void _masterdebug(){cerr<<"]\n";}
template<typename T,typename... V>
void _masterdebug(T t,V... v){_print(t);if(sizeof...(v))cerr<<", ";_masterdebug(v...);}
#ifdef __local__
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] = [";_masterdebug(__VA_ARGS__)
#else
#define debug(...) 
#endif

// ordered_set and ordered_map
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2>
using ordered_map = tree<T1, T2, less<T1>, rb_tree_tag, tree_order_statistics_node_update>;

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);    
    int K; cin >> K;
    for(int i = 0; i < K; i++) cout << "ACL";
    cout << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  if(a<1200){
    cout<<"ABC"<<endl;
  }
  else if(a<2800){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"AGC"<<endl;
  }
  
  return 0;
}


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

using namespace std;

int main(){
	int n,h;
	cin >> n >> h;
	vector<int> a(n);
	vector<int> b(n);
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];	
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	int ans=0;
	int damage = 0;
	int i=n-1;
	while(damage < h){
		if(i >= 0 && a[n-1] < b[i]){
			damage += b[i];
			i--;
			ans++;
		} else {
			ans += (h-damage)/a[n-1] + ((h-damage)%a[n-1] != 0);
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int N;
int takasa[30];
int now;
int kotae;


int main(){
  now = 0;
  kotae = 0;
	cin >> N;
	for(int i=0;i<N;i++){
    cin >> takasa[i];
	}

  for(int i=0;i<N;i++){
    if(now <= takasa[i]){
      kotae ++;
      now = takasa[i];
    }
  }
  cout << kotae << endl;
  return 0;
}

Measured memory_bytes: 256