akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main (){
	int n;
	cin >> n;
	int a[n];
	int max =0;
	int count =0;
	for(int i=0; i< n; i++){
		cin >> a[i];
		if(max <= a[i]){
			count ++;
			max =a[i];
		}
	}
	cout << count << endl;
}


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

int main(){
    int n,m,i,j;
    cin >> n >> m;
    vector<int> a(m),b(m),ans(n);
    for(int i=0;i<m;i++){
        cin >> a.at(i) >> b.at(i);
        ans.at(a.at(i)-1)++;
        ans.at(b.at(i)-1)++;
    }
    for(int i=0;i<n;i++){
        cout << ans.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c >= 22){
        cout<<"bust"<<endl;
    }
    else{
        cout<<"win"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                if (find(S.begin(), S.end(), '0' + i) != S.end())
                {
                    if (find(find(S.begin(), S.end(), '0' + i) + 1, S.end(), '0' + j) != S.end())
                    {
                        if (find(find(find(S.begin(), S.end(), '0' + i) + 1, S.end(), '0' + j) + 1, S.end(), '0' + k) != S.end())
                        {
                            ans++;
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

vector<vector<int>> tree;
vector<int> ds,df;

bool direct = true;

void dfs(const int &cnt, const int &par, const int &stop,vector<int> &d) {
    for(auto t:tree[cnt]) {
        if (t == stop) continue;
        if (t == par) continue;
        d[t] = d[cnt] + 1;
        dfs(t,cnt,stop,d);
    }
}

int main(void)
{
    IOS
    int n; cin >> n;
    tree.resize(n);
    df.resize(n);
    ds.resize(n);
    REP(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);        
    }

    dfs(0,-1,n-1,df);
    dfs(n-1,-1,0,ds);
    int snuke = 0, fennec = 0;
    FOR(i,1,n-1) {
        if (df[i] == 0) snuke++;
        else if (ds[i] == 0) fennec++;
        else if (df[i] <= ds[i]) fennec++;
        else snuke++;
    }

    if (snuke >= fennec) cout << "Snuke" << endl;
    else cout << "Fennec" << endl;

    //cerr << fennec << " " << snuke << endl;
    //REP(i,n) cerr << d[i] << endl;
    // cerr << dcount << endl;
    return 0;
}

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
	int x, y;

	cin>> n>> x >> y;

	int dist[n+1][n+1];
	memset(dist, 0, sizeof(dist));

	vi adj[n+1];

	for(int i = 1; i<n; ++i){
		adj[i].pb(i+1);
		adj[i+1].pb(i);
	}
	adj[x].pb(y);
	adj[y].pb(x);

	int ans = 0;

	for(int i = 1; i<=n; ++i){
		vector<bool> visited(n+1, false);
		queue<int> q;

		dist[i][i] = 0;
		visited[i] = true;
		q.push(i);

		while(!q.empty()){
			int pos = q.front();
			q.pop();

			for(int v: adj[pos]){
				if(!visited[v]){
					visited[v] = true;
					dist[v][i] = dist[pos][i] + 1;
					q.push(v);
				}
			}
		}
	}

	vi res(n+1, 0);
	for(int i = 1; i<=n; ++i)
		for(int j = i+1; j<=n; ++j) res[dist[i][j]]++;
	for(int i = 1; i<n; ++i) cout<< res[i]<< endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}


Measured memory_bytes: 19344
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdio>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

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

int main(void){
  vi used;
  vector<vector <double> > anum(24,vector<double>(2) );

  vector<vector <double> > fnum(8,vector<double>(2) );
  vector<vector <double> > snum(8,vector<double>(2) );
  vector<vector <double> > tnum(8,vector<double>(2) );
  
  
  rep(i,8){
    cin>>fnum[i][1]>>fnum[i][0];
    anum[i][0]=fnum[i][0];
    anum[i][1]=fnum[i][1];
  }

  
  rep(i,8){
    cin>>snum[i][1]>>snum[i][0];
    anum[i+8][0]=snum[i][0];
    anum[i+8][1]=snum[i][1];
  }
  
  rep(i,8){
    cin>>tnum[i][1]>>tnum[i][0];
    anum[i+16][0]=tnum[i][0];
    anum[i+16][1]=tnum[i][1];
  }
  /*
  rep(i,24){
    cout<<anum[i][0]<<" "<<anum[i][1]<<endl;
  }
  */
  sort(all(fnum));
  sort(all(snum));
  sort(all(tnum));
  sort(all(anum));
  rep(i,2){cout<<fnum[i][1]<< " " << fnum[i][0] <<endl; used.push_back(fnum[i][1]);}  
  rep(i,2){cout<<snum[i][1]<< " " << snum[i][0] <<endl; used.push_back(snum[i][1]);}  
  rep(i,2){cout<<tnum[i][1]<< " " << tnum[i][0] <<endl; used.push_back(tnum[i][1]);}
  int cnt = 0;
  int num = 0;
 
  while(cnt<2){
    bool next = false;
    rep(i,used.size()){
      if(anum[num][1]==used[i]){
	num++;
	next = true;
	break;
      }
    }
    if(next)continue;
    cout<< anum[num][1] <<  " " << anum[num][0] << endl;
    used.push_back(anum[num][1]);
    cnt++;
  }
 
} 

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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n,ans = 0;
string s;

void solve(int x,int y)
{
    if(x==n+1)
    {
        ans+=y;
        return;
    }
    int cur = 0;
    for(int i=x;i<=n;i++)
    {
        cur = (cur*10) + (s[i]-'0');
        solve(i+1,cur+y);
    }
}

int32_t main()
{
    IOS;
    cin>>s;
    n = s.size();
    s = ' ' + s;
    solve(1,0);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

class SegTree
{
public:
    SegTree(int size) : nodes_(4 * size + 4, 0), size_(size) {}

    void Set(int index, int value)
    {
        Set(0, 0, size_ - 1, index, value);
    }

    int Get(int left, int right) const
    {
        return Get(0, 0, size_ - 1, left, right);
    }

private:
    void Set(int node, int left, int right, int index, int value)
    {
        if (left == right) {
            nodes_[node] = value;
            return;
        }

        int mid = left + (right - left) / 2;
        if (index <= mid) {
            Set(LeftSon(node), left, mid, index, value);
        } else {
            Set(RightSon(node), mid + 1, right, index, value);
        }
        nodes_[node] = std::max(nodes_[LeftSon(node)], nodes_[RightSon(node)]);
    }

    int Get(int node, int left, int right, int x, int y) const
    {
        if (x <= left && right <= y) {
            return nodes_[node];
        }

        int mid = left + (right - left) / 2;
        int res = 0;

        if (x <= mid) {
            res = std::max(res, Get(LeftSon(node), left, mid, x, y));
        }
        if (mid < y) {
            res = std::max(res, Get(RightSon(node), mid + 1, right, x, y));
        }
        return res;
    }

    static int LeftSon(int node) { return 2 * node + 1; }
    static int RightSon(int node) { return 2 * node + 2; }

    std::vector<int> nodes_;
    int size_;
};

int FindClosest(const std::vector<std::pair<int, int>> &points, int limit)
{
    int res = -1;
    int pow = (1 << 20);

    while (pow > 0) {
        int next_res = res + pow;
        pow >>= 1;

        if (next_res < (int)points.size() && points[next_res].first < limit) {
            res = next_res;
        }
    }
    return res;
}

int main()
{
    int n;
    std::cin >> n;

    std::vector<std::pair<int, int>> points(n);
    for (auto &p : points) {
        std::cin >> p.first >> p.second;
    }
    std::sort(points.begin(), points.end());

    constexpr int kMod = 998244353;
    std::vector<int> ways(n, 0);
    std::vector<int> reach(n, -1);

    SegTree tree(n);
    for (int i = 0; i < n; i += 1) {
        reach[i] = i;
        tree.Set(i, reach[i]);
    }
    for (int i = n - 2; i >= 0; i -= 1) {
        int right = FindClosest(points, points[i].first + points[i].second);
        reach[i] = tree.Get(i, right);
        tree.Set(i, reach[i]);
    }

    ways[n - 1] = 2;
    for (int i = n - 2; i >= 0; i -= 1) {
        ways[i] = ways[i + 1];
        if (reach[i] + 1 < n) {
            ways[i] = (1LL * ways[i] + ways[reach[i] + 1]) % kMod;
        } else {
            ways[i] = (1LL * ways[i] + 1) % kMod;
        }
    }

    std::cout << ways[0] << "\n";
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;
const int MSIZE = 100000;
const double Pi = 3.14159265358979323146;

int main(){
  ll n, a, b;  cin >> n >> a >> b;
  ll bp; cin >> bp;
  ll ans = 0;
  REP(i, n-1){
    ll p; cin >> p;
    ll dis = p-bp;
    ans += min(dis*a, b);
    bp = p;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mp make_pair
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct Edge {
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
static const ll INF = 1e17;

Graph g;
ll ans;
int n;
ll k;


int main(){
  cin >> n >> k;
  ans = 0;
  vector<int> p(n);
  vector<ll> c(n);
  rep(i, n){
    cin >> p[i];
    --p[i];
  }
  rep(i, n){
    cin >> c[i];
    if(i == 0) ans = c[i];
    else chmax(ans, c[i]);
  }

  rep(i, n){
    vector<bool> seen(n, false);
    seen[i] = true;
    int now = i;
    ll sum = 0;
    ll count = k;
    int heiro = 0;
    while(count){
      heiro++;
      if(seen[p[now]]){
        sum += c[p[now]];
        chmax(ans, sum);
        break;
      } else {
        seen[p[now]] = true;
        sum += c[p[now]];
        now = p[now];
        chmax(ans, sum);
      }
      count--;
    }

    if(count) {
      ll div = k / heiro;
      if(sum >= 0) {
        sum = sum * (div - 1);
      }
      ll rem = k % heiro + heiro;
      now = i;
      rep(z, rem){
        sum += c[p[now]];
        now = p[now];
        chmax(ans, sum);
      }
    } else {
      chmax(ans, sum);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3684
N = int(input())
A = list(map(int, input().split()))

A.sort()

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            a, b, c = A[i], A[j], A[k]

            if (a == b) or (b == c) or (c == a):
                continue

            if (a+b > c) and (b+c > a) and (c+a > b):
                ans += 1
print(ans)


Measured memory_bytes: 68048
#include <stdio.h>
int main()
{
  int x,a,b;
  scanf("%d%d%d",&x,&a,&b);
  
  if(a>=b){
    printf("delicious\n");
  }
  else if(b-a<=x){
    printf("safe\n");
  }
  else{
    printf("dangerous\n");
  }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 200000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll ir[202020];
int main()
{
	int num;
	scanf("%d", &num);
	invinit();
	for (int i = 0; i < num + 10; i++)ir[i + 1] = (ir[i] + inv[i + 1]) % mod;
	ll ans = 0;
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%lld", &z);
		ll s = (ir[i + 1] + ir[num - i] + mod - 1) % mod;
		ans = (ans + kai[num] * z%mod*s) % mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll tmp;
    for (int i = 1; i <= 5; i++)
    {
        cin >> tmp;
        if (tmp == 0)
            cout << i << endl;
    }
}

Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

string s;

int main(){
    cin>>s;

    int a,b,c;
    a=b=c=0;
    rep(i,s.size()){
        if(s[i]=='a') a++;
        if(s[i]=='b') b++;
        if(s[i]=='c') c++;
    }

    string ans="NO";
    if(abs(a-b)<=1 && abs(b-c)<=1 && abs(c-a)<=1) ans="YES";

    cout<<ans<<endl;
}

Measured memory_bytes: 3688
#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>;
const double PI = acos(-1);
const ll MOD = 1000000007;

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

  ll ans = 0;

  rep(i,N-2){
    for(int j=i+1; j<N-1; j++){
      for(int k=j+1; k<N; k++){
        if(V[i]!=V[j] && V[j]!=V[k] && V[k]!=V[i]){
          if(V[i]+V[j] > V[k] && V[j]+V[k] > V[i] && V[k]+V[i] > V[j]) {
            ans++;
            //cout << i << j << k << endl;
            continue;
          }
        }
      }
    }
  }

  cout << ans <<endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

int main(){
	int n;
	char s[110];
	scanf("%d%s",&n,s);
	int m=0,t=0;
	rep(i,0,n){
		if(s[i]==')')t++;
		else t--;
		m=max(m,t);
	}
	rep(i,0,m)putchar('(');
	printf("%s",s);
	rep(i,0,m-t)putchar(')');
	return 0;
}

Measured memory_bytes: 128
/*
First, solve the problem.Then write the code. - John Johnson
@author: returnAC
*/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define need_for_speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // Thanks Joshua :)
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	need_for_speed;
	int n;
	cin>>n;
	int q;
	cin>>q;
	string s;
	cin>>s;
	int prefix[n];
	memset(prefix,0,sizeof(prefix));
	prefix[0]=0;
	for(int i=1;i<n;i++)
	{
		if(s[i]=='C'&&s[i-1]=='A')
			prefix[i]+=prefix[i-1]+1;
		else
			prefix[i]+=prefix[i-1];
	}
	while(q--)
	{
		int l,r;
		cin>>l>>r;
		cout<<prefix[r-1]-prefix[l-1]<<endl;
	}
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e10;

ll X, Y;

ll agc008a() {
  ll res = INF;
  if (X <= Y) {
    res = min(res, Y - X);
  }
  if (-X <= Y) {
    res = min(res, 1 + Y + X);
  }
  if (X <= -Y) {
    res = min(res, 1 - Y - X);
  }
  if (-X <= -Y) {
    res = min(res, 2 - Y + X);
  }
  return res;
}

int main() {
  cin >> X >> Y;
  cout << agc008a() << "\n";
  return 0;
}

Measured memory_bytes: 256
main = do
 [_ ,_ ,c] <- map (read::String->Int) .words <$> getLine
 b  <- map (read::String->Int) .words <$> getLine ::IO([Int])
 aa  <- map (map (read::String->Int) .words) .lines <$> getContents  :: IO([[Int]])
 print.length.filter (-c<) .map (vdot b) $aa

vdot :: [Int] -> [Int] -> Int
vdot x y = sum $ zipWith (*) x y

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long 
#define db double
#define all(v) v.begin(),v.end()

using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/


int main(){
    //IOS;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        ll a[n+1];
        FOR(i,n)cin>>a[i];
        vi<ll> p,m;
        FOR(i,n){
            if(a[i]<0)m.pb(a[i]);
            else p.pb(a[i]);
        }
        ll ans=1;
        if(n==k){
            FOR(i,n){
                ans*=a[i];
                ans=(ans%mod+mod)%mod;
            }
            cout<<ans<<"\n";
            return 0;
        }

        ll ip=0,in=0;
        ll np=p.size();
        ll nn=m.size();
        sort(all(p),greater<ll>());
        sort(all(m));
        ans=1;
        if(k%2==1 && np==0){
            FOR(i,k){
                //cout<<m[i]<<" ";
                ans*=m[m.size()-1-i];
                ans=(ans%mod+mod)%mod;
            }
            cout<<ans;
            return 0;
        }

        ll isum=0;

        if(k%2==1){
            ip=1;
            isum=1;
            ans*=p[0];
        }

        while(isum<k){
            if(ip>=np-1){
                ans*=m[in];
                 ans=(ans%mod+mod)%mod;
                ans*=m[in+1];
                 ans=(ans%mod+mod)%mod;
                in+=2;
            }
            else if(in>=nn-1){
                ans*=p[ip];
               ans=(ans%mod+mod)%mod;
                ans*=p[ip+1];
                ans=(ans%mod+mod)%mod;
                ip+=2;
            }
            else if(p[ip]*p[ip+1]>m[in]*m[in+1]){
                ans*=p[ip];
                ans=(ans%mod+mod)%mod;
                ans*=p[ip+1];
                 ans=(ans%mod+mod)%mod;
                ip+=2;
            }
            else{
                ans*=m[in];
                 ans=(ans%mod+mod)%mod;
                ans*=m[in+1];
                 ans=(ans%mod+mod)%mod;
                in+=2;
            }
            isum+=2;
        }

        cout<<ans;

    }
    return 0;
} 

Measured memory_bytes: 6932
#include <iostream>
#include <fstream>//input.txtを呼ぶ時必要
using namespace std;

int main() {
    //std::ifstream in("input.txt");//input.txtを呼ぶ時必要
    //std::cin.rdbuf(in.rdbuf());//input.txtを呼ぶ時必要
    
    int a, b;
    cin >> a >> b;
    int c = a * b;
    if (c % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

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

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

	int ans = max(b+b-1, max(a+a-1, a+b));
	cout << ans << endl;
	return 0;
}


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

int N;
vector<int>A,B;

void solve(){
    sort(A.rbegin(),A.rend());
    sort(B.rbegin(),B.rend());

    int cnt=0;
    multiset<int>S;
    for(int i=0;i<N-1;i++){
        S.insert(B[i]);
        multiset<int>::iterator it=S.lower_bound(A[i]);
        if(it==S.end()){
            cnt++;
        }
        else{
            S.erase(it);
        }
        if((i+1)/2<cnt){
            cout<<i+1<<endl;
            return;
        }
    }
    cout<<"NA"<<endl;
}

int main(){
    while(cin>>N,N){
        A.resize(N);B.resize(N);
        for(int i=0;i<N;i++)cin>>A[i];
        for(int i=0;i<N;i++)cin>>B[i];
        solve();
    }
}

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

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	bool isEqual = false;
	for (int i = 0; i < s.size(); i++)
		if (s.substr(i) + s.substr(0, i) == t)
		{
			isEqual = true;
			break;
		}
	cout << (isEqual ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
def b_powers_of_two(N, A):
    # 参考: https://beta.atcoder.jp/contests/agc029/submissions/3804857
    from bisect import bisect_left
    a = sorted(A)
    ans = 0
    for j in range(N - 1, -1, -1):
        # b > a[j]となるような最小のb(これは2の冪乗である)を探す
        b = 1
        while b <= a[j]:
            b <<= 1

        k = bisect_left(a, b - a[j])
        if k < j and (b - a[j] == a[k]):
            # a[k] <= a[j] であり、かつ、a[j] + a[k] = b(2の冪乗)
            # となるペア(j, k)が見つかれば、貪欲にペアにしてよい。
            # (a[j] を放置すると、ペアにできる可能性がある整数が少なくなり、得にならない)
            ans += 1
            # 整数でなくしておいて、ペアに使えないようにする。
            # ペアのうち、要素番号が大きい方は足し、小さい方は引いておくと、
            # 同じ値が複数あったときも二部探索で以前にペアにした整数を
            # ピックアップすることがなくなる。
            a[j] += 0.1
            a[k] -= 0.1

    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(b_powers_of_two(N, A))

Measured memory_bytes: 26180
A, B = map(int, raw_input().split())
card = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if card.index(A) > card.index(B):
    print "Alice"
elif card.index(A) < card.index(B):
    print "Bob"
else:
    print "Draw"


Measured memory_bytes: 2568
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
   {harry
    string s,t,str="";
    cin>>s>>t;
    lli l1=s.length(),l2=t.length();
    lli dp[l1+1][l2+1],sp[l1+1][l2+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=l1;i++)
       {for(int j=1;j<=l2;j++)
          {if(s[i-1]==t[j-1])
              {dp[i][j]=dp[i-1][j-1]+1;
               sp[i][j]=3;
              }
           else
             {if(dp[i-1][j]>dp[i][j-1])
                 {dp[i][j]=dp[i-1][j];
                  sp[i][j]=1;}
              else
                 {dp[i][j]=dp[i][j-1];
                  sp[i][j]=2;
                 }
              }
              //cout<<sp[i][j]<<" ";
           }
        //cout<<endl;
        }
        int i=l1,j=l2;
        while(i>=1||j>=1)
        {if(sp[i][j]==3)
            {str+=s[i-1];
             if(i>=1)
             {i--;}
             if(j>=1)
             j--;}
        else if(sp[i][j]==2&&j>=1)
            {j--;}
        else if(sp[i][j]==1&&i>=1)
            i--;
         if(i<1)
            j--;
         else if(j<1)
            i--;

        }
        reverse(str.begin(),str.end());
        cout<<str;



    }

















Measured memory_bytes: 140928
var IsTest = false;
var Main = function(Input){
  var Arr = Input.split('\n');
  var Day = Arr[0];
  if(Day == '25'){
    console.log('Christmas');
  } else if(Day == '24'){
    console.log('Christmas Eve');
  } else if(Day == '23'){
    console.log('Christmas Eve Eve');
  } else if(Day == '22'){
    console.log('Christmas Eve Eve Eve');
  }
}

if(IsTest){
  Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));  
} else {
  Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
}



Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll a,b,c;cin>>a>>b>>c;
  ll d=c-a-b;
  if(d<=0){
    cout<<btos(false)<<endl;
    return 0;
  }
  d*=d;
  ll e=4*a*b;
  cout<<btos(d>e)<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int cnt = 0;
		for (int i = 0; i < n; i++) {
			while (a[i] % 2 == 0) {
				cnt++;
				a[i] /= 2;
			}
		}		
		
		pr.println(cnt);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 34268
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

struct N {
  int x, y, cost;
};

bool operator<(const N &lhs, const N &rhs) { return lhs.cost < rhs.cost; }

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<pair<int, int>> gp(n + 1);
  vector<string> mp(h);
  for (int i = 0; i < h; i++) {
    cin >> mp[i];
  }
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      if (mp[i][j] == 'S') {
        gp[0].first = j;
        gp[0].second = i;
      } else if (mp[i][j] >= '1' && mp[i][j] <= '9') {
        gp[mp[i][j] - '0'].first = j;
        gp[mp[i][j] - '0'].second = i;
      }
    }

  int hx[4] = {0, 0, 1, -1};
  int hy[4] = {1, -1, 0, 0};

  int ans = 0;
  for (int i = 0; i < n; i++) {
    multiset<N> q;
    N start{gp[i].first, gp[i].second, 0};
    q.insert(start);
    vector<vector<bool>> ch(h);
    for (int j = 0; j < h; j++)
      ch[j].resize(w);
    while (q.size() > 0) {
      N now = *q.begin();
      q.erase(q.begin());
      if (ch[now.y][now.x])
        continue;
      ch[now.y][now.x] = true;
      if (now.y == gp[i + 1].second && now.x == gp[i + 1].first) {
        ans += now.cost;
        break;
      }
      for (int j = 0; j < 4; j++) {
        int nx = now.x + hx[j], ny = now.y + hy[j];
        if (nx < 0 || nx >= w || ny < 0 || ny >= h)
          continue;
        if (mp[ny][nx] == 'X')
          continue;
        N next{nx, ny, now.cost + 1};
        q.insert(next);
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4072
#include <iostream>
	#include <string>
	#include <vector>
	#include <algorithm>
	#include <cmath>
	#include <cassert>
	#include <iomanip>

	#include <map>
	#include <set>
	#include <queue>
	#include <stack>

	#define ALL(a) (a).begin(),(a).end()
	#define FOR(i,a,b) for(int i=(a);i<(b);i++)
	#define REP(i,n) FOR(i,0,n)
	#define rep(i,n) FOR(i,0,n)
	#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
	#define rrep(i,n) RFOR(i,n,0)
	#define DEBUG(x) cout<<#x<<": "<<x<<endl
	#define vint vector<int>
	#define vdbl vector<double>
	#define vstr vector<string>

	using namespace std;

	typedef long long ll;
	typedef unsigned long long ull;

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

		ll N,W;
		cin >> N >> W;

		ll w[N];
		ll v[N];
		rep(i,N) cin >> w[i] >> v[i];

		vector<ll> vs[4];
		rep(i,N) vs[w[i]-w[0]].push_back(v[i]);

		rep(i,4) sort(vs[i].begin(),vs[i].end(),greater<ll>());

		vector<ll> vssum[4];
		rep(i,4){
			vssum[i].push_back(0);
			rep(j,vs[i].size()) vssum[i].push_back(vssum[i][j] + vs[i][j]);
		}

		ll ans = 0;
		rep(i0,vssum[0].size()){
			rep(i1,vssum[1].size()){
				rep(i2,vssum[2].size()){
					rep(i3,vssum[3].size()){
						if((w[0]*i0 + (w[0]+1)*i1 + (w[0]+2)*i2 + (w[0]+3)*i3) <= W){
							ll a = 0;
							a += vssum[0][i0];
							a += vssum[1][i1];
							a += vssum[2][i2];
							a += vssum[3][i3];

							ans = max(ans,a);
						}
					}
				}
			}
		}

		cout << ans << endl;	
	}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H); rep(i, H) cin >> S[i];

    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '.') {
                int cnt = 0;
                if (i > 0 && j > 0 && S[i - 1][j - 1] == '#') cnt++;
                if (i > 0 && S[i - 1][j] == '#') cnt++;
                if (i > 0 && j < W - 1 && S[i - 1][j + 1] == '#') cnt++;
                if (j > 0 && S[i][j - 1] == '#') cnt++;
                if (j < W - 1 && S[i][j + 1] == '#') cnt++;
                if (i < H - 1 && j > 0 && S[i + 1][j - 1] == '#') cnt++;
                if (i < H - 1 && S[i + 1][j] == '#') cnt++;
                if (i < H - 1 && j < W - 1 && S[i + 1][j + 1] == '#') cnt++;
                S[i][j] = '0' + cnt; // int を char に変換
            }
        }
    }
    
    rep(i, H) {
        cout << S[i] << endl;    
    }
    return 0;
}


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

using namespace std;

vector<int>prime;
int mark[1005];

void sieve()
{
    for(int i=2 ; i<=1000 ; i++){
        if(mark[i] == 0){
            prime.push_back(i);
            for(int j=i+i ; j<=1000 ; j+=i) mark[j] = 1;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);

    sieve();

    int n;
    bool flag = 0;
    cin>>n;
    int gcd = 0;
    unordered_map<int, bool>mp;
    for(int i=0 ; i<n ; i++){
        int x;
        cin>>x;
        gcd = __gcd(gcd, x);
        int sz = prime.size();
        for(int i=0 ; i<sz and prime[i]*prime[i]<=x ; i++){
            if((x%prime[i] == 0)){
                if(mp[prime[i]] == 1){
                    flag = 1;
                    break;
                }
                 while(x%prime[i] == 0){
                    x/=prime[i];
                 }
                 mp[prime[i]] = 1;
            }
        }
        if(mp[x] == 1) flag = 1;
        if(x > 1) mp[x] = 1;
    }

    if(flag == 0) cout<<"pairwise coprime"<<endl;
    else if(gcd == 1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;

    return 0;
}


Measured memory_bytes: 42596
#include <cmath>
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  ll N, i;
  cin >> N;
  for (i = lround(sqrt(N));; --i) {
    if (N % i == 0) {
      i = i + N / i - 2;
      break;
    }
  }
  cout << i << endl;
}


Measured memory_bytes: 256
S = list(input())
temp = 0
ans = 0
letter = ["A", "T", "C", "G"]
for i, val in enumerate(S):
  if val in letter:
    temp += 1
  else:
    if ans < temp:
      ans = temp
    temp = 0
if ans < temp:
  ans = temp
print(ans)
      



Measured memory_bytes: 9024
#include <bits/stdc++.h>
#include  <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
#define endl '\n'
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> index_set;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using ii = pair<int,int>;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mod 1000000007
const int maxn = 1e5+10;

int main(){
		ios_base::sync_with_stdio(false);
		cin.tie(nullptr);
		string s;cin >> s;
		if(s[sz(s)-1] == 's')cout << s << "es";
		else cout << s <<"s";
		
			
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>
typedef long long ll;
// typedef std::pair<ll, ll> pair_ll;
int main() {
	int n;
	std::vector<ll> lx ;
	
	std::cin >> n;
	lx.resize(n);
	ll lmax = 0;
	ll lsum = 0;
	for(int i = 0 ; i < n ; i++)
	{ 
		std::cin >> lx[i];
		lsum += lx[i];
		if (lmax < lx[i])
		{
			lmax = lx[i];
		}
	}
	if (lmax * 2 < lsum) {
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){


 
  int H,W,x;

  for( ; ; ){

    cin>>H>>W;

    if(H==0&&W==0)break;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	x=i+j;
	if(x%2==0){
	cout<<"#";
      }else{
	cout<<".";
      }
    }
    
    cout<<endl;
  }

  cout<<endl;
}   
  return 0;
}

Measured memory_bytes: 3096
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n := readString()
	if n == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1756
#include <iostream>
#include <queue>
#define mp make_pair
using namespace std;
deque<pair<int,int> > q;
bool vis[100005];
int k,ans=0; 
int main()
{
	cin>>k;
	q.push_front(mp(1,1));
	while(!q.empty()){
		pair<int,int> x=q.front();
		q.pop_front();
		if(x.first==0){
			cout<<ans+x.second;
			return 0;
		}
		if(vis[x.first]){
			continue;
		}
		vis[x.first]=1;
		q.push_back(mp((x.first+1)%k,x.second+1));
		q.push_front(mp((x.first*10%k),x.second));
	}
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#define N 500000
#define INFTY 1000000000

int S[N];
int L[N/2+2],R[N/2+2];
int count=0;

int merge(int S[],int n, int left, int mid, int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;

  j=0;
  k=0;

  for(i=0; i<n1; i++) L[i] = S[left+i];
  for(i=0; i<n2; i++) R[i] = S[mid+i];

  L[n1] = R[n2] = INFTY;

  for(i=left; i<right; i++){
    count++;
    if(L[j]<=R[k]) S[i] = L[j++];
    else {
      S[i] = R[k++];
    }

  }
 //printf("%d\n",count);
}

int mergeSort(int S[],int n, int left, int right){
  if(left+1 < right){
    int mid = (left + right) /2;
    mergeSort(S,n,left,mid);
    mergeSort(S,n,mid,right);
    merge(S,n,left,mid,right);
  }
}

int main(){
  int S[N],i,n;

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

  mergeSort(S,n,0,n);

  for(i=0; i<n; i++){
    if(i) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");

  printf("%d\n",count);

  return 0;

}



Measured memory_bytes: 5588
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#define ll long long
int main()
{
    int a;
    while(scanf("%d",&a)!=EOF)
    {
        printf("%d",(a+1)*a/2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,ans=0;
    cin >> n;
    vll v(n);
    rep(i,n) cin >> v[i];
    sort(all(v));
    cout << v[n-1] - v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(){
	int n, m;
	vector<int> dp;
	
	cin>>n>>m;
	
	dp.resize(n+1, (1<<30));
	
	dp[0] = 0;
	
	for(int i = 0; i < m; i++){
		int c;
		
		cin>>c;
		
		for(int j = 0; j <= n; j++){
			if(j + c <= n) dp[j+c] = min(dp[j]+1, dp[j+c]);
		}
	}
	
	cout<<dp[n]<<endl;
}


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

N = input()

sN = set(N)
if len(N) == 1:
    ans = int(N)
elif len(N) > 1 and N[1:] == "9" * (len(N) - 1):
    ans = sum(map(int, list(N)))
else:
    ans = (len(N) - 1) * 9
    fst = int(N[0]) - 1
    ans += fst
print(ans)

Measured memory_bytes: 9144
N=int(input())
a=input().split()
A=[int(b) for b in a]
AS=sorted(A,reverse=True)
N=len(AS)
NN=N//2
if N%2==0:
    answer = 0
    answer += AS[0]
    answer += sum(AS[1:NN]) * 2
    print(answer)
else:
    answer=0
    answer+=AS[0]
    answer += sum(AS[1:NN]) * 2
    answer+=AS[NN]
    print(answer)
    

Measured memory_bytes: 33928
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N), B(N);
	rep(i, N) in >> A[i] >> B[i];

	std::vector<std::pair<LL, LL>>works;
	rep(i, N) works.push_back(std::make_pair(B[i], A[i]));
	std::sort(works.begin(), works.end());

	LL T = works[N - 1].first;
	bool ans = true;
	for (LL i = N - 1; i >= 0; --i)
	{
		T = std::min(T, works[i].first);
		T -= works[i].second;
		if (T < 0)
		{
			ans = false;
			break;
		}
	}

	out << (ans ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 9456
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S;
        int num=0;
        S=sc.next();
        for(int a=0;a<3;a++){
            if(S.charAt(a)=='o'){
                num++;
            }
        }
        System.out.println(700+num*100);
    }
}


Measured memory_bytes: 21844
# coding: utf-8

#N=int(input())
#S=input()
L,R,d = map(int, input().split())
#A,B = input().split()
#List = [int(input()) for i in range(5)]
ans=0
i=L
while i<=R:
    if i%d==0:
        ans+=1
    i+=1
    
print(ans)



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int p[11],c[11];

int main(){
	int D,G; cin >> D >> G;
	repp(i,0,D) cin >> p[i] >> c[i];
	int ans = 123456789;
	repp(i,0,1<<D){
		int s = 0;
		int n = 0;
		repp(k,0,D) if(i&(1<<k)){
			s += p[k] * 100 * (k+1) + c[k];
			n += p[k];
		}
		repm(k,D,0){
			if(s >= G) break;
			if(i&(1<<(k-1))) continue;
			n += min(p[k-1],(G-s+(k-1)*100)/100/k);
			s += p[k-1] * 100 * k;
		}
		if(s>=G) ans = min(ans,n);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
    title: B.cpp
    author: Akhil
    date: 2020-09-19
    time: 17:33:19
*/
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i].first >> v[i].second;
    }
    for (int i = 0; i <= n - 3; i++)
    {
        if (v[i].first == v[i].second and
            v[i + 1].first == v[i + 1].second and
            v[i + 2].first == v[i + 2].second)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
    ll N, K, ans=0, min=0, max=0;
    cin >> N >>K;

    for(int i=0; i<K; i++){
	min += i;
    }
    for(int i=N; i>=N+1-K; i--){
	max += i;
    }
    for(ll i=K; i<=N+1; i++){
	if(min>max)
	    break;
	ans += max-min+1;
	ans %= (ll)(1e9+7);
	
	min += i;
	max += N-i;
    }

    cout << ans << endl;
} 




Measured memory_bytes: 3620
#A
n = int(input())

s = str(n)[-1]

if s == '2' or s =='4' or s == '5' or s == '7' or s == '9':
    print('hon')
elif s == '0' or s == '1' or s == '6' or s == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9116
# -*- coding: utf-8 -*-
sx, sy, tx, ty = map(int,input().split())
movelist = ['U','D','L','R']
moved = []
countX = tx - sx
countY = ty - sy
#first movement
for y in range (0, countY):
    moved.append(movelist[0])

for x in range (0, countX):
    moved.append(movelist[3])

#second movement
for y in range (0, countY):
    moved.append(movelist[1])

for x in range (0, countX):
    moved.append(movelist[2])

#third movement

moved.append(movelist[2])

for y in range (0, countY+1):
    moved.append(movelist[0])

for x in range (0, countX+1):
    moved.append(movelist[3])

moved.append(movelist[1])

#forth movement
moved.append(movelist[3])

for y in range (0,countY+1):
    moved.append(movelist[1])

for x in range (0, countX+1):
    moved.append(movelist[2])

moved.append(movelist[0])

print("".join(moved))

Measured memory_bytes: 3316
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto s = readln.chomp;
  auto x = 0, m = 0;
  foreach (si; s) {
    x += si.predSwitch('I', +1, 'D', -1);
    m = max(m, x);
  }
  writeln(m);
}


Measured memory_bytes: 256