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

auto& scan_in = std::cin;

// input
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
//Cスタイルの入出力とC++スタイルの入出力の同期を切る操作
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { scan_in >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest& ...rest) { scan_in >> first; MACRO_VAR_Scan(rest...); }
#define VEC_ROW(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_VEC_ROW_Init(n, __VA_ARGS__); for(int w_=0; w_<n; ++w_){MACRO_VEC_ROW_Scan(w_, __VA_ARGS__);}
template<typename T> void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); }
template<typename First, typename...Rest>void MACRO_VEC_ROW_Init(int n, First& first, Rest& ...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); }
template<typename T> void MACRO_VEC_ROW_Scan(int p, T& t) { scan_in >> t[p]; }
template<typename First, typename...Rest>void MACRO_VEC_ROW_Scan(int p, First& first, Rest& ...rest) { scan_in >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); }
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)scan_in>>i;

// output
template<typename T>void MACRO_OUT(const T t) { std::cout << t; }
template<typename First, typename...Rest>void MACRO_OUT(const First first, const Rest...rest) { std::cout << first << " "; MACRO_OUT(rest...); }
#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";

// utility
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define RREP(w, n) RFOR(w, 0, n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)


#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")

template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if (f) Out(y); else Out(n); }

signed main() {
    INIT;


    // ⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎⬇︎
    VAR(int, n, y);
    for(int a=0; a<=n; ++a){
        for(int b=0; a+b<=n; ++b){
            int c = n - a - b;
            int x = a * 10000 + b * 5000 + c * 1000;
            if(x == y){
                cout << a << ' ' << b << ' ' << c << endl;
                return 0;
            }
        }
    }
 
    cout << "-1 -1 -1" << endl;
  
	return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N,M;
	cin>>N>>M;
    vi v;
    double val=0;
    F0R(x,N)
    {
    	int nb;
    	cin>>nb;
    	v.pb(nb);
    	val+=nb;
    }
    sort(v.rbegin(),v.rend());
    val=val*1.0/(4*M);
    F0R(x,M)
    {
    	if(v[x]<val)
    	{
    		cout<<"No";
    		return 0;
    	}
    }
    cout<<"Yes";
	return 0;
}
 


Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())
A = list(map(int, input().split()))
heapify(A)

replace = []
for _ in range(M):
    B, C = map(int, input().split())
    replace.append([C, B])

replace.sort(reverse=True)
replace = deque(replace)

while replace and replace[0][0] > A[0]:
    i = heappop(A)
    heappush(A, replace[0][0])
    replace[0][1] -= 1
    if replace[0][1] == 0:
        replace.popleft()

print(sum(A))



Measured memory_bytes: 85760
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');
            decimal A = Decimal.Parse (str[0]);
            decimal B = Decimal.Parse (str[1]);

            Console.WriteLine (Math.Floor (A * B));
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27608
#include <bits/stdc++.h>
using namespace std;
const int mn=310;
int n,m,ans,cnt[mn];
queue<int> q[mn];
bool ex[mn];
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			int x;
			scanf("%d",&x);
			q[i].push(x);
		}
	}
	ans=1000;
	memset(ex,0,sizeof(ex));
	while (1) {
		memset(cnt,0,sizeof(cnt));
		bool t=false;
		for (int i=1;i<=n;i++) {
			while (ex[q[i].front()]&&!q[i].empty())
				q[i].pop();
			if (q[i].empty()) {
				t=true;
				break;
			}
			cnt[q[i].front()]++;
		}
		if (t)
			break;
		int mx=0;
		for (int i=1;i<=m;i++)
			mx=max(mx,cnt[i]);
		ans=min(mx,ans);
		for (int i=1;i<=n;i++)
			if (cnt[q[i].front()]==mx) {
				ex[q[i].front()]=1;
				q[i].pop();
			}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
#import<cstdio>
int main(){int n,m,p,i;for(;scanf("%d%d",&n,&m),n|m;printf("%d\n",p)){int f[12]={0};for(i=n;i--;f[p]+=n)scanf("%d%d",&n,&p);p=0;for(i=10;i>=0;p+=f[i]*i,i--)for(;f[i]&&m;)m--,f[i]--;}}

Measured memory_bytes: 768
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    if (n == 1) {
        println(1)
        return
    }
    var l0 = 2L
    var l1 = 1L
    var cur = -1L
    for (i in 2..n) {
        cur = l0 + l1
        l0 = l1
        l1 = cur
    }
    println(cur)
}

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

