akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long ab = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0;
	long long m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = 0, u = 0, v = 0, w = 0, x = 0, y = 0, z = 0;
	string ss; cin >> ss;
	for (int hi = 0; hi < ss.size(); hi++) {
		if (ss[hi] == 'a') { a++; }
		if (ss[hi] == 'b') { b++; }
		if (ss[hi] == 'c') { c++; }
		if (ss[hi] == 'd') { d++; }
		if (ss[hi] == 'e') { e++; }
		if (ss[hi] == 'f') { f++; }
		if (ss[hi] == 'g') { g++; }
		if (ss[hi] == 'h') { h++; }
		if (ss[hi] == 'i') { i++; }
		if (ss[hi] == 'j') { j++; }
		if (ss[hi] == 'k') { k++; }
		if (ss[hi] == 'l') { l++; }
		if (ss[hi] == 'm') { m++; }
		if (ss[hi] == 'n') { n++; }
		if (ss[hi] == 'o') { o++; }
		if (ss[hi] == 'p') { p++; }
		if (ss[hi] == 'q') { q++; }
		if (ss[hi] == 'r') { r++; }
		if (ss[hi] == 's') { s++; }
		if (ss[hi] == 't') { t++; }
		if (ss[hi] == 'u') { u++; }
		if (ss[hi] == 'v') { v++; }
		if (ss[hi] == 'w') { w++; }
		if (ss[hi] == 'x') { x++; }
		if (ss[hi] == 'y') { y++; }
		if (ss[hi] == 'z') { z++; }
	}
	if (a % 2 != 0) { ab++; }
	if (b % 2 != 0) { ab++; }
	if (c % 2 != 0) { ab++; }
	if (d % 2 != 0) { ab++; }
	if (e % 2 != 0) { ab++; }
	if (f % 2 != 0) { ab++; }
	if (g % 2 != 0) { ab++; }
	if (h % 2 != 0) { ab++; }
	if (i % 2 != 0) { ab++; }
	if (j % 2 != 0) { ab++; }
	if (k % 2 != 0) { ab++; }
	if (l % 2 != 0) { ab++; }
	if (m % 2 != 0) { ab++; }
	if (n % 2 != 0) { ab++; }
	if (o % 2 != 0) { ab++; }
	if (p % 2 != 0) { ab++; }
	if (q % 2 != 0) { ab++; }
	if (r % 2 != 0) { ab++; }
	if (s % 2 != 0) { ab++; }
	if (t % 2 != 0) { ab++; }
	if (u % 2 != 0) { ab++; }
	if (v % 2 != 0) { ab++; }
	if (w % 2 != 0) { ab++; }
	if (x % 2 != 0) { ab++; }
	if (y % 2 != 0) { ab++; }
	if (z % 2 != 0) { ab++; }
	if (ab == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		if(n == 1){
			System.out.println(m);
			return;
		}

		int result = 0;
		for(int i = 1; i <= m/n; i++){
			if((m - i*n) % i == 0){
				result = i;
			}
		}

		System.out.println(result);
	}
}


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

using namespace std;

