akhauriyash/Code-Regression huggingface dataset:
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main()
{
	string s;
	s = "ACL";
	int k;
	cin >> k;
	while(k--)
	{
		cout << s;
	}
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int max1(int num[],int st,int ed)
{
	int maxn=st;
	for(int i=st+1;i<ed;i++){
		if(num[i] > num[maxn]) maxn = i;
	}
	return num[maxn];
}
int main()
{
	//freopen("test.out","w",stdout);
	int n;
	cin >> n;
	int a[n+5],b[n+5],c[n+5];
	for(int i=0;i<n;i++){
		cin >> a[i];
		b[i]=a[i]+1;
		c[i]=a[i]-1;
	}	
	int max=max1(a,0,n);
	max = max1(b,0,n) > max ?max1(b,0,n):max;
	max = max1(c,0,n) > max ?max1(c,0,n):max;
	int p[100005]={0};
	
	for(int i=0;i<n;i++){
		p[a[i]+1]++;
		p[b[i]+1]++;
		p[c[i]+1]++;	
		}		

	int t=max1(p,0,max+2);
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main(int argc, char const *argv[]) {
  int A, B, C,coin=0, day=0;
  std::cin >> A >> B >> C;
  while(coin < C){
    day = day + 1;
    coin = coin + A;
    // + - * / %
    if(day % 7 == 0){
      coin = coin + B;
    }
  }
  std::cout << day << '\n';
}



Measured memory_bytes: 3092
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        int abc[3];
        rep(i, 3) cin >> abc[i];
        if (abc[0] == abc[1] && abc[1] == abc[2] && abc[2] == abc[0]) cout << "Yes" << endl;
        else cout << "No" << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e16
ll n0,k0;
ll dp[100005]={0};
ll fun(ll arr[],ll i)
{
    if(dp[i]!=-1) return dp[i];
    if(i==n0) return 0;
    if(i>n0) return INF;
    ll a=INF;
    for(int j=1;j<=k0;j++)
    {
        if(i+j<=n0)
        a=min(a,fun(arr,i+j)+abs(arr[i+j]-arr[i]));
    }
    
    
    
    dp[i]=a;
    return dp[i];
    
    
}
void solv()
{
    ll a,b,c,d,e,f,n,m,k,t,q;
    cin>>n>>k;
    ll arr[n+1];
    n0=n;
    k0=k;
    for(int i=0;i<n;i++) 
    {
        cin>>arr[i+1];
        dp[i+1]=-1;
    }
    
    a=fun(arr,1);
    
    cout<<a<<"\n";
    
}
int main()
{
    ll a,b,c,d,e,f,n,m,k,t,q;
    t=1;
    //cin>>t;
    string s1,sf,phrase;
    while(t--)
    {
        solv();
    }
    return 0;
}

Measured memory_bytes: 8064
using System;

namespace _0096
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (string.IsNullOrEmpty(s)) break;
                int n = int.Parse(s);
                long ret = 0;
                for (int i = 0; i <= 1000; i++)
                {
                    for (int j = 0; j <= 1000; j++)
                    {
                        int nokori = n - (i + j);
                        if (0 <= nokori && nokori <= 2000)
                        {
                            if (nokori <= 1000) ret += nokori + 1;
                            else ret += 2000 - nokori + 1;
                        }
                    }
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9208
#include<stdio.h>
#include<ctype.h>
int A[200000]={0},here[200000]={0},town[200000]={0};
inline int IN(void)
{
  int x=0,f=1;char c=getchar();
  while(!isdigit(c)&&c!='-')c=getchar();
  if(c=='-')f=-f,c=getchar();
  while(isdigit(c))x=x*10+c-48,c=getchar();
  return f*x;
}
int main(void)
{
  int N,i,j,x;long long K;
  N=IN();i=scanf("%lld",&K);
  for(i=0;i<N;i++)A[i]=IN(),here[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(here[i]<0)here[i]=j,town[j]=i;else{x=here[i];break;}
  if(K>=j)K=(K-x)%(x-j)+x;
  return printf("%d\n",town[K]+1),0;
}

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

typedef long long int ll;  // ± 9.22 × 10^18
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int N, K, ans = 0;

    cin >> N >> K;

    vvi A(N, vi(K));

    for (int i = 0; i < K; i++)
    {
        int d, x;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> x;
            A[x - 1][i]++;
        }
    }

    for(int i = 0; i < N; i++){
        bool f = false;
        for (int j = 0; j < K; j++)
        {
            if (A[i][j] > 0)
            {
                f = true;
            }
        }
        if (!f) ans++;
    }

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


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

template<typename Abel>
struct WeightedUnionFind{
    int num;
    vector<int> par,rank;
    vector<Abel> diff_weight;
    WeightedUnionFind(int n,Abel id=0):
        num(n),par(n),rank(n,1),diff_weight(n,Abel(0)){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        if (x==par[x]) return x;
        int t=root(par[x]);
        diff_weight[x]+=diff_weight[par[x]];
        return par[x]=t;
    }
    bool merge(int x,int y,Abel w){
        w+=weight(x),w-=weight(y);
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y),w=-w;
        par[y]=x;
        rank[x]+=rank[y];
        diff_weight[y]=w;
        --num;
        return true;
    }
    Abel weight(int x){
        root(x);
        return diff_weight[x];
    }
    Abel diff(int x,int y){return weight(y)-weight(x);}
    bool same(int x,int y){return root(x)==root(y);}
    int size(int x){return rank[root(x)];}
    int count(){return num;}
};

// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/1/DSL_1_B

void DSL_1_B(){
    int n,q; cin >> n >> q;
    WeightedUnionFind<int> uf(n);
    for (;q--;){
        int c,x,y,z; cin >> c >> x >> y;
        if (!c){
            cin >> z;
            uf.merge(x,y,z);
        } else {
            if (uf.same(x,y)) cout << uf.diff(x,y) << '\n';
            else cout << '?' << '\n';
        }
    }
}

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


Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
#define mod 1e9+7
typedef long long ll; 
 int main(){
 ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  ll n,i,j,c=0;string s;
   cin>>n>>s;
   ll l=s.length();
   i=0;j=l-1;
  while(i!=j){
   if(s[i]=='W'&&s[j]=='R'){
    s[i]='R';s[j]='W';
     i++;j--;c++;
   }
    else if(s[i]!='W') i++;
    if(s[j]!='R') j--;
    if(i==j+1) break;
  }
  for(i=0;i<l-1;i++){
   if(s[i]=='W'&&s[i+1]=='R') {s[i+1]='W';c++;} 
  }
   cout<<c;
    return 0;
}

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

using namespace std;
string S;

long long int COUNT(string S) {

	long long int ret = 0;

	int N = S.size();
	long long int num = 0;

	for (int i = 0; i < N; i++) {
		if (S[i] == '+') {
			ret += num;
			num = 0;
		}
		else {
			num *= 10;
			num += S[i] - '0'; //cout << "num= " << num << endl;
		}
	}
	ret += num;
	return ret;
}

long long int ans=0;


void CALL(string S, int i) {

	if (i == (int)S.size()) { ans += COUNT(S); return; }

	CALL(S, i + 1);

	string T; int n = S.size();
	T = S.substr(0, i) + "+" + S.substr(i, n - i);
	CALL(T, i + 2);
}

int main(void) {

	cin >> S;

	ans = 0;
	
	CALL(S,1);

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
N=gets.to_i
as=gets.split.map(&:to_i)
bs=gets.split.map(&:to_i)
cs=gets.split.map(&:to_i)
cnt=0
for i in 0..N-1
    cnt+=bs[as[i]-1]
    cnt+=cs[as[i]-1]if i!=N-1 && as[i]+1==as[i+1]
end
p cnt


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
    IOS;
    int n;
    string s;
    cin >> n >> s;
    using ps = pair<string,string>;
    unordered_map<string,int> mp1,mp2;
    int t = 1<<n;
    REP(i,t){
        string s1,s2;
        int k = i;
        REP(j,n){
            if(k%2==1){
                s1.push_back(s[j]);
            }else{
                s2.push_back(s[j]);
            }
            k/=2;
        }
        s1.push_back('A');
        mp1[s1+s2]++;
    }
    REP(i,t){
        string s1,s2;
        int k = i;
        REP(j,n){
            if(k%2==1){
                s2.push_back(s[j+n]);
            }else{
                s1.push_back(s[j+n]);
            }
            k/=2;
        }
        reverse(all(s1));
        reverse(all(s2));
        s1.push_back('A');
        mp2[s1+s2]++;
    }
    ll res = 0;
    for(auto p:mp1){
        ll temp = (ll)p.second*mp2[p.first];
        res += temp;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 92276
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;
vector<pair<int, int>> edge[100000];
int color[100000];
void dfs(int cur, int dist){
   if(color[cur]!=-1) return;
   color[cur] = dist%2;
   for(int i=0;i<(int)edge[cur].size(); i++){
      int next = edge[cur][i].first;
      int weight = edge[cur][i].second;
      if(color[next]==-1){
         dfs(next, (dist+weight)%2);
      }
   }
   return;
}
int main(){
   int N;
   cin >> N;
   for(int i=0;i<N-1;i++){
      int u,v,w;
      cin >> u>>v>>w;
      u--;v--;
      edge[u].push_back(make_pair(v,w));
      edge[v].push_back(make_pair(u,w));
   }
   memset(color,-1,sizeof(color));
   dfs(0, 0);
   for(int i=0;i<N;i++){
      cout << color[i]<<endl;
   }

   return 0;
}


Measured memory_bytes: 8448
given_n = STDIN.gets.chomp.to_i
nums = STDIN.gets.chomp.split(' ').map { |n| n.to_i }
idx = 0
count = 0
while idx + 2 <= given_n - 1
  n1, n2, n3 = nums[idx..idx + 2]
  if (n1 < n2 && n2 < n3) || (n1 > n2 && n2 > n3)
    count += 1
  end
  idx += 1
end
puts count


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vii A(N);
  vi B,C;
  rep(i,0,M){
    int X,Y; cin>>X>>Y;
    A[X-1].pb(Y-1);
    A[Y-1].pb(X-1);
  }
  vector<bool> F(N,1);
  queue<int> Q;
  Q.push(0);
  F[0]=0;
  while(Q.size()>0){
    int X=Q.front(); Q.pop();
    B.pb(X);
    rep(i,0,A[X].size()){
      int Y=A[X][i];
      if(F[Y]){
        F[Y]=0;
        Q.push(Y);
        break;
      }
    }
  }
  Q.push(0);
  while(Q.size()>0){
    int X=Q.front(); Q.pop();
    C.pb(X);
    rep(i,0,A[X].size()){
      int Y=A[X][i];
      if(F[Y]){
        F[Y]=0;
        Q.push(Y);
        break;
      }
    }
  }
  reverse(ALL(C));
  C.pop_back();
  cout<<C.size()+B.size()<<endl;
  rep(i,0,C.size()) cout<<C[i]+1<<" ";
  rep(i,0,B.size()) cout<<B[i]+1<<" ";
  cout<<endl;
  }



Measured memory_bytes: 7156
W,a,b = map(int,input().split())

if a == b:
  print(0)
elif a < b:
  if a+W < b:
    print(b - a - W)
  else:
    print(0)
elif b < a:
  if b+W < a:
    print(a - b - W)
  else:
    print(0)

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n;
    string t;
    cin >> n >> t;
    int mid = n / 2;
    int l = 0;
    int r = mid;
    bool ok = true;
    if(n % 2 != 0) ok = false;
    else{
        while(l < mid && r < n){
        if(t[l] != t[r]){
            ok = false;
            break;
        }
        l++;
        r++;
    }

    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,n;
	cin>>h>>n;
	rep(i,n){
		int a;
		cin>>a;
		h-=a;
	}
	if(h<=0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	ll N, K;cin >> N >> K;
	vector<ll> A(N);rep(i,N) cin >> A[i];

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

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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

void suffix_array(string s,int *sa){
	int n=s.size();
	vector<int> rank(n+1,0),tmp(n+1,0);
	rep(i,n+1) sa[i]=i,rank[i]=(i<n?s[i]:-1);

	for(int k=1;k<=n;k<<=1){
		auto cmp=[&](int i,int j){
			if(rank[i]!=rank[j]) return rank[i]<rank[j];
			int ci=(i+k<=n)?rank[i+k]:-1;
			int cj=(j+k<=n)?rank[j+k]:-1;
			return ci<cj;
		};
		sort(sa,sa+n+1,cmp);
		tmp[sa[0]]=0;
		rep(i,n) tmp[sa[i+1]]=tmp[sa[i]]+cmp(sa[i],sa[i+1]);
		rep(i,n+1) rank[i]=tmp[i];
	}
	return;
}

const int nmax=250010;
int sa[nmax],len[nmax];
string s;

int sprase_table[2][nmax][20];

void init(int *a,int n){
	int logn=31-__builtin_clz(n);
	rep(i,n) sprase_table[0][i][0]=sprase_table[1][i][0]=a[i];
	rep(k,logn)rep(i,n+1-(1<<k)){
		sprase_table[0][i][k+1]=min(sprase_table[0][i][k],sprase_table[0][i+(1<<k)][k]);
		sprase_table[1][i][k+1]=max(sprase_table[1][i][k],sprase_table[1][i+(1<<k)][k]);
	}
	return ;
}

int query(int l,int r,int type){
	int i=31-__builtin_clz(r-l);
	if(type==0)
		return min(sprase_table[0][l][i],sprase_table[0][r-(1<<i)][i]);
	else
		return max(sprase_table[1][l][i],sprase_table[1][r-(1<<i)][i]);
}

int b_search(string x,int type,int n){
	int from,to,l,r;

	l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(s.substr(sa[m],x.size())<x)
			l=m;
		else
			r=m;
	}

	if(s.substr(sa[r],x.size())!=x) return -1;
	from=r;

	l=1,r=n+1;
	while(r-l>1){
		int m=(l+r)/2;
		if(s.substr(sa[m],x.size())<=x)
			l=m;
		else
			r=m;
	}
	if(s.substr(sa[l],x.size())!=x) return -1;
	to=l;
	if(from>to) return -1;
	return query(from,to+1,type);
}

int main(void){
	cin >> s;
	int n=s.size();
	suffix_array(s,sa);
	rep(i,n+1) len[i]=s.substr(sa[i]).size();
	init(len,n+1);

	int m;
	cin >> m;
	rep(loop,m){
		string x,y;
		cin >> x >> y;
		int from=b_search(x,1,n),to=b_search(y,0,n);
		int ans=0;
		if(from!=-1&&to!=-1&&(from-x.size())>=to-y.size()) ans=from-to+y.size();
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int N,A;
  cin >> N >> A;
  
  int xxx;
  xxx = N - N / 1000 * 1000;
  if (xxx > 500)
    xxx -= 500;
  
  if (A >= xxx) {
  	cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int K, X;

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

  cin >> K >> X;

  string ans = 500*K>=X?"Yes":"No";
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int main(){
	long long h,w;cin>>h>>w;
	std::vector<std::vector<char>> inp(h,std::vector<char>(w));
	REP(i,0,h-1)
	{
		REP(j,0,w-1)
		{
			cin>>inp[i][j];
		}
	}
	std::vector<std::vector<long long>> dp;
	dp.resize(h,std::vector<long long>(w,0));
	dp[0][0]=1;
	REP(r,0,h-1)
	{
		REP(c,0,w-1)
		{
			if(inp[r][c]=='#'){continue;}
			if((r-1)>=0){dp[r][c]+=dp[r-1][c];}
			if(c-1>=0){dp[r][c]+=dp[r][c-1];}
			dp[r][c]=(dp[r][c]%N);
		}
	}
	cout<<dp[h-1][w-1]<<"\n";
}

Measured memory_bytes: 9088
def main():
    N,T= (int(i) for i in input().split())
    a_min=1001

    for i in range(N):
        ai,bi= (int(j) for j in input().split())  
        if bi<= T:
            if ai <= a_min:
                a_min = ai

    if a_min==1001:
        print("TLE")
    else:
        print(a_min)
          
     
main()

Measured memory_bytes: 2940
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>


using namespace std;
const long long int MOD=1e9+7;

int main(){
  string s;
  int a[500009];
  cin >> s;
  memset(a, -1, sizeof(a));
  int cur=0;
  if(s[cur]=='<'){
    a[0] = 0;
    while(s[cur]=='<'&&cur<s.size()){
      cur++;
      a[cur] = a[cur-1]+1;
    }
  }
  while(cur<s.size()){
    while(s[cur]=='>' && cur<s.size())cur++;
    a[cur] = 0;
    int subcur=cur-1;
    while(s[subcur]=='>' && subcur>=0){
      a[subcur] = max(a[subcur+1]+1, a[subcur]);
      subcur--;
    }
    while(s[cur]=='<' && cur<s.size()){
      cur++;
      a[cur] = a[cur-1]+1;
    }
  }
  long long ans=0;
  for(int i=0;i<=s.size();i++){
    ans+=a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2820
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc078/d.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int n, z, w;
    cin >> n >> z >> w;
    rep(i, n - 2){
        int tmp;
        cin >> tmp;
    }
    if(n > 2){
        int a, b;
        cin >> a >> b;
        cout << max(abs(w - b), abs(a - b)) << "\n";
    }else{
        int a;
        cin >> a;
        cout << abs(w - a) << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#n 全探索問題
n, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(n)]
INF = float('inf')
mixMP = 10

def rec(idx, a, b, c):
  if idx == n:
    return abs(A-a) + abs(B-b) + abs(C-c)  - mixMP*3 if min(a,b,c)>0 else INF
  res1 = rec(idx+1,a,b,c) #使わない #1本目のノード(dfs)
  res2 = rec(idx+1,a+L[idx],b,c) + mixMP #Aで使う #2本目のノード(dfs)
  res3 = rec(idx+1,a,b+L[idx],c) + mixMP #Bで使う #3本目のノード(dfs)
  res4 = rec(idx+1,a,b,c+L[idx]) + mixMP #Cで使う #4本目のノード(dfs)
  return min(res1, res2, res3, res4)

print(rec(0,0,0,0))

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<stack>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<functional>
#include<queue>

using namespace std;

int main() {
	int n, flag = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a; cin >> a; if (a % 2)flag++;
	}
	if (flag % 2)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
R = []
for i in range(n):
    R.append(int(input()))

def maxR(R):
    n = len(R)
    maxv = R[1] - R[0]
    minv = R[0]
    for i in range(1,n):
        maxv = max(maxv, R[i] - minv)
        minv = min(minv, R[i])
    return maxv

print(maxR(R))



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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n;
      rrep(a,1,3501){
        rrep(b,1,3501){
          if((b*n)%a!=0)continue;
          if((4*b-b*n/a-n)==0)continue;
          if((b*n)%(4*b-b*n/a-n)==0){
             c=(b*n)/(4*b-b*n/a-n);
            if(c<=0)continue;
            cout<<a<<" "<<b<<" "<<c<<"\n";
            return 0;
          }
        }
      }   
      
       
return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
#define MAX 1000001
#define MAXN 200001
#define mod 1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,sum=0,x,m;
    cin>>m>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    vector<ll> vi;
    if(m>=n){
        cout<<0;
    }
    else{
        sort(a,a+n);
        for(i=0;i<n-1;i++){
            x=a[i+1]-a[i];
            vi.pb(x);
           // cout<<x<<" ";
        }
        sort(vi.begin(),vi.end());
        x=n-m;
        for(i=0;i<x;i++){
            sum+=vi[i];
        }
        cout<<sum;
    }
}

Measured memory_bytes: 2168
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

import collections
counter = collections.defaultdict(int)
for key, value in collections.Counter(A).items():
    counter[key] = value

ans = sum(A)

for _ in range(Q):
    b, c = map(int, input().split())
    # print("b: {} c: {} counter: {}".format(b, c, counter))
    v = counter[b]
    counter[b] = 0
    counter[c] += v
    dif = v * (c - b)
    ans += dif
    # print("b: {} c: {} counter: {}".format(b, c, counter))
    print(ans)

Measured memory_bytes: 24216
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <list>
#include <ctime>
#include <random>
using namespace::std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	int a[300002] = {};

	for(int i = 1; i < n; i++){
		if(s[i] == 'E'){
			a[i] = a[i-1]+1;
		} else{
			a[i] = a[i-1]-1;
		}
	}

	for(int i = n-2; i > -1; i--){
		if(s[i] == 'W'){
			a[i] = a[i+1]+1;
		} else{
			a[i] = a[i+1]-1;
		}
	}

	int temp=0, c=0;
	for(int i = 0; i < n; i++){
		if(temp < a[i]) {
			temp = a[i]; 
			c = i;
		}
	}
	// cout << b;
	int ans=0;
	for(int i = 0; i < n; i++){
		if(i < c) {
			if(s[i] == 'W'){
				ans++;
			}
		} else if(i > c){
			if(s[i] == 'E'){
				ans++;
			}
		}
	}
	cout << ans;
	return 0;
}

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

int main(){
    string str;
    int joi, ioi;
    while(cin >> str){
        joi = 0;
        ioi = 0;
        for(int i=0;i<str.size()-2;i++){
            if(str[i] == 'J' && str[i+1] == 'O' && str[i+2] == 'I'){
                joi++;
            }else if(str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I'){
                ioi++;
            }
        }
        cout << joi << endl << ioi << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

ll s(ll n){
  ll ret = 0;
  while (n != 0){
    ret += n % 10;
    n /= 10;
  }
  return ret;
}

int main(void){
  ll n;
  cin >> n;
  
  if (n % s(n) == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    

  return 0;
}


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

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

string S;
int idx;
int N, M;
string alphas;
int curr;

void consume(char c) {
  if(idx >= N) throw exception();
  if(S[idx] != c) throw exception();
  idx ++;
}

bool try_consume(char c) {
  try {
    consume(c);
  } catch(...) {
    return false;
  }
  return true;
}

int E();

int convert(string const& b) {
  int n = b.size();
  int ret = 0;
  for(int i=0; i<n; i++) {
    ret *= 2;
    assert(isdigit(b[i]));
    ret += b[i] - '0';
  }
  return ret;
}

string B() {
  string ret;
  while(1) {
    if(S[idx] == '0') ret += '0';
    else if(S[idx] == '1') ret += '1';
    else break;
    idx++;
  }
  return ret;
}

int Nu() {
  if(try_consume('0')) return 0;
  consume('1');
  return convert("1" + B());
}

int F() {
  if(try_consume('-')) {
    return -F();
  }
  else if(try_consume('(')) {
    int r = E();
    consume(')');
    return r;
  }
  else {
    return Nu();
  }
}

int T() {
  int num1 = F();
  while(try_consume('*')) {
    int num2 = F();
    num1 *= num2;
  }
  return num1;
}

int E() {
  int term1 = T();
  while(1) {
    bool cont = 0;
    while(try_consume('+')) {
      cont = 1;
      int term2 = T();
      term1 += term2;
    }
    while(try_consume('-')) {
      cont = 1;
      int term2 = T();
      term1 -= term2;
    }
    if(!cont) break;
  }
  return term1;
}

bool Q() {
  int expr1 = E();
  consume('=');
  int expr2 = E();
  return expr1 == expr2 && idx == N;
}

int main() {

  string T = "01+-*()=";
  sort(T.begin(), T.end());
  string RS; cin >> RS;
  N = RS.size();
  for(auto c: RS) if(isalpha(c)) alphas.push_back(c);
  sort(alphas.begin(), alphas.end());
  alphas.erase(unique(alphas.begin(), alphas.end()), alphas.end());
  M = alphas.size();

  if(M > T.size()) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  set<string> st;
  do {
    S = RS;
    rep(i, N) {
      if(isalpha(S[i])) S[i] = T[alphas.find(S[i])];
    }
    if(!st.count(S)) {
      st.insert(S);
      idx = curr = 0;
      try { ans += Q(); } catch (...) {}
    }
  } while(next_permutation(T.begin(), T.end()));
  
  cout << ans << endl;

  return 0;
}

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

int main(){
  int N, W;
  cin >> N >> W;
  map<long long, long long> D1;
  map<long long, long long> D2;
  D1[0LL] = 0LL, D2[0LL] = 0LL;
  long long w, v;
  vector<pair<long long, long long>> tmp(0);
  for (int i=0;i<N/2;i++){
    cin >> w >> v;
    for (pair<long long, long long> p : D1){
      tmp.push_back(p);
    }
    for (pair<long long, long long> j : tmp){
      if (j.first + w <= W){
        if (D1.count(j.first + w)){
          D1[j.first+w] = max(j.second + v, D1[j.first+w]);
        }
        else{
          D1[j.first+w] = j.second + v;
        }
      }
    }
    tmp = {};
  }
  for (int i=N/2;i<N;i++){
    cin >> w >> v;
    for (pair<long long, long long> p : D2){
      tmp.push_back(p);
    }
    for (pair<long long, long long> j : tmp){
      if (j.first + w <= W){
        if (D2.count(j.first + w)){
          D2[j.first+w] = max(j.second + v, D2[j.first+w]);
        }
        else{
          D2[j.first+w] = j.second + v;
        }
      }
    }
    tmp = {};
  }
  long long n = D2.size();
  long long t = n;
  vector<long long> L2(0);
  for (pair<long long, long long> p : D2){
    L2.push_back(p.first);
  }
  sort(L2.begin(), L2.end());
  vector<long long> VM(n);
  VM[0] = 0LL;
  long long x;
  for (int i=1;i<n;i++){
    x = D2[L2[i]];
    if (x > VM[i-1]){
      VM[i] = x;
    }
    else{
      VM[i] = VM[i-1];
    }
  }
  long long cnt = 0;
  while (t != 0){
    cnt += 1;
    t /= 2;
  }
  int l, r, d;
  long long M = 0;
  for (pair<long long, long long> p : D1){
    x = p.first;
    if (x + L2[n-1] <= W){
      if (M < p.second + VM[n-1]){
        M = p.second + VM[n-1];
      }
    }
    else{
      l = 0, r = n, d = n / 2;
      for (int j=0;j<=cnt;j++){
        if (x + L2[d] < W){
          l = d + 1;
          d = (l + r) / 2;
        }
        else{
          r = d;
          d = (l + r) / 2;
        }
      }
      if (M < VM[d] + p.second){
        M = VM[d] + p.second;
      }
    }
  }
  cout << M << endl;
}

Measured memory_bytes: 15860
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, m, i, j, k, ans = 0;
	cin >> n >> m >> k;
	vector<long long> a(n), b(m), sa(n + 1), sb(m + 1);
	vector<long long>::iterator it;
	sa[0] = 0; sb[0] = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		sa[i + 1] = sa[i] + a[i];
	}
	for (i = 0; i < m; i++) {
		cin >> b[i];
		sb[i + 1] = sb[i] + b[i];
	}
	for (i = 0; (i <= n) && (sa[i] <= k); i++) {
		it = upper_bound(sb.begin(), sb.end(), k - sa[i]);
		if (it == sb.begin()) ans = max(ans, i);
		else ans = max(ans, i + (long long)(it - sb.begin()) - 1);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 9100
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

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

        }
        Arrays.sort(p);

        int ans =0;
        for(int i=0;i<K;i++){
            ans += p[i];
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 39044
#include<stdio.h>
long long int modpow(long long int a, long long int n, long long int p)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int p = 1000000007;
	long long int cnt[100005];
	long long int i, j;
	for (i = 1; i <= k; i++)
		cnt[i] = modpow(k / i, n, p);
	for (i = k; i > 1; i--)
	{
		cnt[1] = (cnt[1] - cnt[i] + p) % p;
		for (j = 2; j * j <= i; j++)
		{
			if (i % j == 0)
			{
				cnt[j] = (cnt[j] - cnt[i] + p) % p;
				if (j * j < i)
					cnt[i / j] = (cnt[i / j] - cnt[i] + p) % p;
			}
		}
	}
	long long int ans = 0;
	for (i = 1; i <= k; i++)
		ans = (ans + i * cnt[i] % p) % p;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2512
s=input()
s=s.replace("BC","D")
s=s.replace("B"," ")
s=s.replace("C"," ")
s=list(s.split())
ans=0
for u in s:
    if u:
        u=list(u)
        count=0
        cnt=0
        for i in range(len(u)):
            if u[i]=="D":
                count+=i
                cnt+=1
        ans+=count-cnt*(cnt-1)//2
print(ans)

Measured memory_bytes: 66160
//
//#include <atcoder/fenwicktree>
//#include <atcoder/segtree>
//#include <atcoder/lazysegtree>
//#include <atcoder/string>
//#include <atcoder/math>
//#include <atcoder/convolution>
//#include <atcoder/modint>
//#include <atcoder/dsu>
//#include <atcoder/maxflow>
//#include <atcoder/mincostflow>
//#include <atcoder/scc>
//#include <atcoder/twosat>
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, X, M;
    cin >> N >> X >> M;

    // ループするまで回す
    ll A = X;
    ll loopStart = 0;
    ll loopLen = 0;
    ll loopTotal = 0;
    ll sigma = 0;
    struct Item
    {
        ll index;
        ll sigma;
    };
    map<ll, Item> apper; // (数値、Item)
    ll i = 0;
    for(i =0;;++i)
    {
        //
        auto ite = apper.find(A);
        if (ite != apper.end())
        {
            loopStart = ite->second.index;
            loopLen = i - ite->second.index;
            loopTotal = sigma - ite->second.sigma;
            break;
        }
        Item item = { i,sigma };
        apper.insert({ A, item });
        //
        sigma += A;
        A = (A * A) % M;
        //
        if (i+1 == N)
        {
            cout << sigma;
            return 0;
        }
    }
    //
    N -= loopStart;
    sigma += (N / loopLen - 1) * loopTotal;
    // 残りのループ分を出す
    ll remain = N % loopLen;
    for (ll i = 0; i < remain; ++i)
    {
        sigma += A;
        A = (A * A) % M;
    }
    cout << sigma;
    return 0;
}
//492443256280248
//492443256176507
//492443217470467
//       38706040


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  int64_t mi = 1LL<<51;
  REP(a, 1, N) {
    int b = N - a;
    auto A = std::to_string(a);
    auto B = std::to_string(b);
    auto k = A.size();
    auto l = B.size();
    int64_t cand = 0;
    rep(i, k) {
      cand += A[i] - '0';
    }
    rep(i, l) {
      cand += B[i] - '0';
    }
    mi  = std::min(cand, mi);
  }
  cout << mi << endl;
}


Measured memory_bytes: 256
#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()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N,Q;
  cin>>N>>Q;
  vector<vector<int>>g(N);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int>p(Q),x(Q);
  for(int i=0;i<Q;i++)cin>>p[i]>>x[i];
  vector<int>node(N,0);
  for(int i=0;i<Q;i++)node[p[i]-1]+=x[i];
  vector<bool>used(N,false);
  used[0]=true;
  queue<pair<int,ll>>q;
  q.push({0,0});
  while(q.size()){
    int now=q.front().first;
    ll c=q.front().second;
    q.pop();
    for(auto it:g[now]){
      if(used[it])continue;
      used[it]=true;
      q.push({it,node[now]+c});
    }
    node[now]+=c;
  }
  for(auto it:node)cout<<it<<" ";
  cout<<endl;
  return 0;
}


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

int main()
{
    long long a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k & 1) {
        long long aa = b + c, bb = a + c, cc = a + b;
        k--;
        a = aa;
        b = bb;
        c = cc;
    }
    cout << a - b << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if (S[K-1]=='A') S[K-1] = 'a';
  if (S[K-1]=='B') S[K-1] = 'b';
  if (S[K-1]=='C') S[K-1] = 'c';
  cout << S << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  if(n % 10 == 3){
    cout << "bon" << endl;
  }else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> D(10);
  int d;
  for (int i = 0; i < K; i++)
  {
    cin >> d;
    D[d] = 1;
  }

  for (int i = N; N <= 10000; i++)
  {
    int c = i;
    bool ok = true;
    while (c)
    {
      if (D[c % 10])
      {
        ok = false;
        break;
      }
      c /= 10;
    }
    if (ok)
    {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))

    m = min(A)
    M = max(A)

    Result = 1 << 30

    for i in range(m, M+1):
        Result_tmp = 0
        for a in A:
            Result_tmp += (a - i) * (a - i)
        Result = min(Result_tmp, Result)
    print(Result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060