using namespace std;
using pii = pair<int, int>;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  for (int i = 0; i < H; i++)
    cin >> A[i];
  queue<pii> que;
  vector<vector<bool>> M(H, vector<bool>(W, false));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A[i][j] == '#') {
        que.push(make_pair(i, j));
        M[i][j] = true;
      }
    }
  }
  int cnt = 0;
  bool flag = false;
  while (!que.empty()) {
    flag = false;
    int tmp = que.size();
    for (int i = 0; i < tmp; i++) {
      pii now = que.front();
      que.pop();
      int x = now.second, y = now.first;
      for (int k = 0; k < 4; k++) {
        int nx = x + dx[k], ny = y + dy[k];
        if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
        if (M[ny][nx]) continue;
        que.push(make_pair(ny, nx));
        M[ny][nx] = true;
        flag = true;
      }
    }
    if (flag) cnt++;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 9744
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string S){
  if(N%2==1){
    op("No")
    return;
  }
  rep(i,N/2){
    
      if(S[i]!=S[N/2+i]){
       op("No")
        return;
      }
  }
  op("Yes")
  
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, 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;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w; cin >> h >> w;
	int ans = INF;
	int sx, sy, sz;
	rep(i, w - 1) {
		sx = (i + 1)*h;
		sy = (h / 2)*(w - i - 1);
		sz = ((h + 1) / 2)*(w - i - 1);
		ans = min(ans, max({ sx,sy,sz }) - min({ sx,sy,sz }));
	}
	rep(i, h - 1) {
		sx = (i + 1)*w;
		sy = (w / 2)*(h - i - 1);
		sz = ((w + 1) / 2)*(h - i - 1);
		ans = min(ans, max({ sx,sy,sz }) - min({ sx,sy,sz }));
	}
	ans = min(ans, min(((w + 2) / 3)*h - (w / 3)*h, ((h + 2) / 3)*w - (h / 3)*w));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define LL long long
using namespace std;

const int lim1=10000000;
const int lim2=22500000;
const int p=1e9+7;
int n;
int f[lim2+5];

void pre(){
	int L=1,R=10;
	for(int len=1;len<=7;++len){
		for(int i=L;i<R;++i) f[i]=len;
		L*=10;
		R*=10;
	}
	for(int i=lim1;i<=lim2;++i) f[i]=8;
}

LL cale1(){
	LL ret=0;
	LL L=1,R=1;
	int cnt=0;
	while(1){
		while(R<=lim2&&cnt<n) cnt+=f[R++];
		if(cnt<n) break;
		if(cnt==n) (ret+=1)%=p;
		cnt-=f[L++];
		if(L>=lim1) break;
	}
	return ret;
}

LL exp(LL a,LL b){
	LL ret=1,k=a;
	while(b){
		if(b&1) (ret*=k)%=p;
		b>>=1;
		(k*=k)%=p;
	}
	return ret;
}

LL cale2(){
	int lim = n/8, ans = lim;
    for (int t = 1; t <= lim; t++)
    if (n%t == 0) {
        int len = n/t;
        (ans += (1ll*exp(10, len-1)*9%p-t)%p) %= p;
    }
    return ans;
}

int main(){
	scanf("%d",&n);
	pre();
	LL ans=(cale1()+cale2())%p;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 88192
#include<stdio.h>
int main(void)
{
  int N,x=0,max=0,i;
  char S[101];
  scanf("%d",&N);
  scanf("%s",S);

  for(i=0;i<N;i++){
    if(S[i]=='I'){
      x++;
      if(max<x){
	max=x;
      }
    } else if(S[i]=='D'){
      x--;
    }
  }
  printf("%d\n",max);
  return 0;
}

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

using namespace std;
#define ll long long
#define endl '\n'
int main()
{
    double a;
    cin>>a;
    double cnt=0;
    for( int i=1;i<=a;i++)
        if((int)i%2==1)
        cnt++;
    printf("%.10f",cnt/a);
    return 0;
}


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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int n;
    cin >> n;
    cout << pow(2, floor(log2(n))) << "\n";
    return 0;
}


Measured memory_bytes: 512
from itertools import groupby
import heapq

N=int(input())
S=input()
mod=10**9+7

fact=[i for i in range(2*N+1)]
fact[0]=1
for i in range(1,2*N+1):
    fact[i]*=fact[i-1]
    fact[i]%=mod

inverse=[pow(fact[i],mod-2,mod) for i in range(2*N+1)]

data=["" for i in range(2*N)]
for i in range(2*N):
    if S[i]=="B" and i%2==1:
        data[i]="L"
    elif S[i]=="B" and i%2==0:
        data[i]="R"
    elif S[i]=="W" and i%2==1:
        data[i]="R"
    elif S[i]=="W" and i%2==0:
        data[i]="L"


if data[0]=="L" or data[-1]=="R":
    print(0)
    exit()



ans=fact[N]
data=groupby(data)
que=[]
heapq.heapify(que)
i=0
for key,group in data:
    g=len(list(group))
    heapq.heappush(que,(i,g))
    i+=1

rest=0
while que:
    i,R=heapq.heappop(que)
    j,L=heapq.heappop(que)
    if L>R+rest:
        print(0)
        break
    else:
        ans*=fact[R+rest]*inverse[R+rest-L]
        ans%=mod
        rest=R+rest-L
else:
    if rest==0:
        print(ans)
    else:
        print(0)

Measured memory_bytes: 69972
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 1e9
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int dp[1000010]={};
  int dpki[1000010]={};
  int n;
  for(int i=0;i<1000010;i++){
    dp[i]=dpki[i]=i;
  }
  for(int i=2;((i*(i+1)*(i+2))/6)<1000001;i++){
    int num=(i*(i+1)*(i+2))/6;
    for(int j=0;j+num<=1000000;j++){
      if((num%2)){
	dpki[j+num]=min(dpki[j]+1,dpki[j+num]);
      }
      dp[j+num]=min(dp[j]+1,dp[j+num]);
    }
  }
  while(cin>>n,n){
    cout<<dp[n]<<" "<<dpki[n]<<endl;
  }
  return 0;
}