int main()
{
    int n, k, x, y; cin >> n >> k >> x >> y;
    int ans;

    if (n > k) {
        ans = k * x + (n - k) * y;
    } else {
        ans = n * x;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    List<Integer> list = new ArrayList<>();
    int sum = 0;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(sc.nextLine());
      sum += n;
      if(n % 10 != 0){
        list.add(n);
      }
    }
    Collections.sort(list);
    
    int ans = 0;
    if(sum % 10 != 0){
      ans = sum;
    }else if(list.size() > 0){
      ans = sum - list.get(0);
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
#define MAX 1000010
int sosu[MAX]={1,1,0};
vi sos;
void init(){
	for(int i=2;i*i<=MAX;i++)if(!sosu[i])
	for(int j=i*2;j<MAX;j+=i)sosu[j]=true;
	rep(i,MAX)if(sosu[i]==0)sos.pb(i);
}
int main(){
	init();
	map<ll,ll>ma;
	FOR(i,sos)ma[i]=i*i,ma[i*i]=i;
	map<vi,int>be,af;
	int out1=0,out2=0,up=0;
	int n;
	cin>>n;
	rep(i,n){
		ll a;
		cin>>a;
		vi t,nt;
		for(ll j=2;j<2200;j++)if(a%j==0){
			int co=0;
			while(a%j==0){
				co++;
				a/=j;
			}
			co%=3;
			rep(k,co)t.pb(j);
			rep(k,(3-co)%3)nt.pb(j);
		}
		if(a-1){
			if(ma.count(a))t.pb(a),nt.pb(ma[a]);
			else t.pb(a),nt.pb(-1);
		}
		if(t.size()==0)up=1;
		else be[t]++,af[nt]++;
	}
	FOR(it,be){
		vi t=it.first;
		int co1=be[t],co2=af[t];
		(co2?out1:out2)+=max(co1,co2);
	}
	cout<<out1/2+out2+up<<endl;
}






Measured memory_bytes: 44276
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
const int MOD = 1000000007;

ll mul(ll a, ll b) { return a * b % MOD; }

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll res = 0;
  for (int bit = 0; bit < 64; bit++) {
    ll cnt = 0;
    ll t = 1LL << bit;
    for (int i = 0; i < n; i++) {
      if (a[i] & t) cnt++;
    }
    res += mul(mul(cnt, n - cnt), t % MOD);
    res %= MOD;
  }
  cout << res << endl;
}

Measured memory_bytes: 2560
//
// Created by 田代真生 on 2019-10-10.
//

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

long h, w;
long new_x, new_y;
long _max = 0;
long c;
string input;
vector<vector<char>> _map;
queue<vector<long>> que;
// set<vector<long>> already;
// unordered_map<long, unordered_set<long>> already;
vector<vector<long>> candidates={{0,1},{0,-1},{1,0},{-1,0}};

int wfs(long x, long y, long cost){
    for(vector<long> candidate: candidates){
        new_x = x + candidate[0];
        new_y = y + candidate[1];
        if(new_x > w || new_x < 0 || new_y > h || new_y < 0){
            continue;
        }
        if(_map[new_y][new_x] == '.'){
            _map[new_y][new_x] = '#';
            que.push({new_x, new_y, cost + 1});
        }
    }
    if(que.empty()){
        _max = max(cost, _max);
        return 0;
    }
    new_x = que.front()[0];
    new_y = que.front()[1];
    c = que.front()[2];
    que.pop();
    return wfs(new_x, new_y, c);
}

int main(){
    cin >> h >> w;
    _map.resize(h);
    for(int i=0; i<h; i++){
        // already[i] = {};
        _map[i].resize(w);
        cin >> input;
        for(int j=0; j< w; j++){
            _map[i][j] = input[j];
            if(input[j] == '#'){
                que.push({j, i, 0});
                // already[j].insert(i);
            }
        }
    }
    h--;
    w--;
    new_x = que.front()[0];
    new_y = que.front()[1];
    que.pop();
    wfs(new_x, new_y, 0);
    cout << _max << endl;
}

Measured memory_bytes: 197300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
const int INF = 1e8;

int main(){
    string S; cin >> S;
    int N = S.size();

    vector<Int> A(N+1,0);
    rep(i,N){
        if(S[i] == '<') A[i+1]= max(A[i+1], A[i]+1);
    }

    rep(i,N){
        if(S[N-1-i] == '>') A[N-1-i] = max(A[N-1-i], A[N-i]+1);
    }

    Int sum = 0;
    rep(i,N+1) sum += A[i];
    cout << sum << endl;
}


Measured memory_bytes: 4740
n=int(input())
a,b=(int(i) for i in input().split())
p=[int(i) for i in input().split()]
#print(n,a,b,p)

cnta=0
cntb=0
cntc=0

for i in p:
  if i<=a:
    cnta+=1
  if a+1<=i<=b:
    cntb+=1
  if b+1 <= i:
    cntc+=1
    
print(min(cnta,cntb,cntc))

Measured memory_bytes: 3064
<?php
fscanf(STDIN,"%d %d",$n,$m);

$A_i = trim(fgets(STDIN));

$A_list = explode(" ",$A_i);

$count = 0;

$sum_A = 0;

for($i = 0; $i<$n; $i++){
    $sum_A +=  (int)$A_list[$i];
}



for($i = 0; $i<$n; $i++){
    if($A_list[$i] >= (1/(4*$m))*$sum_A ){
        $count ++;
    }
}

if($count >= $m){
    echo "Yes\n";
}else{
    echo "No\n";
}

Measured memory_bytes: 4604
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<ll> b;
    for (int i = 0; i < n; i++)
    {
        ll si = 0;
        for (int j = i; j < n; j++)
        {
            si += a[j];
            b.push_back(si);
        }
    }
    ll ans = 0;
    vector<ll> c(b.size(), 1);
    for (ll bi = 45; bi >= 0; bi--)
    {
        int cnt = 0;
        for (int i = 0; i < b.size(); i++)
        {
            if (c[i] && ((1LL << bi) & b[i])) cnt++;
        }
        if (cnt >= k)
        {
            ans += (1ll << bi);
            for (int i = 0; i < b.size(); i++)
            {
                if ((1ll << bi) & b[i]) {;}
                else c[i] = 0;
            }
        }
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 8172
N = int(input())
a = list(map(int, input().split()))

def get_color(point):
    color = ''
    if 400 > point:
        color = 'grey'
    elif 800 > point:
        color = 'brown'
    elif 1200 > point:
        color = 'green'
    elif 1600 > point:
        color = 'light blue'
    elif 2000 > point:
        color = 'blue'
    elif 2400 > point:
        color = 'yellow'
    elif 2800 > point:
        color = 'orange'
    elif 3200 > point:
        color = 'red'
    else:
        color = 'free'
    return color
dict = {}
for i in range(N):
    color = get_color(a[i])
    if color not in dict.keys():
        dict[color] = 1
    else:
        dict[color] += 1

min_cnt = 0
max_cnt = 0
if 'free' not in dict.keys():
    min_cnt = max_cnt = len(dict.keys())
else:
    min_cnt = max(1, len(dict.keys())-1)
    max_cnt = len(dict.keys())-1 + dict['free']

print(min_cnt, max_cnt)


Measured memory_bytes: 3064
def check(S):
    ans = True
    N = len(S)
    for i in range(N // 2):
        if S[i] != S[N - 1 - i]:
            ans &= False
    return ans


S = input()

N = len(S)

ans = True
ans &= check(S)
ans &= check(S[:(N - 1) // 2])
ans &= check(S[(N + 3) // 2 - 1:])

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
    string s;
    int n,ac=0,wa=0,tle=0,re=0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "AC")
        {
            ac++;
        }
        else if (s == "WA")
        {
            wa++;
        }
        else if (s == "TLE")
        {
            tle++;
        }
        else if (s == "RE")
        {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3596
def dfs(s): # 文字列 s で始まる七五三数の個数
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
  for c in '753':
    ret += dfs(s + c)
  return ret

N = int(input())
print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Measured memory_bytes: 2940
#include<stdio.h>

#define max(a,b) ((a)>(b)?(a):(b))

int main(){
	int n,w,i,j;
	long wv[2][101]={{0}};
	long long dp[101][100002]={{0}},ans=0;
	scanf("%d%d",&n,&w);
	for(i=1;i<=n;i++){
		scanf("%ld%ld",&wv[0][i],&wv[1][i]);
//		dp[i][wv[0][i]]=wv[1][i];
	}
	for(i=0;i<=w;i++){
		for(j=1;j<=n;j++){
			if(wv[0][j]<=i){
				dp[j][i]=max(dp[j-1][i-wv[0][j]]+wv[1][j],dp[j-1][i]);
			}else dp[j][i]=dp[j-1][i];
		}
	}
	printf("%lld\n",dp[n][w]);
	return 0;
}

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

int num[200010],n;
bool bo[200010];
 
inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline bool check(int mid)
{
	for (int i=1;i<=n*2-1;i++) bo[i]=(num[i]<=mid);
	for (int i=0;i<n-1;i++)
	{
		if (bo[n-i]==bo[n-i-1]) return bo[n-i];
		if (bo[n+i]==bo[n+i+1]) return bo[n+i];
	}
	return bo[1];
}

int main()
{
	n=rd();
	for (int i=1;i<=n*2-1;i++) num[i]=rd();
	int l=1,r=n*2-1;
	while (l<r)
	{
		int mid=(l+r)>>1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  
  vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  
  int A=0;
  int B=0;
  cin>>A>>B;
  for (int i = 0; i < N; i++) {
    
  A+=vec.at(i);
 
}
  

  int C=A/(4*M);
  cin>>C;
  if(A==C*4*M){
  for (int i = 0; i < N; i++) {
    if(vec.at(i)>=C){
      B++;
    }
  }
  }
  else{
    for (int i = 0; i < N; i++) {
    if(vec.at(i)>C){
      B++;
    }
    }
  }
  
      
    
 

if(B>=M){
  cout<<"Yes"<<endl;
}
  else{
    cout<<"No"<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, u, v, d[100005] = {}, z[100005] = {};
    vector<int> g[100005] = {};
    queue<int> q;
    cout << "Yes\n";
    cin >> n >> m;
    while (m--) cin >> u >> v, g[u].push_back(v), g[v].push_back(u);
    d[1] = 1;
    q.push(1);
    while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (int i : g[x]) if (!d[i]) d[i] = d[x] + 1, z[i] = x, q.push(i);
    }
    for (int i = 2; i <= n; i++) cout << z[i] << '\n';
}


Measured memory_bytes: 10884
import java.util.*;

public class Main {
	
	public static void main(String[] args) {

		// argumentの取得
		Scanner s = new Scanner(System.in);

		String x = s.next();
      
        switch (x) {
          case "SUN":
            System.out.println(7);
            return;
          case "MON":
            System.out.println(6);
            return;
          case "TUE":
            System.out.println(5);
            return;
          case "WED":
            System.out.println(4);
            return;       
          case "THU":
            System.out.println(3);
            return;
          case "FRI":
            System.out.println(2);
            return;
          case "SAT":
            System.out.println(1);
            return;  
        }
      
      
      
		// 戻り値の返却
		System.out.println(x);
	
	} 
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,k;
  cin>>n>>k;
  int A[n];
  for(int i = 0;i < n;i++)
    cin>>A[i];
  int low = 0;
  int hi = k-1;
  for(int i = n-k;i > 0;i--)
  {
    if(A[hi + 1] > A[low])
      cout<<"Yes"<<"\n";
    else
      cout<<"No"<<"\n";
    low++;
    hi++;
  }
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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 rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#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 bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


int main() {
  int h,w;
  cin >>h>>w;
  int n;
  cin >>n;
  int m = max(h,w);
  
  int ans = 0;
  int s = 0;

  while(s < n){
    s+=m;
    ans++;
  }
  cout<<ans<<endl;
  return 0;

}

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

using namespace std;

bool check(int a,int b){
	if(a > 8 || b> 8){
		return false;
	}
	return true;
}

int main(){
	// freopen("b100aIn.txt","r",stdin);
	// freopen("b100aOut.txt","w",stdout);
	int a,b;
	cin>>a>>b;

	if(check(a,b)){
		cout<<"Yay!"<<endl;
	}else{
		cout<<":("<<endl;
	}


	return 0;
}

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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2==1){
    cout<<"No"<<endl;
  }else{
    bool a=true;
    for(int i=0;i<n/2 ;i++){
      if(s[i]!=s[i+n/2]){
        a=false;
      }
    }

    if(a==true){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }

    
}

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

std::deque<std::pair<int, int>> dq;

int main() {
  dq.clear();
  int n, l;
  std::cin >> n >> l;
  bool f = true;
  for (int i = 0; i < n; ++i) {
    int x;
    std::cin >> x;
    while (!dq.empty() && (i - dq.front().second >= l)) dq.pop_front();
    while (!dq.empty() && (dq.back().first > x)) dq.pop_back();
    dq.push_back({x, i});
    if (i >= l - 1) {
      if (!f) std::cout << " ";
      f = false;
      std::cout << dq.front().first;
    }
  }
  std::cout << std::endl;
  return 0;
}



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

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s == u){a=a-1;}
  if(t == u){b=b-1;}
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int A,B,C,D; cin>>A>>B>>C>>D;
  int N; cin>>N;
  vi X(N+2),Y(N+2),R(N+2);
  X[N]=A;
  Y[N]=B;
  X[N+1]=C;
  Y[N+1]=D;
  vector<vector<double>> E(N+2,vector<double>(N+2));
  rep(i,0,N) cin>>X[i]>>Y[i]>>R[i];
  rep(i,0,N+2){
    rep(j,0,N+2){
      int P=X[i]-X[j],Q=Y[i]-Y[j];
      double S=sqrt(P*P+Q*Q);
      S-=R[i]+R[j];
      double ZE=0;
      E[i][j]=max(ZE,S);
    }
  }
  priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> Q;
  Q.push(mp(0,N));
  vector<double> F(N+2,-1);
  F[N]=0;
  while(Q.size()>0){
    int P=Q.top().second;
    double S=Q.top().first;
    Q.pop();
    rep(i,0,N+2){
      if(F[i]==-1||F[i]>E[P][i]+S){
        F[i]=E[P][i]+S;
        Q.push(mp(E[P][i]+S,i));
      }
    }
  }
  printf("%.10lf\n",F[N+1]);
  }



Measured memory_bytes: 13936
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	int sum=1;
	vector<int> v(N);
	for(int i=0; i<N; i++){	
		cin>>v[i];
	}
	int sub=v[0];
	for(int i=0; i<N-1; i++){	
	if(sub<=v[i+1]){
		sum++;
		sub=v[i+1];
	}
	
	
}cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    string s; cin>>s; ll f1=0,f2=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]=='<') f1=1;
        if(s[i]=='>') f2=1;
    }
    if(f1==0 || f2==0)
    {
        ll n=s.size();
        cout<<(n*(n+1))/2;
        return 0;
    }
    //cout<<f1<<" "<<f2<<endl;
    ll ans=0,c=-1;
    ll p1=0,p;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]=='<') c++;
        else if(c!=-1)
        {
            ans+=((c*(c+1))/2);
            c=-1;
        }
    }
    //cout<<ans<<endl;
    if(c!=-1)
    {
        c++;
        ans+=((c*(c+1))/2);
    }
    //cout<<ans<<endl;
    c=0;
    for(ll i=s.size()-1;i>=0;i--)
    {
        if(s[i]=='>')
        {
            p=i; break;
        }
    }
    //cout<<p<<endl;
    vector<ll>a,b;
    for(ll i=p;i>=0;i--)
    {
        if(s[i]=='>') c++;
        else if(c!=0)
        {
            a.pb(c);
            c=0;
        }
        if(s[i]=='<') p1++;
        else if(p1!=0)
        {
            b.pb(p1);
            p1=0;
        }
    }
    if(c!=0)
    {
        a.pb(c);
        b.pb(0);
    }
    else b.pb(p1);
    //for(ll i=0;i<a.size();i++)
    //{
    //    cout<<a[i]<<" "<<b[i]<<endl;
    //}
    for(ll i=0;i<a.size();i++)
    {
        if(a[i]<b[i])
        {
            ll k=a[i]-1;
            ans+=((k*(k+1))/2);
            ans+=b[i];
        }
        else ans+=((a[i]*(a[i]+1))/2);
    }
    cout<<ans;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	VI a(3);
	cin >>a[0] >>a[1] >>a[2];
	
	int ans =0, rm=0;
	
	auto mx =*max_element(all(a));
	rep(i, 3){
		if(a[i] == mx) continue;
		int su = (mx - a[i]) /2;
		ans +=su;
		a[i] += 2*su;
		if(a[i] != mx) rm++;
	}
	if(rm == 2) ans++;
	else if(rm==1) ans+=2;
	cout << ans <<"\n";
	return 0;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	int n, m;
	cin >> n >> m;
	int l = 1;
	int r = n;
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		l = max(l, x);
		r = min(r, y);
	}
	int ans = r - l + 1;
	cout << max(ans, 0) << endl;
	return 0;
}



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

