akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

public class Remainder
{
    static int[] PrimeFactors;

    static public void Main()
    {
        var HN = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var H = HN[0];
        var N = HN[1];
        var A =   Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
      
        if(H <= A.Sum()){
          Console.WriteLine("Yes");
        }else{
          Console.WriteLine("No");
        }
        

        

    }

    static void PublicFactorization(int n)
    {
        int i = 2;
        int tmp = n;

        while(i*i <= n)
        {
            if(tmp % i == 0)
            {
                tmp /= i;
                PrimeFactors[i]++;
            }
            else
            {
                i++;
            }
        }

        if(tmp != 1)
        {
            PrimeFactors[tmp]++;
        }
    }

}


Measured memory_bytes: 19296
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<long long>A(N-1,0), B(N-1,0), C(N,0);
  long long a=1, z=1e9+7;
  for(int i=1; i<N; i++){
    a*=i, a%=z, A[i-1]=a;
  }
  a=1;
  for(int i=N-1; i>0; i--){
    a*=i, a%=z, B[(N-1)-i]=a;
  }
  for(int i=0; i<N; i++){
    cin>>a;
    C[i]=a;
  }
  long long ans=0;
  for(int i=0; i<N-1; i++){
    if(N<4){
       if(i==0) ans+=((C[N-1]-C[i])*B[N-3-i])%z, ans%=z;
       else if(i==N-2) ans+=((C[N-1]-C[i])*A[i-1])%z, ans%=z;
    }
    else{
      if(i==0) ans+=((C[N-1]-C[i])*B[N-3-i])%z, ans%=z;
      else if(i==N-2) ans+=((C[N-1]-C[i])*A[i-1])%z, ans%=z;
      else ans+=((C[N-1]-C[i])*((A[i-1]*B[N-3-i])%z))%z, ans%=z;
//      cout<<"i:"<<i<<" C:"<<C[N-1]-C[i]<<" ans:"<<ans<<endl;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int a[10000];
int b[10000];
int c[10000];
int main(){
  string s,t;
  int ans=0;
  cin>>s>>t;
  for(int i=0;i<3;i++){
    if(s[i]==t[i]) ans++;
  }
  cout<<ans<<"\n";

  return(0);
}

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

int main(void){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> vec(N);
  for(int i = 0; i < N; i++){
    string S;
    int P;
    cin >> S >> P;
    vec[i] = make_tuple(S, -P, i + 1);
  }
  sort(vec.begin(), vec.end());
  for(int i = 0; i < N; i++){
   cout << get<2>(vec[i])<< 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++)
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)

using ll = long long;

int main(){
  int n;
  cin >> n;
  int ans=0;
  int l,r;

  rep(i,n){
    cin >> l >> r;
    ans += r-l+1;
  }

  cout << ans << endl;
}

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



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

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

int n,m;

int main()
{
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    return 0;

}




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

int main()
{
    string s;
    cin >> s;
    if (s.back() == 's') s.append("es");
    else s.append("s");
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	string S;
	cin >> S;
	if (S == "SUN") {
		cout << "7" << endl;
	}
	else if (S == "MON") {
		cout << "6" << endl;
	}
	else if (S == "TUE") {
		cout << "5" << endl;
	}
	else if (S == "WED") {
		cout << "4" << endl;
	}
	else if (S == "THU") {
		cout << "3" << endl;
	}
	else if (S == "FRI") {
		cout << "2" << endl;
	}
	else if (S == "SAT") {
		cout << "1" << endl;
	}
	
	return 0;
}


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

int main(){

  int n, a;
  map<int, int> cnt;

  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>a;
    cnt[a]++;
    if(cnt[a]<a) ans++;
    else if(cnt[a]==a) ans-=a-1;
    else if(a<cnt[a]) ans++;
  }

  cout<<ans<<endl;

  return 0;
}


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

bool isprime(long long int val) {
    if (val <= 1)return false;
    for (long long int i = 2; i*i <= val; i++) {
        if (val%i == 0LL)return false;
    }
    return true;
}

int main(){
    int n;
    cin>>n;
    vector<int> v;
    int k=n;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            n/=i;
            v.push_back(i);
        }
        if(isprime(n)){
            v.push_back(n);
            break;
        }
    }
    cout<<k<<":";
    for(int i=0;i<v.size();i++){
        cout<<" "<<v[i];
    }
    cout<<endl;
}


