akhauriyash/Code-Regression huggingface dataset:
N = int(input())
al = [int(an) for an in input().split()]
a = [ "4" if al[i]%4==0 else "k" if al[i]%2!=0 else "g" for i in range(N)]
if a.count("k") == a.count("4") or len(a) == a.count("g") + a.count("4"):
	print("Yes")
elif (a.count("k") - 1) == a.count("4")  and a.count("g")==0:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 14252
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        System.out.println(solve(a));
    }
    public static long solve(long[] a) {
        int answer = 0;
        for (int i = 0; i < a.length; i++) {
            answer += sub(a[i]);
        }
        return answer;
    }
    public static long sub(long x) {
        int count = 0;
        while (x % 2 == 0) {
            count += 1;
            x /= 2;
        }
        return count;
    }
}


Measured memory_bytes: 33248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=202;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      string s;
      cin>>s;
      sort(all(s));
      if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
      {
            cout<<"Yes\n";
      }
      else cout<<"No\n";
}  
// I never lose. I either win or I learn

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

int main(){
	int n,k;
	cin>>n>>k;
	
	long long ans=k;
	
	for(int i=1;i<=n-1;i++){
		ans=ans*(k-1);	
	}
	if(ans<=0)cout<<LONG_LONG_MAX+ans;
	else cout<<ans;
}

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

std::string s;
void input()
{
    std::cin>>s;
}