const int mxsz = 2e5 + 3;
int n;
int h[mxsz];
LL ft[mxsz], a[mxsz];
void upd(int p, LL v){for (;p <= n; p += (p & -p)) ft[p] = max(ft[p], v);}
LL get(int p){return p ? max(ft[p], get(p-(p&-p))) : 0;}

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> h[i];
	for (int i = 1; i <= n; i++) cin >> a[i];
	LL mx = 0, curr;
	for (int i = 1; i <= n; i++){
		mx = max(mx, (curr = get(h[i]-1) + a[i]));
		upd(h[i], curr);
	}
	cout << mx << '\n';
	return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
#define N 101
#define M 10000001
int main(){
  int i,j,total,count=0,a,b,c,d,min,k;
  int A[N][N],color[N],e[N],pi[N];
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      A[i][j]=-1;
  }
  }
  scanf("%d",&total);
  for(i=0;i<total;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d%d",&d,&c);
      A[a][d]=c;
    }
  }
  for(i=0;i<total;i++){
    color[i]=0; pi[i]=-1; e[i]=M;
  }
  e[0]=0;
  while(1){
    min=M;
    for(i=0;i<total;i++){
      if(color[i]!=2 && e[i]<min){
        min=e[i]; k=i;
      }
    }
if(min==M)break;
    color[k]=2;
    for(i=0;i<total;i++){
      if(A[k][i]!=-1&&color[i]!=2&&(A[k][i]+e[k])<e[i]){
        pi[i]=k;e[i]=A[k][i]+e[k];color[i]=1;
         }
    }
  }
  for(i=0;i<total;i++)printf("%d %d\n",i,e[i]);
  return 0;
}


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