Measured memory_bytes: 3160
var n,i,k:integer;
    flag:boolean;
begin
  readln(n);
  flag:=true;
  for i:=1 to n do begin
  read(k);
  if ((k mod 2)=0)and flag then
  flag:=(((k mod 3)=0)or((k mod 5)=0));
  end;
if flag then 
write('APPROVED') else
write('DENIED');

end.


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int x=sc.nextInt();
        int []a=new int[n];
        int d=0,count=0;
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        while(true){
            d+=a[count];
            count++;
            if(d>x)break;
            if(count==n){
                count++;
                break;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22868
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define SENTINEL 2000000000000

using namespace std;

using llong = long long;


llong merge_sort(vector<int>& a, int low, int mid, int high)
{
    int i = 0, j = 0, k;
    llong cnt = 0;
    vector<int> left(a.begin() + low, a.begin() + mid);
    vector<int> right(a.begin() + mid, a.begin() + high);
    for (k = low; k < high and i < left.size() and j < right.size(); ++k)
    {
        if (left[i] <= right[j])
        {
            a[k] = left[i];
            ++i;
        }else
        {
            a[k] = right[j];
            ++j;
	        cnt += left.size() - i;
        }
    }
    while (i < left.size())
    {
        a[k] = left[i];
        ++k;
        ++i;
    }
    while (j < right.size())
    {
        a[k] = right[j];
        ++k;
        ++j;
    }
    return cnt;

}

llong count_inversions(vector<int>& data, int low, int high)
{
    llong v1, v2, v3;
    int mid = (low + high) / 2;
    if (low + 1 < high)
    {
        v1 = count_inversions(data, low, mid);
        v2 = count_inversions(data, mid, high);
        v3 = merge_sort(data, low, mid, high);
        return v1 + v2 + v3;
    }
    return 0;
}

int main()
{
    int n;
    vector<int> a;
    cin >> n;
    
	    a.resize(n);
	    for (int i = 0; i < n; ++i)
	    {
		    cin >> a[i];
	    }
	    cout << count_inversions(a, 0, n)<< endl;
    
    return 0;
}


Measured memory_bytes: 4328
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
f=-1
for i in a:
  if b[-1]<i:
    if f==1:b[-1]=i
    else:
      b.append(i)
      f=1
  if b[-1]>i:
    if f==-1:b[-1]=i
    else:
      b.append(i)
      f=-1
if f==-1:del b[-1]
if len(b)==0:exit(print(1000))
ans=1000
for i in range(0,len(b),2):
  bb=ans//b[i]
  ans-=bb*b[i]
  ans+=bb*b[i+1]
print(ans)


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int n,w;
int weight[110];
int value[110];

ll dp[110][100100];

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

int main(){
    cin >> n >> w;
    rep(i,n) cin >> weight[i] >> value[i];

    for(int i=0; i<n; i++){
        for(int sw=0; sw<=w; sw++){
            if(sw + weight[i] <= w) chmax(dp[i+1][sw + weight[i]], dp[i][sw] + value[i]);
            chmax(dp[i+1][sw], dp[i][sw]);
        }
    }

    dunk(dp[n][w]);
}

Measured memory_bytes: 79360
#include<cstdio>
#include<algorithm>
using namespace std;
int a[300100];
int b[2][300100];
int main() 
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		char q;
		scanf(" %1c", &q);
		if (q == 'E')
			a[i] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		if (!a[i])
			b[0][i]++;
		b[0][i] += b[0][i - 1];
	}
	for (int i = n; i >= 0; i--)
	{
		if (a[i])
			b[1][i]++;
		b[1][i] += b[1][i + 1];
	}
	int dap = 400000;
	for (int i = 1; i <= n; i++)
	{
		dap = min(dap, b[0][i - 1] + b[1][i + 1]);
	}
	printf("%d", dap);
}