Measured memory_bytes: 10808
#include <iostream>
#include <cstdio>
using namespace std;
#define min(x,y) (x<y? (x):(y))

int main ()
{
	long long a, n, cnt=5;
	long long  minn=0x3f3f3f3f3f3f3f3f;
	cin>>n;
	while(cnt--)
	{
		cin>>a;
		minn=min(minn, a);
	}
	if(n%minn)
		cout<<n/minn+1+4;
	else
		cout<<n/minn+4;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;

int main() {
	ll n;
	cin >> n;
	set<ll>s;
	
	for (ll i =0; i < n; i ++ ) {
		ll a;
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;

int main()
{
	ll a;
	string b;
	cin >> a >> b;
	cout << (a*((b[0] - '0')*100 +(b[2] - '0')*10 +(b[3] - '0'))/100) << endl;
}

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

using namespace std;

string s;

int n;

bool check(int l, int r)
{
    for (int i = l, j = r; i < j; i++, j--)
    {
        if (s[i] != s[j]) return false;
    }
    return true;
}

int main()
{
    //freopen("file.inp","r",stdin);
    cin >> s;
    n = s.size();
    s = ' ' + s;
    int mid = n / 2;
    if (check(1, n) && check(1, mid) && check(mid + 2, n)) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
s=n.times.map{gets.chop}.group_by(&:itself).map{ |k, v| [k,v.count] }.to_h
m=gets.to_i
t=m.times.map{gets.chop}.group_by(&:itself).map{ |k, v| [k,v.count] }.to_h
ans=s.map{ |k,v| t[k].nil? ? v : v-t[k] }.sort.reverse.first
puts ans>0 ? ans: 0


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

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

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

int main() {
    ios::sync_with_stdio(false);
    string s;
    int q;
    cin >> s >> q;
    bool flip = false;

    int action;
    int f;
    char c;
    string head, tail;

    rep(i, q) {
        cin >> action;
        if (action == 1) {
            flip = flip ? false : true;
        } else {
            // action == 2
            cin >> f >> c;
            if (f == 1) {
                if (flip == false)
                    head.push_back(c);
                else
                    tail.push_back(c);
            } else {
                if (flip == false)
                    tail.push_back(c);
                else
                    head.push_back(c);
            }
        }
    }

    reverse(head.begin(), head.end());
    s = head + s + tail;
    if (flip)
        reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 1200
H, W = map(int, input().split())

S = [""] * H

for i in range(H):
    S[i] = input()

dist = [[1000000 for i in range(W)] for j in range(H)]

dist[0][0] = 0 if S[0][0] == "." else 1

for i in range(H):
    for j in range(W):
        if i > 0:
            if S[i][j] == "#":
                dist[i][j] = min(dist[i][j], dist[i - 1][j] +
                                 (1 if S[i - 1][j] == "." else 0))
            else:
                dist[i][j] = min(dist[i][j], dist[i - 1][j])
        if j > 0:
            if S[i][j] == "#":
                dist[i][j] = min(dist[i][j], dist[i][j - 1] +
                                 (1 if S[i][j - 1] == "." else 0))
            else:
                dist[i][j] = min(dist[i][j], dist[i][j - 1])

print(dist[H - 1][W - 1])


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	int change = 0;
	for (int i = 1; i < s.size(); ++i) {
		if (s[i] != s[i - 1]) change++;
	}
	cout << change << '\n';
	return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	S := next()

	isMonth := func(s string) bool {
		x, err := strconv.Atoi(s)
		if err != nil {
			return false
		}
		return x <= 12 && x >= 1
	}

	switch {
	case isMonth(S[:2]) && isMonth(S[2:]): fmt.Println("AMBIGUOUS")
	case isMonth(S[2:]): fmt.Println("YYMM")
	case isMonth(S[:2]): fmt.Println("MMYY")
	default: fmt.Println("NA")
	}
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){

  int a,b,tmp,r;

  scanf("%d %d",&a,&b);

  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  while(b>0){
    r=a%b;
    a=b;
    b=r;
  }
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 592
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		String[] s = new String[n];
		int[] t = new int[n];
		// スペース区切りの入力
		for ( int i=0; i<n; i++ ) {
			s[i] = sc.next();
			t[i] = sc.nextInt();
		}
		String x = sc.next();
		int f = 0;
		int t0 = 0;

		for ( int i=0; i<n; i++ ) {
			if ( f == 0 ) {
				if (s[i].equals(x)) {
					f = 1;
				}
			} else {
				t0 = t0 + t[i];
			}
		}

		// 出力
		System.out.println(t0);
	}
}

Measured memory_bytes: 23124
#include <iostream>
using namespace std;
#define long long long
long gcd(long a, long b){
	long r;
	while (b > 0) r = a % b, a = b, b = r;
	return a;
}
int main() {
	long a, b, c, d; cin >> a >> b >> c >> d;
	long ans = b - a + 1; a--;
	a = a / c + a / d - a / (c * d / gcd(c, d));
	b = b / c + b / d - b / (c * d / gcd(c, d));
	cout << ans - (b - a);
}

Measured memory_bytes: 256
import queue
h,w = map(int,input().split())
maze_ = []
ans = 0
for _ in range(h):
    maze = list(input())
    maze_.append(maze)
for i in range(h):
    for j in range(w):
        if maze_[i][j] == ".":
            dist = [[-1]*w for i in range(h)]
            dist[i][j] = 0
            q = queue.Queue()
            q.put([i,j])
            while not q.empty():
                now = q.get()
                y = now[0]
                x = now[1]
                if x>0 and maze_[y][x-1] == "." and dist[y][x-1] == -1:
                    dist[y][x-1] = dist[y][x] + 1
                    q.put([y,x-1])
                if y>0 and maze_[y-1][x] == "." and dist[y-1][x] == -1:
                    dist[y-1][x] = dist[y][x] + 1
                    q.put([y-1,x])
                if x<w-1 and maze_[y][x+1] == "." and dist[y][x+1] == -1:
                    dist[y][x+1] = dist[y][x] + 1
                    q.put([y,x+1])
                if y<h-1 and maze_[y+1][x] == "." and dist[y+1][x] == -1:
                    dist[y+1][x] = dist[y][x] + 1
                    q.put([y+1,x])
            saidai = 0
            for s in range(h):
                for t in range(w):
                    saidai = max(saidai,dist[s][t])
            ans = max(ans,saidai)
print(ans)

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint>PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};

int N,a[100010];
int ans=0,ans1=0;;

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>N;
    rep(i,0,N)cin>>a[i];
    sort(a,a+N);
    if(N%2==0){
         rep(i,N/2,N){
            if(i==N/2)ans+=a[i];
            else ans+=2*a[i];
        }
        rep(i,0,N/2){
           if(i==N/2-1)ans-=a[i];
           else ans-=2*a[i];
        }
    }else{
        rep(i,N/2,N)ans+=2*a[i];
        ans-=a[N/2]+a[N/2+1];
        rep(i,0,N/2)ans-=2*a[i];
        rep(i,N/2+1,N)ans1+=2*a[i];
        rep(i,0,N/2+1)ans1-=2*a[i];
        ans1+=a[N/2]+a[N/2-1];
        //cout<<ans<<" "<<ans1<<endl;
        chmax(ans,ans1);
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18, MOD = 1e15 + 37;
const ld PI = acos(-1);

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int &i : p) {
        cin >> i;
    }

    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < k; ++i) {
        sum += p[i];
    }
    cout << sum << "\n";
}


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

