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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll m=0;
  ll a=0;
  ll r=0;
  ll c=0;
  ll h=0;
  ll n;
  cin >> n;
  REP(i,n){
    string s;
    cin >> s;
    if(s[0]=='M') m++;
    if(s[0]=='A') a++;
    if(s[0]=='R') r++;
    if(s[0]=='C') c++;
    if(s[0]=='H') h++;
  }

  ll ans = 0;
  ans += m * a * r;
  ans += m * a * c;
  ans += m * a * h;
  ans += m * r * c;
  ans += m * r * h;
  ans += m * c * h;
  ans += a * r * c;
  ans += a * r * h;
  ans += a * c * h;
  ans += r * c * h;

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  vector<ld> p(n);
  rep(i,n){
    cin>>p[i];
  }

  ld ans[n+10][n+10]={};
  ans[0][0]=1.0;
  rep(i,n){
    rep(j,n+1){
      ans[i+1][j+1]+=ans[i][j]*p[i];
      ans[i+1][j]+=ans[i][j]*(1-p[i]);
    }
  }


  ld z=0.0;
    rep(i,n+1){
      if(i>n-i) z+=ans[n][i];
    }

  cout << fixed << setprecision (20);
  cout << z << endl;
}


Measured memory_bytes: 141824
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[N][j][A * j]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 56564
#include <stdio.h>

int
main(void)
{
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);

	int rec1 = A * B;
	int rec2 = C * D;

	int res;
	if (rec1 > rec2)
		res = rec1;
	else if (rec1 < rec2)
		res = rec2;
	else
		res = rec1;

	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int end = str.length();
		HashSet<Character> set = new HashSet<>();
		ArrayDeque<Suffix> deq = new ArrayDeque<>();
		for (int i = str.length() - 1; i >= 0; i--) {
		    set.add(str.charAt(i));
		    if (set.size() == 26) {
		        deq.push(new Suffix(str.substring(i, end)));
		        end = i;
		        set.clear();
		    }
		}
		Suffix suf = new Suffix(str.substring(0, end));
		StringBuilder sb = new StringBuilder();
		char c = suf.getFirst(0);
		sb.append(c);
		while (deq.size() > 0) {
		    Suffix tmp = deq.pop();
		    c = tmp.getFirst(c);
		    sb.append(c);
		}
		System.out.println(sb);
	}
	
	static class Suffix {
	    String value;
	    
	    public Suffix (String value) {
	        this.value = value;
	    }
	    
	    public char getFirst(char c) {
	        return getFirst(value.indexOf(c) + 1);
	    }
	    
	    public char getFirst(int idx) {
	        HashSet<Character> set = new HashSet<>();
	        for (int i = idx; i < value.length(); i++) {
	            set.add(value.charAt(i));
	        }
	        for (char c = 'a'; c <= 'z'; c = (char)(c + 1)) {
	            if (!set.contains(c)) {
	                return c;
	            }
	        }
	        return 'X';
	    }
	    
	}
}