Measured memory_bytes: 3712
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] in = new int[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
      in[i] = sc.nextInt();
      sum += in[i];
    }
    int total = 0;
    double line = sum / (4.0 * m);
    for(int i = 0; i < n; i++){
      if(in[i] >= line){
        total++;
      }
    }
    if(total >= m){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define F first
#define S second
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
	d.resize(G.size());
	REP(i, d.size())d[i] = INF;
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push(make_pair(0, s));
	while (!q.empty()) {
		P a = q.top();
		q.pop();
		if (d[a.second] < a.first)continue;
		REP(i, G[a.second].size()) {
			Edge e = G[a.second][i];
			if (d[e.to] > d[a.second] + e.cap) {
				d[e.to] = d[a.second] + e.cap;
				q.push(make_pair(d[e.to], e.to));
			}
		}
	}
}

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

	ll n, m;
	cin >> n >> m;
	map<P, ll> mp;

	Graph g(n + 2 * m);
	ll con = n;
	REP(i, m) {
		ll p, q, c;
		cin >> p >> q >> c;
		p--; q--;
		if (mp.find({ p,c }) == mp.end()) {
			mp[{p, c}] = con;
			add_edge(g, p, con, 1, true, 1);
			con++;
		}
		if (mp.find({ q,c }) == mp.end()) {
			mp[{q, c}] = con;
			add_edge(g, q, con, 1, true, 1);
			con++;
		}
		add_edge(g, mp[{ q, c }], mp[{ p, c }], 0, true, 0);
	}
	
	Array d;
	Dijkstra(g, 0, d);

	if (d[n - 1] == INF) cout << -1 << endl;
	else cout << d[n - 1] /2 << endl;

	return 0;
}

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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

ll MOD=1000000007;

signed main() {
	llin(n);
	llin(a);
	llin(b);
	say(min(a,b));
	say(' ')
	sal((a+b-n>0)?a+b-n:0);
}

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

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

const int MOD = 1e9 + 7;

template <int mod>
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt<MOD>;

void solve() {
  int n;
  cin >> n;

  modint all = modint(10).pow(n);
  modint r1 = modint(9).pow(n);
  r1 *= 2;
  modint r2 = modint(8).pow(n);

  cout << all - r1 + r2 << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3612
a, b, c = map(int, input().split())
k = int(input())

cnt = 0
while True:
    if a < b:
        break
    cnt += 1
    b *= 2

while True:
    if b < c:
        break
    cnt += 1
    c *= 2

if cnt > k:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9124
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define long long long
#define LF '\n'
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

struct Article {
  int v, w;
  char t;
  long d;
  string name;

  Article(): Article(0,0,0,0, "") {}

  Article(int v, int w, char t, long d, const string &name)
    : v(v), w(w), t(t), d(d), name(name) {}

  bool operator < (const Article &a) const {
    return
       (v != a.v) ? v < a.v
      :(w != a.w) ? w < a.w
      :(t != a.t) ? t < a.t
      :(d != a.d) ? d < a.d
      :name < a.name;
  }
};

istream& operator>> (istream &is, Article &a) {
  is >> a.v >> a.w >> a.t >> a.d >> a.name;
  return is;
}

ostream& operator<< (ostream &os, const Article &a) {
  os <<
    a.v << ' ' <<
    a.w << ' ' <<
    a.t << ' ' <<
    a.d << ' ' <<
    a.name;
  return os;
}

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<Article> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  for (const auto &e : a) {
    cout << e << LF;
  }

  return 0;
}




Measured memory_bytes: 11120
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//fac[]はn! inv[]はMODにおける逆元 finv[]はinv[]とfinv[]の累積積
const long long MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算(nCkをO(1)で)
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    COMinit();
    long long N;cin >> N;
    if(N == 1){
        cout << 0 << endl;
        return 0;
    }
    long long ans = mod_pow(10,N);
    ans %= MOD;
    ans -= mod_pow(9,N);
    ans %= MOD;
    if(ans < 0) ans += MOD;
    ans -= mod_pow(9,N);
    ans %= MOD;
    if(ans < 0) ans += MOD;
    ans += mod_pow(8,N);
    ans %= MOD;
    cout << ans << endl;
}


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

typedef unsigned long long ll;
using namespace std;

