akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;

bool comp(pair<int,int> a, pair<int,int> b){
    return a.second > b.second;
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i,N)cin >> A[i];
    sort(A.begin(),A.end());

    vector<pair<int,int> > to(M);
    rep(i,M){
        int b,c;
        cin >> b >> c;
        to[i] = make_pair(b,c);
    }
    sort(to.begin(),to.end(),comp);
    queue<int> que;
    for(auto e : A){
        que.push(e);
    }
    
    rep(i,M){
        int b = to[i].first;
        int c = to[i].second;
        if(que.front()>=c)break;
        while(b>0 && que.front()<c){
            que.pop();
            que.push(c);
            b--;
        }
    }
    ll res = 0;
    while(!que.empty()){
        res += que.front();
        que.pop();
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str;
	cin >> str;
	string str2;
	cin >> str2;
	int cnt = 0;
	bool flg = true;
	size_t i=0;
	while (i < str.size()) {
		if (str[i] != str2[i]) {
			flg = false;
		}
		++i;
	}
	if (flg) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
	
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

struct data_t {
	int height;
	int width;
	int dia;

	bool operator<( const data_t& right) const {
		if (dia == right.dia) {
			return (height < right.height);
		}
		else {
			return ((dia == right.dia) || (dia < right.dia));
		}
	}
};

int main(void) {
	int h,w;
	int ind = 0;
	cin >> h;
	cin >> w;
	int lim = ((149-1)*149)/2;
	std::vector<data_t> all(lim);

	for (int i = 1; i < 150; i++) {
		for (int j = i+1; j < 151; j++) {
			all[ind].height = i;
			all[ind].width = j;
			all[ind].dia = pow(i,2) + pow(j,2);
			ind++;
		}
	}

	std::sort(all.begin(), all.end());

	while (h!=0||w!=0) {
		int d = pow(h,2) + pow(w,2);
		bool find = false;
		bool pro = false;
		for (int i = 0; i < lim && !find; i++) {
			if (pro) {
				cout << all[i].height << " " << all[i].width << endl;
				find = true;
			}
			else {
				if (h == all[i].height && w == all[i].width) {
					pro = true;
				}
			}
		}
		cin >> h;
		cin >> w;
	}

	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    cout.fill(a + '0');
    cout << "" << setw(b) << "" << endl;
    return 0;
}


Measured memory_bytes: 256
K = int(input())
A,B = map(int,input().split())
list = []
n = range(A,B+1)
ind = range(B-A+1)
for i in n:
    list.append(i)
counter = 0

for i in ind:
    if list[i] % K == 0:
        counter += 1
    else:
        counter += 0
if counter >= 1:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9136
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;


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

    string s;
    cin >> s;

    unsigned int numR = 0;
    unsigned int numG = 0;
    unsigned int numB = 0;

    for (int i = 0; i < N; i++) {
        if (s[i] == 'R') numR++;
        else if (s[i] == 'G') numG++;
        else if (s[i] == 'B') numB++;
    }

    unsigned int comp = 0;
    for (unsigned int j = 1; j < N - 1; j++) {
        unsigned int maxD = min(j, N - j - 1);
        for (unsigned int d = 1; d <= maxD; d++) {
            unsigned int i = j - d;
            unsigned int k = j + d;
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) comp++;
        }
    }

    cout << numR * numG * numB - comp << endl;
    return 0;
}


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