intervals = []

for _ in range(n):
    x, l = list(map(int, input().split()))
    intervals.append((x-l, x+l))

intervals = sorted(intervals, key=lambda x: x[1])

cnt = n
lastEnd = intervals[0][1]

for i in range(1, n):
    if intervals[i][0] < lastEnd:
        cnt -= 1
    else:
        lastEnd = intervals[i][1]

print(cnt)

Measured memory_bytes: 24680
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val branch = Array(n + 1) { mutableListOf<Int>() }
    val minDist = Array(n + 1) { Int.MAX_VALUE / 2 }
    val froms = Array(n + 1) { 0 }
    (1 until n).forEach {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        branch[a].add(b)
        branch[b].add(a)
    }
    val queue = ArrayDeque<Int>()
    queue.add(1)
    minDist[1] = 0
    while (queue.isNotEmpty()) {
        val cur = queue.pollFirst()!!
        val bs = branch[cur]
        for (to in bs) {
            if (minDist[to] > minDist[cur] + 1) {
                queue.add(to)
                minDist[to] = minDist[cur] + 1
                froms[to] = cur
            }
        }
    }
    var cut = n
    for (i in 1 until (minDist[n] + 1) / 2) {
        cut = froms[cut]
    }
    branch[cut].remove(froms[cut])
    branch[froms[cut]].remove(cut)

    (1..n).forEach { minDist[it] = Int.MAX_VALUE / 2 }
    queue.add(1)
    minDist[1] = 0
    var count = 1
    while (queue.isNotEmpty()) {
        val cur = queue.pollFirst()!!
        val bs = branch[cur]
        for (to in bs) {
            if (minDist[to] > minDist[cur] + 1) {
                queue.add(to)
                minDist[to] = minDist[cur] + 1
                froms[to] = cur
                count++
            }
        }
    }
    if (count * 2 > n) {
        println("Fennec")
    } else {
        println("Snuke")
    }
}