int main() {
    int k;
    cin >> k;
    vector<string> lunluns;
    vector<string> prev_digit;
    vector<string> initials = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
    for (auto i : initials) {
        lunluns.emplace_back(i);
        prev_digit.emplace_back(i);
    }
    while ((int)lunluns.size() < k) {
        vector<string> next;
        for (auto p : prev_digit) {
            char c = p[p.size() - 1];
            if (c > '0') {
                next.emplace_back(p + char(c - 1));
            }
            next.emplace_back(p + c);
            if (c < '9') {
                next.emplace_back(p + char(c + 1));
            }
        }
        for (auto n: next) {
            lunluns.emplace_back(n);
        }
        prev_digit = next;
    }
    cout << lunluns[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 16272
#include<iostream>
    #include<vector>
    using namespace std;
    int main(){
        int n,m;
        cin>>n>>m;
        vector<vector<int>>roads(n,vector<int>(n,0));
        for(int i=0;i<m;i++)
        {
            int f,s;    
            cin>>f>>s;
            f--,s--;
            roads[f][s]++;
            roads[s][f]++;
        }
        for(int i=0;i<n;i++)
        {
            int result=0;
            for(int j=0;j<n;j++)
            {
                result+=roads[i][j];
            }
            cout<<result<<endl;
        }
    }

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+7;
int vac[N][4],dp[N][4];
main()
{
    int n;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
            scanf("%lld",&vac[i][j]);
    }
    dp[0][0]=vac[0][0];
    dp[0][1]=vac[0][1];
    dp[0][2]=vac[0][2];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
                dp[i][j]=vac[i][j]+max(dp[i-1][j+1],dp[i-1][j+2]);
            if(j==1)
                dp[i][j]=vac[i][j]+max(dp[i-1][j+1],dp[i-1][j-1]);
            if(j==2)
                dp[i][j]=vac[i][j]+max(dp[i-1][j-1],dp[i-1][j-2]);
        }
    }
    printf("%lld\n",max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
}


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

using namespace std;

#define ll long long

bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}

void solve()
{
   ll n,k;
   cin>>n>>k;
   ll a[n];
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   vector<pair<ll,ll>>v;
   int j=0;
   for(int i=k;i<n;i++)
   {
       v.push_back(make_pair(a[j],a[i]));
       j++;
   }
   for(int i=0;i<v.size();i++)
   {
       //cout<<v[i].first<<" "<<v[i].second<<endl;
      if(v[i].first<v[i].second)
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
   }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


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

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

    if( k > a +b )
        cout<< a - ( k - (a + b)) <<endl;
    else if( k > a)
        cout<< a<<endl;
    else
        cout<<k<<endl;

    return 0;                          
}


Measured memory_bytes: 3636
#include <iostream>
#include <utility>

using namespace std;

int main(int argc, char const* argv[])
{
    int n, ar[100], swapc = 0;

    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> ar[i];
    }

    bool next = true;
    while (next) {
        next = false;
        for (int i = 0; i < n - 1; i++) {
            if(ar[i] > ar[i+1]){
                swap(ar[i], ar[i+1]);
                swapc++;
                next = true;
            }
        }
    }

    for (int i = 0; i < n - 1; i++) {
        cout << ar[i] << " ";
    }
    cout << ar[n - 1] << endl;
    cout << swapc << endl;

    return 0;
}

Measured memory_bytes: 3164
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define P                 pair<int,int>
#define vi                vector<int>
#define mi                map<int,int>
#define pqb               priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mod               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //fir defining the precision int the decimal upto y places. 
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)     type *a=new type[n];
#define test(t)            int t; cin>>t; while(t--)
#define no                cout<<"No\n";
#define yes               cout<<"Yes\n";
#define NO                cout<<"NO\n";
#define YES               cout<<"YES\n";



void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);

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

int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}

int LCS(int si, string &a, int pi, string &b, vector<vi> &dp)
{
//Base Case
	if (si == a.length() or pi == b.length())
		return 0;


	if (dp[si][pi] != -1)
		return dp[si][pi];

	//Recursive Case
	int ctr;

	if (a[si] == b[pi])
	{
		ctr = LCS(si + 1, a, pi + 1, b, dp) + 1;
	}

	else
	{
		int c1 = LCS(si + 1, a, pi, b, dp);
		int c2 = LCS(si, a, pi + 1, b, dp);

		ctr = max(c1, c2);
	}

	dp[si][pi] = ctr;

	return ctr;
}