int dp[3][100001];
int cost[3][100001];

int recurse(int i, int j) {
	if(dp[i][j] != -1) {
    	return dp[i][j];
    } else if(j == 0) {
    	return dp[i][j] = cost[i][j];
    } else {
      	int x, y;
      	switch(i) {
          case 0: x = 1, y = 2;
            break;
          case 1: x = 0, y = 2;
            break;
          case 2: x = 0, y = 1;
            break;
        }
    	return dp[i][j] = max(recurse(x, j - 1), recurse(y, j - 1)) + cost[i][j]; 
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
	int n; cin >> n;
  	for(int i = 0; i < n; ++i) cin >> cost[0][i] >> cost[1][i] >> cost[2][i];
 	memset(dp, -1, sizeof dp);
  	cout << max(recurse(0, n - 1), max(recurse(1, n - 1), recurse(2, n - 1)));
} //farewell, until we meet again..

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    int x;
    cin >> x;
    OP(x * x * x)
    return 0;
}


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

typedef long long int ll;
using namespace std;

const ll MOD = 1e9 + 7;

int main()
{
	int n,k; cin>>n>>k;
	vector<ll> dp(n+1,0);

	map<int,int> mp;

	for(int i=0;i<k;i++){
		int x; cin>>x; mp[x]++;
	}

	dp[0]=1;

	for(int i=1;i<=n;i++){
		if(mp[i]) continue;
		dp[i] += dp[i-1];
		if(i-2>=0) dp[i] += dp[i-2];
		dp[i] %= MOD;
	}

	cout<<dp[n];
}
















