akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;
// 変数初期化
vector<ll> bsv; // binary_search用のvector
ll a,b,c,n,m;
typedef pair<ll, ll> Pll;
vector<Pll> facts; // 素因数分解の結果格納用(基数:乗数)
vector<vector<ll> > bit_search_v; //nit全探索の結果格納用

// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
    if (bsv[index] >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(int key) {
    int ng = -1;
    int ok = (ll)bsv.size();

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    // OK(key以上となる)のindex番号を返す
    return ok;
}

// 最大公約数
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

// 最小公倍数
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

//　素因数分解
void prime_fact(ll target){
    ll base=2, exp=0;
    while (base*base<=target) {
        while (target%base==0) {
            target /= base; exp++;
        }
        if (exp>0) {
            facts.push_back(make_pair(base, exp));
        }
        base++; exp=0;
    }
    if (target>1) facts.push_back(make_pair(target,1));
}
// prime_factの結果の確認用
void print_facts(){
    for (int i=0; i<facts.size(); i++) {
        cout << facts[i].first << " " << facts[i].second << endl;
    }
}

// bit全探索
void bit_search(ll target){
    for (ll i=0; i<(1<<target); ++i) {
        if (i==0) continue;
        vector<ll> v;
        for (ll j=0; j<target; ++j) {
            if (i&(1<<j)) v.push_back(j);
            if (i&(1<<j)) cout << i << "  :  " << j << endl;
        }
        bit_search_v.push_back(v);
    }
}
// bit全探索の結果確認用
void print_bit_search(){
    for (ll i=0; i<bit_search_v.size(); ++i) {
        for (ll j=0; j<bit_search_v[i].size(); ++j) {
            cout << bit_search_v[i][j] << " ";
        }
        cout << endl;
    }
}



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

    cin >> n;
    vector<ll> A(n);
    ll ma = 0;
    for(ll i = 0; i < n;i++){
        cin >> A[i];
        bsv.push_back(A[i]+i+1);
    }
    VSORT(bsv);
    ll ans =0;
    for(ll i = 0; i < n;i++){
        ans += (binary_search((i+1)-A[i]+1)-binary_search((i+1)-A[i]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6396
import sys
from collections import Counter


def read():
    return sys.stdin.readline().rstrip()


def main():
    n = int(read())
    a = Counter(map(int, read().split()))
    s = sum(k * v for k, v in a.items())
    q = int(read())
    for _ in range(q):
        b, c = map(int, read().split())
        k = a[b]
        a[b] = 0
        a[c] += k
        s += (c - b) * k
        print(s)


if __name__ == '__main__':
    main()

Measured memory_bytes: 22188
#include <bits/stdc++.h>
using namespace std;
int n, k, s, t, a[55];
long long C[55][55], ps[55][55];
int main() {
	scanf("%d%d%d%d", &n, &k, &s, &t);
	if ((s & t) != s || (s | t) != t) {
		puts("0");
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if ((a[i] & s) != s || (a[i] | t) != t) {
			i--;
			n--;
		}
	}
	k = min(k, n);
	for (int i = C[0][0] = 1; i <= n; i++) {
		for (int j = C[i][0] = 1; j <= i; j++)
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
		ps[i][1] = C[i][1];
		for (int j = 2; j <= i; j++) {
			ps[i][j] = ps[i][j - 1] + C[i][j];
		}
	}
	int fa = s ^ t;
	long long ans = 0;
	for (int mask = fa; ; mask = (mask - 1) & fa) {
		map<int, int> mp;
		for (int i = 1; i <= n; i++) {
			mp[a[i] & mask]++;
		}
		long long cur = 0;
		for (auto &it : mp) {
			cur += ps[it.second][min(k, it.second)];
		}
		if (__builtin_popcount(mask) & 1) ans -= cur;
		else ans += cur;
		if (!mask) break;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3812
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	string s;
	cin >> s;

	vi ans(s.size());
	vi L(s.size());
	vi R(s.size());

	int tmp = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'R') tmp = 0;
		else if (s[i] == 'L')
		{
			tmp++;
			L[i] = tmp;
		}
	}
	tmp = 0;
	for (int i = s.size(); i >= 0; i--)
	{
		if (s[i] == 'L') tmp = 0;
		else if (s[i] == 'R')
		{
			tmp++;
			R[i] = tmp;
		}
	}

	for (int i = 0; i < s.size(); i++)
	{
		if (R[i] != 0)
		{
			if (R[i] % 2 == 0)
			{
				ans[i + R[i]]++;
			}
			else
			{
				ans[i + (R[i] - 1)]++;
			}
		}
		
		if (L[i] != 0)
		{
			if (L[i] % 2 == 0)
			{
				ans[i - L[i]]++;
			}
			else
			{
				ans[i - (L[i] - 1)]++;
			}

		}
	}
	rep(i, s.size()) cout << ans[i] << " ";
	cout << endl;
	system("pause");
}

Measured memory_bytes: 2040
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var s1 = int.Parse(S.Substring(0, 2));
            var s2 = int.Parse(S.Substring(2, 2));

            var isYYMM = s2 > 0 && s2 < 13;
            var isMMYY = s1 > 0 && s1 < 13;

            if (isYYMM)
            {
                if (isMMYY)
                {
                    Console.WriteLine("AMBIGUOUS");
                }
                else
                {
                    Console.WriteLine("YYMM");
                }
            }
            else
            {
                if (isMMYY)
                {
                    Console.WriteLine("MMYY");
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 13140
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        Integer L[] = new Integer[N];
        int prev = 0;
        boolean isAllSame = true;
        for(int i = 0; i < N ; i++) {
            L[i] = scan.nextInt();
            if(prev == 0)
                prev = L[i];
            if(i > 0 && prev != L[i].intValue())
                isAllSame = false;
        }

        if(isAllSame) {
            long NL = N;
            os.println(NL*(NL-1)*(NL-2)/(3*2*1));
            return;
        }

        Arrays.sort(L, Comparator.reverseOrder());

        long answer = 0;
        for(int a = 0; a < N ; a++) {
            for(int b = a+1; b < N ; b++) {
                for(int c = b+1; c < N ; c++) {
                    if(L[b] + L[c] <= L[a])
                        break;
                    if(L[a] + L[b] > L[c] &&  L[a] + L[c] > L[b])
                        answer++;
                }

            }
        }

        os.println(answer);

    }
}

Measured memory_bytes: 26592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    int n,m;cin>>n>>m;
    if(n==m)out("Yes");
    else out("No");
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = reader.readLine().split(" ");
        int N = Integer.parseInt(arr[0]);
        int K = Integer.parseInt(arr[1]);
        int cnt = 1;
        while (Math.pow(K, cnt) <= N)
            cnt++;
        System.out.println(cnt);
    }
}

Measured memory_bytes: 22612
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

int f(int b, int n) {
	return n < b ? n : f(b, n / b) + (n % b);
}

signed main() {
	int n, s; cin >> n >> s;
	int ans = 1ll << 60;
	if (s == n) {
		ans = n + 1;
	}
	for (int i = 2; i * i <= n; i++) {
		if (f(i, n) == s) minup(ans, i);
	}
	for (int p = 1; p * p < n; p++) {
		int q = s - p;
		int b = (n - q) / p;
		if (p < b && 0 <= q && q < b && b >= 2 && p * b + q == n)
			minup(ans, b);
	}
	cout << (ans == 1ll << 60 ? -1 : ans) << endl;
	system("pause");
}

Measured memory_bytes: 504
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
int n, cnt, ans, a[81][81], b[81][81], c, d, tmp, m, h, w, x, y, sum, k, q;
bitset<640 * 80 + 100 + 6400> dp[100][100];

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

  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];
  dp[1][1][abs(a[0][0] - b[0][0]) + 6400] = true;

  rrep(i, 1, h + 1) {
    rrep(j, 1, w + 1) {
      dp[i][j] |= (dp[i - 1][j] << (abs(a[i - 1][j - 1] - b[i - 1][j - 1]))) |
                  (dp[i - 1][j] >> (abs(a[i - 1][j - 1] - b[i - 1][j - 1])));
      dp[i][j] |= (dp[i][j - 1] << (abs(a[i - 1][j - 1] - b[i - 1][j - 1]))) |
                  (dp[i][j - 1] >> (abs(a[i - 1][j - 1] - b[i - 1][j - 1])));
    }
  }

  rep(i, 640 * 80 + 1) {
    if (dp[h][w][i + 6400]) {
      Cout(i);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 56832
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(0),cin.tie(0);
int main(void)
{
	AC;
	long long int T,a,b,n=0,i;
	cin>>a>>b;
	a=b/a;;
	while(a>0){
		a/=2;
		n++;
	}
	cout<<n<<"\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
#define N 200005

queue<int>q;
int a[N],b[N]={0};
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    for(int i=n;i>=1;i--)
    {
        int sum=0;
        for(int j=i;j<=n;j+=i)
        {
            sum+=b[j];
        }
        if(sum%2!=a[i])
            b[i]=1,sum++,q.push(i);

    }
    cout<<q.size()<<endl;
    while(q.size()){printf("%d\n",q.front());q.pop();}
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
    int H,W; cin>>H>>W;
    map<char,int> mp;
    vector<char> v;
    REP(i,H){
        string s; cin>>s;
        for(char c:s){
            ++mp[c];
            if(mp[c]==1){ v.push_back(c); }
        }
    }
    bool ok = true;
    int g1 = (H%2==1 && W%2==1);
    int g2 = (W/2)*(H%2==1) + (H/2)*(W%2==1);
    int g4 = (H/2)*(W/2);
    REP(count,g1){
        ok = false;
        for(char c:v){
            if( (mp[c]%4)%2==1 ){ --mp[c]; ok = true; break;}
        }
        
    }
    int stock = g2;
    if(ok){
        REP(count,g2){
            for(char c:v){
                if(mp[c]%4==2 ){ mp[c] -= 2; --stock; break;}
            }
        }
        if(stock%2==1){ ok = false;}
    }
    if(ok){
        REP(count,g4+stock/2){
            for(char c:v){
                if(mp[c]%4!=0){ ok = false; break;}
                else if(mp[c]>0){ mp[c] -= 4; break;}
            }
            if(!ok){break;}
        }
    }
    if(ok){
        for(char c:v){
            
            if(mp[c]!=0){ ok =false; break;}
        }
    }
    
    cout << (ok?Liny:Linn);
}

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

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var A = ReadLine().Split().Select(long.Parse).ToArray();


        long money = 1000;
        long have = 0;
        int index = 0;
        while (index < N - 1)
        {
            while (index < N - 1 && A[index] > A[index + 1])
            {
                index++;
            }
            have = money / A[index];
            money = money % A[index];
            while (index < N - 1 && A[index] < A[index + 1])
            {
                index++;
            }
            money += A[index] * have;
            have = 0;
            index++;
        }
        WriteLine(money);
    }
}