int32_t main()
{

	io();
	clock_t begin = clock();

	int te = 1;


	// test(t)
	// {

	int n, k, m, q, i;
	string s, p;

	cin >> s >> p;

	int r = s.length();
	int c = p.length();

	vector<vi> dp(r + 1, vi(c + 1, -1));

	int pq = LCS(0, s, 0, p, dp);

	// for (int i = 0; i < 3; i++)
	// {
	// 	for (int j = 0; j < 6; j++)
	// 		cout << dp[i][j] << " ";
	// 	cout << "\n";
	// }
	// cout << "\n\n";

	string res;

	i = 0;
	int j = 0;

	while (i < r and j < c)
	{

		if (s[i] == p[j])
		{
			res += s[i];

			i++;
			j++;
		}
		else
		{
			if (dp[i][j + 1] > dp[i + 1][j])
				j++;
			else
				i++;
		}
	}

	cout << res << "\n";


//te++;
// double c_time = (double) (clock() - begin) / CLOCKS_PER_SEC;
// cout << ps(c_time, 4) << " seconds\n";
//}

	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int r, c, k; cin >> r >> c >> k;
    vvi val(r+5, vi(c+5, 0));
    rep(i, k) {
        int rr, cc, v;
        cin >> rr >> cc >> v;
        rr--; cc--;
        val[rr][cc] = v;
    }
    
    vector<vll> dp(c+5, vll(4, 0));
    dp[0][1] = val[0][0];
    ll mx = -1;
    
    rep(i, r){
        vector<vll> pd(c+5, vll(4, 0));
        rep(j, c){
            rep(n, 4) dp[j+1][n] = max(dp[j+1][n], dp[j][n]);
            rep(n, 3) dp[j+1][n+1] = max(dp[j+1][n+1], dp[j][n] + val[i][j+1]);
            mx = max({dp[j][0], dp[j][1], dp[j][2], dp[j][3]});
            pd[j][0] = mx;
            pd[j][1] = mx + val[i+1][j];
        }
        dp = pd;
    }

    cout << mx << endl;
    return;
}

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

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