Measured memory_bytes: 5760
#include <stdio.h>
int main()
{
    int x,n,i,num;
    scanf("%d %d",&x,&n);
    if(n==0)
    {
        printf("%d",x);
    }
    else
    {
        int diff,re;
        int ara[103]= {0};
        for(i=0; i<n; i++)
        {
            scanf("%d",&num);
            ara[num]=1;
        }
        for(i=x,diff=0;;diff++)
        {
            if(ara[x-diff]==0)
            {
                re=x-diff;
                break;
            }
            else if(ara[x+diff]==0)
            {
                re=x+diff;
                break;
            }
        }
        printf("%d",re);
    }
    return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;


int main(){

    method(gcd,int,int a,int b){
        while(b){
            a %= b;
            swap(a,b);
        }
        return a;
    };

    int n = in();
    int ans = in();
    rep(i,n-1){
        ans = gcd(ans,in());
    }

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


Measured memory_bytes: 3640
package main

import (
	"fmt"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	for i := 0; i <= n; i++ {
		for j := 0; j <= n - i; j++ {
			k := n - i -j
			if 10000*i + 5000*j + 1000*k == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}

	fmt.Println("-1 -1 -1")
	return
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<cstring>

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

char p[MAX];

int main(){

	memset(p,1,sizeof(p));

	p[0] = 0;
	p[1] = 0;

	for(int i=2;i<sqrt(MAX)+1;i++){
		for(int j=i*2;j<MAX; j+=i){
			if(p[j])p[j]=0;
		}
	}
	int a,d,n;
	int cnt;
	while(std::cin >> a >> d >> n,(a||d||n)){
		cnt = 0;
		while(1){
			if(p[a]){
				cnt++;
				if(cnt == n)break;
			}
			a += d;
		}
		std::cout << a << std::endl;
	}
	return 0;
}

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

const int N = 3033; 

int n, m, ok, dp[N][N];
string s,t;

void xd(int i, int j) {
	if(i == n + 1  or j == m + 1)
		return;
	if(dp[i][j] == dp[i + 1][j + 1] + 1 and s[i] == t[j]) {
		ok = 1;
		cout << s[i] ;
		xd(i + 1, j + 1);
	}
	else {
		if(dp[i + 1][j] > dp[i][j + 1])
			xd(i + 1, j);
		else
			xd(i, j + 1);
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	s = '#' + s;
	t = '#' + t;
	n = s.size(); 
	m = t.size(); 
	for(int i = n - 1; i > 0; i--) {
		for(int j = m - 1; j > 0; j--) {
			if(s[i] == t[j]) {
				dp[i][j] = dp[i + 1][j + 1] + 1;
			}
			else
				dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
		}
	}

	//cout << dp[1][1] ;
	xd(1,1);
	if(!ok) cout << " ";	
}



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

int main(){
	int n;
	cin >> n;
	vector<int> ans(n);
	rep(i,n-1){
		int a;
		cin >> a;
		ans[a-1]++;
	}
	for(int x : ans){
		cout << x << endl;
	}
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  ll A, B, C; cin >> A >> B >> C;
  if (A%2 && B%2 && C%2) cout << min({A*B, B*C, C*A}) << endl;
  else cout << 0 << endl;
  



  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


int main()
{	
	ll N, M;
	cin >> N >> M;
	vector<pair<ll, ll>> ab(N);
	priority_queue<ll> pq;
	for (ll i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		ab[i] = make_pair(a, b);
	}
 
	sort(ab.begin(), ab.end());
	ll res = 0;
	ll id = 0;
	for (ll i = M - 1; i >= 0; i--) {
		while (id<N) {
			if (i + ab[id].first <= M) {
				pq.push(ab[id].second);
				id++;
			}
			else {
				break;
			}
		}
		if (!pq.empty()) {
			res += pq.top();
			pq.pop();
		}
		
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
char a[101],b[101],aa,bb,c,d;
int main(){
    cin>>a>>b;
    aa=strlen(a);
    bb=strlen(b);
    sort(a,a+aa);
    sort(b,b+bb);
    reverse(b,b+bb);
    c=min(aa,bb);
    for(int i=0;i<c;i++){
        if(a[i]<b[i])d++;
    }

    if(aa<bb){
            int f=0;
        for(int i=0;i<c;i++){

            if(a[i]>b[i])f++;
        }
        if(f==0){cout<<"Yes"<<endl;}
        else if(d>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else if(d>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 256
N = int(input())
dp = [[0 for i in range((N+1))] for _ in range(0,3)]
for i in range(1,N+1):
    a,b,c = map(int,input().split())
    for j in range(0,3):
        if j == 0:
            dp[j][i] = max(dp[2][i-1]+a,dp[1][i-1]+a)
        elif j == 1:
            dp[j][i] = max(dp[0][i-1]+b,dp[2][i-1]+b)
        else:
            dp[j][i] = max(dp[0][i-1]+c,dp[1][i-1]+c)
print(max(dp[0][N],dp[1][N],dp[2][N]))


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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
 ll a ,b,c;
 cin >>a>>b>>c;

    ll dif = a-b;
    c-= dif;
    if(c < 0)c=0;
    cout << c;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>   
using namespace std;   
  
int main(){   
       
    int l, v, w, N, W, maxv, num = 1;   
    char c;   
       
    while(cin >> W){   
        if(W == 0) break;   
        cin >> N;   
        vector<int> A(W + 1);   
        A[0] = 0;   
        for(int i = 1; i <= W; i++) A[i] = -1;   
        for(int j = 0; j < N; j++){   
            cin >> v >> c >> w;   
            for(int k = W; k >= 0; k--){   
                if(A[k] > -1 && k+w <= W){   
                    A[k+w] = max(A[k+w], A[k]+v);   
                }   
            }   
        }   
           
        maxv = 0;   
        for(l = 0; l <= W; l++) maxv = max(maxv, A[l]);   
        for(l = 0; l <= W; l++) if(A[l] == maxv) break;   
           
        cout << "Case " << num << ":" << endl;   
        cout << maxv << endl << l << endl;   
        num++;   
    }   
       
    return 0;   
}  

Measured memory_bytes: 0
// E - Yutori
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K,C; string S;
	cin>>N>>K>>C>>S;

	vector<int> R(N,-1);

	int r_pos = 0;
	for(int r=N-1; r>=0; --r){
		if(S[r] == 'o'){
			R[r_pos++] = r;
			if(r_pos > K) return 0; // 働ける日に余裕があると、その日に必ず働く必要がない
			r -= C;
		}
	}

	reverse(R.begin(), R.begin() + r_pos);

	int l_pos = 0;
	for(int l=0; l<N; ++l){
		if(S[l] == 'o'){
			if(R[l_pos++] == l) cout<< l + 1 <<endl;
			l += C;
		}
	}

}

Measured memory_bytes: 2564
import java.util.Scanner;

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

        long ans = 0;

        if (k == 0) {
            System.out.println(n * n);
            sc.close();
            return;
        }

        for (long b = k+1; b <= n; b++) {
            long p = n / b;
            long r = n - p * b;
            ans += p * Math.max(0, b - k);
            ans += Math.max(0, r - k + 1);
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 21844
N,M = map(int,input().split())
import heapq
from collections import defaultdict
l = []
heapq.heapify(l)
d = defaultdict(list)

for i in range(N):
    a,b = map(int,input().split())
    if a > M:
        continue
    d[a].append(b)

ans = 0
for i in range(M+1):
    for v in d[i]:
        heapq.heappush(l,-v)
    if len(l) == 0:
        continue
    ans += -heapq.heappop(l)
print(ans)


Measured memory_bytes: 27676
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    std::cin >> n;
    pair<int,int> red[100],blue[100];
    for (int i = 0; i < n; i++) {
        std::cin >> red[i].first >> red[i].second;
    }
    for (int i = 0; i < n; i++) {
        std::cin >> blue[i].first >> blue[i].second;
    }
    sort(red,red+n);
    sort(blue,blue+n);
    
    bool redf[100];
    for (int i = 0; i < 100; i++) {
        redf[i]=true;
    }
    
    int ans=0;
    for (int i = 0; i <n; i++) {
        int max=-1;
        int k=-1;
        for (int j = 0; j < n; j++) {
            if(redf[j]){
                if(blue[i].first>red[j].first && blue[i].second>red[j].second){
                    if(max<red[j].second){
                        k=j;
                        max=red[j].second;
                    }
                }
            }
        }
        if(k!=-1){
            redf[k]=false;
            ans++;
        }
    }
    std::cout << ans << std::endl;

}


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

int main() {
  string str;
  getline(cin, str);
  for (auto ch : str) {
    if (isalpha(ch) && isupper(ch)) {
      cout << (char)(tolower(ch));
    } else if (isalpha(ch) && islower(ch)) {
      cout << (char)toupper(ch);
    } else {
      cout << ch;
    }
  }
  cout << endl;
}



Measured memory_bytes: 3148
#include<iostream>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;
const int n=2,m=4;
const int dir=4,dx[dir]={1,0,-1,0},dy[dir]={0,1,0,-1};
struct board{
	int a[2][4],zx,zy,dep;
};
queue<board> que;
set<board> ss;
bool operator < (board a,board b){
	int i,j;
	for (i=0;i<n;i++) for (j=0;j<m;j++)
		if (a.a[i][j]!=b.a[i][j]) return a.a[i][j]<b.a[i][j];
	return false;
}
bool read(board &a){
	int i,j;
	board ans;
	a.dep=0;
	for (i=0;i<n;i++) for (j=0;j<m;j++){
		if (scanf("%d",&a.a[i][j])!=1) return false;
		if (a.a[i][j]==0){
			a.zx=i; a.zy=j;
		}
	}
	return true;
}
bool leag(int x,int y){
	return x>=0&&x<n&&y>=0&&y<m;
}
int main(){
	board st,to,ed;
	int i,j,x,y;
	for (i=0;i<n;i++) for (j=0;j<m;j++)
		st.a[i][j]=i*m+j;
	st.zx=0; st.zy=0; st.dep=0;
	que.push(st); ss.insert(st);
	while (que.size()){
		st=que.front();
		que.pop();
		for (i=0;i<dir;i++){
			if (!leag(x=st.zx+dx[i],y=st.zy+dy[i])) continue;
			to=st; to.dep++;
			swap(to.a[to.zx][to.zy],to.a[x][y]);
			to.zx=x; to.zy=y;
			if (ss.find(to)!=ss.end()) continue;
			que.push(to); ss.insert(to);
		}
	}
	while (read(ed)){
		if (ss.find(ed)==ss.end()){
			puts("-1");
			continue;
		}
		printf("%d\n",ss.find(ed)->dep);
	}
	return 0;
}


Measured memory_bytes: 5060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<lint> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	for (int i = 0; i < N; i++) A[i] %= M;
	for (int i = 0; i < N - 1; i++) {
		A[i + 1] += A[i];
		A[i + 1] %= M;
	}

	map<int, lint> mod;
	for (int i = 0; i < N; i++) mod[A[i] % M]++;

	lint ans = mod[0] * (mod[0] + 1) / 2 - mod[0] * (mod[0] - 1) / 2;
	for (const auto &elem : mod) ans += elem.second * (elem.second - 1) / 2;

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}


bool vis[100000+10];
int main()
{
  int n ,k,p;
   cin>>n>>p;
   int c=0;
   map<int,int>m;
   int pen=0;
   for(int i=0;i<p;i++)
   {
      int x;
      string y;
      cin>>x;
      cin.ignore();
      cin>>y;
      if(vis[x]==true) continue;
      if(y=="WA")
         m[x]++;
      else if(y=="AC" )
      {
          vis[x]=true;
          c++;
          pen+=m[x];
      }
   }
   cout<<c<<" "<<pen<<endl;


}



Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;

int main() {
#ifdef XCODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    int n; cin >> s >> n;
    for (char &c : s) {
        if (c == 'a') {
            continue;
        }
        int count = 'a' - c + 26;
        if (count <= n) {
            n -= count;
            c = 'a';
        }
    }
    n %= 26;
    s.back() = ((int) (s.back() - 'a') + n) % 26 + 'a';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std ;
int main  ( ) {

	int n , m ;
	cin >> n >> m ;
	if ( n < m ) {
		for (int i = 1 ; i<= m ; i++) {

			cout<< n ;
		}
	} else {

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

			cout<< m;
		}
	}

}

Measured memory_bytes: 256
import sys
import numpy as np

h, n = map(int, raw_input().split())
ab = np.array(sys.stdin.read().split(), dtype=np.int64)
aaa = ab[0::2]
bbb = ab[1::2]

dp = np.zeros(10001, dtype=np.int64)
for i in range(1, h + 1):
    dp[i] = (dp[i - aaa] + bbb).min()
print(dp[h])


# https://atcoder.jp/contests/abc153/submissions/9776226


Measured memory_bytes: 16092
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    H, W, K = map(int, input().split())
    c = [None] * H
    for i in range(H):
        c[i] = input()

    ans = 0
    for i in range(2**H):
        for j in range(2**W):
            tmp = 0
            # print(i,j)
            for ii in range(H):
                for jj in range(W):
                    # print(ii,jj)
                    if c[ii][jj] == '#':
                        # print((i >> ii)&1,)
                        if ((i >> ii)&1) or ((j >> jj)&1):
                            pass
                        else:
                            tmp += 1
            # print(tmp)
            if tmp == K:
                ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9460
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc085_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int billCount = input[0];
            int sum = input[1];
            for (int x = 0; x <= billCount; x++)
            {
                for (int y = 0; y <= billCount - x; y++)
                {
                    int z = billCount - x - y;
                    if (10000 * x + 5000 * y + 1000 * z == sum)
                    {
                        Console.WriteLine($"{x} {y} {z}");
                        return;
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
   long long n;
   cin>>n;
   vector<long long>p(n);
   rep(i,n){
       cin>>p[i];
   }
   int ans=0;
   for(int i=2;i<n;i++){
       vector<long long> tp(3);
       tp[0]=p[i-2];
       tp[1]=p[i-1];
       tp[2]=p[i];
       sort(tp.begin(),tp.end());
       if(tp[1]==p[i-1]){
           ans++;
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  string s,t;
  cin>>s>>t;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)==t.at(i)){
      count++;
    }
  }
  if(count==s.size()){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3632