Measured memory_bytes: 28232
#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>
signed main(){
  int memo=0;
  string S; cin>>S;
  string ans="YES";
  rep(i,0,S.size()){
    if(S.size()-i>=4&&S.substr(i,5)=="dream"){
      memo=1;
      i+=4;
    }
    else if(S.size()-i>=1&&S.substr(i,2)=="er"){
      i+=2;
      if(i>S.size())
        break;
      if(S.size()-i>=2&&S.substr(i,3)=="ase"){
        memo=2;
        i+=2;
      }
      else if(memo==1){
        i--;
        memo=0;
      }
      else{
        ans="NO";
        break;
      }
    }
    else if(S[i]=='r'){
      if(memo!=2){
        ans="NO";
        break;
      }
      memo=0;
    }
    else{
      ans="NO";
      break;
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#define F first
#define S second
#define pb push_back
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vLL vector<LL>
using namespace std;
typedef long long LL;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vint a, b;
    for (int i = 0; i < n; i++)
    {
        int u;
        cin >> u;
        if (u < 0)
        {
            b.pb(u);
        }
        else
        {
            a.pb(u);
        }
    }
    sort(all(b));
    sort(all(a));
    if (sz(b) % 2)
    {
        if (sz(a))
        {
            if (a.front() < -b.back())
            {
                a.front() = -a.front();
            }
            else
            {
                b.back() = -b.back();
            }
        }
        else
        {
            b.back() = -b.back();
        }
    }
    LL ans = 0;
    for (int i = 0; i < sz(a); i++)
    {
        ans += a[i];
    }
    for (int i = 0; i < sz(b); i++)
    {
        ans -= b[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

void set(int y, int x, char c){
  data[y][x] = c;
  for(int i=0;i<8;++i){
    int ny = y + dy[i];
    int nx = x + dx[i];
    bool f = false;
    while(min(ny, nx) >= 0 && max(ny, nx) < 8){
      if(data[ny][nx] == '.') break;
      if(data[ny][nx] == c){
        f = true;
        break;
      }
      ny += dy[i];
      nx += dx[i];
    }
    if(f){
      ny = y + dy[i];
      nx = x + dx[i];
      while(data[ny][nx] != c){
        data[ny][nx] = c;
        ny += dy[i];
        nx += dx[i];
      }
    }
  }
}

int calc(int y, int x, char c){
  int res = 0;
  for(int i=0;i<8;++i){
    int ny = y + dy[i];
    int nx = x + dx[i];
    int cnt = 0;
    while(min(ny, nx) >= 0 && max(ny, nx) < 8){
      if(data[ny][nx] == '.') break;
      if(data[ny][nx] == c){
        res += cnt;
        break;
      }
      ++cnt;
      ny += dy[i];
      nx += dx[i];
    }
  }
  return res;
}

bool set(int t){
  int px = -1, py = -1;
  int valM = 0;
  if(t){
    for(int i=0;i<8;++i){
      for(int j=0;j<8;++j){
        if(data[i][j] == '.'){
          int tmp = calc(i, j, 'o');
          if(valM < tmp){
            px = j;
            py = i;
            valM = tmp;
          }
        }
      }
    }
    if(valM) set(py, px, 'o');
  }else{
    for(int i=7;i>=0;--i){
      for(int j=7;j>=0;--j){
        if(data[i][j] == '.'){
          int tmp = calc(i, j, 'x');
          if(valM < tmp){
            px = j;
            py = i;
            valM = tmp;
          }
        }
      }
    }
    if(valM) set(py, px, 'x');
  }
  if(px == -1 && py == -1) return false;
  return true;
}

void solve(){
  int turn = 1;
  bool pre = true;
  while(1){
    bool tmp = set(turn);
    if(!pre && !tmp) break;
    pre = tmp;
    turn = 1 - turn;
  }
}

main(){
  while(cin >> data[0]){
    for(int i=1;i<8;++i){
      cin >> data[i];
    }
    solve();
    for(int i=0;i<8;i++){
      cout << data[i] << endl;
    }
  }
  return 0;
}

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

int main(void)
{
    IOS
    int K; cin >> K;
    int A, B;
    cin >> A >> B;
    int k = K;
    while(k <= B) {
        if (k >= A) {
            OUT("OK")
            return 0;
        }
        k+= K;
    }
    
    OUT("NG")

    return 0;
}

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

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

using namespace std;
using lint=long long;

int main(){
	int n;scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	lint ans=a[0]-1;
	int x=2;
	for(int i=1;i<n;i++){
		if(a[i]==x){
			x++;
		}
		else if(a[i]>x){
			ans+=(a[i]-1)/x;
		}
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3808
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using namespace std;

void Main()
{
   int X, Y, Z, K;
   cin >> X >> Y >> Z >> K;
   vector<int64_t> A(X), B(Y), C(Z);
   for (auto &v : A)
   {
      cin >> v;
   }
   for (auto &v : B)
   {
      cin >> v;
   }
   for (auto &v : C)
   {
      cin >> v;
   }

   vector<int64_t> AB(X * Y);
   int x, y, z;
   for (x = 0; x < X; x++)
   {
      for (y = 0; y < Y; y++)
      {
         AB[x * Y + y] = A[x] + B[y];
      }
   }
   std::sort(AB.begin(), AB.end(), std::greater<int64_t>());
   vector<int64_t> ABC(std::min(X * Y, K) * K);
   for (x = 0; x < std::min(X * Y, K); x++)
   {
      for (z = 0; z < Z; z++)
      {
         ABC[x * Z + z] = AB[x] + C[z];
      }
   }
   std::sort(ABC.begin(), ABC.end(), std::greater<int64_t>());
   for (z = 0; z < K; z++)
   {
      cout << ABC[z] << endl;
   }
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}

Measured memory_bytes: 78464
#include <iostream>
using namespace std;
int main() 
{
	int h,n0,t=0;
	cin>>h>>n0;
	const int n =n0;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		t = t+a[i];
	}
	if(t>=h)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";	
	}
	
	return 0;
}

Measured memory_bytes: 4008
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n;
LL a[202020];
LL rui[202020];//[0,i)

pair<LL, LL>divide(LL b, LL e) {
	LL ok = b, ng = e;
	LL ds = rui[e] - rui[b - 1];
	while (ng - ok > 1) {
		LL mid = (ok + ng) / 2;
		LL ps = rui[mid] - rui[b - 1];
		if (ps * 2 <= ds) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}

	pair<LL, LL> ret1 = make_pair(rui[ok] - rui[b - 1], rui[e] - rui[ok]);
	pair<LL, LL> ret2 = make_pair(rui[ok + 1] - rui[b - 1], rui[e] - rui[ok + 1]);

	if (ret1.first - ret1.second > ret2.second - ret2.first) {
		return ret1;
	}
	else {
		return ret2;
	}
}

LL calc(LL it) {
	vector<pair<LL, LL>>psum(2);
	psum[0] = divide(1, it);
	psum[1] = divide(it + 1, n);
	return max({ psum[0].first, psum[0].second, psum[1].first, psum[1].second }) - min({ psum[0].first, psum[0].second, psum[1].first, psum[1].second });
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = 1; i <= n; i++)rui[i] = rui[i - 1] + a[i];
	LL ans = INF<LL>();
	for (int i = 2; i <= n - 2; i++) {
		ans = min(ans, calc(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    string a,b,f; int c,d; 
    cin>>a>>b>>c>>d;
    cin>>f;
    if(a==f){
        c--;
    }else{
        d--;
    }
        cout<<c<<" "<<d;
    return 0;
}


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


int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	ll n,w;
	cin>>n>>w;
	ll in[n][2];
	ll max_val=0;
	for(ll i=0;i<n;i++)
	{
		cin>>in[i][0]>>in[i][1];
		max_val=max_val+in[i][1];
	}
	ll dp[max_val+1];
	const ll INF=(ll)1e18;
	for(ll i=0;i<=max_val;i++)
	{
		dp[i]=INF;	
	}
	// dp[i] will represent the maximum sum with total number of weights equal to i
	dp[0]=0;
	for(ll i=0;i<n;i++)
	{
		ll value=in[i][1];
		for(ll j=max_val-value;j>=0;j--)
		{
			dp[j+value]=min(dp[j+value],dp[j]+in[i][0]);
		}
	}
	ll ans=0;
	for(ll i=0;i<=max_val;i++)	
	{
		// cout<<dp[i]<<'\n';
		if(dp[i]<=w)
			ans=max(ans,i);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 1024
from itertools import accumulate
import bisect
n = int(input())
l = list(range(1,int((2*n)**0.5)+2))
l = list(accumulate(l))
a = []
while n:
  i = bisect.bisect_left(l,n)
  a.append(i+1)
  n-=i+1
print(*a,sep='\n')

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

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

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

  sort(a, a + n);

  for (int i = n - 1; i > 0; i--) {
    a[i - 1] *= a[i] / gcd(a[i], a[i - 1]);
  }

  cout << a[0] << endl;

  return 0;
}

Measured memory_bytes: 3152
import math
from collections import Counter
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, P = map(int, input().split())
A = [int(i)%2 for i in input().split()]
m = Counter(A)
num0 = m[0]
num1 = m[1]
num = 0
if P == 0:
    for i in range(num1+1):
        if i%2 == 0:
            num += combinations_count(num1, i)
    print((2**num0)*num)
else:
    for i in range(num1+1):
        if i%2 == 1:
            num += combinations_count(num1, i)
    print((2**num0)*num)

Measured memory_bytes: 3316
N = int(input())
As = list(map(int, input().split()))

tmp = []
for i in range(1, len(As)):
    if As[i]-As[i-1]>0:
        tmp.append(1)
    elif As[i]-As[i-1]<0:
        tmp.append(-1)
    else:
        tmp.append(0)

seq = False
money = 1000
stock = 0
for i, pm in enumerate(tmp, 1):
    if pm==1:
        if seq == False:
            stock = As[i-1]
            seq = True
    if pm==-1:
        if stock:
            stock_num = money//stock
            money-=stock*stock_num

            max_ = As[i-1]
            money+=max_*stock_num

            seq = False
            stock = 0
    if len(tmp) == i:
        if stock<As[i] and stock!=0:
            stock_num = money//stock
            money-=stock*stock_num
            max_ = As[i]
            money+=max_*stock_num
print(money)



Measured memory_bytes: 9184
#include <stdio.h>

int main(void) {
   
   int A,B,C;
   
   scanf("%d%d%d",&A,&B,&C);
   
   if ((A < C && C < B) || (B < C && C < A)) {
      printf("Yes\n");
   }
   else {
      printf("No\n");
   }
   
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;
typedef pair<int, int> P;

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

int main()  {
    string a, b;
    cin >> a >> b;
    long long int ans = 0;
    ans = stoi(a + b);
    bool flag = false;
    for (int i = 0; i <= 1000; ++i) {
        if (ans == pow(i, 2)) flag = true;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
b=min(A)
p=0
for i in range(N):
  if A[i]!=b:
    p+=1
if p%(K-1)==0:
  print(p//(K-1))
else:
  print(p//(K-1)+1)

Measured memory_bytes: 20468
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl "\n"
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    string s;
    cin>>s;
    ll index=0;
    ll ans=0;
    while(index<3)
    {
        ll low=index;
        while(low<3 && s[low]==s[index])
        {
            low++;
        }
        if(s[index]=='R')
            ans=max(ans,low-index);
        index=low;
    }
    cout<<ans<<nl;
}


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

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  sort(s.begin(), s.end());
  rep(i,n) cout << s[i];
  cout << endl;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	bool MMYY = false, YYMM = false;
	int k;
	cin >> k;
	if (k / 100 <= 12 && k / 100 >= 1)
		MMYY = true;
	if (k % 100 <= 12 && k % 100 >= 1)
		YYMM = true;
	if (MMYY && YYMM)
		cout << "AMBIGUOUS";
	else if (MMYY)
		cout << "MMYY";
	else if (YYMM)
		cout << "YYMM";
	else
		cout << "NA";
}

Measured memory_bytes: 256
N,X=map(int,input().split())

a,p=[1],[1]

for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def solve(n,x): #n,x
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<=1+a[n-1]:
        return  solve(n-1,x-1)
    else:
        return p[n-1]+1+solve(n-1,x-2-a[n-1])

print(solve(N,X))


Measured memory_bytes: 3064
N= int(input())
H = list(map(int, input().split()))

i = 0
j = 0
ans = 0
while i < int(len(H))-1:
    if int(H[i])>=int(H[i+1]):
        j+=1
        if j>ans:
            ans=(j)
    else:
        j = 0
    
    i +=1
print(ans)

Measured memory_bytes: 14224
import sys, time
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
a = [list(map(int, input().split()))[::-1] for _ in range(n)]
#print(*a, sep="\n")
opponent = [-1 for _ in range(n)]
played = list(range(n))
match = 0
day = 0
while match < n*(n-1)//2:
	approved = False
	for i in played:
		if a[i] != []:
			opponent[i] = a[i].pop()-1
	played_next = []
	#print(opponent)
	for i in played:
		if opponent[i] != -1 and opponent[opponent[i]] == i:
			approved = True
			match += 1
			played_next += [i, opponent[i]]
			opponent[opponent[i]] = -1
			opponent[i] = -1
	#print(opponent)
	if not approved:
		print(-1)
		sys.exit()
	day += 1
	played = played_next
print(day)

Measured memory_bytes: 34736
#include<bits/stdc++.h>
using namespace std;
char s[1000005];
int n,a[1000005],sum,mx[1000005],b[1000005];
int f(int x)
{
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='?')
        {
            if(mx[i]+(ans+1)*2<=x)ans++,b[i]=1;
            else b[i]=-1;
        }
        else if(s[i]=='1')b[i]=1;
        else b[i]=-1;
    }
    int anss=b[1];
    for(int i=2;i<=n;i++)b[i]+=b[i-1],anss=min(anss,b[i]);
    return min(anss,0);
}
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
        if(s[i]=='1')sum++,a[i]=a[i-1]+1;
        else sum--,a[i]=a[i-1]-1;
    mx[n]=a[n];
    for(int i=n-1;i>=1;i--)mx[i]=max(mx[i+1],a[i]);
    int z=max(mx[1],0);
    printf("%d",min(z-f(z),z+1-f(z+1)));
    return 0;
}

Measured memory_bytes: 16492
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
struct node
{
    int x,y,d,step,k;
    node(int x=0,int y=0,int d=0,int step=0,int k=0):
    x(x),y(y),d(d),step(step),k(k){}
    bool operator<(const node&o)const
    {
        if(step!=o.step) return step>o.step;
        return k<o.k;
    }
};
int sx,sy,ex,ey;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int main()
{
    int h,w,k;scanf("%d%d%d",&h,&w,&k);
    scanf("%d%d%d%d",&sx,&sy,&ex,&ey);
    char s[h+5][w+5];
    for(int i=1;i<=h;i++)
        scanf("%s",s[i]+1);
    int f[h+5][w+5][4],g[h+5][w+5][4];
    bool vis[h+5][w+5][4];
    memset(vis,false,sizeof(vis));
    memset(f,inf,sizeof(f));
    memset(g,0,sizeof(g));
    priority_queue<node>q;
    for(int i=0;i<4;i++)
    {
        f[sx][sy][i]=1;
        g[sx][sy][i]=k;
        q.push(node(sx,sy,i,1,k));
    }
    while(!q.empty())
    {
        int x=q.top().x,y=q.top().y,d=q.top().d;q.pop();
        if(x==ex&&y==ey) break;
        if(vis[x][y][d]) continue;
        vis[x][y][d]=true;
        for(int i=0;i<4;i++)
        {
            int xx=x+dx[i];
            int yy=y+dy[i];
            if(xx<1||x>h||yy<1||yy>w||s[xx][yy]=='@') continue;
            int ff=f[x][y][d]+(i!=d);
            int gg=i==d?g[x][y][d]-1:k-1;
            if(gg==-1) ff++,gg=k-1;
            if(f[xx][yy][i]>ff||f[xx][yy][i]==ff&&g[xx][yy][i]<gg)
                f[xx][yy][i]=ff,g[xx][yy][i]=gg,q.push(node(xx,yy,i,ff,gg));
        }
    }
    int ans=inf;
    for(int i=0;i<4;i++) ans=min(ans,f[ex][ey][i]);
    if(ans==inf) ans=-1;
    printf("%d\n",ans);
}


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

int main() {
  int a, b;
  cin >> a >> b;
  struct tm t = {};
  t.tm_year = 2018 - 1900;
  t.tm_mon = 0;
  t.tm_mday = 0;
  int ans = 0;
  while (++t.tm_mday) {
    mktime(&t);
    if (t.tm_mon + 1 == t.tm_mday) ans++;
    if (t.tm_mon + 1 == a && t.tm_mday == b) break;
  }
  cout << ans << "\n";
}

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

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

  vector<int> A(N), B(N), C(N - 1);
  for (int i = 0; i < N; i++) {
    int temp;
    cin >> temp;
    
    A.at(i) = temp;
  }
  for (int i = 0; i < N; i++) {
    int temp;
    cin >> temp;
    
    B.at(i) = temp;
  }
  for (int i = 0; i < (N - 1); i++) {
    int temp;
    cin >> temp;
    
    C.at(i) = temp;
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += B.at(A.at(i) - 1);
    
    if (i != 0) {
      if ((A.at(i - 1) + 1) == A.at(i)) {

        ans += C.at(A.at(i - 1) - 1);
      }
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
class Main{
  public static void main(String[] args) {
    try{
      BufferedReader br =
        new BufferedReader(new InputStreamReader(System.in));
      while(true){
        String[] str = br.readLine().split("\\s");
        if(str == null) throw new Exception();
        int a = Integer.parseInt(str[0]) + Integer.parseInt(str[1]);
        String b = "" + a;
        System.out.println(b.length());
      }
    }catch(Exception e){}
  }
}

Measured memory_bytes: 24500
#include<iostream>
#include<cstring>
#include<cstdio>
#define N (601)
using namespace std;
int n,m;
char s[N][N],a[N][N],b[N][N];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1; i<=n; ++i)
		scanf("%s",s[i]+1);
	memcpy(a,s,sizeof(s)); memcpy(b,s,sizeof(s));
	for (int i=1; i<=m; ++i)
		a[1][i]=b[n][i]='#';
	for (int j=2; j<m; ++j)
		for (int i=2; i<n; ++i)
			if (j%2) a[i][j]='#';
			else b[i][j]='#';
	for (int i=1; i<=n; ++i)
	{
		for (int j=1; j<=m; ++j)
			printf("%c",a[i][j]);
		printf("\n");
	}
	printf("\n");
	for (int i=1; i<=n; ++i)
	{
		for (int j=1; j<=m; ++j)
			printf("%c",b[i][j]);
		printf("\n");
	}	
}

Measured memory_bytes: 1792
#include <iostream> 
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int n, r;
    while(true){
        cin >> n >> r;
        if(n == 0 && r == 0) break;
        int ans  = 0;
        int box = r;
        map<int, int> mp;
        rep(i, n) mp[i]  = 0;
       bool flag = false; 
        while(true){
           rep(i, n){
               if(box > 0){
                   mp[i]++;
                   box--;
               }else{
                   box = mp[i];
                   mp[i] = 0;
               }
               if(mp[i] == r){
                   ans = i;
                   flag = true;
                   break;
               }
           } 
           if(flag) break;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
check=dict()
N,b,d=0,[],0
#ttfは235、chaはabc

def dfs_sub(n,ttf,cha):
    global check,d
    check[0]=min(check[n]+n*d,check[0]) if 0 in check else check[n]+n*d
    if n//ttf==0:
        check[n//ttf]=min(check[n]+(n%ttf)*d,check[n//ttf]) if n//ttf in check else check[n]+(n%ttf)*d
    else:
        if n//ttf in check:
            if check[n//ttf]>check[n]+(n%ttf)*d+cha:
                check[n//ttf]=check[n]+(n%ttf)*d+cha
                dfs(n//ttf)
        else:
            check[n//ttf]=check[n]+(n%ttf)*d+cha
            dfs(n//ttf)
    if 1+n//ttf in check:
        if check[1+n//ttf]>check[n]+(ttf-n%ttf)*d+cha:
            check[1+n//ttf]=check[n]+(ttf-n%ttf)*d+cha
            dfs(1+n//ttf)
    else:
        check[1+n//ttf]=check[n]+(ttf-n%ttf)*d+cha
        dfs(1+n//ttf)


def dfs(n):
    global b,check,d
    for i,j in zip([2,3,5],b):
        dfs_sub(n,i,j)

t=int(input())
for i in range(t):
    N,*b,d=map(int,input().split())
    check={N:0}
    dfs(N)
    print(check[0])


Measured memory_bytes: 127228
#include <iostream>

const int MAXN = 100;

int a[MAXN];

int solve(int n) {
  int ans = -1;
  for (int i = 1; i <= 100; ++i) {
    int cur = 0;
    for (int j = 0; j < n; ++j) {
      cur += (a[j] - i) * (a[j] - i);
    }
    if (ans == -1 || cur < ans) ans = cur;
  }
  return ans;
}

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <cmath>

using namespace std;

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

  int n,sum1=0,sum2=0;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++)
    cin >> b[i];
  for(int i=0;i<n;i++)
  {
    if(a[i]>b[i])
    {
      sum1+=a[i];
      sum2+=b[i];
    }
  }
  cout<<sum1-sum2<<'\n';
}

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


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>v;

    for(ll i=1;i*i<=k;i++)
    {
        if(k%i==0)
        {
            v.push_back(i);
            if(k/i!=i)v.push_back(k/i);
        }
    }

    ll counter;

    sort(v.begin(),v.end());

    for(int i=0;i<v.size();i++)
    {
        if(k/v[i]>=n)counter=v[i];
    }
    cout<<counter<<endl;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
XY = [tuple(map(int, input().split())) for _ in range(N)]

"""
辺の上に点が乗っていても四角形の中に含まれると見なされるので、辺はいずれかの点の上を通るように引くと面積を小さくできる
各点のx,yをsetで持っておいて、全探索できるか？
→ N <= 50なので4つの辺の選び方が50**4、この範囲にK個以上入っているかでさらに *50なので間に合うか微妙？
小さい値で ^5 なので、間に合うかも
"""

LR = [] # left,right
TB = [] # top, bottom
for x,y in XY:
    LR.append(x)
    TB.append(y)


LR = list(set(LR))
LR.sort()
TB = list(set(TB))
TB.sort()


def more_than_K(l,r,t,b):
    cnt = 0
    for x,y in XY:
        if l <= x <= r and b <= y <= t:
            cnt += 1
    return cnt >= K

ans = float("inf")
for p in range(len(LR)):
    for q in range(p+1, len(LR)):
        for r in range(len(TB)):
            for s in range(r+1, len(TB)):

                if more_than_K(LR[p], LR[q], TB[s], TB[r]):
                    ans = min(ans, (LR[q] - LR[p]) * (TB[s] - TB[r]))


print(ans)


Measured memory_bytes: 55900
#include <stdio.h>

int main()
{
  char s[52];
  int n, k, i;

  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%s", &s);

i = k - 1;
s[i] = s[i] + 32;

printf("%s\n", s);

return 0;
}

Measured memory_bytes: 1600
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;

  int k = N/2;
  if ( N % 2 == 1 ) k = N - (N/2);
  std::cout << std::fixed << std::setprecision(10) << (double) k/N << std::endl;

  return 0;
}


Measured memory_bytes: 256