signed main() {
	int N, P;
	string S;
	cin >> N >> P >> S;

	if (P == 2 or P == 5) {
		long long ans = 0;
		for (int r = 0; r < N; r++) {
			if ((S[r] - '0') % P == 0) {
				ans += r + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}

	// 各桁の数値のMODをとる
	vector<int> d(N+1);
	int ten = 1;
	for (int i = N - 1; i >= 0; i--) {
		int num = (S[i] - '0') * ten;
		d[i] = num % P;
		ten *= 10;
		ten %= P;
	}

	// 累積和をとる
	for (int i = N - 1; i >= 0; i--) {
		d[i] += d[i+1];
		d[i] %= P;
	}

	long long ans = 0;
	map<int, int> mp;
	mp[0] = 1;
	for (int i = N - 1; i >= 0; i--) {
		ans += mp[d[i]];
		mp[d[i]]++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1668
N, X = map(int, input().split())
L = list(map(int, input().split()))
ruiseki = [0]
for i in range(len(L)):
    ruiseki.append(ruiseki[i] + L[i])
ans = 0
for i in ruiseki:
    if i <= X:
        ans += 1
print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef pair<int,int> pri;
typedef vector<long long> vecll;
typedef pair<long long,long long> prill;

#define REP(i,a,b) for (int i = a; i < b; i++)

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

    string s;
    cin>>s;
    int c=0;
    if(s[0]=='R'&&s[1]=='R'){if(s[1]=='R'&&s[2]=='R')c=3;else c=2;}
    else if(s[1]=='R'&&s[2]=='R')c=2;
    else if(s[0]=='R'|| s[1]=='R'|| s[2]=='R')c++;
    cout<<c;

}

Measured memory_bytes: 3644
#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;
    cin >> a >> b;
    if (a > b * 2){
        cout << a - b * 2 <<endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

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

namespace ConsoleApp2
{
    using static System.Console;
    using static System.Math;

    class Program
    {
        static void Main(string[] args)
        {
            var nl = ReadLine().Split().Select(int.Parse).ToArray();
            var l = nl[1];
            var n = nl[0];
            var start = l;
            var end = (l + n - 1);
            var total = (l + (l + n - 1)) * n / 2;
            var min = 0;
            if (start < 0)
                if (end < 0)
                    min = end;
                else
                    min = 0;
            else
                min = start;
            WriteLine(total - min);
        }
    }
}


Measured memory_bytes: 13268
s=input()
t=input()
if len(s)<len(t):
  print("UNRESTORABLE")
  exit()
n=len(s)
m=len(t)
for i in range(n-m,-1,-1):
  x=s[i:i+m]
  for j in range(m+1): #
    if j==m:
      print((s[:i]+t+s[i+m:]).replace("?","a"))
      exit()
    if x[j]=="?":
      continue
    elif x[j]!=t[j]:
      break
print("UNRESTORABLE")

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
  int N,i,flag=0;
  int H[100000];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
  }
  for(i=N-1;i>0;i--){
    if(H[i]-H[i-1]==-1){
      H[i-1]--;
    }else if(H[i]-H[i-1]>=0){
      continue;
    }else{
      flag=1;
      break;
    }
  }
  if(flag==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int n, x, arr[1004], times;
int main(){
    scanf("%d%d", &n, &x);
    for(int i=0; i<n; i++){
        scanf("%d", &arr[i]);
        if(i>0){
            arr[i]=arr[i]+arr[i-1];
        }
        if(arr[i]<=x){
            times=i+1;
        }
    }
    printf("%d", times+1);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	int N, M;
	cin >> N >> M;
	VI v(N, -1);

	REP(i, M) {
		int s, c;
		cin >> s >> c; s--;
		if (v.at(s) == -1 || v.at(s) == c)v.at(s) = c;
		else {cout << -1 << endl; return 0;}
	}

	if (N != 1 && v.at(0) == 0) {cout << -1 << endl; return 0;}
	if (N == 1 && (v.at(0) == 0 || v.at(0) == -1)) {cout << 0 << endl; return 0;}
	REP(i, N) {
		if (i == 0 && v.at(i) == -1) {cout << 1; }
		else if (v.at(i) == -1)cout << 0;
		else cout << v.at(i);
	}
	cout << "\n";



	return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	private static final char UNAVAILABLE = 'Z';
	private static final int[][] table = {
		{60, 2, 600},
		{80, 5, 800},
		{100, 10, 1000},
		{120, 15, 1200},
		{140, 20, 1400},
		{160, 25, 1600}
	};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numItem = 0;
		while((numItem = sc.nextInt()) != 0){
			int fee = 0;
			int width, height, depth, weight;
			for(int i = 0; i < numItem; i++){
				width = sc.nextInt();
				height = sc.nextInt();
				depth = sc.nextInt();
				weight = sc.nextInt();
				fee += getFee(judgeSize(weight, width + height + depth));
			}
			System.out.println(fee);
		}
		sc.close();
	}
	
	public static int getFee(char size){
		return (size == UNAVAILABLE)? 0 : table[size - 'A'][2];
	}

	public static char judgeSize(int weight, int length){
		char s1 = judgeSizeByWeight(weight);
		char s2 = judgeSizeByLength(length);
		return (char)Math.max(s1, s2);
	}
	
	private static char judgeSizeByWeight(int weight){
		if(weight <= 2)	return 'A';
		if(weight <= 5)	return 'B';
		if(weight <= 10)	return 'C';
		if(weight <= 15) return 'D';
		if(weight <= 20)	return 'E';
		if(weight <= 25)	return 'F';
		return UNAVAILABLE;
	}
	
	private static char judgeSizeByLength(int length){
		if(length <= 60)	return 'A';
		if(length <= 80)	return 'B';
		if(length <= 100)return 'C';
		if(length <= 120)return 'D';
		if(length <= 140)return 'E';
		if(length <= 160)return 'F';
		return UNAVAILABLE;
	}
	
}

Measured memory_bytes: 56460
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int len = s.length();
    String fs;
    String ls = "";
    int lslen = 0;

    for(int i = 0;i < len;i++){
      fs = s.substring(i,(i+1));
      if(fs.equals("0") || fs.equals("1")){
        ls = ls + fs;
      }else if(fs.equals("B")){
        if(!(ls.equals(""))){
          lslen = ls.length();
          lslen -= 1;
          ls = ls.substring(0,lslen);
        }
      }
    }
    System.out.println(ls);
  }
}


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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	ll n, d;
	cin >> n >> d;
	d *= d;
	ll x, y;
	int ans = 0;
	loop(n) {
		cin >> x >> y;
		if (d >= x * x + y * y) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int main()
{
	fastio();
	string st;
	cin>>st;
	int l=st.size();
	if(st[l-1]=='s') cout<<st+"es"<<endl;
	else cout<<st+'s'<<endl;
}

Measured memory_bytes: 3652
import copy
n = int(input())
p = list(map(int, input().split()))
copy_p = copy.deepcopy(p)
copy_p.sort()
cnt = 0
f = True
for i in range(len(p)):
    if copy_p[i] != p[i]:
        cnt += 1
        f = False

if cnt == 2 or f:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3444
from sys import stdin

def Sieve(n): #n以下の素数全列挙(O(nloglogn)) retは素数が入ってる。divlisはその数字の素因数が一つ入ってる

    ret = []
    divlis = [-1] * (n+1) #何で割ったかのリスト(初期値は-1)
    
    flag = [True] * (n+1)
    flag[0] = False
    flag[1] = False

    ind = 2
    while ind <= n:

        if flag[ind]:
            ret.append(ind)

            ind2 = ind ** 2

            while ind2 <= n:
                flag[ind2] = False
                divlis[ind2] = ind
                ind2 += ind

        ind += 1

    return ret,divlis

N = int(stdin.readline())
A = list(map(int,stdin.readline().split()))

pri,divlis = Sieve(10**6+10)

pw = True
dic = {}

for i in range(N):

    na = A[i]
    while divlis[na] != -1:

        tmp = divlis[na]
        if tmp in dic:
            pw = False
            dic[tmp] += 1
        else:
            dic[tmp] = 1
        
        while na % tmp == 0:
            na //= tmp

    if na != 1:
        if na in dic:
            pw = False
            dic[na] += 1
        else:
            dic[na] = 1
#print (dic)
if pw:
    print ("pairwise coprime")
else:
    nmax = 0
    for i in dic:
        nmax = max(nmax,dic[i])

    if nmax != N:
        print ("setwise coprime")

    else:
        print ("not coprime")
    
        
        
    


Measured memory_bytes: 200912
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n + 1);
    a[0] = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
    }
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] + a[i + 1] > x) {
            ans += a[i] + a[i + 1] - x;
            a[i + 1] = x - a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
long long f[101];
int n;
void kk(int x)
{
	if(f[x])
	return;
	else
	{
		kk(x-1);
		kk(x-2);
		f[x]=f[x-1]+f[x-2];
	}
}
int main()
{
	f[0]=2;
	f[1]=1;
	cin>>n;
	kk(n);
	cout<<f[n];
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		long now = 7;
		int count =1;
		while (now%K!=0 &&count <=K) {
			count ++;
			now = (now *10+7)%K;
		}
		if (count <=K) {
			System.out.println(count);
			return ;
		}
		System.out.println(-1);
	}
}