int main(){
    int S, K; cin >> K >> S;
    int cnt = 0;
    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            int k = S - i - j;
            if(k <= K && 0 <= k) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
K = int(input())
seven = 7
MOD7 = 7 % K
MOD70 = 70 % K
MOD77 = MOD7 + MOD70
if K % 2 == 0:
    print(-1)
elif MOD7 == 0:
    print(1)
else:
    for i in range(1,10**6):
        if MOD77 % K == 0:
            break
        MOD70 = (MOD70 * 10) % K
        MOD77 += MOD70
        MOD77 = MOD77 % K
    if i >= 10**6 - 1:
        print(-1)
    else:
        print(i+1)

Measured memory_bytes: 9192
#include<stdio.h>
#define NUM 10000

int main(){
  int m[NUM],f[NUM],r[NUM],sum;
  int i,count=0;

  for(i=0;i<NUM;i++){
    scanf("%d%d%d",&m[i],&f[i],&r[i]);
    if(m[i]==-1&&f[i]==-1&&r[i]==-1) break;
    count++;
  }

  for(i=0;i<count;i++){
    if(m[i]==-1 || f[i]==-1){
      printf("F\n");
    }
    else{
      sum = m[i]+f[i];
      if(sum>=80) printf("A\n");
      else if(sum>=65) printf("B\n");
      else if(sum>=50) printf("C\n");
      else if(sum<30) printf("F\n");
      else{
	if(r[i]>=50) printf("C\n");
	else printf("D\n");
      }
    }
  }

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,t; cin >> n >> t;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  map<ll,ll> b;
  ll max_n = 0;
  ll minA = 1LL << 60;
  rep(i,n){
    chmin(minA,a[i]);
    b[a[i]-minA]++;
    chmax(max_n,a[i]-minA);
  }
  
  cout << b[max_n] << endl;
  
  return 0;
}

Measured memory_bytes: 7296
import java.util.*;

/**
 *
 * @author kouki
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String numbers = sc.nextLine();
        int[] syujin = new int[numbers.length() - 2];
        int min = 0;

        for (int i = 0; i < numbers.length() - 2; i++) {
            String runrun = "";
            runrun = numbers.substring(i, i + 3);
            //System.out.println(runrun);
            int runrun2 = Integer.parseInt(runrun);
            syujin[i] = Math.abs(runrun2-753);
        }
        min = syujin[0];
        for (int i = 0; i < syujin.length; i++) {
            //System.out.println(syujin[i]);
            if (min > syujin[i]) {
                min = syujin[i];
            }
        }

        System.out.println(min);
    }

}

Measured memory_bytes: 22100
// https://beta.atcoder.jp/contests/abc074
// status:
// tag:

#define SUBMIT
//#define DEBUG

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

int main() {
    int N, A;
    cin >> N >> A;
    auto ans = N * N - A;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int input = sc.nextInt();
        int i = 1;
        while (input != 0) {
            System.out.println("Case " + i + ": " + input);
            input =sc.nextInt();
            i++;
        }

        sc.close();
    }
}


Measured memory_bytes: 42248
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;


int main() {
    int n, x, y;
    
    cin>>n>>x>>y;
    
    vector<int> a(n,0);
    vector<vector<int>> p(n+1, vector<int>(n+1, 0));
    
    Rep(i,1, n){
        Rep(j, i+1, n+1){
            p[i][j] = min(abs(j-i), abs(x-i)+1+abs(j-y));
            //cout<<i <<" "<<j<<" "<<min(abs(j-i), abs(x-i)+1+abs(j-y))<<endl;
        }
    }
    
    rep(i,n+1){
        rep(j, n+1){
            a[p[i][j]] ++;
        }
    }
    
    Rep(i, 1, n){
        cout<<a[i]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

llint x;
double p;

double calc(llint x)
{
	return 1/p*x;
}

int main(void)
{
	cin >> x;
	cin >> p;
	p /= 100;
	
	double ans;
	if(x % 2 == 0) ans = calc(x/2);
	else ans = 1 + p*calc((x-1)/2) + (1-p)*calc((x+1)/2);
	
	printf("%.11f\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=1000000000; 
int main(){
   int n, x,l;
   cin >> n >> x;
   int count = 1,now=0;
   for (int i = 0; i < n;i++){
      cin >> l;
      now+=l;
      if(now<=x)
         count++;
   }
   cout << count << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int s,w;
    cin>>s>>w;
    if(s<=w) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  while (cin >> s, s != "0") {
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
      ans += s[i] - '0';
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 3188
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		// 入力
		Scanner sc = new Scanner(System.in);
		String atcoder = sc.next();
		String S = sc.next();
		String contest = sc.next();
		
		// 略称を決定
		String ryaku = "A" + getPos(S, 0) + "C";
		
		// 出力
		System.out.println(ryaku);
	}

	// 文字列のx文字目を取得する関数
	public static String getPos(String str, int pos){
		return String.valueOf(str.charAt(pos));
	}

}


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

import sys
from operator import itemgetter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
AB=[]
for i in range(N):
    a,b=MAP()
    AB.append((a, b))

AB.sort(key=itemgetter(1))
time=0
for i in range(N):
    a,b=AB[i]
    time+=a
    if b<time:
        No()
        exit()
Yes()


Measured memory_bytes: 31904
#include<bits/stdc++.h>
using namespace std;
//#define  ONLINE_JUDGE 1
int main()
{
	/*
	#ifdef ONLINE_JUDGE
	freopen("C:/Users/wyx/Desktop/Amy/wangyixuan/c++/test data/data.txt", "r",stdin);
	#endif
	*/
	/*---------------Begin code---------------*/
	long long a,b,c,d=0;
	cin>>a>>b;
	for(int i=0;i<b;i++)
	{
		cin>>c;
		d+=c;
	}
	if(d>a)
	{
		cout<<"-1"; 
	}
	else
	{
		cout<<a-d;
	}
	/*---------------End  code----------------*/
	/*
	#ifdef ONLINE_JUDGE
	fclose(stdin);
	#endif
	system("pause");
	*/
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int     ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;







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

  string s,t;
  cin>>s>>t;
  ll ans=0;
  for(ll i=0;i<zz(s);i++) if(s[i]!=t[i]) ans++;
  cout<<ans<<nn;





}


