akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  string a, b;
  cin >> a >> b;
  a = "#" + a;
  b = "@" + b;
  int la = a.size();
  int lb = b.size();
  /// dp[i][j] = lcs upto i'th posisiton of string a & j'th position of string b;
  vector <vector <int> > dp (la + 5, vector <int> (lb + 5, 0));
  vector <vector <int> > path(la + 5, vector <int> (lb + 5, 0));
  for (int i = 1; i < la; i++) {
    for (int j = 1; j < lb; j++) {
      if (a[i] == b[j]) {
        dp[i][j] = 1 + dp[i - 1][j - 1];
        path[i][j] = path[i - 1][j - 1];
      }
      else {
        if (dp[i][j - 1] >= dp[i - 1][j]) {
          dp[i][j] = dp[i][j - 1];
          path[i][j] = path[i][j - 1];
        }
        else {
          dp[i][j] = dp[i - 1][j];
          path[i][j] = path[i - 1][j];
        }
      }
    }
  }
  /// cout << dp[la - 1][lb - 1] << endl;
  int mx = dp[la - 1][lb - 1];
  string ans = "";
  int cur = 0;
  for (int i = la - 1; i >= 1; i--) {
    for (int j = lb - 1; j >= 1; j--) {
      if (a[i] == b[j] && cur + dp[i][j] == mx) {
        ans += a[i];
        cur ++;
        break;
      }
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 71040
#include <iostream>
#include <string>
#include <queue>
using namespace std;
main(){
    queue<pair<string,int> >v;
    int N,Q,T;
    string s;
    for(cin>>N>>Q;N--;)cin>>s>>T,v.push(make_pair(s,T));
    for(T=0;!v.empty();){
        pair<string,int>p=v.front();v.pop();
        if(p.second>Q)T+=Q,p.second-=Q,v.push(p);
        else T+=p.second,cout<<p.first<<' '<<T<<endl;
    }
}

Measured memory_bytes: 6324
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;

}

Node treeMaximum(Node x){
  while(x->right!=NIL)x=x->right;
  return x;


}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)return treeMinimum(x->right);

  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->parent=y->parent;

  if(y->parent!=NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;

  if(y!=z)z->key=y->key;
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
    
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;

}



Measured memory_bytes: 20516
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	string S;
	cin >> S;
	if(S == "ARC") cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