Measured memory_bytes: 35660
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()

const ll Mod = 998244353;

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

    ll n; cin>>n;
    vll a(n);
    map<ll,ll> m;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(m.find(a[i])==m.end())
            m[a[i]]=1;
        else
            m[a[i]]++;
    }
    ll ans=0;
    for(pll p:m){
        ans+=(p.second)*(p.second-1)/2;
    }
    for(ll i=0;i<n;i++){
        cout<<ans-m[a[i]]+1<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int D,N;
    cin>>D>>N;
    if (D==0)
        if (N<100)
            cout<<N<<endl;
        else
            cout<<N+1<<endl;
            if (D==1)
                if (N<100)
                    cout<<N*100<<endl;
                else
                    cout<<(N+1)*100<<endl;
                    if (D==2)
                        if (N<100)
                            cout<<N*10000<<endl;
                        else
                            cout<<(N+1)*10000<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    string all = "abcdefghijklmnopqrstuvwxyz";
    string s;
    cin >> s;
    sort(s.begin(), s.end());

    s.erase(unique(s.begin(), s.end()), s.end());
    // cout << unique(s.begin(), s.end()) << endl;
    int i;
    for (i = 0; i < all.size(); i++){
        if (s[i] != all[i]) {
            cout << all[i] << endl;
            return 0;
        }
    }
    if (i == all.size()) cout << "None" << endl;


    return 0;
}









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

using namespace std;