Measured memory_bytes: 38024
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define M 1000000007
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	int n;
	cin >> n;
	int a[n+1]={0};
	for(int i=0;i<n-1;i++){
		int num;
		cin >> num;
		a[num]++;
	}
	for(int i=0;i<n;i++){
		cout << a[i+1] << endl;
	}
} 

Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
//a power n mod p
long long int modp(lld a,lld p,lld n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    lld fac[n+1]; 
    fac[0] = 1; 
    for (lld i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
   // cin>>t;
    lld n,i,j,ans=0,y,z,x;
    string s;
    vector<vector<long long int > > v(3);
    cin>>n>>s;
    lld a[3];
    a[0]=a[1]=a[2]=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='R') v[0].pb(i);
        else if (s[i]=='G') v[1].pb(i);
    }
    a[0]=v[0].size();
    a[1]=v[1].size();
    a[2]=n-a[0]-a[1];
   // cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" ";
    for(i=0;i<a[0];i++)
    {
        for(j=0;j<a[1];j++)
        {
            x= 2*v[1][j]-v[0][i];
            y= 2*v[0][i]-v[1][j];
            z= v[0][i]+v[1][j];
            if(z%2==1) z=-1;
            else z/=2;
            ans+=a[2];
            if(x>=0 && x<n && s[x]=='B')
            {
                 ans+=-1;
            }
            if(y>=0 && y<n && s[y]=='B')
            {
                 ans+=-1;   
            }
            if(z>=0 && z<n && s[z]=='B')
            {
                 ans+=-1;   
            }
            
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3712
N = int(input())
mod = 10 ** 9 + 7

# GAC, ACG, A?GC, AG?C, AGC
last_a = [1, 4, 16]
last_g = [1, 4, 15]
last_c = [1, 4, 14]
last_t = [1, 4, 16]
for i in range(3, N):
    last_a.append(last_a[i - 1] + last_g[i - 1] + last_c[i - 1] + last_t[i - 1])
    last_g.append(last_a[i - 1] + last_g[i - 1] + (last_c[i - 1] - last_a[i - 2] + last_g[i - 3]) + last_t[i - 1])
    last_c.append((last_a[i - 1] - last_g[i - 2]) + (last_g[i - 1] - last_a[i - 2] - (last_a[i - 3] * 2)) + last_c[i - 1] + (last_t[i - 1] - last_a[i - 3]))
    last_t.append(last_a[i - 1] + last_g[i - 1] + last_c[i - 1] + last_t[i - 1])

N -= 1
print((last_a[N] + last_g[N] + last_c[N] + last_t[N]) % mod)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int a,b;
vector<int> as, bs;

bool canMake(int f, int e)
{
	int l = e - f + 1;
	int c = 0;
	for (int i = 0; i < a; i++)
	{
		if(as[i] == bs[f + c])
		{
			c++;
			if(l == c)
				return true;
		}
	}
	return false;
}

int main(void)
{
	while(cin >> a >> b && a && b)
	{
		as.resize(a);
		bs.resize(b);
		for (int i = 0; i < a; i++)
		{
			cin >> as[i];
		}
		for (int i = 0; i < b; i++)
		{
			cin >> bs[i];
		}

		int left = 0, right = 0;
		int ans = 0;
		for (int i = 0; left + ans < b; i++)
		{
			if(canMake(left, right))
			{
				ans = max(ans, right - left + 1);
				right++;
			}
			else
			{
				left++;
				right = max(right, left);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
N = int(input())
S = list(input() for _ in range(N))

ac = 0
wa = 0
tle = 0
re = 0

for s in S:
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    elif s == "RE":
        re += 1

print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 16172
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<list>

using namespace std;

/*
125

125
1 + 25 + 12 + 5
1 + 2 + 5

176

*/

char s[11];

bool bit(int n, int i){
  // From right
  int ret;
  ret = (n >> i) & 1;
  fprintf(stderr, "bit(%d, %d) = %d\n", n, i, ret);
  return ret;
}

long long int pow(int x, int n){
  if(n == 0)
    return 1;

  return x * pow(x, n - 1);
}

long long int calc(char* str, int n){
  fprintf(stderr, "--- %s, %d ---\n", str, n);
  
  long long int a = atoll(str);
  fprintf(stderr, "a = %lld\n", a);

  if(strlen(str) == 1)
    return a;

  long long int sum = 0;
  int cnt = 0;
  for(int i = 0; i < strlen(str) - 1; i++){
    if(bit(n, i)){
      // insert + at the position i from right
      long long int d = a % pow(10, cnt + 1);
      sum += d;
      a /= pow(10, cnt + 1);
      cnt = 0;

      fprintf(stderr, "%d\n", d);
    } 
    else
      cnt++;
  }
  sum += a;

  fprintf(stderr, "%lld\nsum = %lld\n", a, sum);

  return sum;
}

int main(){
  scanf("%s\n", s);

  long long int ans = 0;
  for(int i = 0; i < pow(2, strlen(s) - 1); i++){
    ans += calc(s, i);
  }
  printf("%lld\n", ans);

  return 0;
}


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

int main(void){
    
    int n, x;
    cin>>n>>x;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    
    int idx=n;
    int vmin=x;
    int cnt=0;
    for(int i=0; i<n; i++){
        x-=a[i];
        cnt++;
        if(vmin>a[i]){
            vmin=a[i];
            idx=i;
        }
    }
    
    while(x>=vmin){
        cnt++;
        x-=vmin;
    }
    
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;


int main() {
  int n, k;
  string s;

  cin >> n >> k >> s;
  s[k - 1] = tolower(s[k - 1]);
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
/*
17D8101031C 杉山　祥吾 ID:keisei334 c++
*/

#include<iostream>
#include<cmath>

using namespace std;

struct Point{
  double x;
  double y;
};

void KochCurve(int n,Point a,Point b){
  Point s,t,u;
  double th;

  if(n==0) return;

  th = M_PI * 60.0 / 180.0;
  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  KochCurve(n - 1, a, s);
  cout<<s.x<<" "<<s.y<<"\n";
  KochCurve(n - 1, s, u);
  cout<<u.x<<" "<<u.y<<"\n";
  KochCurve(n - 1, u, t);
  cout<<t.x<<" "<<t.y<<"\n";
  KochCurve(n - 1, t, b);
}

int main(){
  Point a,b;
  int n;
  
  cin>>n;

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  cout<<a.x<<" "<<a.y<<"\n";
  KochCurve(n,a,b);
  cout<<b.x<<" "<<b.y<<"\n";

  return 0;
}

/*実行結果
1
0 0
33.3333 0
50 28.8675
66.6667 0
100 0

2
0 0
11.1111 0
16.6667 9.6225
22.2222 0
33.3333 0
38.8889 9.6225
33.3333 19.245
44.4444 19.245
50 28.8675
55.5556 19.245
66.6667 19.245
61.1111 9.6225
66.6667 0
77.7778 0
83.3333 9.6225
88.8889 0
100 0
*/



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

import sys
import os
import math

for s in sys.stdin:
    n, m = map(int, s.split())
    if n == m == 0:
        break

    lst = [i for i in range(1, n+1)]

    remove_index = m - 1
    while len(lst) > 1:
        del lst[remove_index]

        # next index
        remove_index += (m - 1)
        if remove_index >= len(lst):
            remove_index = remove_index % len(lst)

    print(lst[0])

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

using namespace std;

#define int long long

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, n, ans = 0;
    cin >> a >> b >> n;
    for (int i = n - 1; i <= n; ++i) ans = max(ans, a * i / b - a * (i / b));
    if (n >= b - 1 && b > 1) {
        int x = b - 1 + (n - b + 1) / (b - 1) * (b - 1);
        ans = max(ans, a * x / b - a * (x / b));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vct vector<ll>
#define vpp vector<pair<ll,ll> >
#define ump unordered_map<ll,ll>
#define smp map<ll,ll>
#define st set<ll>
int main()
{
    string s;cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(s[i]=='L')
            {
                cout<<"No";
                return 0;
            }
        }
        else
        {
            if(s[i]=='R')
            {
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    
    for(int i=A; i<=A+K-1; i++)
    {
       if(i<=B) cout << i << endl;
    }
    
        
    for(int i=B-K+1; i<=B; i++)
    {
       if(i>A+K-1) cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define N 65000
using namespace std;
typedef long long ll;

int main(){
  ll n,p,j[N],a,c;
  while(1){
    cin>>n;
    if(!n) break;
    c=0;
    for(int i=0;i<n;i++) cin>>p,c+=p;
    for(int i=0;i<n-1;i++) cin>>j[i],c+=j[i];
    sort(j,j+n-1);
    a=c;
    for(int i=0;i<n-1;i++) c-=j[i],a=max(a,c*(i+2));
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1676
#define _CRT_NO_SECURE_WARNINGS
#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <string>
#include <iomanip>
#include <set>
#include <random>
#include <queue>
#include <map>
#include <ctime>
#include <sstream>
#include <cstdlib>
using namespace std;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std; int INF = 1e6; typedef long long ll; typedef double d; typedef unsigned long long ull;

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	int first = a, s = b, th = c;
	vector<int>test(3);
	test[0] = first;
	test[1] = s;
	test[2] = th;
	sort(test.begin(), test.end());
	c == test[1] ? cout << "Yes" << endl : cout << "No" << endl;
	
}

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

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

#define SLAY ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0);
#define LL long long
#define PII pair<int , int>
#define PLL pair<long long , long long>
#define INPUT freopen("/Users/amrfahmy/Documents/Problem solving/CF/CF/input.txt", "r", stdin);
using namespace std;
 
const LL MOD = 1000000007;
LL arr[1000000];
LL b[1000];
LL n,q,c,cnt,mx,m,temp,k;
string str;



bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
    return (a.first < b.first);
}

int main()
{
    bool readfromfile=false; if(!readfromfile){SLAY} else{INPUT}
    
 

    cin>>n>>m;
    //for(int i = 0 ; i < n ; i++)cin>>arr[i];
   
    if((n==2 && m==3) || (n==3 && m==2 ))cout<<1;
    if((n==1 && m==2) || ( n==2 && m==1))cout<<3;
    if((n==1 && m==3) || (n==3 && m==1))cout<<2;

    return 0;
}
 



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;

constexpr int UNKNOWN = (1 << 25);

void solve(vector<vector<int>> &matrix) {
  const int h = matrix.size();
  const int w = matrix[0].size();

  vector<vector<bool>> is_question(h - 1, vector<bool>(w - 1));
  vector<pair<int, int>> questions; // r, c
  vector<int> num_qr(h - 1, 0), num_qc(w - 1, 0);
  vector<int> sum_r(h - 1, 0), sum_c(w - 1, 0);

  for(int i = 0; i < h - 1; ++i) {
    sum_r[i] += matrix[i][w - 1];
  }

  for(int i = 0; i < w - 1; ++i) {
    sum_c[i] += matrix[h - 1][i];
  }

  for(int i = 0; i < h - 1; ++i) {
    for(int j = 0; j < w - 1; ++j) {
      if(matrix[i][j] == UNKNOWN) {
	questions.emplace_back(i, j);
	++num_qr[i];
	++num_qc[j];
	is_question[i][j] = true;
      }
      else {
	sum_r[i] -= matrix[i][j];
	sum_c[j] -= matrix[i][j];
      }
    }
  }

  while(!questions.empty()) {
    bool unloop = true;
    int i = 0;

    while(i < questions.size()) {
      const int r = questions[i].first;
      const int c = questions[i].second;

      int value = UNKNOWN;
      if(num_qr[r] == 1) {
	value = sum_r[r];
      }
      else if(num_qc[c] == 1) {
	value = sum_c[c];
      }

      if(value == UNKNOWN) {
	++i;
	continue;
      }

      matrix[r][c] = value;
      sum_r[r] -= value;
      sum_c[c] -= value;
      --num_qr[r];
      --num_qc[c];
      unloop = false;
      questions.erase(questions.begin() + i);
    }

    if(unloop) break;
  }

  if(questions.empty()) { // unique answer
    for(int i = 0; i < h - 1; ++i) {
      for(int j = 0; j < w - 1; ++j) {
	if(is_question[i][j]) {
	  cout << matrix[i][j] << endl;
	}
      }
    }
  }
  else {
    cout << "NO" << endl;
  }
  //cout << endl;
}

int main(){
  bool first = true;
  for(int p, s; cin >> p >> s && p;) {
    if(!first) cout << endl;
    first = false;

    vector<vector<int>> matrix(p + 1, vector<int>(s + 1));
    for(auto &row : matrix) {
      for(auto &e : row) {
	string input;
	cin >> input;
	e = (input == "?" ? UNKNOWN : stoi(input));
      }
    }

    solve(matrix);
  }

  return 0;
}

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    int A, B;
    cin >> A >> B;
    int ans = -1;
    for(int i = 0; i <= 1250; i++){
        int a = i*0.08;
        int b = i*0.1;
        if(a==A && b==B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


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

signed main(){
  int N;
  cin>>N;
  string ans="No";
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j==N){
        ans="Yes";
        break;
      }
    }
  }
  cout<<ans<<endl;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S;
    cin >> S; 
    int K;
    cin >> K;
    map<string, int> m;
    for (int i = 1; i < S.length()+1; i++) {
        if (S.length() > 50 && i > 10) {
            break;
        }
        for (int j = 0; j < S.length()-i+1; j++) {
            string sub = S.substr(j, i);
            m[sub] = 1;
        }
    }
    int cnt = 0;
    for (auto item : m) {
        cnt++;
        if (cnt == K) {
            print(item.first);
            break;
        }
    }

}

signed main() {
    solve();
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    ll n,m,ans=0;
    cin >> n >> m;
    priority_queue<pair<ll,ll> > que;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        que.push(make_pair(a,1));
    }
    for (ll i=0;i<m;i++){
        ll b,c; 
        cin >> b >> c;
        que.push(make_pair(c,b));
    }
    for (ll i=0;i<n;i++){
        pair<ll,ll> p=que.top();
        que.pop();
        ans+=p.first;
        if (p.second>1){
            que.push(make_pair(p.first,p.second-1));
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int INF = 1e9;

int N, K;
int A[50];
vector<int> cat() {
  int lack[50];
  for (int i = 0; i < N; ++i) {
    lack[i] = max(0, (K + 1) - A[i]);
  }
  
  vector<int> seq;
  int prev = -1;
  while (true) {
    bool all = true;
    for (int i = 0; i < N; ++i) {
      if (lack[i] > 0) all = false;
    }
    if (all) break;
    
    int mxi = 0;
    int mx = -INF;
    for (int i = 0; i < N; ++i) {
      if (i == prev) continue;
      if (lack[i] > mx) {
        mx = lack[i];
        mxi = i;
      }
    }
    seq.push_back(mxi);
    --lack[mxi];
    prev = mxi;
  }
  
  return seq;
}

vector<int> sub() {
  int C[50] = {};
  int V[50] = {};
  vector<int> seq = cat();
  
  int prev = -1;
  vector<int> ans;
  
  for (int v : seq) {
    for (int i = 0; i < N; ++i) {
      if (i == prev) continue;
      if (i == v) continue;
      ans.push_back(i);
      ++C[i];
      ++V[i];
    }
    ans.push_back(v);
    ++C[v];
    V[v] += 2;
    prev = v;
  }
  
  for (int i = 0; i < N; ++i) {
    if (C[i] > A[i]) return vector<int>();
  }
  
  int st = (prev + 1) % N;
  for (int z = 0; z <= K; ++z) {
    for (int i = 0; i < N; ++i) {
      int idx = (st + i) % N;
      if (V[idx] < K + 1) {
        ans.push_back(idx);
        ++V[idx];
      }
    }
  }
  
  return ans;
}

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  
  vector<int> ans = sub();
  if (ans.empty()) {
    cout << -1 << endl;
  } else {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); ++i) {
      cout << ans[i] + 1 << (i + 1 == ans.size() ? '\n' : ' ');
    }
  }
}

Measured memory_bytes: 640
"""
E問題
繋がっている都市同士は同じ州にあっても違う州にあってもよい→考えにくい
→「繋がっていない都市は必ず違う州にある」のほうが考えやすい
→繋がっていない都市にすべて辺を張って二部グラフが構成できるかどうかで判定できそう？
（必要条件ではあるけど十分条件であるかどうかはわからない）
→この条件だと同じ州にあるなら必ず任意の二都市間は繋がっているので十分条件も満たしてそう！
（∵繋がっていない都市に辺を張った時同じ州内に辺を持たないため）

（繋がっていない都市に辺を張った）グラフが連結⇒都市の選び方は高々1通り
連結でないなら複数の選び方が存在する
→最小となるような選び方はどのように決めればよいか？
→それぞれの連結成分ごとに、片方にai都市、もう片方にbi都市振り分けられるとすると
L = [[a1, b1], [a2, b2], ... , [ak, bk]]
とできて、(sum(A)+sum(B) == n)
s = Σ[i = 1 to k](aiかbiのどちらかを選んで足す)　としたときに
もっともsがn//2に近くなるようにsを選べばよく、これはdpでO(nk)でできる
"""
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import numpy as np

n, m = map(int, input().split())
G = [{i for i in range(n) if i != j} for j in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].remove(b)
  G[b].remove(a)

seen = [-1]*n
L = []
def is_bipartite(v, color):
  seen[v] = color
  L[-1][color] += 1
  for i in G[v]:
    if seen[i] != -1:
      if seen[i] == color:
        return False
    else:
      if not is_bipartite(i, color^1):
        return False
  return True

for i in range(n):
  if seen[i] == -1:
    L.append([0, 0])
    if not is_bipartite(i, 0):
      print(-1)
      break
else:
  dp = np.zeros((len(L)+1, n+1), dtype=bool)
  dp[0, 0] = True
  for i, ab in enumerate(L):
    a, b = ab
    dp[i+1, a:] |= dp[i, :n+1-a]
    dp[i+1, b:] |= dp[i, :n+1-b]
  temp = n//2
  dp = dp[-1].tolist()
  while not dp[temp]:
    temp += 1
  r = n - temp
  print(temp*(temp-1)//2 + r*(r-1)//2)

Measured memory_bytes: 44788
#include <iostream>
#include <vector>
using namespace std;
int X,Y;
char map[100][100];
bool used[100][100];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

bool input(){
	cin >> X >> Y;
	if(X == 0 && Y == 0) return false;
	for(int i = 0;i < X;++i){
		for(int j = 0;j < Y;++j){
			cin >> map[i][j];
		}
	}
	fill(used[0],used[0]+100*100,false);
	return true;
}

void dfs(int sx,int sy,char symbol){
	used[sx][sy] = 1;
	for(int i = 0;i < 4;++i){
		int cx = sx + dx[i],cy = sy + dy[i];
		if(cx >= 0 && cy >= 0 && cx < X && cy < Y && !used[cx][cy] && map[cx][cy] == symbol){
			dfs(cx,cy,symbol);
		}
	}
}

int main(){
	while(input()){
		int res = 0;
		for(int i = 0;i < X;++i){
			for(int j  = 0;j < Y;++j){
				if(!used[i][j]){
					char crt = map[i][j];
					dfs(i,j,crt);
					++res;
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, m;
    cin >> n >> m;
    ll sx[n], sy[n], cx[m], cy[m];
    for (int i = 0; i < n; i++) {
        cin >> sx[i] >> sy[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> cx[i] >> cy[i];
    }
    ll d, min, min_num;
    for (int i = 0; i < n; i++) {
        min = 10000000000000;
        for (int j = 0; j < m; j++) {
            d = abs(sx[i] - cx[j]) + abs(sy[i] - cy[j]);
            if (min > d) {
                min = d;
                min_num = j;
            }
        }
        cout << min_num + 1 << endl;
    }
    return 0;
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  bool a=false;
  if(A==7 && B==5 && C==5){
    a=true;
  }
  else if(A==5 && B==7 && C==5){
    a=true;
  }
  else if(A==5 && B==5 && C==7){
    a=true;
  }
  if(a){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

int main(){
  
  int n;
  float x,total;
  string u;
  
  cin >> n;
  
  for(int i=0; i<n; i++){
    cin >> x >> u;
    if(u == "JPY"){
      total += x;
    }else{
      total += 380000.0*x;
    }
  }
  
  cout << total << endl;

}
  
  
  

Measured memory_bytes: 256
from math import factorial

n=int(input())
p=[int(i)-1 for i in input().split()]
q=[int(i)-1 for i in input().split()]

plst=[i for i in range(n)]
qlst=[i for i in range(n)]
pls=[]
qls=[]

for i in p:
    a=plst.index(i)
    pls.append(a)
    plst.remove(i)
for i in q:
    a=qlst.index(i)
    qls.append(a)
    qlst.remove(i)

ansp=1
ansq=1

for i in range(n):
    ansp+=pls[i]*(factorial(n-i-1))
for i in range(n):
    ansq+=qls[i]*(factorial(n-i-1))
    
print(abs(ansp-ansq))

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

int main(void){
 
  int N,c=0;
  cin >> N;
  int data[N];
  
  for(int i=0;i<N;i++) cin >> data[i];
  
  sort(data,data+N);
  
  for(int i=0;i<N;i++){
      if(i != N-1) c+= data[i];
      if(i == N-1) c+= (data[i] / 2);
  }
  cout << c << endl;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
using namespace std;

typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

int main(){
  int N;
  cin >> N;
  cout << N/2+N%2 << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> in(N + 1);
  for (int i = 1; i < N + 1; i++) cin >> in[i];

  int cnt = 0;
  for (int i = 1; i < N; i++) {
    if (in[i] == i) {
      swap(in[i], in[i + 1]);
      cnt++;
    }
  }
  if (in[N] == N) cnt++;

  cout << cnt << endl;

  return 0;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int n;
int cnt[105];
ll dp[105];

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    cin >> n;

    FORN(i,2,n){
        int val=i;

        for(int j=2;val>1;j++){
            while(val%j==0){
                cnt[j]++;
                val/=j;
            }
        }
    }

    dp[1]=1;

    FORN(i,1,100){
        if(cnt[i]){
            FORRN(j,75,1){
                FORN(x,1,cnt[i]){
                    if(j*(x+1)<=75)
                        dp[j*(x+1)]+=dp[j];
                }
            }
        }
    }

    cout << dp[75] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
void solve()
{
    int n;
    ll m;
    cin>>n>>m;
    ll a[n],lc;
    for(int i=0;i<n;i++)
    cin>>a[i];
    a[0]/=2;
    lc=a[0];
    int co=0;
    if(lc&1)
    co++;
    for(int i=1;i<n;i++)
    {
        a[i]/=2;
        if(a[i]&1)
        co++;
        ll g=__gcd(lc,a[i]);
        lc = lc/g;
        lc=(lc*a[i]);
        if(lc>m)
        {
            cout<<0<<endl;
            return;
        }
    }
    //cout<<lc<<endl;
    if((lc>m))
    cout<<0<<endl;
    else if(lc%2==0)
    {
        if(co!=0)
        cout<<0<<endl;
        else
        {
            for(int i=0;i<n;i++)
            {
                if((lc/a[i])&1)
                continue;
                cout<<0<<endl;
                return;
            }
            cout<<(m-lc)/(2*lc)+1<<endl;
        }
    }
    else
    {
        if(co!=n)
        cout<<0<<endl;
        else
        cout<<(m-lc)/(2*lc)+1<<endl;
    }
}
int main()
{
    solve();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef tuple<int, int, int> T;

int N, M;
vector<int> G[1010], rG[1010];
vector<T> edges;
bool flag1[1010], flag2[1010];
int dist[1010];

void bfs1() {
    deque<int> q;
    q.pb(0);
    flag1[0] = true;
    
    while (q.size()) {
        int v = q.front(); q.pop_front();
        rep(i, G[v].size()) {
            int nv = G[v][i];
            if (flag1[nv]) continue;
            flag1[nv] = true;
            q.pb(nv);
        }
    }
}

void bfs2() {
    deque<int> q;
    q.pb(N-1);
    flag2[N-1] = true;
    
    while (q.size()) {
        int v = q.front(); q.pop_front();
        rep(i, rG[v].size()) {
            int nv = rG[v][i];
            if (flag2[nv]) continue;
            flag2[nv] = true;
            q.pb(nv);
        }
    }
}

int bellman_ford() {
    rep(i, N) dist[i] = 1000000000000000;
    dist[0] = 0;
    rep(i, N) rep(j, M) {
        int a = get<0>(edges[j]), b = get<1>(edges[j]), c = get<2>(edges[j]);
        if (flag1[a] && flag2[b] && dist[b]>dist[a]+c) {
            dist[b] = dist[a]+c;
            if (i==N-1) return -1000000000000000;
        }
    }
    return dist[N-1];
}

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        G[a-1].pb(b-1);
        rG[b-1].pb(a-1);
        edges.pb(make_tuple(a-1, b-1, -c));
    }
    
    rep(i, N) flag1[i] = false;
    rep(i, N) flag2[i] = false;
    bfs1();
    bfs2();
    int ans = -bellman_ford();
    if (ans==1000000000000000) cout << "inf" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

import static java.lang.Integer.parseInt;

/**
 * Parentheses
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		Deque<Character> stackP = new ArrayDeque<>();
		Deque<Integer> stackX = new ArrayDeque<>();
		stackP.push('\0');
		stackX.push(-1);

		int n = parseInt(br.readLine());

		for (int i = 0; i < n; i++) {

			line = br.readLine();

			char p = line.charAt(0);
			int x = parseInt(line.substring(line.indexOf(' ') + 1));

			if (stackP.peek() == p) {
				x += stackX.pop();
				stackX.push(x);
			} else if (stackP.peek() == '(' && p == ')') {
				if (stackX.peek() == x) {
					stackX.pop();
					stackP.pop();
				} else if (stackX.peek() > x) {
					int y = stackX.pop() - x;
					stackX.push(y);
				} else {
					stackP.pop();
					x -= stackX.pop();
					stackP.push(p);
					stackX.push(x);
				}
			} else {
				stackP.push(p);
				stackX.push(x);
			}
		}

		System.out.println(stackX.peek() == -1 ? "YES" : "NO");

	}
}

Measured memory_bytes: 25344
#include <iostream>
#include <string.h>
 
using namespace std;
bool Flag[100002];
 
void solve()
{
    int n;
    while(cin >> n, n)
    {
        memset(Flag, 0, sizeof(Flag));
		int last_input = 0;
        for(int i = 0; i < n; ++i)
        {
            int input;
            cin >> input;
			last_input = input;
            Flag[input] = true;
        }
        int first_flag = true;
        for(int i = 1; i <= last_input; ++i)
        {
            if(Flag[i])
            {
                if(!first_flag)
                {
                    cout << " ";
				}
				first_flag = false;
                int pos = i + 1;
                while(Flag[pos] == true)
                {
                    ++pos;
                }
                if(pos == i + 1)
                {
                    cout << i;
                }
                else
                {
                    cout << i << "-" << pos - 1;
                }
                i = pos;
            }   
        }
        cout << endl;
    }
}
 
int main()
{
    solve();
    return(0);
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    ll a[n];
    a[0] = 0;
    repd(i, 1, n) { cin >> a[i]; }
    ll count[n] = {};
    repd(i, 1, n) { count[a[i] - 1]++; }

    rep(i, n) { cout << count[i] << endl; }
    return 0;
}



Measured memory_bytes: 6748
def main():

    n,k = map(int,input().split())
    l = [0] * n
    for i in range(k):
        d = int(input())
        listA=list(map(int,input().split()))
        for j in range(d):
            l[listA[j]-1] += 1

    print(l.count(0))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9192
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int x;cin>>x;
    if (x <= 599) {
        cout << 8 << endl;
    }
    else if (x <= 799) {
        cout << 7 << endl;
    }
    else if (x <= 999) {
        cout << 6 << endl;
    }
    else if (x <= 1199) {
        cout << 5 << endl;
    }
    else if (x <= 1399) {
        cout << 4 << endl;
    }
    else if (x <= 1599) {
        cout << 3 << endl;
    }
    else if (x <= 1799) {
        cout << 2 << endl;
    }
    else if (x <= 1999) {
        cout << 1 << endl;
    }

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3648
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int n, k;
    cin >> n >> k;

    cout << (n - 1 + k - 2) / (k - 1) << endl;

    return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	vll dp1(n+1), dp2(n+1);
	dp1[0] = 0, dp2[0] = 1;
	for (int i = 1; i <= n; i++) {
		if (s[i-1] == '0') {
			dp1[i] = (3 * dp1[i-1]) % MOD;
			dp2[i] = dp2[i-1];
		}
		else {
			dp1[i] = (3 * dp1[i-1] + dp2[i-1]) % MOD;
			dp2[i] = (2 * dp2[i-1]) % MOD;
		}
	}

	ll answer = (dp1[n] + dp2[n]) % MOD;
	cout << answer << endl;
}


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

int N;

void add(int a, int w, vector<int> &bit) 
{
    for (int x = a; x <= N; x += x & -x) bit[x] += w;
}
int sum(int a, vector<int> &bit) {
    int ret = 0;
    for (int x = a; x > 0; x -= x & -x) ret += bit[x];
    return ret;
}

void test(vector<vector<int>> &grid)
{
    for (int i = 0; i < 26; i++)
    {
        for (int j = 1; j <= N; j++) cout << sum(j, grid[i]) - sum(j - 1, grid[i]) << " ";
        cout << endl;
    }
}

int main()
{
    cin >> N;
    string s;
    cin >> s;
    vector<vector<int>> BIT(26, vector<int>(N + 1, 0));
    for (int i = 0; i < N; i++){
        add(i + 1, 1, BIT[s[i] - 'a']);
    }
    int q;
    cin >> q;
    int a, b;
    for (int i = 0; i < q; i++)
    {
        cin >> a >> b;
        if (a == 1)
        {
            char c;
            cin >> c;
            if (sum(b, BIT[c - 'a']) - sum(b - 1, BIT[c - 'a']) == 1) continue;
            int tmp;
            for (int j = 0; j < 26; j++)
            {
                if (sum(b, BIT[j]) - sum(b - 1, BIT[j]) == 1){
                    tmp = j;
                    break;
                }
            }
            add(b, 1, BIT[c - 'a']);
            add(b, -1, BIT[tmp]);
        }
        else {
            int c;
            cin >> c;
            int tmp = 0;
            for (int j = 0; j < 26; j++)
            {
                tmp += (sum(c, BIT[j]) - sum(b - 1, BIT[j]) > 0);
            }
            cout << tmp << endl;
        }
    }
}

Measured memory_bytes: 53764
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n, k, ans;

void solve()
{
    cin >> n >> k;
    for (int i = 1; i <= n;++i)
    {
        int x;
        cin >> x;
        if(x>=k)
            ans++;
    }
    cout << ans;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long s1=min(a,b);
    long long s2=min(c,d);
    cout<<s1+s2<<endl;
    return 0;
}

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

using namespace std;

int main(void) {
  double v;
  while (cin >> v) {
    int n = 0;
    while (n - v * v / (19.6 * 5) - 1.0 < -1e-10) {
      n++;
    }
    cout << n << endl;
  }

  return 0;
}


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

int main(){
	int b,r,g,c,s,t;
	while(cin >> b >> r >> g >> c >> s >> t,b || r || g || c || s || t){
		int bonus = b * 5 + r * 3,medal = 100 + bonus * 13 + b * 15 + r * 15 + g * 7 + c * 2;
		t -= bonus + s;
		medal -= t * 3;
		cout << medal << endl;
	}
	return 0;
}

Measured memory_bytes: 2984
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define N 100
 
int main(){
 
  int x,top=0;
  char s[N];
  int num[N];
 
  while(scanf("%s",s)!=EOF){
    if(s[0] == '+'){
      num[top-2] = num[top-2] + num[top-1];
      top--;
    }else if(s[0] == '-'){
      num[top-2]=num[top-2]-num[top-1];
      top--;
    }else if(s[0] == '*'){
      num[top-2]=num[top-2]*num[top-1];
      top--;
    }else{
      num[top]=atoi(s);
      top++;
    }
  }
  printf("%d\n",num[0]);
  return 0;
}

Measured memory_bytes: 2756
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1ll << 30ll)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, L, a[1000100];
RPQ que;

signed main(){
    cin >> N >> L;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        que.push(mk(a[i], i));
        if(i < L - 1){
            continue;
        }
        while(!que.empty()){
            if(que.top().second <= i - L){
                que.pop();
            }
            else {
                break;
            }
        }
        cout << que.top().first;
        if(i < N - 1)cout << " ";
    }
    cout << endl;

    return 0;
}

/*


*/


Measured memory_bytes: 27140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    int s = N+M;
    cout << s*(s-1)/2-N*M << "\n";
}

Measured memory_bytes: 256