// 0, 1, 2, 3, 4,  5,  6,   7,   8,   9,   10
// 1, 1, 2, 3, 8, 15, 48, 105, 304, 945, 3040
int main(){
    LL n;
    cin >> n;
    if(n % 2 == 0){
        LL ans = 0;
        LL base = 10;
        while(base <= n){
            ans += n / base;
            base *= 5;
        }

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



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

#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
const int INF=1000000;


int main(void){
    short int H,W;
    cin >> H >> W;
    vector<vector<bool>>  tile(H,vector<bool>(W,false));
    vector<vector<bool>> seen=tile;

    char c;
    fr(i,0,H){
        fr(j,0,W){
            cin >> c;
            if(c=='#') continue;
            tile.at(i).at(j)=!tile.at(i).at(j);
        }
    }

    
    vector<vector<int>>  dist(H,vector<int>(W,INF));

    dist.at(0).at(0)=0;

    fr(i,0,H-1){
        fr(j,0,W-1){
            seen.at(i).at(j)=true;

            if(seen.at(i+1).at(j)==false){
                if(tile.at(i).at(j)==tile.at(i+1).at(j)) {
                    if(dist.at(i).at(j) < dist.at(i+1).at(j)) dist.at(i+1).at(j)=dist.at(i).at(j);
                }else{
                    if(dist.at(i).at(j)+1 < dist.at(i+1).at(j)) dist.at(i+1).at(j)=dist.at(i).at(j)+1;
                }
            }

            if(seen.at(i).at(j+1)==false){
                if(tile.at(i).at(j)==tile.at(i).at(j+1)) {
                    if(dist.at(i).at(j) < dist.at(i).at(j+1)) dist.at(i).at(j+1)=dist.at(i).at(j);
                }else{
                    if(dist.at(i).at(j)+1 < dist.at(i).at(j+1)) dist.at(i).at(j+1)=dist.at(i).at(j)+1;
                }
            }
        }
    }

    fr(i,0,H-1){
        seen.at(i).at(W-1)=true;
        if(seen.at(i+1).at(W-1)==false){
            if(tile.at(i).at(W-1)==tile.at(i+1).at(W-1)) {
                if(dist.at(i).at(W-1) < dist.at(i+1).at(W-1)) dist.at(i+1).at(W-1)=dist.at(i).at(W-1);
            }else{
                if(dist.at(i).at(W-1)+1 < dist.at(i+1).at(W-1)) dist.at(i+1).at(W-1)=dist.at(i).at(W-1)+1;
            }
        }
    }

    fr(j,0,W-1){
        if(seen.at(H-1).at(j+1)==false){
            if(tile.at(H-1).at(j)==tile.at(H-1).at(j+1)) {
                if(dist.at(H-1).at(j) < dist.at(H-1).at(j+1)) dist.at(H-1).at(j+1)=dist.at(H-1).at(j);
            }else{
                if(dist.at(H-1).at(j)+1 < dist.at(H-1).at(j+1)) dist.at(H-1).at(j+1)=dist.at(H-1).at(j)+1;
            }
        }
    }

    if(dist.at(H-1).at(W-1)==0){
        if(tile.at(0).at(0)==false){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }else if(tile.at(0).at(0)==true && tile.at(H-1).at(W-1)==true){
        cout << dist.at(H-1).at(W-1)/2 << endl;
    }else{
        cout << dist.at(H-1).at(W-1)/2+1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const long long INF = 1LL << 60;
const ll C = 1000000000+7;

int main() {
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    for(int i=0; i<N; i++) cin >> X[i];

    Y = X;
    sort(Y.begin(), Y.end());
    ll mid_l = Y[N/2 - 1], mid_r = Y[N/2];

    for(int i=0; i<N; i++) {
        if(X[i] <= mid_l) {
            cout << mid_r << endl;
        }
        else if(X[i] >= mid_r) {
            cout << mid_l << endl;
        }
    }
}

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

string s;
int a[30] = {0};

int main() {
  cin >> s;
  for(int i = 0; i < s.size(); ++i) ++a[s[i] - 'a'];
  for(int i = 0; i < 26; ++i)
    if(a[i] == 0) {
      cout << (char)('a' + i) << endl;
      return 0;
    }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
using namespace std;

int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	if(c > b) {
		cout << b + min(c, b + a + 1) << "\n";
	}
	else {
		cout << b + c << "\n"; 
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}
//最小公倍数

int main() {
	
	int N;
	vector<ll> A;

	cin>>N;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.push_back(a);
	}
	sort(A.begin(),A.end());
	cout<<A[N-1]-A[0]<<endl;

	return 0;
}

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

using namespace std;

const int Z = 100005; 
const int N = 100005; 
bool ab[N+Z], ac[N+Z], bc[N+Z];

bool match(char c0, char c1){
    return (c0=='?'||c1=='?'||c0==c1);
}

void solve() {
    string a,b,c;
    cin >> a >> b >> c;
    int A = a.size();
    int B = b.size();
    int C = c.size();
    int res = A+B+C;

    for (int i = 0; i < A; i++) {
        for (int j = 0; j < B; j++) {
            if (!match(a[i], b[j]))
                ab[i-j + Z] = 1;
        }
    }
    for (int i = 0; i < A; i++) {
        for (int j = 0; j < C; j++) {
            if (!match(a[i], c[j]))
                ac[i-j + Z] = 1;
        }
    }
    for (int i = 0; i < B; i++) {
        for (int j = 0; j < C; j++) {
            if (!match(b[i], c[j]))
                bc[i-j + Z] = 1;
        }
    }
    const int M = 2020 * 2; 
    for (int i = -M; i < M; i++) {
        for (int j = -M; j < M; j++) {
            if (!ab[i+Z] && !ac[j+Z] && !bc[j-i+Z]) {
                int L = min({0,i,j});
                int R = max({A,i+B,j+C});
                res = min(res, R-L);
            }
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

int main() {
  int N;
  set<int> mochi;
  cin >> N;
  for (int i=0; i<N; i++) {
    int d;
    cin >> d;
    mochi.insert(d);
  }
  cout << mochi.size() << endl;
  return 0;
}


Measured memory_bytes: 256
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
lim = int((1e+9)+7)
right = [0 for _ in range(n)]
left = [0 for _ in range(n)]
for i in range(n):
    for j in range(n):
        if a[j] < a[i]:
            if i < j:
                right[i] += 1
            else:
                left[i] += 1
ans = 0
def c(g):
    re = g*(g-1)//2
    return re

for i in range(n):
    ans = (ans - (left[i]*k) + ((right[i]+left[i])*c(k+1)))%lim
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    string s;
    cin >> s;
    string ans = "";
    for(int i = 0;i < 1 << (s.size() - 1);i++){
          
          int sum = s[0] - '0';
          string t = s.substr(0,1);
          
          for(int j = 1;j < s.size();j++){
                if((i >> (j - 1)) & 1){
                      sum += (s[j] - '0');
                      t += "+" + s.substr(j,1);
                }else{
                      sum -= (s[j] - '0');
                      t += "-" + s.substr(j,1);
                }
          }
          if(sum == 7){
                ans = t + "=7";
          }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(n)]
lst = []
lst2 = []
cnt = 0

for i in range(n):
    for j in range(k[i][0]):
        lst.append(k[i][j+1])

for i in range(m):
    if lst.count(i+1) == n:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoderBeginnerContest
{
    internal class Program
    {
        public static int N { get; private set; }
        public static int M { get; private set; }

        private static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.WriteLine(r); }

        private static object GetResult()
        {
            var inputs = CR.GetIntegers().ToList();
            N = inputs[0];
            M = inputs[1];

            return N == M ? "Yes" : "No";
        }
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var X = long.Parse(Console.ReadLine());
            var y = 100L;
            var count = 0L;
            while (true)
            {
                count++;
                y += (long)(y * 0.01);
                if (y >= X)
                {
                    break;
                }
            }

            Console.WriteLine(count.ToString());
        }
    }
}


Measured memory_bytes: 27536
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

//#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

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

const int MOD = 1000000007;

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    VI a(m), b(m), c(m);
    REP(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
    }

    vector<vector<PII>> edge(n, vector<PII>());
    REP(i, m) {
        edge[a[i]].push_back(make_pair(b[i], c[i]));
        edge[b[i]].push_back(make_pair(a[i], c[i]));
    }

    int ans=0;
    REP(i, n) {
        priority_queue<PII> q;
        VI d(n, INT_MAX);
        d[i] = 0;
        q.push(make_pair(-0,i));

        while(!q.empty()){
            int cost = q.top().first;
            int v = q.top().second;
            q.pop();
            if(d[v]<cost){
                continue;
            }
            REP(j,edge[v].size()){
                if(d[edge[v][j].first] > d[v] + edge[v][j].second){
                    d[edge[v][j].first] = d[v] + edge[v][j].second;
                    q.push(make_pair(-d[edge[v][j].first],edge[v][j].first));
                }
            }
        }
        REP(j,edge[i].size()){
            if(d[edge[i][j].first] < edge[i][j].second){
                ans ++;
            }
        }
    }

    cout << ans/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int N=1<<18;
class StarrySkyTree{
public:
  ll Mi[555555],A[555555];
  void init(){fill(Mi,Mi+555555,0);fill(A,A+555555,0);}
  void add(int a,int b,int x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2]);
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return LLONG_MAX;if(a<=l&&r<=b)return Mi[k]+A[k];
    ll left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return min(left,right)+A[k];
  }
};

StarrySkyTree r;
void Main() {
  ll n,m,s,t;
  cin >> n >> m >> s >> t;
  n++;
  r.init();
  REP(i,1,n+1) {
    ll x;
    R x;
    r.add(i-1,i,x);
  }
  ll sum=0;
  rep(i,n-1) {
    ll x=r.getMin(i,i+1),y=r.getMin(i+1,i+2);
    ll z=abs(x-y);
    if(x<y) sum-=s*z;
    else sum+=t*z;
  }
  while(m--) {
    ll x,y,z;
    cin >> x >> y >> z;
    if(x) {
      ll xx=r.getMin(x-1,x),yy=r.getMin(x,x+1);
      ll zz=abs(xx-yy);
      if(xx<yy) sum+=s*zz;
      else sum-=t*zz;
    }
    if(y!=n-1) {
      ll xx=r.getMin(y,y+1),yy=r.getMin(y+1,y+2);
      ll zz=abs(xx-yy);
      if(xx<yy) sum+=s*zz;
      else sum-=t*zz;
    }
    r.add(x,y+1,z);
    if(x) {
      ll xx=r.getMin(x-1,x),yy=r.getMin(x,x+1);
      ll zz=abs(xx-yy);
      if(xx<yy) sum-=s*zz;
      else sum+=t*zz;
    }
    if(y!=n-1) {
      ll xx=r.getMin(y,y+1),yy=r.getMin(y+1,y+2);
      ll zz=abs(xx-yy);
      if(xx<yy) sum-=s*zz;
      else sum+=t*zz;
    }
    pr(sum);
  }
}

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


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

int main() {
  
  int N;
  long int sum = 0;

  cin >> N;
  
  vector<int> a(3 * N);

  for (int i = 0; i < 3 * N; i++) cin >> a.at(i);  
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());  
  
  for (int i = 0; i < 2 * N; i++) {
    if (i % 2 == 1) sum += a.at(i); 
  }
  
  cout << sum << endl;
  
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    string S; cin >> S;
    vector<int> dig_pos[10];
    int num_dig[10];
    int ans = 0;
    rep(i, N) dig_pos[S[i]-'0'].push_back(i);
    rep(i, 10) num_dig[i] = dig_pos[i].size();
    rep(i, 1000){
        bool ok = false;
        string S = "";
        int val = i;
        rep(j, 3){
            S += ('0' + (val % 10));
            val /= 10;
        }
        reverse(S.begin(), S.end());
        if(num_dig[S[0]-'0'] > 0 && num_dig[S[1]-'0'] > 0 && num_dig[S[2]-'0'] > 0){
            int st = dig_pos[S[0]-'0'][0], fin = dig_pos[S[2]-'0'][num_dig[S[2]-'0']-1];
            int aim = S[1]-'0';
            rep(j, num_dig[aim]){
                if(st < dig_pos[aim][j] && dig_pos[aim][j] < fin){
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import sys

sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

class Geometry:

    def add(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return (x1+x2, y1+y2)

    def sub(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return (x1-x2, y1-y2)

    def mul(self, a, b):
        x1, y1 = a
        if not isinstance(b, tuple):
            return (x1*b, y1*b)
        x2, y2 = b 
        return (x1*x2, y1*y2)

    def dot(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return x1*x2 + y1*y2

    def norm(self, a):
        x, y = a
        return x**2 + y**2

    def project(self, seg, p):
        """ 線分segに対する点pの射影 """
        p1, p2 = seg
        base = self.sub(p2, p1)
        r = self.dot(self.sub(p, p1), base) / self.norm(base)
        return self.add(p1, self.mul(base, r))

    def reflect(self, seg, p):
        """ 線分segを対称軸とした点pの線対称の点 """
        return self.add(p, self.mul(self.sub(self.project(seg, p), p), 2))

gm = Geometry()
x1, y1, x2, y2 = MAP()
seg = ((x1, y1), (x2, y2))
Q = INT()
for i in range(Q):
    x, y  = MAP()
    res = gm.reflect(seg, (x, y))
    print(*res)



Measured memory_bytes: 5768
n = int(input())

a = [list(input()) for i in range(n)]

b = [[0]* 26 for i in range(n)]
for i in range(n):
    for j in a[i]:
        b[i][ord(j)-97] += 1
su = ""

for i in range(26):
    if min(b,key = lambda x:x[i])[i] != 0:
        su += chr(i+97)*min(b,key = lambda x:x[i])[i]
print(su)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
//const Int mod = (1e9)+7;
const Int mod = 998244353;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int N, S;
vector<Int> A;

_int used[3001][3001];
_int mem[3001][3001];
Int dfs(Int idx, Int sum){
  if(idx == N) return sum == S;
  if(sum > S) return 0;
  if(used[idx][sum]++) return mem[idx][sum];
  Int res = (sum == S);
  res += dfs(idx + 1, sum);
  res += dfs(idx + 1, sum + A[idx]);
  res %= mod;
  return mem[idx][sum] = res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>N>>S;
  A.resize(N);
  cin>>A;

  Int ans = 0;
  for(Int i=0;i<N;i++){
    Int a = 1;
    Int b = dfs(i, 0);
    pr(i, a, b);
    ans += a * b;
    ans %= mod;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

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

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int a, b;
    cin >> a >> b;
    a += b + 1;
    cout << a / 2 << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)

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;}

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

int N;
int col[100010];
vector<pair<int,int>>g[100010];

void dfs(int now,int par,int dist){
	col[now]=dist%2;
	for(auto e:g[now]){
		if(e.fi==par)continue;
		dfs(e.fi,now,dist+e.se);
	}
}

signed main()
{
	//IOS();
	cin>>N;
	rep(i,0,N-1){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	dfs(0,-1,0);
	rep(i,0,N){
		cout<<col[i]<<endl;
	}
}


Measured memory_bytes: 10240
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

    for(int i = 0; i<s.length(); i+=2){
        cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define MOD 998244353
#define INF 1e18
ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}



using namespace std;

int main(void){
  ll n, s;
  cin >> n >> s;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }

  vector<vector<ll>> dp(n + 1, vector<ll>(s + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i < n + 1; i++){
    dp[i][0] = 1;
    for (int j = 0; j < s + 1; j++){
      if (j >= a[i-1])
        dp[i][j] = (dp[i-1][j]*2 + dp[i-1][j-a[i-1]]) % MOD;
      else
        dp[i][j] = dp[i-1][j]*2 % MOD;
    }
  }
  cout << dp[n][s] << endl;



  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n;

ll query(ll x){
    cout << x << endl;
    cout << flush;
    string s;
    cin >> s;
    if(s[0] == 'V') exit(0);
    if(s[0] == 'M') return 0;
    if(s[0] == 'F') return 1;
    return -1;
}

int main(){
    cin >> n;
    ll left_state = query(0);
    // ll right_state = query(n-1);
    ll l = 0;
    ll r = n;
    for(ll i = 0;i < 19;i++){
        ll x = (l+r)/2;
        cerr << i << " " << l << " " << r << " " << x << endl;

        ll ret = query(x);
        if((x % 2) == ((left_state+ret)%2)){
            l = x;
        }else{
            r = x;
        }
    }
}


Measured memory_bytes: 3860
#include <stdio.h>
#include <memory.h>
int main(void){
  int m,na,nb,p[201]={},i,max,ans;
  while(scanf("%d %d %d",&m,&na,&nb),m+na+nb){
    memset(p,0,sizeof(int)*201);
    for(i=1;i<=m;i++)
      scanf("%d",&p[i]);
    max=p[na]-p[na+1];
    ans=na;
    for(i=na;i<=nb;i++){
      if(max<=p[i]-p[i+1]){
	max=p[i]-p[i+1];
	ans=i;
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 600
mod = 1000000007
eps = 10**-9
inf = 10**15


def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.buffer.readline

    A, B, Q = map(int, input().split())
    S = [-inf]
    for _ in range(A):
        S.append(int(input()))
    S.append(inf)
    T = [-inf]
    for _ in range(B):
        T.append(int(input()))
    T.append(inf)

    for _ in range(Q):
        x = int(input())
        i = bisect_left(S, x)
        j = bisect_left(T, x)
        ans = []
        ans.append(x - S[i-1] + abs(S[i-1] - T[j-1]))
        ans.append(x - S[i-1] + abs(S[i-1] - T[j]))
        ans.append(x - T[j-1] + abs(T[j-1] - S[i-1]))
        ans.append(x - T[j-1] + abs(T[j-1] - S[i]))
        ans.append(S[i] - x + abs(S[i] - T[j-1]))
        ans.append(S[i] - x + abs(S[i] - T[j]))
        ans.append(T[j] - x + abs(T[j] - S[i-1]))
        ans.append(T[j] - x + abs(T[j] - S[i]))
        print(min(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 74880
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////




int main() {

	int N;

	cin >> N;
	string s;
	cin >> s;

	char t[MAX];

	
	rep(i, s.size()) {
		t[i] = s[i] +N;
		if (t[i] > 'Z') { t[i] -= 26; }
	}

	rep(i, s.size()) { cout << t[i]; }

		

	system("PAUSE");
}


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

using namespace std;

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

    vector<long long> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    long long maxn = 1000000000000000000;
    long long ans = 1;
    for(int i = 0; i < N; i++) {
        if(A[i] <= maxn / ans) {
            ans *= A[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int stack[100];
int tail = 0;

void push(int v) {
	stack[tail++] = v;
}

int pop() {
	tail--;
	return stack[tail];
}

int main() {
	int x, y;
	string s;
	while (cin >> s) {
		if (s == "+" || s == "-" || s == "*") {
			y = pop();
			x = pop();
			if (s == "+")
				push(x + y);
			if (s == "-")
				push(x - y);
			if (s == "*")
				push(x * y);
		}
		else {
			push(stoi(s));
		}
		
	}
	cout << pop() << endl;

	return 0;
}


Measured memory_bytes: 3144
S = input()
answer = "keyence"
a = 0

for s in S:
    if s == answer[a]:
        a += 1
        if a == len(answer):
            print("YES")
            break
    else:
        tmp = len(answer)-a
        if S[-tmp:] == answer[a:]:
            print("YES")
        else:
            print("NO")
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int n;
int dp[200001];
int main()
{
    cin >> n;
    rep(i, n)
    {
        int x;
        cin >> x;
        dp[x] = dp[x - 1] + 1;
    }
    int mx = 0;
    rep(i, n + 1)
    {
        mx = max(mx, dp[i]);
    }
    cout << n - mx << endl;
}

Measured memory_bytes: 1024
n = gets.to_i
arr = gets.chomp.split(' ').map{|num| num.to_i}
enter = 'APPROVED'
arr.each do |a|
  if a % 2 == 0
    unless a % 3 == 0 || a % 5 == 0
      enter = 'DENIED'
    end
  end
end
unless n.class == String
  print(enter)
end



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

using namespace std;

const long long int MOD = 1e9 + 7;

vector <long long int> prime;

long long int mypow(long long int x,long long int n)
{
	long long int res = 1;
	while(n>0)
	{
		if(n%2==1)
		{
			res = ((res%MOD)*(x%MOD)%MOD);
			res%=MOD;
		}
		x = ((x%MOD)*(x%MOD)%MOD);
		x%=MOD;
		n/=2;
	}
	return res;
}

void eratos(void)
{
	bool isprime[100001];
	memset(isprime,true,sizeof(isprime));
	for(int i=2;i<=100000;i++)
	{
		if(isprime[i])
		{
			prime.push_back(i);
			for(int j=2*i;j<=100000;j+=i)
			{
				isprime[j] = false;
			}
		}
	}
}

long long int phi(long long int a)
{
	map <long long int,long long int> cnt;
	long long int tot = 1;
	for(int j=0;j<prime.size();j++)
	{
		if(a==1)
		{
			break;
		}
		while(1)
		{
			if(a%prime[j]!=0)
			{
				break;
			}
			a/=prime[j];
			cnt[prime[j]]++;
		}
	}
	if(a!=1)
	{
		cnt[a]++;
	}
	for(auto it : cnt)
	{
		long long int val = mypow(it.first,it.second) - mypow(it.first,it.second-1);
		val%=MOD;
		if(val < 0)
		{
			val += MOD;
		}
		tot*=val;
		tot%=MOD;
	}
	return tot;	
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long int k,n;

	cin >> n >> k;

	eratos();

	long long int res = 0;

	for(long long int g=k;g>=1;g--)
	{
		long long int num = mypow(k/g,n);
		num = ((num%MOD)*(phi(g)%MOD)%MOD);
		res = ((res%MOD) + (num%MOD)%MOD);
		res%=MOD;
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3892
// E - Get Everything

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int N, M;

int dp[4096]; // dp[bit]: 開いた宝箱の状態がbitの時のコストの最小値
int cost[1000];
int can_open[1000];

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

	int a, b;
	for (int i=0; i<M; i++) {
		cin >> a >> b;
		cost[i] = a;
		int c;
		for (int j=0; j<b; j++) {
			cin >> c;
			c--;
			can_open[i] |= (1<<c);
		}
	}

	fill(dp, dp+4096, INF);
	dp[0] = 0;
	for (int i=0; i<M; i++) {
		for (int bit = 0; bit <= (1<<N) - 1; bit++) {
			if (dp[bit] == INF) continue;
			dp[bit | can_open[i]] = min(dp[bit | can_open[i]], dp[bit] + cost[i]);
		}
	}

	int ans;
	if (dp[(1<<N) - 1] == INF) {
		ans = -1;
	} else {
		ans = dp[(1<<N) - 1];
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
	string A;
	string B;
	cin >> A >> B;
	if(A.size() > B.size()){
		cout << "GREATER" << endl;
	}else if(A.size() < B.size()){
		cout << "LESS" << endl;
	}else if(A > B){
		cout << "GREATER" << endl;
	}else if(A < B){
		cout << "LESS" << endl;
	}else{
		cout << "EQUAL" << endl;
	}
}

Measured memory_bytes: 256
(let* ((n (read))
       (m (sort (loop :repeat n :collect (read)) #'<))
       (ll (make-array (+ 2 (expt 10 6)) :element-type 'bit :initial-element 1))
       (ans 0))
  (if (cdr m)
      (loop :for k :in m
            :for x :in (concatenate 'list (cdr m) '(-1))
            :do(cond ((and (= k x) (= 1 (aref ll k)))
                      (loop :for j :from k :upto (1+ (expt 10 6)) :by k
                            :if (= 1 (aref ll j)) :do(setf (aref ll j) 0)))
                     ((and (not (= k x)) (= 1 (aref ll k)))
                      (loop :for j :from k :upto (1+ (expt 10 6)) :by k
                            :if (= 1 (aref ll j)) :do(setf (aref ll j) 0))
                      (incf ans))))
      (incf ans))

  (princ ans))

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

# In[5]:


# S = input()


# In[6]:


# S_tail = list(S)
# S_tail.append("R")
# group = []
# tmp = []
# count = 0
# while count < len(S):
#     tmp.append(S_tail[count])
#     if S_tail[count] != S_tail[count+1]:
#         group.append(tmp)
#         tmp = []
#     count += 1


# In[7]:


# print(group)
# group_cnt = []
# count2 = 0
# for i in range(0,len(group),2):
# #     print("aaa")
#     if count2%2 == 0:
# #         print(group[i], len(group[i])//2)
#         count2 += len(group[i])
#         r_tmp = len(group[i])//2
#     else:
# #         print(group[i], len(group[i])//2+1)
#         count2 += len(group[i])
#         r_tmp = len(group[i])//2+1
        
#     if count2%2 == 0:
# #         print(group[i+1], len(group[i+1])//2)
#         count2 += len(group[i+1])
#         l_tmp = len(group[i+1])//2
#     else:
# #         print(group[i+1], len(group[i+1])//2+1)
#         count2 += len(group[i+1])
#         l_tmp = len(group[i+1])//2+1
# #     print(r_tmp, l_tmp)
#     group_cnt.append(r_tmp+l_tmp)
#     group_cnt.append(len(group[i])+len(group[i+1]) - (r_tmp+l_tmp))
#     r_tmp = 0
#     l_tmp = 0
# # print(group_cnt)


# In[8]:


# ans = [[0]*(len(group[i])-1)+[group_cnt[i]] if i%2 == 0 else [group_cnt[i]]+[0]*(len(group[i])-1) for i in range(len(group))]
# ans2 = []
# for i in range(len(ans)):
#     ans2 += ans[i]
# print(" ".join(list(map(str,ans2))))


# In[12]:


def main():
  s = input()
  ans = [1] * len(s)
  for i in range(len(s)-2):
    if s[i]=='R' and s[i+1]=='R':
      ans[i+2] += ans[i]
      ans[i] = 0
#     print(ans)
  for i in range(len(s)-1, 1, -1):
    if s[i]=='L' and s[i-1]=='L':
      ans[i-2] += ans[i]
      ans[i] = 0
#     print(ans)
  print(" ".join(map(str, ans)))
  
if __name__ == '__main__':
  main()


# In[ ]:






Measured memory_bytes: 10484
#include <stdio.h>

int main(){

    long long int n, soma = 0;
    scanf("%lld", &n);
    long long int termos[n];

    for(int i = 0; i < n; ++i){
        if((i + 1)%3 == 0 || (i + 1)%5 == 0){
            termos[i] = 0;
        } else{
            termos[i] = i + 1;
        }
    }

    for(int i = 0; i < n; ++i){
        soma += termos[i];
    }

    printf("%lld\n", soma);

    return 0;
}

Measured memory_bytes: 9456
import numpy as np

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

n = np.arange(1,N+1)
k = np.ceil( np.log10(K/n)/np.log10(2.0) )
k[k < 0.0] = 0.0
ans = np.sum( 0.5**(k)/N )

print('{:.9f}'.format(ans))

Measured memory_bytes: 15532
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	long int N, M;
	scanf("%ld %ld\n", &N, &M);
	if (N >= 3 && M >= 3){
		printf("%ld", (N - 2)*(M - 2));
	}
	else if (N == 2 || M == 2){
		printf("0\n");
	}
	else if (N == 1&&M==1){
		printf("1\n");
	}
	else if (N == 1 && M >= 3){
		printf("%ld\n", M - 2);
	}
	else if (N >= 3 && M == 1){
		printf("%ld\n", N - 2);
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)

{  

    int n,i,ai,min,max;
	long sum;

    sum=0;  

    min=1000000;  

    max=-1000000;  

    scanf("%d",&n);  

    for(i=1;i<=n;i++){  

     scanf("%d",&ai);  

     sum+=ai;  

     if(min>ai){   

      min=ai;  

      }  

     if(max<ai){  

      max=ai;   

     }  

    }  

    printf("%d %d %lld\n",min,max,sum);  

    return 0;

}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

#define int long long 

struct UnionFind {
    vector<int> par; //親ノード
    vector<int> sizes; //高さ

    UnionFind(int N = 1){ init(N); }

    void init(int N = 1){
        par.resize(N);
        sizes.resize(N);

        for(int i = 0; i < N; ++i){
            par[i] = i;
            sizes[i] = 1;
        }
    }

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

    bool is_same(int x,int y){ 
        return root(x) == root(y); 
    }

    bool merge(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(sizes[x] < sizes[y]) swap(x,y);
        par[y] = x;
        sizes[x] += sizes[y];
        sizes[y] = 0;
        return true;
    }
};

signed main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(M),B(M);
    for(int i=0;i<M;i++) {
        cin >> A[i] >> B[i];
        A[i]--,B[i]--;
    }

    UnionFind uni(N);
    vector<int> ans(M);
    ans[M-1] = N*(N-1)/2;
    
    for(int i=M-1;i>0;i--){
        bool same = uni.root(A[i]) == uni.root(B[i]);
        if(!same) ans[i-1] = ans[i] - (uni.sizes[uni.root(A[i])] * uni.sizes[uni.root(B[i])]);
        else ans[i-1] = ans[i];
        uni.merge(A[i],B[i]);
    }

    for(int i=0;i<M;i++) cout << ans[i] << endl; 
}

Measured memory_bytes: 5248
use proconio::{fastout, input, marker::Usize1};

#[fastout]
fn main() {
    input! {
        n:usize,
        a:[Usize1; n],
        b:[i64; n],
        c:[i64; n-1],
    }

    let mut res = 0;
    for i in 0..n {
        res += b[a[i]];
        if i > 0 {
            if a[i - 1] + 1 == a[i] {
                res += c[a[i - 1]];
            }
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define MAX 100010
#define inf 1000000010
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int n,m,s;
vector<pii> E[MAX];

void compute(){
  int d[MAX];
  fill(d,d+MAX,inf);
  priority_queue<pii,vector<pii>,greater<pii> > pq;
  d[s]=0;
  pq.push(mp(0,s));

  while(pq.size()){
    pii u = pq.top();
    pq.pop();

    if(d[u.s]<u.f)continue;

    FOR(i,0,E[u.s].size()){
      int next = E[u.s][i].f;
      int cost = d[u.s]+E[u.s][i].s;
      if(cost<d[next]){
        d[next] = cost;
        pq.push(mp(cost,next));
      }
    }
  }
  FOR(i,0,n){
    if(d[i]==inf)cout<<"INF"<<endl;
    else cout<<d[i]<<endl;
  }
}

int main()
{
  cin>>n>>m>>s;
  FOR(i,0,m){
    int a,b,c;
    cin>>a>>b>>c;
    E[a].pb(mp(b,c));
  }
  compute();
  return 0;
}



Measured memory_bytes: 13028