typedef pair< int,int > PII;
typedef long long int lo;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,cev,a[li],b[li],dp[102][li];
string s;
vector<int> v;

lo f(lo sira,lo kar){
	lo mn=MIN;
	if(kar<0) return MIN;
	if(sira>n){
		if(kar==0) return 0;
		return MIN;
	}
	if(~dp[sira][kar]) return dp[sira][kar];
	mn=min(mn,f(sira+1,kar-b[sira])+a[sira]);
	mn=min(mn,f(sira+1,kar));
	return dp[sira][kar]=mn;
}

int main(){
	memset(dp,-1,sizeof(dp));
	scanf("%lld %lld",&n,&m);
	for(lo i=1;i<=n;i++){
		scanf("%lld %lld",&a[i],&b[i]);
	}
	for(lo i=1;i<=100003;i++){
		if(f(1,i)<=m){
			cev=i;
		}
	}
	printf("%lld",cev);
	return 0;
}


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

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

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

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

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

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

    int d;
    cin >> d;
    cout << "Christmas";
    REP(i, 25 - d) cout << " Eve";
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;vector<vector<int> >a(11,vector<int>(331));void r(int n,int u,int s,int d){a[n][s]++;for(int i=10;i-->0;)if(!(u>>i&1))r(n+1,u^1<<i,s+d*i,d+1);}main(){r(0,0,0,1);for(int n,s;cin>>n>>s;)cout<<a[n][s]<<"\n";}

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

using namespace std;

int main()
{
    string a,b;
    cin >> a >> b;
    for (int i=a.size();i>=0;i--)
    {
         if (a[0]==b[0]&&i==0)
        {
            cout << "Yes";
            break;
        }
        else if (a[i]!=b[i] && i!=a.size())
        {
            cout << "No";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3620
N, K = [int(i) for i in input().split()]
HS = [int(i) for i in input().split()]

dp = [float('inf')]*N

dp[0] = 0
dp[1] = abs(HS[1] - HS[0])

for i in range(2, N):
  dp[i] = min([dp[i-k] + abs(HS[i] - HS[i-k]) for k in range(1, K + 1)])

print(dp[N-1])


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

using namespace std;

int main()
{
    long long  n,x,mini=0,k;
    cin>>n>>x;
    long long v[n+1];
    v[0]=0;
    for(int i=1;i<=n;i++){
        cin>>v[i];
        if(v[i]+v[i-1]>x){
            k=x-(v[i]+v[i-1]);
            k=abs(k);
            v[i]-=k;
            //cout<<k<<" ";
            mini+=(k<0?0:k);
            if(v[i]<0)v[i]=0;
        }
    }
    cout<<mini;

    return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
PY = [list(map(int, input().split()))+[i] for i in range(M)]

count = [0] * N
ans = [""]*M


PY.sort(key = lambda x:x[1])
for p,_,i in PY:
    count[p-1] += 1
    ans[i] = str(p).zfill(6) + str(count[p-1]).zfill(6)

for a in ans:
    print(a)

Measured memory_bytes: 32608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
long long n,W;
const ll maxn=105;
const ll maxw=100005;
ll w[maxn],v[maxn];
ll dp[maxn][maxw];
int main(){

    while(cin>>n>>W)
    {
        rep1(i,n) cin>>w[i]>>v[i];
        memset(dp,0,sizeof(dp));
        rep1(i,n)
        {

            rep1(j,W)
            {
                if(j<w[i]) dp[i][j]=dp[i-1][j];
                else dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }
        }
        /*rep1(i,n)
        {
            rep1(j,W) {cout<<dp[i][j]<<" ";}
            cout<<"\n";
        }*/
        cout<<dp[n][W]<<"\n";
    }
}


Measured memory_bytes: 82304
#include<stdio.h>

char S[17];
char code[17] = "CODEFESTIVAL2016";
int result = 0;

int main(void) {
	scanf("%s", S);
	for(int i=0; i<17; i++) {
		if(S[i] != code[i])
			result++;
	}
	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <map>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iterator>
#include <deque>
#include <bitset>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <fstream>
#include <ios>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <bitset>
#include <queue>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
    long long D, T, S, ans;
    cin >> D >> T >> S;
    if (T * S >= D) {
        cout << "Yes";
    }
    else
        cout << "No";
}



Measured memory_bytes: 3616