int main()
{
    input();
    int value = std::stoi(s);
    std::string res = "AMBIGUOUS";
    int first = value % 100; //**??
    int second = (value - first)/100; //??**

    if(first>=13||first==0)res = "MMYY";//**??の??は西暦を表す
    if(second>=13||second==0)res = "YYMM";//??**の??は西暦を表す
    if((second>=13||second==0)&&(first>=13||first==0))res = "NA";
    std::cout<<res<<std::endl;

}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int t = 0;
  while (a >= b) {
    b *= 2;
    t++;
  }
  while (b >= c) {
    c *= 2;
    t++;
  }
  if (t <= k) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3588
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let l: u64 = sc.read();
    let t: u64 = sc.read();
    let xw: Vec<_> = (0..n)
        .map(|_| (sc.read::<u64>(), sc.read::<u32>() == 1))
        .collect();

    let n = n as u64;
    let mut clock_count = 0;
    let mut counter_count = 0;
    for &(x, clockwise) in xw.iter() {
        if clockwise {
            clock_count += (x + t) / l;
        } else {
            counter_count += (l - x + t - 1) / l;
        }
    }

    clock_count %= n;
    counter_count %= n;
    let mut end_state = xw
        .iter()
        .map(|&(x, clockwise)| {
            if clockwise {
                ((x + t) % l, clockwise)
            } else {
                ((l - (l - x + t) % l) % l, clockwise)
            }
        })
        .collect::<Vec<_>>();
    end_state.sort();
    let first = (clock_count - counter_count + n) % n;
    for i in 0..n {
        println!("{}", end_state[((first + i) % n) as usize].0);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 9340
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;
bool cmp(const pair<int,int>&a , const pair<int,int>&b){
  if(a.second != b.second) return a.second < b.second;
  return a.first < b.first;
}
signed main(){
 // ios::sync_with_stdio(false);cin.tie(0);

 int n;
 cin >> n;
 double sum =  0.0;

 for(int i=0;i<n;i++){
   double x;
   cin >> x;
   sum += (1.0 / x);
 }
 sum = 1.0 / sum;

 printf("%0.10lf\n",sum);

}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{	rtn
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 401, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[4 * N], dp[N][N], sum[4 * N];


int get(int l, int r)
{
	if ( l == r ) return dp[l][r] = 0;

	int &mafia = dp[l][r];
	if (mafia != -1 ) return mafia;

	int ans = INF;
	for (int p = l; p < r; p++) {
		int a1 = get(l, p), a2 =  get(p + 1, r);
		int total = a1 + a2 + (sum[r] - sum[l - 1]);
		ans = min(ans, total);
	}

	return mafia = ans;
}

void solve()
{
	cin >> n;
	lop(i, 1, n + 1) cin >> arr[i], arr[i + n] = i;
	lop(i, 1, n + 1) sum[i] = sum[i - 1] + arr[i];

	memset(dp, -1, sizeof dp);
	lop(i, 1, n + 1)lop(j, i, n + 1) get(i, j);
	cout << dp[1][n];





}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
	// INP();
	int test = 1;
	//cin >> test;

	// cout << setprecision(9) << fixed;
	// clock_t z = clock();
	while (test--)solve();
	// cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
}











inline void INP()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt",  "r",  stdin);
	freopen("output.txt", "w", stdout);
#endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 1664
#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>
using namespace std;
typedef struct Train{
   public:
   int a;
   int b;
   int v;
}Train;

int main(){
   int n,m,s,t;
   scanf("%d%d%d%d", &n,&m,&s,&t);
   s--;t--;
   vector<Train> edge[n];
   for(int i = 0 ; i < m ; i ++){
      int u,v,a,b;
      Train t1;
      Train t2;
      scanf("%d%d%d%d", &u,&v,&a,&b);
      u--;v--;
      t1.v=v; t1.a=a; t1.b=b;
      t2.v=u; t2.a=a; t2.b=b;
      edge[u].push_back(t1);
      edge[v].push_back(t2);
   }
   long long minMoney[n];
   long long minSnook[n];
   for(int i = 0 ; i < n ; i++) {
      minMoney[i]=LLONG_MAX;
      minSnook[i]=LLONG_MAX;
   }
   priority_queue<pair<long long,int> > pq_money;
   pq_money.push(make_pair(0LL, s));
   minMoney[s] = 0;
   while(!pq_money.empty()){
      pair<long long, int> p= pq_money.top();
      pq_money.pop();
      long long money = -p.first;
      int pos = p.second;
      if( minMoney[pos] > money) continue;
      //cout << pos <<", "<< minMoney[pos] << endl;
      for( int i = 0 ; i < (int)edge[pos].size(); i++){
         int next = edge[pos][i].v;
         int cost = edge[pos][i].a;
         if( minMoney[next] > money+cost){
            minMoney[next] = money+cost;
            pq_money.push(make_pair(-(money+cost), next));
         }
      }
   }
   priority_queue<pair<long long,int> > pq_snook;
   pq_snook.push(make_pair(0LL, t));
   minSnook[t] = 0;
   while(!pq_snook.empty()){
      pair<long long, int> p= pq_snook.top();
      pq_snook.pop();
      long long snook = -p.first;
      int pos = p.second;
      if( minSnook[pos] > snook) continue;
      //cout << pos <<", "<< minSnook[pos] << endl;
      for( int i = 0 ; i < (int)edge[pos].size(); i++){
         int next = edge[pos][i].v;
         int cost = edge[pos][i].b;
         if( minSnook[next] > snook+cost){
            minSnook[next] = snook+cost;
            pq_snook.push(make_pair(-(snook+cost), next));
         }
      }
   }
   long long ans[n];
   ans[n-1] = minMoney[n-1]+minSnook[n-1];
   for(int i = n-2; i >= 0; i--){
      ans[i] = min(ans[i+1], minMoney[i]+minSnook[i]); 
   }
   for(int i = 0 ; i < n; i++){
      //cout<< 1000000000000000LL-ans[i]<<endl;
      printf("%lld\n", 1000000000000000LL-ans[i]);
   }
   return 0;
}


Measured memory_bytes: 11892
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()
#define fi first
#define se second
#define sqrt(x) sqrt(abs(x))
#define sqr(x) ((x) * (x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define fill(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb emplace_back
#define popcnt __builtin_popcount
#define ctz __builtin_ctz

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;

template <class T> using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T>
istream& operator >> (istream &in, vector <T> &a) {
    for (T &i: a) in >> i;
    return in;
}

template <class T>
ostream& operator << (ostream &out, vector <T> &a) {
    for (T &i: a) out << i << ' ';
    out << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream &out, set <T> &a) {
    for (auto &i: a) out << i << ' ';
    out << '\n';
    return out;
}

template <class T, class U>
istream& operator >> (istream &in, pair <T, U> &p) {
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator << (ostream &out, pair <T, U> &p) {
    out << p.first << ' ' << p.second << '\n';
    return out;
}

void fastIO() {
    ios_base:: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
}

void solve();

string s;

signed main() {
    fastIO();

    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");

    return 0;
}

/// ЗАПУСКАЕМ ГУСЯ:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */



Measured memory_bytes: 256
//stringray

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

/*#ifndef __LOCAL__ 
#pragma comment(linker,"/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif*/ 

using namespace std;
using namespace __gnu_pbds;
 
//#define int int64_t

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ost;

typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<set<int>> vsi;

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define F first
#define S second
#define fore(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define debug(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0)


const int N1=100*1000;
const int N2=1000*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T>
istream& operator >> (istream& is,vector<T>& vec){
  for(T &x:vec)is>>x;
  //for(int i=0;i<vec.size();++i)is>>x[i];
  return is;
}

template<typename T>
ostream& operator << (ostream& os,vector<T>& vec){
  for(int i=0;i<vec.size();++i){
    os<<vec[i]<<(i+1==vec.size()?"":" ");
  }
  return os;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll FIXED_RANDOM=chrono::steady_clock::now().time_since_epoch().count();

struct chash {
    static unsigned long long hash_f(unsigned long long x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    static unsigned hash_combine(unsigned a, unsigned b) { return a * 31 + b; }
    int operator()(int x) const { return hash_f(x); }
};
//unordered_map <int, int, chash> m; way to use this 
//the way you're supposed to do is it by initializing FIXED_RANDOM with something like chrono::steady_clock::now().time_since_epoch().count()(current time in microseconds or something like that) and instead of hash_f(x) do hash_f(FIXED_RANDOM^x) 

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

ll mpow(ll a, ll b){
  ll ret=1;
  while(b>0){
    if(b&1LL)(ret*=a)%=mod;
    (a*=a)%=mod;
    b>>=1LL;
  }
  return ret;
}

void solve(){

  int a,b;cin>>a>>b;
  cout<<max(0,a-2*b)<<endl;
}
int32_t  main(){
  IOS;
  cout<<(fixed)<<setprecision(6);
  solve();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int h,w;
vector<vector<char>> a;
int dp[1100][1100];//0,0~i,jの経路数
int main(){
 cin>>h>>w;
  a.resize(h,vector<char>(w));
 rep(i,h){
   rep(j,w)
   cin>>a[i][j]; 
 }
  dp[0][0]=1;
  rep(i,h){
    rep(j,w){
      if(a[i][j]!='#'){
          if(i-1>=0)dp[i][j]+=dp[i-1][j];
           dp[i][j]%=inf;
          if(j-1>=0)dp[i][j]+=dp[i][j-1];
        dp[i][j]%=inf;
      }
    }
  }
 /* rep(i,h){
   rep(j,w)
   cout<<dp[i][j];
    cout<<endl;
 }*/
  cout<<dp[h-1][w-1]<<endl;
  /////////////n
}

Measured memory_bytes: 5504
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int c[6];
    bool check = true;
    for(int i =0 ; i < 6; i++){
        cin >> c[i];
    }
    for(int i = 0; i < 5; i ++ ){
        for(int j = 0; j < 5; j++){
            if(abs(c[i]-c[j]) > c[5]){
                check= false;
            }
        }
    }
    if(check){
        cout << "Yay!" << endl;
    }else{
        cout<<":("<< endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

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

    sort(ALL(A));
    vector<int> Vec(1000100, 0);
    rep(i, n) {
        int a = A[i];
        if(Vec[a] != 0) {
            Vec[a] = 2;
            continue;
        }
        for(int j = a; j < 1000100; j += a) {
            Vec[j]++;
        }
    }
    int ans = 0;
    for(auto x : A) {
        if(Vec[x] == 1) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7988
#include<bits/stdc++.h>
using namespace std;
 
int a[100005];
int dp[100005][50];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    int L,Q;
    scanf("%d%d",&L,&Q);
    for(int i = 1;i <= n;i++)
    {
        int id = upper_bound(a+1,a+1+n,a[i]+L)-a-1;
        if(a[i] + L >= a[n])
            dp[i][0] = n;
        else
            dp[i][0] = id;
    }
     
    for(int i = 1;i <= 30;i++)
    {
        for(int j = 1;j <= n;j++)
            dp[j][i] = dp[dp[j][i-1]][i-1];
    }
    while(Q--)
    {
        int L,R;
        scanf("%d%d",&L,&R);
        if(R<L)
            swap(L,R);  
        long long ans=0;
        for(int i = 30;i >= 0;i--)
        {
            if(dp[L][i] < R)
            {
                ans=ans+(1ll<<i);
                L = dp[L][i];
            }
        }
        printf("%lld\n",ans+1);
    }
    return 0;
}

Measured memory_bytes: 20736
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n;cin>>n;
  vector<pair<ll,ll>>v(n);
  rep(i,n)cin>>v[i].first;
  rep(i,n)v[i].second=i+1;
  sort(all(v));
  // cout<<v<<endl;
  set<ll>st;
  st.insert(0);
  st.insert(n+1);
  ll ans=0;
  rep(i,n){
    ll x=v[i].second;
    st.insert(x);
    ll left=*st.find(x)-*(--st.find(x));
    ll right=*(++st.find(x))-*st.find(x);
    ans+=v[i].first*left*right;
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 12800
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
	int n, m, sum;
	int a[1005];
	cin >> n >> m;
	sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	if(a[n-m]>=(sum*1.0/(4*m)))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            int N = Integer.parseInt(br.readLine());
            int ans = 0;
            for (int i = N; i > 0; i--) {
                ans = i;
                double tmpSqrt = Math.sqrt(i);

                if (tmpSqrt % 1 == 0) {
                    break;
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using pll = pair<ll,ll>;
const ll INF64 = 1LL << 60;
const int INF = (1 << 29);

int main(){
    string s; cin >> s;
    string t; cin >> t;
    int n = s.size();
    int m = t.size();
    string tmp = s;

    rep(i,n){
        if(tmp[i]=='?') tmp[i] = 'a';
    }

    vector<string> ans;
    rep(i,n-m+1){
        bool flag = true;
        for(int j=i; j<i+m; j++){
            if(s[j]=='?') continue;
            else if(s[j]!=t[j-i]){
                flag = false;
                // cout << "i " << i << endl;
                // cout << s[j] << " " << t[j] << endl;
                break;
            }
        }
        if(flag){
            string v = tmp;
            string u = v.replace(i,m,t);
            ans.push_back(u);
        }
    }

    sort(ans.begin(), ans.end());
    if(ans.size()==0) cout << "UNRESTORABLE" << endl;
    else cout << ans[0] << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include<vector>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;

int main()
{
    ll n,w;
    cin>>n>>w;
    ll c[n],p[n];
    for(ll i=0;i<n;i++){
        cin>>c[i]>>p[i];
    }
for(ll i=0;i<n-1;i++){
        for(ll j=0;j<n-i-1;j++){
            if(c[j]>=c[j+1]){
                swap(c[j],c[j+1]);
                swap(p[j],p[j+1]);
            }
        }
    }

    ll m[n+1][w+1];
    for(ll i=0;i<=n;i++)
        m[i][0] = 0;
    for(ll i=0;i<=w;i++)
        m[0][i] = 0;

    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=w;j++){
            if(j<c[i-1]){
                m[i][j]=m[i-1][j];
            }
            else{
                m[i][j]= max(m[i-1][j],p[i-1]+m[i-1][j-c[i-1]]);
            }
        }
    }



    cout<<m[n][w];

}




Measured memory_bytes: 79104
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int a, b;
    cin >> a >> b;
    cout << ( ( a * 3 + b ) / 2 ) << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;

 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int ans = 0;
    for(int i = 0; i < n; i++){
      int nownum = sc.nextInt();
      boolean prime = true;
      for(int j = 2; j * j <= nownum; j++){
        if(nownum % j == 0){
          prime = false;
          break;
        }
      }
      if(prime){ans++;}
    }
    System.out.println(ans);
  }
 
  
// LinkedList<Integer>[] setsu = new LinkedList[n];
// for(int i = 0; i < n; i++){
//   setsu[i] = new LinkedList<Integer>();
// } 

 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A1(N), A2(N);
    rep(i, N) cin >> A1[i];
    rep(i, N) cin >> A2[i];
    ll ans = 0;
    rep(i, N) {
        ll c = 0;
        rep(j, i + 1) {
            c += A1[j];
        }
        rep2(j, i, N) {
            c += A2[j];
        }
        ans = max(ans, c);
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N;
pair<int, int> A[MAXN];
int ans;

int main() {
	register int i;
	scanf( "%d", &N );
	for( i = 1; i <= N; ++i )
		scanf( "%d", &A[i].first ), A[i].second = i;
	sort( A + 1, A + N + 1 );
	for( i = 1; i <= N; ++i )
		ans += (i - A[i].second) & 1;
	printf( "%d\n", ans >> 1 );
	return 0;
}

Measured memory_bytes: 896
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

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

inline ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

ll a, b, c, d;

ll f(ll i)
{
  return (i / c + i / d - i / lcm(c, d)) + 1;
}

int main()
{
  init_main();

  cin >> a >> b >> c >> d;
  cout << (b - a + 1) - (f(b) - f(a - 1)) << endl;

  return 0;
}

Measured memory_bytes: 256
import math
import itertools
import statistics
#import collections
n = int(input())
A = list(map(int, input().split()))
alice = 0
bob = 0
A.sort(reverse=True)
for i in range(n):
    if i%2==0:
        alice += A[i]
    else:
        bob += A[i]
 
print(alice-bob)

Measured memory_bytes: 6044
S = input()

Left  = int(S[0:2])
Right = int(S[2:4])


if   0 < Left <= 12 and 0 < Right <= 12:
	print("AMBIGUOUS")
elif 0 < Left <= 12 and (Right >= 12 or Right == 0):
	print("MMYY")
elif (Left >= 12 or Left == 0) and 0 < Right <= 12:
	print("YYMM")
else:
	print("NA")


Measured memory_bytes: 3060
#ABC072C
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[0]*(max(A)+1)
back=A[0]
count=0
for a in A:
	if back==a:
		count+=1
	else:
		B[back]=count
		back=a
		count=1
B[back]=count
num=sum(B[0:min(3,len(B))])
for n in range(max(A)-1):
	if num<sum(B[n:n+3]):
		num=sum(B[n:n+3])
print(num)

Measured memory_bytes: 13964
#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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll X,Y; cin >> X >> Y;
    cout << (abs(X-Y) <= 1 ? "Brown" : "Alice") << endl;
    return 0;
}

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

int main(){
  double n;
  double ans=0.0;
  cin >> n ;
  if(n==1.0){
    ans=1.0;
  }else if(((int)n % 2)==1){
    ans=((n+1.0)/2.0)/n;
  }else{
    ans=0.5;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
a = inpl()
ans = 0
for i in range(0, N, 2):
	if a[i]%2==1:
		ans+=1
print(ans)


# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9176
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

#------------------------------------------#

BIG_NUM = 2000000000
HUGE_NUM = 9999999999999999
MOD = 1000000007
EPS = 0.000000001

#------------------------------------------#

N,T = map(int,input().split())

table = [0]*(T+1)

for loop in range(N):
    left,right = map(int,input().split())
    table[left] += 1
    table[right] -= 1

ans = table[0]
for i in range(1,T+1):
    table[i] += table[i-1]
    ans = max(ans,table[i])

print("%d"%(ans))




Measured memory_bytes: 10220
#include<bits/stdc++.h>
using namespace std;
int x,y,z;
int main()
{
	scanf("%d/%d/%d",&x,&y,&z);
	if(x<2019) puts("Heisei");
	else if(x==2019)
	{
		if(y<4) puts("Heisei");
		else if(y==4)
		{
			if(z<30) puts("Heisei");
			else if(z==30) puts("Heisei");
			else puts("TBD");
		}
		else puts("TBD");
	}
	else puts("TBD");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;cin >> n;
    string w[n];
    
    for (int i=0;i<n;i++){
        cin >> w[i];

        if (i == 0){
            continue;
        }

        for (int j=0;j<i; j++){
            if (w[j] == w[i]) {
                cout << "No" << endl;
                return 0;
            }
        }

        int size_n_1 = w[i-1].size();
        if (w[i-1][size_n_1 -1] != w[i][0]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if ((a==7 && b==5 && c==5) || (a==5 && b==7 && c==5) || (a==5 && b==5 && c==7)){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum = 0, p=1, i;
    for(i=0; i<strlen(str); i++){
        sum += p*getChar(str[i]);
        p = p*5;
    }
    return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1));}

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i=0;; i++){
        h = (h1(key) + i * h2(key))% M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i=0;; i++){
        h = (h1(key) + i*h2(key))%M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n ,h;
    char str[L], com[9];

    for(i=0; i<M; i++){
        H[i][0] ='\0';
    }
    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%s %s", com, str);
        if(com[0]  == 'i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }

    return 0;
}



Measured memory_bytes: 16096
#include <stdio.h>
#include <stdlib.h>
#define ABS(x) ((x < 0) ? -x : x)
#define LL long long

void solve(LL *a, int n){
    int i;
    LL min = 1e15, dif, dif_abs, sum;
    //printf("%lld\n", min);
    sum = 0;
    for(i = 0; i < n; ++i) { sum += a[i]; }
    dif = -sum;
    for(i = 0; i < n-1; ++i) {
        dif += 2*a[i];
        dif_abs = ABS(dif);
        //printf("%lld ", dif_abs);
        if(dif_abs < min) { min = dif_abs; }
    }
    //printf("\n");
    printf("%lld\n", min);
}

int main(void) {
    int n, i;
    scanf("%d", &n);
    LL *a = (LL*)malloc((n+4)*sizeof(LL));
    for(i = 0; i < n; ++i) { scanf("%lld", &a[i]); }
    solve(a,n);
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int main()
{
  int arr[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51},x;
  scanf("%d",&x);
  printf("%d",arr[x-1]);
  return 0;
}

Measured memory_bytes: 128
"""
https://atcoder.jp/contests/abc139/tasks/abc139_b
"""

import numpy as np


def calc(A: int, B: int) -> int:
    return int(np.ceil((B - 1) / (A - 1)))


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    A, B = load_input_as_int_array()
    result = calc(A, B)
    print(result)


main()


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

int  main(){
    int N;
    cin>>N;
    map<string,int> s;
    int count=0;
    for(int i=0;i<N;i++){
        string line;
        cin>>line;
        map<string,int>::iterator itr=s.find(line);
        if(itr==s.end()){
            s[line]=1;
            count++;
        }else{
            continue;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 19092
#include <stdio.h>

int main (){
    int max=0;
    int count=0;
    int N;
    scanf("%d",&N);
    int H[N];
    for (int i = 0; i < N; i++){
        scanf("%d",&H[i]);
    }
    for (int i = 0; i < N-1; i++){
        if (H[i+1] <= H[i]){
            count++;
            if (max < count) max = count;
        }
        else count = 0;
    }
    printf("%d",max);
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
int n, a, b, p[100], q1=0, q2=0, q3=0;
cin >> n >> a >> b;
for(int i=0; i<n; i++){
cin >> p[i];
if(p[i]<=a)
q1++;
else if(p[i]<=b)
q2++;
else
q3++;
}

if(q1>q2)
q1 = q2;
if(q1>q3)
q1=q3;

cout << q1;
return 0;
}

Measured memory_bytes: 256
/**
 *    author:  math2do
 *    created: 13.04.2020 22:41:50
**/

#include <bits/stdc++.h>

using namespace std;

const int mod = (int) (1e9 + 7);

inline int mul(int a, int b) {
  long long res = (long long) a * b;
  a = (int) (res % mod);
  return a;
}

inline int power(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    b >>= 1;
    a = mul(a, a);
  }
  return res;
}

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) {
    a += mod;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> dp(k + 1, 0);
  auto get = [&](int i) {
    int cnt = k / i;
    return power(cnt, n);
  }; 
  dp[k] = 1;
  for (int i = k - 1; i >= 1; i--) {
    dp[i] = get(i);
    for (int j = i + i; j <= k; j += i) {
      sub(dp[i], dp[j]);
    }     
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    add(ans, mul(dp[i], i));
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	int a, b;
	string s;

	cin >> a >> b >> s;

	if (s[a] != '-') {
		cout << "No" << endl;
		return 0;

	}

	for (int i = 0; i < s.size(); i++) {
		if (i != a) {
			if (s[i] == '-') {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
int n,a;
deque <int> q;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a);
        if(i&1) q.push_back(a);
        else q.push_front(a);
    }
    if(n&1) reverse(q.begin(),q.end());
    while(!q.empty()){
        int f=q.front();
        printf("%d ",f);
        q.pop_front();
    }
    return 0;
}

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

int cnt_digits(long long N) {
    int digits = 0;

    while(N > 0) {
        N /= 10;
        digits++;
    }
    return digits;
}

int main() {
    int N;
    cin >> N;
    int x[N], y[N], h[N];
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }
    int MAX = 100;
    for(int posY = 0; posY <= MAX; posY++) {
        for(int posX = 0; posX <= MAX; posX++) {
            int needH = -1;

            for(int i = 0; i < N; i++) {
                if(h[i] > 0) {
                    int tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i]);
                    if(needH == -1) {
                        needH = tmp;
                    } else {
                        if(needH != tmp) {
                            needH = -2;
                            break;
                        }
                    }
                }
            }
            if(needH == -2) continue;

            for(int i = 0; i < N; i++) {
                if(h[i] == 0) {
                    int dist = abs(posY - y[i]) + abs(posX - x[i]);
                    if(needH > dist) {
                        needH = -2;
                        break;
                    }
                }
            }
            if(needH == -2) continue;
            cout << posX << " " << posY << " " << needH << endl;
        }
    }
}

Measured memory_bytes: 3612
#include <stdio.h>
int main(void){
char s[100];
       int kokomade,count;
  scanf("%s",s);
  for(count=0;;){
    if(s[count]=='\0'){kokomade=count;break;}
  count++;
  }
  s[kokomade-8]='\0';
  printf("%s",s);
return 0;
}

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

ll N, M;

signed main(){
    cin >> N >> M;
    if(N>M) {
        for(int i=0;i<N;i++) cout << M;
    }
    else for(int i=0;i<M;i++) cout << N;
    cout << endl;
    return 0;
}

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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H, W;
    string s;
    cin >> H >> W;
    rep(i, W+2) cout << '#';
    cout << '\n';
    rep(i, H) {
        cout << '#';
        cin >> s;
        cout << s << '#' <<'\n';
    }
    rep(i, W+2) cout << '#';
    cout << '\n';
}

Measured memory_bytes: 256
N,M=map(int,input().split())
S=[list(map(str,input().split())) for _ in range(M)]
for i in range(0,10**N):
    i=str(i)
    if len(i)==N:
        flag=True
        for t in range(M):
            if i[int(S[t][0])-1]==S[t][1]:
                continue
            else:
                flag=False
        if flag==True:
            print(i)
            break
        else:
            continue
    else:
        continue
if flag==False:
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin >> a ;
    int ac = 0 , wa = 0 , tle = 0 , re = 0 ;
    for(int i = 0 ; i < a ; i++){
        string b;
        cin >> b ;
        if(b=="AC")
            ac++;
        else if(b=="WA")
            wa++;
        else if(b=="TLE")
            tle++;
        else
            re++;
    }
    cout <<  "AC x " << ac  << endl;
    cout <<  "WA x " << wa  << endl;
    cout << "TLE x " << tle << endl;
    cout <<  "RE x " << re  << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int A, B, C, D;
  D = N % 10;
  N /= 10;
  C = N % 10;
  N /= 10;
  B = N % 10;
  A = N / 10;
  
  if      (A + B + C + D == 7) cout << A << "+" << B << "+" << C << "+" << D;
  else if (A + B + C - D == 7) cout << A << "+" << B << "+" << C << "-" << D;
  else if (A + B - C + D == 7) cout << A << "+" << B << "-" << C << "+" << D;
  else if (A + B - C - D == 7) cout << A << "+" << B << "-" << C << "-" << D;
  else if (A - B + C + D == 7) cout << A << "-" << B << "+" << C << "+" << D;
  else if (A - B + C - D == 7) cout << A << "-" << B << "+" << C << "-" << D;
  else if (A - B - C + D == 7) cout << A << "-" << B << "-" << C << "+" << D;
  else if (A - B - C - D == 7) cout << A << "-" << B << "-" << C << "-" << D;
  
  cout << "=7" << endl;
}

Measured memory_bytes: 256