Measured memory_bytes: 98380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  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 {
    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 *= a;
    if (t&1) a *= *this;
    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(int n,int a)
{
    mint up = 1;
    mint down = 1;
    rep(i,a)
    {
        up *= n-i;
        down *= i+1;
    }

    return up/down;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    mint up = 1;
    mint down = 1;
    mint ans = 2;

    ans = ans.pow(n);
    ans -=1;
    ans -= choose(n,a);
    ans -= choose(n,b);

    cout << ans.x << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

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

  while(true){
    int n,w;cin >>n>>w;
    if(n==0) break;
    ld res=0.01;
    int v[101]={0};
    for(int i=0;i<n;i++){
      int a;cin>>a;
      v[a/w]++;
    }
    ld ma=-1,koumoku=0;
    for(int i=0;i<101;i++){
      if(ma<v[i])ma=v[i];
      if(v[i]!=0) koumoku=i;
    }
    for(int i=0;i<koumoku;i++){
      res+=(1-i/koumoku)*(v[i]/ma);
    }
    cout <<setprecision(10)<<res<<endl;
  }
}

Measured memory_bytes: 3240
MOD = 1000000007
n, *a = map(int, open(0).read().split())
wa = a + [0]
for i in range(n-1, 0, -1):
    wa[i-1] += wa[i]

ans = 0
for i in range(n):
    ans += a[i] * wa[i+1]
    ans %= MOD
print(ans)

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


int main() {

  int n ; cin >> n;
  float sum = 0;
  
  for ( int i = 0 ; i < n ; i++) {
  	
    float a; string s; cin >> a >> s ; 
    if ( s == "JPY" ) sum += a;
    else sum+= 380000 * a ;
  }
 cout << sum ; 


}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int X; cin >> X;

	cout << 10 - X / 200  << endl;

	return 0;
}



