akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;

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

double INF = 10e8;
int plus20[40];
int maxh[21];

int main(){
    while(1){
        double r;
        int n;
        cin >> r >> n;

        if(r==0) break;

        REP(i, 40) plus20[i] = 0;
        REP(i, n){
            int xr, xl;
            double h;
            cin >> xr >> xl >> h;
            for(int j = xr+20; j < xl+20; j++){
                plus20[j] = max((double)plus20[j], h);
            }
        }

        REP(i, 21) maxh[i] = 0;
        REP(i, r+1){
            if(i==r){
                maxh[i] = 0;
            } else {
                double ph = min(plus20[20+i], plus20[20+i-1]);
                double nh = min(plus20[20-i], plus20[20-i-1]);
                maxh[i] = min(ph, nh);
            }
        }

        double output = INF;
        REP(i, r){
            output = min(output, r - sqrt(pow(r, 2)-pow(i, 2)) + maxh[i]);
        }

        cout << fixed << setprecision(4) << output << endl;
    }
}

Measured memory_bytes: 3248
class Hello {
static void Main(string[] args) {
  string[] stArrayData = System.Console.ReadLine().Trim().Split(' ');
    var seki = int.Parse(stArrayData[0]) * int.Parse(stArrayData[1]);
    
    if(seki % 2 != 0)
    {
    	System.Console.WriteLine("Odd");
    }
    else
    {
   	System.Console.WriteLine("Even");
   }
}
}


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