/* Final check before submit :

1. array size or integer overflow.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***

*/



Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[100],cnt=0,sum=0,flag=0;
  cin>>n;
  for(int i=0;i<n;++i) cin>>a[i];
  sort(a,a+n,greater<int>());
  for(int i=0;i<n;++i){
    if(a[i]%2==0) sum+=a[i];
    else ++cnt;
  }
  if(cnt%2) --cnt;
  for(int i=0;i<n&&flag!=cnt;++i){
    if(a[i]%2) {
      sum+=a[i];
      ++flag;
    }
  }
  cout<<sum/2<<endl;
  return 0;
}



Measured memory_bytes: 3160
N, M = map(int, input().split()) 
ans = []
if M % 2 != 0:
    for i in range((M + 1)//2):
        ans.append((1 + i, M + 1 - i))
        
    for j in range((M - 1)//2):
        ans.append((M + 2 + j, 2*M + 1 - j))
else:
    for i in range(M//2):
        ans.append((1 + i, M + 1 - i))
        ans.append((M + 2 + i, 2*M + 1 - i))
              
for i in range(M):
    print(*ans[i])

Measured memory_bytes: 73732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long ans = 0;
		for (long i = 1; i <= N; i++) {
			long x = N / i;
			ans += i * x * (x + 1) / 2;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35512
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn=2e5+3,du=1e9+7;
int n,m;
vector<int> g[mxn];
int vis[mxn];
int c;
void dfs(int u)
{
    c++;
    vis[u]=1;
    for (int v : g[u])
        if (!vis[v]) dfs(v);
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin>>n>>m;
    map<pair<int,int>,int> mp;
    for (int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        if (mp[{u,v}]==0)
            {
                g[u].push_back(v);
                g[v].push_back(u);
                mp[{u,v}]=mp[{v,u}]=1;
            }
    }
    int ans=0;
    for (int i=1;i<=n;i++)
    if (!vis[i])
    {
        c=0;
        dfs(i);
        ans=max(ans,c);
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 47356
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 2e5 + 5;
const double eps = 1e-9;
ll fac[MAXN], ifac[MAXN];

ll pw(ll a, ll b) {
	ll r = 1;
	while (b)
		if (b & 1)
			r = (r*a) % MOD, b--;
		else
			a = (a*a) % MOD, b /= 2ll;
	return r;
}

inline ll inv(ll x) {
	return pw(x, MOD-2);
}

inline ll bin(ll n, ll k) {
	return (fac[n] * ifac[k] % MOD) * ifac[n-k] % MOD;
}

int main() {
	fac[0] = ifac[0] = 1;
	for (ll i = 1; i < MAXN; i++)
		fac[i] = fac[i-1] * i % MOD, ifac[i] = inv(fac[i]);
	ll n, m, k; scanf("%lld %lld %lld", &n, &m, &k);
	ll ans = 0, dx = 0, dy = 0;
	for (ll i = 1; i < n; i++)
		dx = (dx + (i * (n-i) % MOD)) % MOD;
	dx = dx * (m*m%MOD) % MOD;
	for (ll i = 1; i < m; i++)
		dy = (dy + (i * (m-i) % MOD)) % MOD;
	dy = dy * (n*n%MOD) % MOD;
	ans = (dx+dy)%MOD;
	ans = (ans*bin(n*m-2, k-2)) % MOD;
	prl(ans);
    return 0;
}


Measured memory_bytes: 3328
N, K = map(int, input().split())
S = input()

against = [(S[i] != S[i+1]) for i in range(N-1)]
unhappy = sum(against)

if K > unhappy:
    print(N - 1)
else:
    print(N - max(unhappy - 2 * K + 1, 1))

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

int main(){
	/*input*/
	int n;	cin >> n;
	long double* x = new long double[n];
	char** u = new char*[n];
	for(int i = 0; i < n; i++){
		u[i] = new char [3];
	}
	for(int i = 0; i < n; i++){
		cin >> x[i] >> u[i];
	}
	/*calculation*/
	long double o = 0.0;
	for(int i = 0; i < n; i++){
		if(/*u[i] == "JPY"*/u[i][0] == 'J'){
			o+=x[i];
		}else if(/*u[i] == "BTC"*/u[i][0] == 'B'){
			o+=x[i] * 380000.0;
		}
	}

	/*output*/
	cout << o << endl;
	delete[] x;
	for(int i = 0; i < n; i++){
		delete[] u[i];
	}
	delete[] u; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <math.h>
#include <set>
#include <fstream>
using namespace std;

int main()
{
	char b,a;
	cin>>b;
	if(b=='A')
		a='T';
	if(b=='T')
		a='A';
	if(b=='G')
		a='C';
	if(b=='C')
		a='G';
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
import collections
import itertools

def resolve():

    N,K,Q=map(int,input().split())
    A=[0]*Q
    Aans=[0]*N
    
    for i in range(Q):
        A[i]=int(input())
        Aans[A[i]-1]+=1

    for i in range(N):
        if(0>=K-Q+(Aans[i])):
            print("No")
        else:
            print("Yes")
    
resolve()


Measured memory_bytes: 13900
#include<stdio.h>
main()
{
    long long a,b,k,i,j,l,p;
    scanf("%lld%lld%lld",&a,&b,&k);
    p=b-a+1;
    l=2*k-1;
    if(p<=l)
    {
        for(i=a;i<=b;i++)
            printf("%lld\n",i);
    }
    else
    {
        for(i=0;i<k;i++)
            printf("%lld\n",a++);
            for(i=(b-k+1);i<=b;i++)
            printf("%lld\n",i);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int a,b;
    string s;
    cin >> a >> b >> s;
    rep(i,s.size()) {
        if (i==a) {
            if(s[i] !='-') {
                cout << "No" << "\n";
                return 0; 
            }
        } else {
            if (s[i]-'0' < 0 || s[i]-'0' > 9) {
                cout << "No" << "\n";
                return 0; 
            }
        }
    }
    cout << "Yes" << "\n";
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

money = 1000
kabu, comp = 0, 0
for cnt, i in enumerate(a):
    comp = a[cnt+1]-a[cnt] if cnt+1<len(a) else -1
    if kabu == 0 and comp > 0:
        kabu = money // i
        money -= kabu*i
    elif kabu > 0 and comp < 0:
        money += kabu*i
        kabu = 0

print(money)

Measured memory_bytes: 9204
n=list(map(int,input()))
if n[len(n)-1]==3:
    print("bon")
elif n[len(n)-1]==0 :
    print("pon")
elif n[len(n)-1]==1 :
    print("pon")
elif n[len(n)-1]==6 :
    print("pon")
elif n[len(n)-1]==8 :
    print("pon")
else:
    print("hon")

    

Measured memory_bytes: 9180
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var a = cin.Read();
            var b = cin.Read();
            var x = int.Parse(a + b);
            if ((int)Sqrt(x) * (int)Sqrt(x) == x) WriteLine("Yes");
            else WriteLine("No");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   int n,k;scanf("%d%d",&n,&k);
   int x[100];
   for(int i = 0;i < n;i++){
      scanf("%d",&x[i]);
   }
   int ans=0;
   for(int i = 0;i < n;i++)
      ans += MIN(x[i],(MAX(x[i],k)-MIN(x[i],k)))*2;
   printf("%d",ans);
}


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

using namespace std;

struct teresa{
  int hoge;
  string fuga;
  
  teresa(){
      cin>>hoge;
      hoge=pow(hoge,3);
  }
};

int main(){
    teresa teresakunn;
    cout<<teresakunn.hoge<<endl;
    
    return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    string O, E;
    cin >> O >> E;
    int min_len = (int)E.size();
    string pass;
    for(int i = 0; i < min_len; i++){
        pass += O.at(i);
        pass += E.at(i);
    }
    if((int)(O.size() - E.size()) == 1){
        pass += O.at(min_len);
    }
    cout << pass << endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
using namespace std;
void swap(int* x,int* y){
	int tmp;
	tmp =*x; *x =*y; *y =tmp;
}
int main(){
	int n;
	cin >>n;
	int x[n]={},p=1,sum =0;
	for(int i=0;i<n;i++){
		cin >>x[i]; 
	}
	while(p!=0){
		p=0;
		for(int i=n-1;i>0;i--){
			if(x[i]<x[i-1]){
				swap(&x[i],&x[i-1]);
				p=1; sum++;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(i==0) cout<<x[i];
		else cout<<" "<<x[i];
	}
	cout<<"\n"<<sum<<"\n";

}


Measured memory_bytes: 3092
#include<iostream>

using namespace std;
int main()
{
    int n,x=0;
    cin>>n;
    for(int i=2;i*i<=n;i+=1){
        if(n%i==0){
            x = 1;
            int val = n;
            while(n--){
               int x1=0;val++;
               for(int j=2;j*j<=val;j+=1){
                   if(val%j==0){
                       x1 = 1;break;
                   }
               }
               if(x1==0){
                  cout<<val<<endl;

                  return 0;
               }
            }
            break;
        }
    }
    if(x==0) cout<<n<<endl;
    /**else{
        int val = n;
        while(n--){
            int x1=0;val++;
            for(int j=2;j*j<=val;j+=1){
                if(val%j==0){
                    x1 = 1;break;
                }
            }
            if(x1==0){
                cout<<val<<endl;

                return 0;
            }
        }
    }*/


    return 0;
}


Measured memory_bytes: 256
/*
 * Insertion Sort
 *
 */
#include<stdio.h>
int A[100];

//Output function
void printSequence(int length){
    int i;
    for(i=0; i<length; i++){
        if(i!=0)printf(" ");
        printf("%d",A[i]);
    }

    printf("\n");

}

int main(void){
    int key=0, length, i, j;

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


    //Insertion Sort Algo
    for(i=1; i<=length; i++){
        printSequence(length);

        key = A[i];
        j = i - 1;

        while(j>=0 && A[j]>key){
            A[j+1] = A[j];
            j--;
        }

        A[j+1] = key;
    }

    return 0;
}



Measured memory_bytes: 2140
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

struct mint {

  ll x; 

  mint(ll x=0):x((x%mod+mod)%mod){} //コンストラクタを呼んで自動的にmodを取っている。

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

  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    //メンバ関数にはthisポインタがある。メンバ変数の値を返す。
    return *this;
  }

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

  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }

  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }

  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }

  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }

  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1); //a=x/2
    a *= a; //繰り返し二乗法
    if (t&1) a *= *this; //tが奇数のときはxを1回かける
    return a;
  }



  // for prime mod

  mint inv() const {
    return pow(mod-2);
  }

  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
    
};
mint choose(ll n,ll r){
  mint x=1, y=1;
  rep(i,r){
    x*=n-i;
    y*=i+1;
  }
  return x/y;
}

int main()
{
    ll r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    mint ans=0;
    ans+=choose(c2+r2+2,c2+1);
    ans-=choose(r1+c2+1,r1);
    ans-=choose(c1+r2+1,c1);
    ans+=choose(r1+c1,r1);
    cout << ans.x << endl;
    
    return 0;
} 

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
			int[] height = new int[10];
			for (int i = 0; i < 10; i++) {
					height[i] = scan.nextInt();
			}
			Arrays.sort(height);
			
			for(int i=9;i>6;i--){
				System.out.println(height[i]);
			}
		}
}

Measured memory_bytes: 26260
n,m=map(int,input().split())
list=[list(map(int,input().split())) for _ in range(n)]
list.sort()
ans=0
temp=0
for i in range(n):
    ans+=list[i][0]*list[i][1]
    temp+=list[i][1]
    if temp>=m:
        ans-=list[i][0]*(temp-m)
        print(ans)
        break

Measured memory_bytes: 27760
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cout<<a[i]<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const ll p = 78294349;

int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    ll k, a, b;
    cin>>k>>a>>b;
    if (k<=a||b<=a+2)
    {
        cout<<k+1<<endl;
        return 0;
    }
    ll answer = a;
    k-=(a-1);
    if (k%2==1)
    {
        answer++; k--;
    }
    answer+=(b-a)*(k/2);
    cout<<answer;
}

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

int main() {
	string s;
	cin >> s;
	int n[26] = {};
	int m[26] = {};
	for (int i = 0; i < s.length(); i++) {
		for (int j = 0; j < 26; j++) {
			if (s[i] - 'a' == j) {
				m[j] = max(m[j], n[j]);
				n[j] = 0;
			} else {
				n[j]++;
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		m[i] = max(m[i], n[i]);
	}
	int r = m[0];
	for (int i = 1; i < 26; i++) {
		r = min(r, m[i]);
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int n,num;
    cin >> n >> num;
    vector<int> vec;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        vec.push_back(a);
    }
    sort(vec.begin(),vec.end());
    int count = 0;
    for(int i=0; i<vec.size(); i++){
        num -= vec[i];
        if(num<0){
            break;
        }
        count++;
    }
    if(num>0){
        cout << count-1 <<endl;
    }else{
        cout << count <<endl;
    }
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
long long a,v,b,w,t;
int main(){
	cin>>a>>v>>b>>w>>t;
	if(a>b){
		a=-a;
		b=-b;
	}
	if(a+v*t>=b+w*t)cout<<"YES";
	else cout<<"NO";
	return 0;
}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(H);
    scanInt(W);
    vector<vector<char>> board(H, vector<char>(W));
    REP(i, H){
        REP(j, W){
            board[i][j] = getchar();
        }
        getchar();
    }
    bool flag = true;
    REP(i, H){
        REP(j, W){
            if (board[i][j] == '.') continue;
            flag = false;
            if (i != 0 && board[i - 1][j] == '#') flag = true;
            if (i != H - 1 && board[i + 1][j] == '#') flag = true;
            if (j != 0 && board[i][j - 1] == '#') flag = true;
            if (j != W - 1 && board[i][j + 1] == '#') flag = true;
            if (!flag) break;
        }
        if (!flag) break;
    }
    if (flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
s = input()
ans = 0
for i in range(2 ** (len(s) - 1)):
    q = '{:0>10b}'.format(i)[::-1]
    formula = s[0]
    for j in range(1, len(s)):
        if q[j - 1] == '1':
            formula += '+'
        formula += s[j]
    ans += eval(formula)
    
print(ans)

Measured memory_bytes: 3060
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
l=[2,1]
for i in range(2,n+2):
    l.append(l[i-1]+l[i-2])
print(l[n])

Measured memory_bytes: 9124
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    p = sorted(p)
    print(sum(p[:K]))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9268
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,q,i,j,a,b,S=0;
	cin>>n;
	vector<ll>arr(n);
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		S ^= arr[i];
	}
	for(i=0;i<n;i++)
	{
		cout<<(S^arr[i])<<" ";
	}
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 085 A / Link: http://abc085.contest.atcoder.jp/tasks/abc085_a  ----- */


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


	string s; cin >> s;
	cout << "2018";
	FOR(i, 4, SZ(s)) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const int M=998244353;

const int MAXL=600;
char str[305];
int f[305][305][605],g[305],sg[305],k,n,ans;

int main () {
	
	scanf ("%s%d",str,&k);
	for (int i=0,ii=strlen (str);i<ii;i++) {
		if (str[i]=='0') n++;
		else g[n]++;
	}
	for (int i=n;i>=0;i--) {
		sg[i]=sg[i+1]+g[i];
	}
	if (n==0) {puts ("1"); return 0;}
	for (int j=0;j<=g[n];j++) f[n][j][0]=1;
	for (int i=n-1;i>0;i--) {
		for (int j=0;j<=sg[i];j++) {
			for (int k=0;k<=j&&k<=g[i];k++) {
				for (int l=0;l<=sg[i];l++) {
					f[i][j][l]+=f[i+1][j-k][l];
					if (f[i][j][l]>=M) f[i][j][l]-=M;
				}
			}
			for (int k=g[i]+1;k<=j;k++) {
				for (int l=0;l<=sg[i]&&l<=MAXL;l++) {
					f[i][j][l+k-g[i]]+=f[i+1][j-k][l];
					if (f[i][j][l+k-g[i]]>=M) f[i][j][l+k-g[i]]-=M;
				}
			}
		}
	}
	for (int j=0;j<=sg[1];j++) {
		for (int l=0;l<=MAXL;l++) {
			int p=l+sg[1]-j;
			if (p>k) break;
			ans+=f[1][j][l];
			if (ans>=M) ans-=M;
		}
	}
	printf ("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 54484
#include<iostream>

using namespace std;

int main() {
  int A,B,C,N;
  cin >> A >> B >> C >> N;
  
  int res=0;
  
  for(int a=0; a<=A; a++) {
    for(int b=0; b<=B; b++) {
      for(int c=0; c<=C; c++) {
        int answer = 500*a + 100*b + 50*c;
        if( answer == N ) res++;
      }
    }
  }
  
  cout << res << endl;
}
    

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>

using namespace std;

ifstream f("1.in");

int a, b, c, d, e, k;

int main() 
{
      cin >> a >> b >> c >> d >> e >> k;
      if (e - a <= k) cout << "Yay!" << endl;
      else cout << ":(" << endl;
}


Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , m , k , a[N] , id[N] , cur , ans ;

bool mark[N] ;

int C , comp[N] , cnt[N]  ;
vector <int> g[N] ;

inline bool cmp (int x , int y) { return a[x] < a[y] ; }

void dfs (int v , int C) {
	comp[v] = C ;
	for (int u : g[v])
		if (!comp[u]) dfs(u , C) ;
}

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> m ;
	for (int i = 0 ; i < n ; i ++) cin >> a[i] ;

	for (int i = 0 , u , v ; i < m ; i ++) {
		cin >> u >> v ;
		g[u].push_back(v) ;
		g[v].push_back(u) ;
	}

	for (int i = 0 ; i < n ; i ++)
		if (!comp[i]) dfs(i , ++C) ;

	k = C - 1 ;

	iota(id , id + n , 0) ;
	sort(id , id + n , cmp) ;

	for (int i = 0 ; i < n ; i ++) {
		int v = id[i] ;

		if (cnt[comp[v]] || cur == 2 * k) continue ;

		mark[v] = 1 ;
		ans += a[v] ;
		cnt[comp[v]] ++ ;
		cur ++ ;
	}

	for (int i = 0 ; i < n ; i ++) {
		int v = id[i] ;

		if (mark[v] || cnt[comp[v]] == k || cur == 2 * k) continue ;

		mark[v] = 1 ;
		ans += a[v] ;
		cnt[comp[v]] ++ ;
		cur ++ ;
	}

	if (cur < 2 * k) return cout << "Impossible\n" , 0 ;

	cout << ans << '\n' ;
}

Measured memory_bytes: 9472
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
template<class T>
T gcd(T x, T y) {
	return y ? gcd(y, x % y) : x;
}

template<class T>
vector<T> enum_div(T n) {
	vector<T> ret;
	for (T i = 1; i * i < n; ++i) {

		if (n % i == 0) {
			ret.push_back(i);

			if (i != 1 && i * i != n) {
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}

template<class T>
map<T, int> prime_factorization(T n) {
	map<T, int> ret;

	for (long long i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}

	if (n != 1)ret[n] = 1;
	return ret;
}

template<class T>
long long C(T n, T r) {
	static map<pair<T, T>, long long> _map;
	if (n < r) return 0;

	if (n == r || r == 0) {
		_map[make_pair(n, r)] = 1ll;
	}
	else if (_map[make_pair(n, r)] == 0) {
		_map[make_pair(n, r)] = (C(n - 1, r) + C(n - 1, r - 1));
	}

	_map[make_pair(n, r)] %= MOD;
	return _map[make_pair(n, r)];
}

int main() {

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

		maxD = max(maxD, d);

		if ((i == 0 && d != 0) || (i != 0 && d == 0)) {
			cout << 0 << endl;
			return 0;
		}
	}

	vector<long long> p;
	for (int i = 1; i <= maxD; ++i) {
		for (int j = 0; j < mp[i]; ++j) {
			p.push_back(mp[i - 1]);
		}
	}

	unsigned long long ans = 1ll;
	for (int i = 0; i < p.size(); ++i) {
		ans *= (p[i]);
		ans %= 998244353ll;
	}

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

Measured memory_bytes: 7676
#include <cstdio>

int main(int argc, char const *argv[]) {
  int N, count = 1, max = 0;
  scanf("%d", &N);

  scanf("%d", &max);
  for (int i = 1; i < N; ++i) {
    int height = 0;
    scanf("%d", &height);
    if (height >= max) {
      ++count;
      max = height;
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
void main()
{
	auto io = new IO();
	auto input = io.str();
	writeln(input[0..4]," ",input[4..$]);
}



import std.stdio,std.string,std.conv;
class IO
{
	string str( size_t lines = 1 )
	{
		return readln().chomp();
	}
	T[] line( T = real , string sp = " "  )( size_t lines = 1 ) 
	{
		T[] ret;
		foreach( i ; 0..lines )
			ret ~= readln().chomp().split(sp).convert!T();
		return ret;
	}
	T[][] rect( T = real , string sp = " " )( size_t lines = 1 )
	{
		T[][] ret = new T[][](lines);
		foreach( i ; 0..lines )
			ret[i] = readln().chomp().split(sp).convert!T();
		return ret;
	}
}
R[] convert( R , T )( T[] args ) pure
{
	R[] ret = new R[](args.length);
	foreach( i ; 0..args.length )
		ret[i] = args[i].to!R();
	return ret;
}

T sum( T )( in T[] args ) pure nothrow
{
	T ret = 0;
	foreach( elm ; args )
		ret += elm;
	return ret;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

 ll n;cin>>n;
 if(n%2==1){
  cout<<0<<endl;
  return 0;
 }

 ll t = n;
 ll ans = 0;
 ans += t/10;
 t /= 10;
 while(t>0){
  ans += t/5;
  t /= 5;
 }

 cout<<ans<<endl;


  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long MOD = 1000000007;

int main() {
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;

    if (V <= W) {
        cout << "NO" << endl;
    }

    else {
        ld Oitsuki = static_cast<ld>((abs(A - B))) / static_cast<ld>(V - W);
        if(Oitsuki>T){
            cout << "NO" << endl;
        }

        else{
            cout << "YES" << endl;
        }
    }

    return 0;
}

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

long long mod = 1e9+7,dp[110][4][4][4];
int main(void){
    long long n,ans = 0;
    cin >> n;
    dp[0][0][0][0] = 1;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                for(int l = 0;l < 4;l++){
                    for(int m = 0;m < 4;m++){
                        if(k == 1 && l == 2 && m == 3) continue;
                        if(k == 2 && l == 1 && m == 3) continue;
                        if(k == 1 && l == 3 && m == 2) continue;
                        if(j == 1 && l == 2 && m == 3) continue;
                        if(j == 1 && k == 2 && m == 3) continue;
                        dp[i+1][k][l][m] += (dp[i][j][k][l]);
                        dp[i+1][k][l][m] %= mod;
                    }
                }
            }
        }
    }
    
    for(int j = 0;j < 4;j++)for(int k = 0;k < 4;k++)for(int l = 0;l < 4;l++){
        ans+=(dp[n][j][k][l]);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;
#define pb push_back
#define mp make_pair
#define INF 1e15
#define mod 1000000007
#define eps 1e-6
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef int ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=900;
ll n,n2,ans,x,y,a[N+10][N+10];
char s[N+10][N+10];
int main()
{
	cin>>n;
	n2=n*2;
	for(ll i=1;i<=n;i++)
	{
		scanf("\n%s",s[i]);
		for(ll j=n;j>=1;j--)
			s[i][j]=s[i][j-1];
		for(ll j=n+1;j<n2;j++)
			s[i][j]=s[i][j-n];
	}
	for(ll i=n+1;i<n2;i++)
		for(ll j=1;j<n2;j++)
			s[i][j]=s[i-n][j];
	for(ll di=1;di<=n2-1;di++)
	{
		x=1,y=n2-di;
		for(ll i=1;i<n2;i++)
			for(ll j=1;j<n2;j++)
				a[i][j]=0;
		for(;x<n2&&y<n2;x++,y++)
			for(ll xx=x,yy=y;xx<n2&&yy<n2;xx++,yy++)
				a[xx][y]=a[x][yy]=(s[xx][y]==s[x][yy]);
		for(ll i=1;i<n2;i++)
			for(ll j=1;j<n2;j++)
				a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
		for(ll i=n,j=n2-di+n-1;i<n2&&j<n2;i++,j++)
			if(a[i][j]-a[i-n][j]-a[i][j-n]+a[i-n][j-n]==n*n)
				ans++;
	}
	for(ll di=n2;di<=4*n-3;di++)
	{
		x=di-n2+2,y=1;
		for(ll i=1;i<n2;i++)
			for(ll j=1;j<n2;j++)
				a[i][j]=0;
		for(;x<n2&&y<n2;x++,y++)
			for(ll xx=x,yy=y;xx<n2&&yy<n2;xx++,yy++)
				a[xx][y]=a[x][yy]=(s[xx][y]==s[x][yy]);
		for(ll i=1;i<n2;i++)
			for(ll j=1;j<n2;j++)
				a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
		for(ll i=di-n2+2+n-1,j=n;i<n2&&j<n2;i++,j++)
			if(a[i][j]-a[i-n][j]-a[i][j-n]+a[i-n][j-n]==n*n)
				ans++;
	}
	cout<<ans;
}

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

N = int(input())
A = [0] * N
B = list(map(int,input().split()))

A[0] = B[0]
A[N-1] = B[N-2]
for i in range(1, N-1):
    if B[i] - B[i-1] < 0:
        A[i] = B[i]
    else:
        A[i] = B[i-1]

print(sum(A))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            checked
            {
                string[] s;
#if false
                int N = int.Parse(Console.ReadLine());
#else
                s = Console.ReadLine().Split(' ');
                int N = int.Parse(s[0]);
                int K = int.Parse(s[1]);
#endif

                int[] v = new int[N];

#if true
                s = Console.ReadLine().Split(' ');
                for (int i = 0; i < N; i++)
                {
                    v[i] = int.Parse(s[i]);
                }
#else
                for (int i = 0; i < N; i++)
                {
                    v[i] = int.Parse(Console.ReadLine());
                }
#endif

                int[] c = new int[N];
                for (int i = 1; i < N; i++)
                {
                    c[i] = int.MaxValue;
                }

                for (int i = 1; i < N; i++)
                {
                    for (int j = 1; j <= K; j++)
                    {
                        if (i - j >= 0)
                        {
                            c[i] = Math.Min(c[i - j] + Math.Abs(v[i] - v[i - j]), c[i]);
                        }
                    }
                }

                Console.WriteLine(c[N - 1]);
            }
        }
    }
}


Measured memory_bytes: 16864