Measured memory_bytes: 3652
# https://atcoder.jp/contests/abc105/tasks/abc105_c

import itertools
import collections
import bisect

# 1024 = 10 ** 3 == 2**10 -> 10 ** 9 == 2 ** 30

def main():
    N = int(input())
    if N == 0:
        print(0)
        exit()

    v = 2
    ans = []
    while N != 0:
        if N % v == 0:
            ans.append(0)
        else:
            N -= (v // 2)
            ans.append(1)

        v *= -2
    print(''.join(map(str, ans[::-1])))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    map<int, int> a;
    int prev; cin >> prev;
    a[prev]++;

    int ans = 0;
    for (int i = 2; i <= 1000000; i++)
    {
        int f;
        if (prev % 2 == 0) f = prev / 2;
        else f = 3 * prev + 1;

        a[f]++;
        if (a[f] >= 2) 
        {
            ans = i;
            break;
        }
        prev = f;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
int main(){
    int n;cin>>n;
    int ans=0;
    map<string,bool> mp;
    rep(i,n){
        string s;
        cin>>s;
        if(mp[s])continue;
        mp[s]=true;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 19212
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    cout<<(s<t?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,M;
vector<int> S,T;

Int dp[2000+10][2000+10];

Int solve(void) {
    dp[0][0] = 1;
    for(int row = 1;row <= N;row++) {
        for(int col = 1;col <= M;col++) {
            dp[row][col] = (dp[row][col-1]+dp[row-1][col] + MOD -dp[row-1][col-1]) % MOD;
            if(S[row] == T[col])
                dp[row][col] = (dp[row][col] + dp[row-1][col-1]) % MOD;
   
        }
    }

    return dp[N][M];
}

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

    S.push_back(-1);
    for(int i = 0;i < N;i++) {
        int s;
        cin>>s;
        S.push_back(s);
        dp[i+1][0] = 1;
    }

    T.push_back(-1);
    for(int j = 0;j < M;j++) {
        int t;
        cin>>t;
        T.push_back(t);
        dp[0][j+1] = 1;
    }

    cout<<solve()<<endl;

    return 0;
}


Measured memory_bytes: 31744
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;


class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    if(m == n-1){
        puts("0");
        return 0;
    }else if(n > 2*m+2){
        puts("Impossible");
        return 0;
    }
    vector<int> v(n);
    for (auto &&item : v) scanf("%d", &item);
    UnionFind uni(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        uni.unite(a, b);
    }
    map<int, vector<int>> x;
    for (int i = 0; i < n; ++i) {
        x[uni.root(i)].emplace_back(v[i]);
    }
    vector<int> u;
    ll ans = 0, y = 0;
    for (auto &&i : x) {
        sort(i.second.begin(), i.second.end());
        for (int j = 0; j < i.second.size(); ++j) {
            if(j == 0) ans += i.second[j], y++;
            else u.emplace_back(i.second[j]);
        }
    }
    sort(u.begin(), u.end());
    int i = 0;
    while(i+y < 2*(n-m-1)){
        ans += u[i++];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 7040
# include <stdio.h>
int x[101], y[101];
int main()
{    
int a=0, b=0, m=100,i;    
long long n;    
scanf("%lld",&n);    
++n;    
while(n>1)    
{        
if(n%2) 
{
a++;
x[a]=m;
m--;
n--;    
}
else 
{
b++;
y[b]=m;
m--;
n/=2;    
}   
}
printf("%d\n",(a+b)*2);    
for(i=1;i<=a;i++)        
printf("%d ",x[i]);    
for(i=b;i>=1;i--)        
printf("%d ",y[i]);    
for(i=101-a-b;i<=100;i++)        
printf("%d ",i);   
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define pdd pair<double,double>
#define cpdd const pdd
int mod=1e9+7;
int main(){
    int n;
    scanf("%d",&n);
    char c[200005];
    scanf("%s",c+1);
    int val[200005];
    int now=0;
    for(int i = 1;c[i]!=0;i++){
        if(c[i]=='B'){
            if(now&1){
                val[i]=-1;
            }
            else{
                val[i]=1;
            }
        }
        if(c[i]=='W'){
            if(now&1){
                val[i]=1;
            }
            else{
                val[i]=-1;
            }
        }
        now++;
    }
    LL ans=1;
    LL cnt=0;
    for(int i = 1;c[i]!=0;i++){
        if(val[i]==1)cnt++;
        else{
            ans*=cnt;
            cnt--;
            ans%=mod;
        }
    }
    if(cnt!=0)ans=0;
    for(int i = 1;i<=n;i++)
        ans*=i,ans%=mod;
    printf("%lld\n",ans);
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

class union_find{
	private:
	vector<int> parent,rank;
	int size;
	public:
    int cnt;

    union_find()=default;
    union_find(int n){ init(n); }

    void init(int n){
		size=n;
		cnt=n;
		parent.resize(size);
		rank.resize(size);
		for(int i=0; i<size; ++i){
			parent[i]=i;
			rank[i]=0;
		}
	}

	int find(int x){
		if(parent[x]==x) return x;
		else return parent[x]=find(parent[x]);
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			parent[x]=y;
		} else {
			parent[y]=x;
			if(rank[x]==rank[y]) ++rank[x];
		}
		--cnt;
	}

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

struct edge{
    int s,d,c;
    bool operator<(const edge &other)const{
        return c<other.c;
    }
};

void solve(){
    int n,m;
    cin >> n >> m;
    vector<edge> es(m);
    for(auto &e:es){
        cin >> e.s >> e.d >> e.c;
        --e.s;
        --e.d;
    }
    sort(es.begin(),es.end());

    int min_cost=0;
    vector<int> candidate;
    {
        union_find uf(n);
        rep(i,0,m){
            auto &e=es[i];
            if(uf.is_same(e.s,e.d)) continue;
            candidate.push_back(i);
            uf.unite(e.s,e.d);
            min_cost+=e.c;
        }
    }

    int ans_num=0,ans_cost=0;
    for(int id:candidate){
        union_find uf(n);
        int cost=0;
        rep(i,0,m){
            if(i==id) continue;
            auto &e=es[i];
            if(uf.is_same(e.s,e.d)) continue;
            uf.unite(e.s,e.d);
            cost+=e.c;
        }
        if(cost==min_cost and uf.cnt==1) continue;
        ++ans_num;
        ans_cost+=es[id].c;
    }
    cout << ans_num << " " << ans_cost << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	double mid = 0;
	rep(i, N) {
		mid += a[i];
	}
	mid /= N;
	int ans = 0;
	double minv = 1e8;
	rep(i, N) {
		if (minv > abs(mid - a[i])) {
			ans = i;
			minv = abs(mid - a[i]);
		}
	}
	cout << ans << endl;
	
	return 0;

}

Measured memory_bytes: 256
s=input()
n=len(s)
a,b,c=0,0,0
for i in range(n):
  if s[i]=="a":
    a+=1
  elif s[i]=="b":
    b+=1
  elif s[i]=="c":
    c+=1
if max(a,b,c)-min(a,b,c)<=1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 39536
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    rep(k,K,N+2){
        ll min_num = k*(k-1)/2;
        ll max_num = N*(N+1)/2 - (N-k)*(N-k+1)/2;
        // print(k,min_num, max_num);

        ans += max_num - min_num + 1;
        ans %= MOD;
    }
    print(ans);

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
vector<bool> Prime(100010, true);
vector<int64_t> S(100010, 0);

void init()
{
  for (int n = 2; n <= 100000; n++)
  {
    Prime.at(0) = false;
    Prime.at(1) = false;
    if (Prime.at(n))
    {
      for (int m = 2 * n; m <= 100000; m += n)
        Prime.at(m) = false;
    }
  }
}

int main()
{
  int64_t Q, l, r;
  cin >> Q;
  vector<pair<int64_t, int64_t>> lr(Q);
  for (int i = 0; i < Q; i++)
  {
    cin >> l >> r;
    lr.at(i) = make_pair(l, r);
  }
  init();
  for (int i = 3; i <= 100000; i += 2)
  {
    S.at(i) += S.at(i - 2);
    if (Prime.at(i) && Prime.at((i + 1) / 2))
      S.at(i)++;
  }
  for (int i = 0; i < Q; i++)
  {
    if (lr.at(i).first != 1)
      cout << S.at(lr.at(i).second) - S.at(lr.at(i).first - 2) << endl;
    else
      cout << S.at(lr.at(i).second) << endl;
  }
}


Measured memory_bytes: 2944
S = int(input())
x = S//100
y = S%100
yymm = (1<=y<=12)
mmyy = (1<=x<=12)

ans = "NA"
if yymm and mmyy:
    ans = 'AMBIGUOUS'
elif yymm and not(mmyy):
    ans = 'YYMM'
elif mmyy and not(yymm):
    ans = 'MMYY'

print(ans)  

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



ll cnt[100];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll a,b; cin >> a >> b ;
  vector<string> str;

  rep(i,a){
    string inp; cin >> inp;
    str.pb(inp);
  }


  rep(i,b+2) cout << "#" ;
  cout << endl;
  rep(i,a){
    cout << "#" << str[i] << "#" << endl;
  }
  rep(i,b+2) cout << "#" ;
  cout << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main()
{
	char str[90];
	
	while( fgets( str, 81, stdin ) != 0 ){
		while( 1 ){
			for( int i = 0; i < strlen( str ); i++ ){
				if( isalpha( str[i] ) ) str[i]++;
				
				if( str[i] > 'z' ){
				 	str[i] = 'a';
				}
			}
			
			if( strstr( str, "the" ) != NULL || strstr( str, "this" ) != NULL || strstr( str, "that" ) != NULL ) break;
		}
		
		std::cout << str;
	}

 	return 0;
}

Measured memory_bytes: 1100
import java.util.*;
    public class Main {// Main
        public static void main(String[] args){
           Scanner sc = new Scanner(System.in);
          int n = sc.nextInt();
          int a = sc.nextInt();
          int b = sc.nextInt();
          int c = sc.nextInt();
          int d = sc.nextInt();
          String s  = sc.next();
          s = " " + s;
          int v = 1;
          for(int i=a;i<c-1;i++){
          if(s.substring(i,i+2).equals("##")) { v=0; break; }
          }
        
      for(int i=b;i<d-1;i++){
        if(v==0) break;
          if(s.substring(i,i+2).equals("##")) { v=0; break; }
          }
          int putin = 0;
       if(d<c && v==1){
         for(int i=b-1;i<d;i++){
           if(s.substring(i,i+3).equals("...")) { putin = 1; break; }
        }
        if(putin==1) v=1;
        else v=0;
    }		
          if(v==1) System.out.println("Yes");
          else System.out.println("No");
        }
    }

Measured memory_bytes: 41116
#include <iostream>
#include <array>
#include <cstdint>
#include <algorithm>

int main()
{
	std::size_t NumOfStick;
	std::array<std::uint32_t, 200> length;

	std::cin >> NumOfStick;
	NumOfStick <<= 1;

	for (std::size_t i = 0; i < NumOfStick; i++) {
		std::cin >> length.at(i);
	}

	std::sort(length.begin(), length.begin() + NumOfStick);

	std::uint32_t total = 0;

	for (std::size_t i = 0; i < NumOfStick; i += 2) {
		total += length.at(i);
	}
	std::cout << total << std::endl;

	return 0;
}

Measured memory_bytes: 256