int main() {
   
 int N,W;
 cin >> N >> W;
    
 long long weight[N+1],value[N+1];   
    for(int i=1;i<=N;i++){
        cin >> weight[i];
        cin >> value[i];
    }

 long long dp[N+1][W+1];
    for(int i=0;i<=W;i++){
        dp[0][i] = 0;
    }
    for(int i=0;i<=N;i++){
        dp[i][0] = 0;
    }

    for(int i=1;i<=N;i++){
        for(int j=1;j<=W;j++){
            if(j - weight[i] >= 0){
                dp[i][j] = max( dp[i-1][j] , dp[i-1][j-weight[i]] + value[i]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 82416
#include<iostream>
#include<algorithm>
using namespace std;
int n,cnt[11];
main()
{
	while(cin>>n,n)
	{
		string s;cin>>s;
		for(int i=0;i<n;i++)cnt[i]=0;
		int b=0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='M')cnt[i%n]++;
			else if(s[i]=='L')cnt[i%n]+=b+1,b=0;
			else b+=cnt[i%n]+1,cnt[i%n]=0;
		}
		sort(cnt,cnt+n);
		for(int i=0;i<n;i++)cout<<cnt[i]<<" ";
		cout<<b<<endl;
	}
}



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

using namespace std;

int main(){
	long long n, d, x, y;
  cin>>n>>d;
  int cnt = 0;
  while(n--){
	  cin>>x>>y;
  	if(d*d>= x*x + y*y) cnt++;
  }
  cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n;
  cin >> n;
  double a[n];
  rep(i,n) cin >> a[i];
  double sum=0;
  rep(i,n) sum+=1./a[i];
  std::cout << std::fixed;
  std::cout << std::setprecision(10) << 1./sum << endl;

  
  return 0;
    

}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

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

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int w1, w2, s1, s2, melt, limit;
    //100gあたりmeltグラム溶けます。ビーカーには水+砂糖でlimitグラムまで入ります。
    //w1<w2
    //s1<s2
    cin>>w1>>w2>>s1>>s2>>melt>>limit;

    vi w;

    for(int i=0; i<=limit; i+=w2*100){
        w.emplace_back(i);
        for(int j=i+w1*100; j<=limit; j+=w1*100){
            w.emplace_back(j);
        }
    }
    sort(ALL(w));
    w.erase(unique(ALL(w)), w.end());
    w.erase(w.begin());//0を消す

    vi s;

    for(int i=0; i<=limit; i+=s2){
        s.emplace_back(i);
        for(int j=i+s1; j<=limit; j+=s1){
            s.emplace_back(j);
        }
    }
    sort(ALL(s));
    s.erase(unique(ALL(s)), s.end());

    double mx = -5.f;
    pii ans = pii(0,0);
    REP(i,w.size()){
        REP(j,s.size()){
            //DEBUG2(w[i], s[j]);
            if( (w[i]/100)*melt < s[j] )  continue;
            if( w[i]+s[j] > limit )      continue;

            double pertmp = (100.f*s[j]) / ((double)w[i]+s[j]);
            //DEBUG2(mx, pertmp);
            if(chmax(mx,pertmp)){
                ans.first = w[i];
                ans.second = s[j];
            }
        }
    }

    cout << ans.first+ans.second << " " << ans.second << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
char a[N],b[N];
int n,m;
int main(){
  scanf("%s%s",a+1,b+1);
  n=strlen(a+1),m=strlen(b+1);
  int ans=1e9;
  for(int i=1;i<=n-m+1;i++){
    int ret=0;
    for(int j=1;j<=m;j++){
      if(a[i+j-1]!=b[j])ret++;
    }
    ans=min(ans,ret);
  }
  printf("%d\n",ans);
  return 0; 
}

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

int main() {
  int N, H, max_hight = 0, count = 0;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> H;
    if (H >= max_hight) {
      max_hight = H;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}


set<char> NVC({'k', 's' , 't', 'h', 'p'});

bool check1(int idx,const string &str){
  if(idx+2 > (int)str.size()) return 0;
  set<char> V({'i','u'});
  if(idx+2 == (int)(str.size())) return NVC.count(str[idx]) && V.count(str[idx+1]) ;
  return NVC.count(str[idx]) && V.count(str[idx+1]) && NVC.count(str[idx+2]);
}

bool check2(int idx,const string &str){
  set<char> V({'a','o'});
  if(idx+2 >= (int)str.size() ||!NVC.count(str[idx]) || !NVC.count(str[idx+2])) return 0;
  if(!V.count(str[idx+1])) return 0;

  if(idx+3 < (int)str.size() && str[idx+1] == str[idx+3]) return 1;
  
  if(idx+4 <(int)(str.size()) && str[idx+3]=='y' && str[idx+1] == str[idx+4]) return 1;
  return 0;
}

string checkNV(string str){
  
  set<char> V({'a','i','u','e','o'});
  string res;
  bool can = 1;
  for(int i=0;i<(int)str.size();i++){
    char ch = str[i];
    if(i && ch == 'y' && NVC.count(str[i-1])) str[i] = 'k';
    if((check1(i,str) || check2(i,str)) && can)res =res + ch + '(' + str[i+1] + ')',i++,can = 0;
    else res += ch, can = can | V.count(ch);
  }
  return res;
}

signed main(){

  while(1){
    string str;
    cin>>str;
    if(str == "#") break;
    string ans = checkNV(str);
    cout<<ans<<endl;
  }
  return 0;
}

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

string s;
set<char> st;
int main()
{
    cin>>s;
    for(int i=0;i<s.length();i++)
        st.insert(s[i]);
    if(st.size()==3)
        cout<<"Yes";
    else
        cout<<"No";

}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  int a[n+1],ans[n+1];
  for(i=1;i<n+1;i++)ans[i]=0;
  for(i=2;i<n+1;i++){
    scanf("%d",&a[i]);
    ans[a[i]]++;
  }
  for(i=1;i<n+1;i++)printf("%d\n",ans[i]);
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	int p1, p2, p3;
	cin >> p1 >> p2;
	int ans = 0;
	for (int i = 2; i < n; i++) {
		cin >> p3;
		if ((p1 < p2 && p2 < p3) || (p3 < p2 && p2 < p1)) ans++;
		p1 = p2;
		p2 = p3;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359


typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
const int DEADLINE = 60 * 8 + 59;//8:59までに出社


int main(void) {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int ans = INF;
	for (int i = 0; i <= X+Y; i++) {
		chmin(ans, A * max(0, X - i) + B * max(0,Y - i) + C * 2 * i);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >>a>>b;
  if(a >= 1 && a<=9&&b>=1&&b<=9)
    cout << a*b << endl;
  else
    cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 1; i < n; ++i) { //leader is 0
        if (s[i] == 'E') {
            cnt++;
        }
    }
    //cout << cnt << endl;
    int ans = cnt;
    for (int i = 1; i < n; ++i) {
        if (s[i - 1] == 'W') {
            cnt++;
        }
        if (s[i] == 'E') {
            cnt--;
        }
        if (cnt < ans) {
            ans = cnt;
        }
        //cout << cnt << endl;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 900
# 二項係数を"やるだけ"にしてくれるライブラリ
from collections import Counter
MAX = 1000010
MOD = 10**9+7
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX


# テーブルを作る前処理
def COMinit():
    global factrial, inverse, factrial_inverse
    factrial[0] = 1
    factrial[1] = 1
    inverse[1] = 1
    factrial_inverse[0] = 1
    factrial_inverse[1] = 1
    for i in range(2, MAX):
        factrial[i] = factrial[i-1] * i % MOD
        inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD
        factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD


# 二項係数計算
def COM(n, k):
    global factrial, inverse, factrial_inverse
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD


# 前処理完了
COMinit()

X, Y = map(int, input().split())
ans = 0
if (X+Y) % 3 != 0:
    print(0)
else:
    ans = 0
    m = (2*X - Y) // 3
    n = X - 2*m
    if m < 0 or n < 0:
        print(0)
    else:
        print(COM(n+m, n))


Measured memory_bytes: 62320
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  string ans = "Yes";
  map<char, int> cnt;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == t[i]){
      cnt[s[i]]++;
    }
    else{
      if(cnt[s[i]] > 0 || cnt[t[i]] > 0){
        ans = "No";
        break;
      }
      else{
        cnt[t[i]]++;
        char u = s[i];
        char v = t[i];
        for(int j = i; j < s.length(); j++){
          if(s[j] == u){
            s[j] = v;
          }
          else if(s[j] == v){
            s[j] = u;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, Q, K;

  cin >> N >> K >> Q;

  ll score[100001];
  REP(i, N+1) {score[i] = 0;}

  int tmp_a;
  REP(i, Q) {
    cin >> tmp_a;
    ++score[tmp_a];
  }

  for(long i=1; i<=N; ++i){
    if(score[i] + K - Q > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
int main(){
	int n;
	cin>>n;
	cout<<(n*n*n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int min_price;
    min_price = min(a+b, b+c);
    min_price = min(min_price, a+c);
    out(min_price);
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
typedef long long ll;
#include<string.h>

#include<vector>
#define pb push_back

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

int main(){

  ll N,res=0,small=1000000001;
  cin >> N;
  vector<ll> H;
  vector<bool> Flag(N);
  
  rep(i,0,N){
    int temp;
    cin >> temp;
    H.pb(temp);
  }
  for(int i=N-1; i>=0; i--){
    if(small > H[i]){
      small = H[i];
    }else if(small < H[i]-1){
      cout << "No" << endl;
      return 0;
    }else if(small == H[i]-1){
      H[i]--;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 1404
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    int ans=0;
    int q;

    rep(i,n){
        int e;
        cin >>e;
        q=min(k-e,e);
        ans+=q*2;

    }
    cout << ans;
    

    return 0;
}

Measured memory_bytes: 256
// Author--> darklight13
#define _CRT_SECURE_NO_DEPRECATE
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
	string a,b;cin>>a>>b;
	int n = a.length(),m = b.length();
	int dp[n+1][m+1];
	memset(dp,0,sizeof dp);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i-1]==b[j-1])
			{
				dp[i][j] = dp[i-1][j-1]+1;
			}else
			{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	// for(int i=1;i<=n;i++)
	// {
	// 	for(int j=1;j<=m;j++)
	// 	{
	// 		cout<<dp[i][j]<<' ';
	// 	}cout<<'\n';
	// }
	int i=n,j=m;
	std::vector<char>ans;
	while(i>0&&j>0)
	{
		if(a[i-1]==b[j-1])
		{
			ans.push_back(a[i-1]);
			i--;j--;
			continue;
		}
		if(dp[i-1][j]>dp[i][j-1])
		{
			i--;
		}else
		{
			j--;
		}
	}
	reverse(ans.begin(),ans.end());
	for(auto it:ans)	cout<<it;
    return 0;
}

Measured memory_bytes: 70656
def counting_sort(A, B, k):
    C=[0 for i in range(k)]
    for j in range(n):
        C[A[j]] += 1
    for i  in range(1,k):
        C[i] = C[i] + C[i-1]
    for j in range(n-1,-1, -1):
        B[C[A[j]]-1] = A[j]
        C[A[j]] -= 1

if __name__ == "__main__":
    n=int(input())
    A=list(map(int,input().split()))
    B=[-1 for i in range(n)]
    counting_sort(A,B,max(A)+1)
    print(*B)


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

using namespace std;

bool isPrime(int x){
	if(x == 2) return true;
	if(x < 2 || x % 2 == 0) return false;
	int sqrtx = sqrt(x);
	for(int i = 3; i <= sqrtx; i = i + 2){
		if(x % i == 0) return false;
	}
	return true;
}

int main(){
	int n, count = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(isPrime(x)) count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N;
    cin >> N;
    int A[N+1];
    rep(i,N+1) cin >> A[i];
    if(N==0){
        if(A[0]!=1) cout << -1 << endl;
        else cout << 1 << endl;
        return 0;
    }
    else if(A[0]!=0){
        cout << -1 << endl;
        return 0;
    }
    lint sum=accumulate(A,A+N+1,0LL)-A[0];
    lint ans=1;
    lint vec=1;
    for(int i=1;i<=N;i++){
        vec*=2;
        if(vec>sum) vec=sum;
        ans+=vec;
        vec-=A[i];
        if(vec<0){
            cout << -1 << endl;
            return 0;
        }
        sum-=A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

long long x, y, mcd;

void extendedEuclid(long long a, long long b){
	if(b == 0){
		x = 1;
		y = 0;
		mcd = a;
	}
	else{
		extendedEuclid(b, a % b);
		x = y;
		y = (mcd - a*x) / b;
	}
}

// retorna (a/b) mod m
long long moduloDivision(long long a, long long b, long long modulo){
//	if(a % b != 0)
//	return -1;	// Division inexacta
	extendedEuclid(b,modulo);
	if(x < 0)
	x += modulo;
	return (x * (a / mcd)) % modulo;
}


const int maxN = 200000;
const long long mod = 1000000007;
vector<long long> V1(maxN+1), V2(maxN+1);

int main(){
	ios_base::sync_with_stdio(0);cin.tie(NULL);
	long long H,W,A,B,i;
	long long x,y,k,ans;
	cin>>H>>W>>A>>B;
	x = B+1;
	V1[0] = 1;
	for(i=1,x=B+1,y=1; i<H; i++,x++,y++){
		V1[i] = (V1[i-1] * x) % mod;
		V1[i] = moduloDivision(V1[i], y, mod);
	}
	for(i=H-A; i<H; i++)
	V1[i] = V1[i-1];
	
	V2[H-1] = 1;
	for(i=H-2,x=W-B-1,y=1; i>=0; i--,x++,y++){
		V2[i] = (V2[i+1] * x) % mod;
		V2[i] = moduloDivision(V2[i], y, mod);
	}

	ans = 0;
	for(i=0; i<H; i++){
		k = (V1[i] * V2[i]) % mod;
		ans = (ans + k) % mod;
	}

//	for(i=0; i<H; i++){ cout<<V1[i]<<" "; }	cout<<endl;
//	for(i=0; i<H; i++){ cout<<V2[i]<<" "; }	cout<<endl;

	cout<<ans<<endl;
}

Measured memory_bytes: 3328
mod = 998244353
n = int(input())
import collections
dat = list(map(int, input().split()))
c = collections.Counter(dat)
ma = max(c)
#print(c)
res = 1
#print(c)
can = True

for i in range(1,ma ):
    #print("{0} ^ {1}".format(i, i+1))
    #print("={0} ^ {1}".format(c[i], c[i+1]))
    #res *= c[i] ** (c[i+1])
    if c[i] == 0:
        can = False
        break
    for ii in range(c[i+1]):
        res *= c[i]
        res %= mod
        #print("=={0}".format(res))


if dat[0] != 0:
    print(0)
elif c[0] != 1:
    print(0)
elif can is False:
    print(0)
else:
    print(res)


Measured memory_bytes: 19936
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define PRINT
#define LCERR
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

class Solution {
public:
    vector<int> water_into_dams(const vector<int>& y) {
        const int N = y.size() - 1;
        vector<int> x(N + 1);
        x[N] = y[N];
        for (int i = 1; i < N; ++i) {
            if (i % 2 == 1) {
                x[N] -= y[i];
            } else {
                x[N] += y[i];
            }
        } // x[N] = y[N] - y[1] + y[2] - y[3] + y[4] ...
        for (int i = N - 1; i >= 1; --i) {
            x[i] = 2 * y[i] - x[i + 1];
        }
        return x;
    }
private:

};

int solve() {
    Solution solution;
    // handle IO here
    int N;
    cin >> N;
    vector<int> y(N + 1, 0); // y[0] is not used
    for (int i = 1; i <= N; ++i) {
        cin >> y[i];
    }
    auto x = solution.water_into_dams(y);
    for (int i = 1; i <= N - 1; ++i) {
        cout << x[i] << ' ';
    }
    cout << x[N] << endl;
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1020000,mo=998244353;
const ll MOD1=2LL*mo*mo,MOD=6LL*mo*mo;
int n,cnt[N],mu[N],res,s1[N],s2[N],v1[N],v2[N],inv[N];
int prime[N],len,mrk[N];

inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
void getp(int n){
	mu[1]=1;
	rep(i,2,n){
		if(!mrk[i])prime[++len]=i,mu[i]=-1;
		rep(j,1,len){
			if(i*prime[j]>n)break;
			mrk[i*prime[j]]=prime[j];
			if(i%prime[j]==0)break;
			mu[i*prime[j]]=-mu[i];
		}
	}
}
int main() {
	int mx=1;read(n);rep(i,1,n){int x;read(x);cnt[x]++;umax(mx,x);}
	n=mx;
	rep(i,1,n)v1[i]=1LL*cnt[i]*i%mo,v2[i]=1LL*cnt[i]*i*i%mo;
	rep(i,1,n)for(int j=i;j<=n;j+=i)
		add(s1[i],v1[j]),add(s2[i],v2[j]);
	inv[1]=1;rep(i,2,n)inv[i]=1LL*(mo-mo/i)*inv[mo%i]%mo;getp(n);
//	rep(i,1,n)cerr<<mu[i]<<' ';cerr<<endl;
	rep(g,1,n){
		ll ans=0;
		per(d,n/g,1){
			ans+=(1LL*s1[g*d]*s1[g*d]-s2[g*d])*mu[d];
		//	ans%=mo;
			ans=ans<0?ans+MOD1:ans;
			ans=ans<MOD?ans:ans-MOD;
		}
		ans=1LL*(ans%mo+mo)%mo*inv[2]%mo;
	//	if(ans)cerr<<g<<' '<<ans<<endl;
		res=(res+ans*inv[g])%mo;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
int digits(ll m){
    int count = 0;
    while (m > 0){
        m /= 10;
        count++;
    }
    return count;
}
int main() {
    int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
    int z = 2 * max(x,y);
    ll sum = 0;
    ll sum_min = INFINITY;
    for (int i = 0; i <= z; i += 2) {
        if((x - i/2 >= 0) && (y - i/2 >= 0)) {
            sum = c * i + a * (x - (i / 2)) + b * (y - (i / 2));
        }
        if(x - i/2 < 0)sum = c * i + b * (y - (i / 2));
        if(y - i/2 < 0)sum = c * i + a * (x - (i / 2));
        sum_min = min(sum,sum_min);
    }
    print(sum_min);
}


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

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

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

			}
			
			Arrays.sort(b, Collections.reverseOrder());
			int max = b[0];
			int sec = b[1];
			
			for (int i = 0; i < n; i++) {
				if (a[i] == max) {
					System.out.println(sec);
				} else {
					System.out.println(max);
				}

			}

		}

	}

}

Measured memory_bytes: 96884
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder174
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine()); // kの倍数が登場するのは何項目か

            var remainder = 7 % k;

            // k以上辿っていたらループしているため処理を終了する
            for (var i =1; i<k+1 ;i++ )
            {
                if (remainder == 0)
                {
                    Console.WriteLine(i);
                    return;
                }

                // 項数が増えるたびに数はn * 10 + 7増えるため
                // 余りも同じだけ増える。それをkで割った余りを再び計算する 
                remainder = (remainder * 10 + 7) % k;

            }

            // 割り切れなかった場合は、-1を出力する
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 27508
import math

a,b,x = map(int,input().split())

tr = a*a*b/2

if x <= tr:
  rlt = (180/math.pi)*math.atan2(a*b**2, 2*x)
else:
  rlt = (180/math.pi)*math.atan2(2*(a**2*b - x), a**3)
  
print(rlt)

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

template <typename T>
int selection_sort(std::vector<T>& xs)
{
  int changed {0};
  for (int i{0}; i < xs.size(); ++i)
  {
    int mini{i};
    for (int j{i}; j < xs.size(); ++j)
    {
      if (xs[mini] > xs[j])
      {
        mini = j;
      }
    }
    if (i != mini)
    {
      std::swap(xs[i], xs[mini]);
      ++changed;
    }

  }
  return changed;
}

int main()
{
  int n{};
  std::vector<int> xs{};
  std::cin >> n;
  xs.resize(n);
  for (int i{0}; i < n; ++i)
  {
    std::cin >> xs[i];
  }

  int changed{selection_sort(xs)};
  for (int i{0}; i < n-1; ++i)
  {
    std::cout << xs[i] << ' ';
  }
  std::cout << xs[n-1] << std::endl
    << changed << std::endl;
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    string s ;
    int count =0;
    int countb=0;
    cin>>s;
 for(int i=0;i<s.size();i++)
 {
       if(s[i]=='x')
       {
           count++;
       }
       if(s[i]=='o')
       {
           countb++;
       }
 }
 int d = 700+(100*countb);
 cout<<d<<endl;
    return 0 ;
}


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

int main()
{
    long long A,B;
    int K;
    cin>>A>>B>>K;
    for(int i=K; i>=1; i-=2){
        if(A%2==1){ A--; }
        B+=A/2;
        A/=2;
        
        if(i!=1){
        if(B%2==1){ B--;}
        A+=B/2;
        B/=2;
        }
    }
    cout << A <<" " << B<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 1e9+7;

ll add(ll a,ll b)
{
	a%=MOD; b%=MOD;
	a+=b;a%=MOD;
	if(a<0) a+=MOD;
	return a;
}
ll mult(ll a, ll b)
{
	a%=MOD; b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}
ll pw(ll a, ll b)
{
	ll r=1;
	while(b){
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
ll inverse(ll a)
{
	return pw(a,MOD-2);
}
const int MAXN = 100005;

void NO(){ cout<<0<<'\n'; exit(0); }

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	int a[n];
	forn(i,0,n) cin>>a[i];
	
	int c[3]{};
	ll ans=1;
	
	forn(i,0,n){
		int cnt=0;
		forn(j,0,3){
			if(a[i]==c[j]) cnt++;
		}
		ans=mult(ans,cnt);
		forn(j,0,3){
			if(a[i]==c[j]){ c[j]++; break; }
		}
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<vector<int> > PtoY(n+1);

	vector<pair<int,int> > ID(m);

	for(int i=0;i<m;i++)
	{
		int p,y;
		cin >> p >> y;
		ID[i]=make_pair(p,y);
		PtoY[p].push_back(y);
	}

	for(int i=0;i<n+1;i++)
		sort(PtoY[i].begin(),PtoY[i].end());

	for(int i=0;i<m;i++)
	{
		int p=ID[i].first;
		cout << setfill('0') << setw(6) << p; 

		auto itr = PtoY[p].begin();
//rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
/*
		for(int j=0;j<PtoY[p].size();j++)
		{
			if(*itr==ID[i].second)
			{
				cout << setfill('0') << setw(6) << j+1 << endl;
				break;
			}
			itr++;
		}
*/
		auto itr1=lower_bound(PtoY[p].begin(),PtoY[p].end(),ID[i].second);
		auto itr2=PtoY[p].begin();
		cout << setfill('0') << setw(6) << itr1-itr2+1 << endl;
//		cout << PtoY[p].size() << endl;
//		cout << *itr1 << " : " << &itr1 << endl;
//		cout << *itr2 << " : " << &itr2 << endl;
	}

}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define endl "\n";
int main() {
#ifndef ONLINE_JUDGE
	freopen("i.txt", "r", stdin);
	freopen("o.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	if (s[n - 1] == 's') {
		s += "es";
	}
	else {
		s += "s";
	}
	cout << s;
}

Measured memory_bytes: 3648
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp

ans = 0
t.each_char.with_index do |c, i|
  if i >= k && c == t[i - k]
    t[i] = "x"
    next
  end

  score = [p, s, r][%w(r p s).find_index(c)]
  ans += score
end

puts ans


Measured memory_bytes: 14616
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
typedef complex<ld> point;

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

    int h1,m1;
    cin >> h1 >> m1;
    int h2,m2;
    cin >> h2 >> m2;
    int v1=h1*60+m1;
    int v2=h2*60+m2;
    int k;
    cin >> k;
    db(max(0,v2-v1-k))

    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

int N, K;
const ll MOD = 998244353;
ll F[4002], F_inv[4002];

ll modpow(ll a, ll b) {
	ll rtn = 1, kakeru = a;
	while (b > 0) {
		if (b & 1)rtn *= kakeru;
		kakeru *= kakeru;
		kakeru %= MOD;
		rtn %= MOD;
		b >>= 1;
	}
	return rtn;
}

void calc_fac() {
	F[0] = 1, F[1] = 1;
	for (int i = 2; i <= 4001; i++) {
		F[i] = F[i - 1] * i;
		F[i] %= MOD;
	}

	F_inv[4001] = modpow(F[4001], MOD - 2);
	for (int j = 4000; j >= 0; j--) {
		F_inv[j] = F_inv[j + 1] * (j + 1);
		F_inv[j] %= MOD;
	}

}

ll comb(ll a, ll b) {
	if (a < 0)return 0;
	if (b < 0)return 0;
	if (b > a)return 0;
	ll ans = (F[a] * F_inv[b])%MOD * F_inv[a - b];
	return ans % MOD;
}

ll hcomb(ll a, ll b) {
	return comb(a + b - 1, b);
}

int main() {

	calc_fac();

	cin >> K >> N;
	
	for (int i = 2; i <= 2 * K; i++) {
		if (i % 2 == 1) {
			ll cnt = 0;
			int A = min((i - 1) / 2, (2 * (K + 1) - i) / 2);
			for (int j = 0; j <= A; j++) {
				ll tmp = 1;
				tmp *= (modpow(2, j) * comb(A, j)) % MOD;
				tmp *= hcomb(K - 2 * A + j, N - j);
				tmp %= MOD;
				cnt += tmp;
				cnt %= MOD;
			}
			cout << cnt << endl;
		}
		else {
			ll cnt = 0;
			int A = min((i) / 2, (2 * (K + 1) - i) / 2) - 1;
			for (int j = 0; j <= A; j++) {
				ll tmp = 1;
				tmp *= (modpow(2, j) * comb(A, j)) % MOD;
				ll a = hcomb(K - 2 * A + j - 1, N - j) + hcomb(K - 2 * A + j - 1, N - j - 1);
				a %= MOD;
				tmp *= a;
				tmp %= MOD;
				cnt += tmp;
				cnt %= MOD;
			}
			cout << cnt << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public static void Main(string[] args)
	{
		string[] inputs = Console.ReadLine().Split(' ');
		int n = int.Parse(inputs[0]);
		int k = int.Parse(inputs[1]);
		string s = Console.ReadLine();
		for(int i = 0; i < s.Length;i++) {
		if(i==(k-1)) {
		Console.Write((char)(s[k-1] - 'A' +'a'));
		
		}else
		Console.Write(s[i]);
		
		
		}
		
		Console.WriteLine();
	}

	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}


}

Measured memory_bytes: 11092
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(M)]
m = min(a) + min(b)
for i in range(M):
    if m > a[s[i][0]-1] + b[s[i][1]-1] - s[i][2]:
        m = a[s[i][0]-1] + b[s[i][1]-1] - s[i][2]
print(m)


Measured memory_bytes: 80068
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << n / (a + b) * a + (n % (a + b) > a ? a : n % (a + b));
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};
const ll mod = 1000000007;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    // k * (k-1)^(n-1)を出力
    cout << fixed << setprecision(0) << k*pow(k-1,n-1) << endl;
}

Measured memory_bytes: 384
#include <queue>
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int n, m, ans = 0, dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
string s[20];
int solve(int cx, int cy, int ex, int ey){
	int d[n][m];
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			d[i][j] = -1;
		}
	}
	queue<pair<int, int> > bfs;
	bfs.push(make_pair(cx, cy));
	d[cx][cy] = 0;
	while (!bfs.empty()){
		int x = bfs.front().first, y = bfs.front().second;
		bfs.pop();
		if (x == ex && y == ey) break;
		for (int i = 0; i < 4; i++){
			int tx = x + dx[i], ty = y + dy[i];
			if (tx < 0 || tx >= n || ty < 0 || ty >= m || s[tx][ty] == '#' || d[tx][ty] != -1) continue;
			d[tx][ty] = d[x][y] + 1;
			bfs.push(make_pair(tx, ty));
		}
	}
	return d[ex][ey];
}
int main(){
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			for (int k = 0; k < n; k++){
				for (int l = 0; l < m; l++){
					if (s[i][j] == '#' || s[k][l] == '#') continue;
					ans = max(ans, solve(i, j, k, l));
				}
			}
		}
	}
	printf("%d\n", ans);
}

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

int main(){
	int w;
	while(1){
		cin>>w;
		if(w==-1) break;
		int cost=0;
		if(w>30){
			cost += (w-30)*160;
			w = 30;
		}
		if(w<=30 && w>20){
			cost += (w-20)*140;
			w = 20;
		}
		if(w<=20 && w>10){
			cost += (w-10)*125;
			w = 10;
		}
		if(w<=10){
			cost += 1150;
		}
		cout<<4280-cost<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from collections import Counter

N = int(input())
D = Counter(int(i) for i in input().split())
M = int(input())
T = [int(i) for i in input().split()]

for t in T:
    if D[t] <= 0:
        print("NO")
        quit()
    if t in D:
        D[t] -= 1
print("YES")


Measured memory_bytes: 46168
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');
var input = stdin.toString().trim().split('\n');

var S = parseInt(input[0], 10);
var h = Math.floor(S / (60 * 60));
var m = Math.floor(S % (60 * 60) / 60);
var s = Math.floor(S % 60);


console.log([h,m,s].join(':'));

Measured memory_bytes: 15540
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;
  
int main() {
  string s;
  cin >> s;
  int len = sz(s);
  vm dp(3,0);
  int q=0;
  rep(i,len) {
    vm dp2(dp);
    if(s[i]=='A') {
      dp2[0] += mint(3).pow(q);
    } else if(s[i]=='B') {
      dp2[1] += dp[0];
    } else if(s[i]=='C') {
      dp2[2] += dp[1];
    } else {
      dp2[0] = dp[0]*3+mint(3).pow(q);
      dp2[1] = dp[1]*3+dp[0];
      dp2[2] = dp[2]*3+dp[1];
      q++;
    }
    dp = dp2;
  }
  cout << dp[2].x << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, A, B = map(int, read().split())

mul = N // (A + B)
m = N % (A + B)

ans = A * mul + min(A, m)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a,x=0;
  cin >> n>>a;
  if(a%2==1) x++;
  for(int i=0;i<(n-1)/2;i++){
    cin>>a>>a;
    if(a%2==1) x++;
  }
  cout << x << endl;
}


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

int apartment1[3][10];
int apartment2[3][10];
int apartment3[3][10];
int apartment4[3][10];

int main(){
      //ここにプログラムを書いていく
	int a,b,c,d,e;
	cin>>a;
	for(int f=0;f<a;f++){
		cin>>b>>c>>d>>e;
		if (b==1){
			apartment1[c-1][d-1]+=e;
		}
		if (b==2){
			apartment2[c-1][d-1]+=e;
		}
		if (b==3){
			apartment3[c-1][d-1]+=e;
		}
		if (b==4){
			apartment4[c-1][d-1]+=e;
		}		
	}
	for(int v=0;v<3;v++){
		for(int k=0;k<10;k++){
			cout<<' '<<apartment1[v][k];
		}
		cout<<endl;
	}

	cout<<"####################"<<endl;
	for(int v=0;v<3;v++){
		for(int k=0;k<10;k++){
			cout<<' '<<apartment2[v][k];
		}
		cout<<endl;
	}

	cout<<"####################"<<endl;
	for(int v=0;v<3;v++){
		for(int k=0;k<10;k++){
			cout<<' '<<apartment3[v][k];
		}
		cout<<endl;
	}

	cout<<"####################"<<endl;
	for(int v=0;v<3;v++){
		for(int k=0;k<10;k++){
			cout<<' '<<apartment4[v][k];
		}
		cout<<endl;
	}

}



Measured memory_bytes: 3096
from collections import deque


H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(lambda x: int(x) - 1, input().split())
grid = [input() for _ in range(H)]

INF = float('inf')
path = [[[(INF, INF)] * 4 for _ in range(W)] for _ in range(H)] #3次元配列。各方向に対して(コスト、連続移動ます)のtapleを持つ

D = [(-1, 0), (0, 1), (1, 0), (0, -1)] # 上:0, 右:1, 下:2, 左:3

# 初期処理
q = deque() #探索しているところをここに加えていくんだと思う。
for d in range(4):
    path[x1][y1][d] = (1, 0)  # スタート地点では(1, 0)
    q.append((x1, y1, d, 1, 0)) # (x, y, 進行方向[d], 移動回数[c], 進行済マス数[k])

# 01BFS
while q:
    x, y, d, c, k = q.popleft()

    # nx, ny: 次の座標
    # nd: 次の進行方向
    # nc: 次の移動回数
    # nk: 次の進行済マス数
    for nd in range(4):
        if nd == d:
            dx, dy = D[nd]
            nk = 1 if k == K else k + 1
            nc = c + 1 if k == K else c
        else:
            dx, dy = 0, 0
            nk = 0
            nc = c + 1
        nx = x + dx; ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and grid[nx][ny] == '.' and path[nx][ny][nd] > (nc, nk):
            path[nx][ny][nd] = (nc, nk)
            if nc == c:
                q.appendleft((nx, ny, nd, nc, nk))
            else:
                q.append((nx, ny, nd, nc, nk))

# ゴール地点の最小コストを求める
ans = INF
for d in range(4):
    ans = min(ans, path[x2][y2][d][0])
ans = -1 if ans == INF else ans
print(ans)

Measured memory_bytes: 399952
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll Q, H, S, D, N;
struct sav{
	ll num, ord;
}a[5];
bool cmp(sav x, sav y) {
	return x.num < y.num;
}
int main() {
	scanf("%lld %lld %lld %lld %lld", &Q, &H, &S, &D, &N);
	a[1].num = Q * 8; a[1].ord = 1;
	a[2].num = H * 4; a[2].ord = 2;
	a[3].num = S * 2; a[3].ord = 4;
	a[4].num = D * 1; a[4].ord = 8;
	sort(a + 1, a + 5, cmp);
	ll tmp = 0, ans = 0, i = 1; N *= 4;
	while (tmp < N) {
		while (N - tmp < a[i].ord) i ++;
		ans += (N - tmp) / a[i].ord * a[i].num / (8 / a[i].ord);
		tmp += (N - tmp) / a[i].ord * a[i].ord;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll n, t;
  cin >> n >> t;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> ma(n), mi(n);
  mi[0] = a[0];
  for (int i = 1; i < n; i++) {
    mi[i] = min(mi[i-1], a[i]);
  }
  ma[n-1] = a[n-1];
  for (int i = n-2; i >= 0; i--) {
    ma[i] = max(ma[i+1], a[i]);
  }

  ll max_value = 0;
  rep(i, n) {
    chmax(max_value, ma[i] - mi[i]);
  }

  set<pair<int, int>> s;
  rep(i, n) {
    if (ma[i] - mi[i] == max_value) {
      pair<int, int> p(ma[i], mi[i]);
      s.insert(p);
    }
  }

  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
    int i, ans1 = 0, ans9 = 0, ans7 = 0, ans4 = 0, ans;
    int n[4];

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

    for (i = 0; i < 4; i++) {
        if (n[i] == 1)
            ans1 = 1;
        else if(n[i] == 9)
            ans9 = 1;
        else if(n[i] == 7)
            ans7 = 1;
        else if(n[i] == 4)
            ans4 = 1;
    }

    ans = ans1 + ans9 + ans7 + ans4;

    if (ans == 4)
        printf("YES");
    else
        printf("NO");

    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  vector<pair<int,int>> ba;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    ba.push_back(make_pair(b,a));
  }
  sort(ba.begin(),ba.end());
  
  bool ans=true;
  int NowTime=0;
  rep(i,n){
    int a=ba[i].second,b=ba[i].first;
    NowTime+=a;
    if(NowTime>b){
      ans=false;
      break;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 2420
//arc070d.cpp
#include<iostream>
#include<vector>
using namespace std;

int MOD = 10007;

int main(){
    int ans=0;
    int N,K;
    cin >> N >> K;
    int a_sub;
    vector<int> a;
    int i,j;
    a.push_back(0);
    for(i=1; i<=N; i++){
        cin >> a_sub;
        if(a_sub<K){
            a.push_back(a_sub);
        }
    }
    int M=a.size()-1;
    if(M<=0){
        cout << ans << endl;
        return 0;
    }
    int dp[2][2*K+1], dp_rev[K+1];
    dp[0][0]=1;
    for(j=1; j<=2*K; j++){
        dp[0][j]=0;
    }
    for(i=1; i<=M; i++){
        for(j=0; j<=2*K; j++){
            if(j-a[i]<0){
                dp[i%2][j]=dp[!(i%2)][j];
            }else{
                dp[i%2][j]=dp[!(i%2)][j]+dp[!(i%2)][j-a[i]];
                dp[i%2][j]%=MOD;
            }
        }
    }
    for(i=1; i<=M; i++){
        for(j=0; j<=K; j++){
            if(j-a[i]<0){
                dp_rev[j]=dp[M%2][j];
            }else{
                dp_rev[j]=dp[M%2][j]+(MOD-dp_rev[j-a[i]]);
                dp_rev[j]%=MOD;
            }
        }
        for(j=K; j<K+a[i]; j++){
            if((dp[M%2][j]>0)&&(dp_rev[j-a[i]]>0)){
                break;
            }
        }
        if(j>=K+a[i]){
            ans++;
        }
    }
    cout << ans <<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3788