akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#
#import numpy as np

def main():
	n,x,y=MI()
	ans=[0]*(n)

	for i in range(1,n):
		for j in range(i+1,n+1):
			dis=min(j-i,abs(x-i)+abs(y-j)+1,abs(x-j)+abs(y-i)+1)
			ans[dis]+=1


	print(*ans[1:],sep="\n")


















if __name__ == "__main__":
	main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];
 
 
int main () {
    int N; string S;
    cin >> N >> S;
    long long r =0, g =0, b = 0;
    for(auto c : S){
        if(c == 'R') ++r;
        else if(c == 'G') ++g;
        else ++b;
    }

    long long all = r*g*b;
    long long sub =0;
    for(int i = 0; i<N; ++i){
        for(int j =i+1; j<N; ++j){
            if(S[i]== S[j])continue;
            int k  =j*2-i;
            if(k>=N || S[k] == S[i]|| S[k]== S[j])continue;
            ++sub;
        }
    }
    cout << all-sub << endl;





}

Measured memory_bytes: 3636
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

S = input()

if S[0] == S[1] == S[2]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 5304
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}

long long a[110000][3];
long long dp[110000][3];

int main() {
	int n, _a, _b, _c;
        cin >> n;
	for (int i=0; i<n; i++) {
		cin >> _a >> _b >> _c;
		a[i][0] = _a;
		a[i][1] = _b;
		a[i][2] = _c;
	}

	for (int i = 0; i < n+1; i++) {
		for (int j = 0; j < 3; j++) {
			dp[i][j] = 0;
		}
	}


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				chmax(dp[i+1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	long long res = 0;
	for (int j = 0; j < 3; j++) chmax(res, dp[n][j]);
	cout << res << endl;
	}




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

int main()
{
	int N; cin >> N;
	string ans = "No";
	rep(i, 9) rep(j, 9) if (N == (i + 1) * (j + 1)) ans = "Yes";
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
 
char str[1010];
int cnt[1000];
int main()
{
    scanf("%s", str);
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0;str[i];++i)
        ++cnt[ str[i] ];
    if(cnt['N'] && cnt['S'] && !cnt['W'] && !cnt['E'])
    {
        puts("Yes");
        return 0;
    }
    if(cnt['W'] && cnt['E'] && !cnt['N'] && !cnt['S'])
    {
        puts("Yes");
        return 0;
    }
    if(cnt['N'] && cnt['S'] && cnt['W'] && cnt['E'])
    {
        puts("Yes");
        return 0;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b;
    cin >> a >> b;

    if(a == 1) a += 13;
    if(b == 1) b += 13;

    if(a > b){
        p("Alice");
    }else if(a < b){
        p("Bob");
    }else{
        p("Draw");
    }
}


Measured memory_bytes: 256
require 'time'

intToDay = ["Sunday",
            "Monday",
             "Tuesday",
            "Wednesday",
           "Thursday",
            "Friday",
           "Saturday"]
loop do
  data = gets.split.map(&:to_i)
  break if data[0] == 0
  puts intToDay[Date.new(2004,data[0],data[1]).wday]
end

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

int main(void){
    long long int A, B, K;
    cin >> A >> B >> K;

    long long int ans1;
    if(A > K) ans1 = A-K;
    else ans1 = 0;
    
    long long int ans2;
    if(ans1 > 0) ans2 = B;
    else ans2 = B+A-K;
    if(ans2 < 0) ans2 = 0;

    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vl cum(n, 0);
    cum[0] = a[0];
    for (int i = 1; i < n; ++i) {
        cum[i] = cum[i - 1] + a[i];
    }
    auto check = [&](ll mid) {
        ll cnt = 0;
        for (int i = 0; i < n; ++i) {
            ll temp = a.end() - lower_bound(a.begin(), a.end(), mid - a[i]);
            if (temp >= 0)
                cnt += temp;
        }
        return cnt >= m;
    };
    ll ok = 0;
    ll ng = 4 * 100000;
    while (abs(ok - ng) != 1) {
        ll mid = (ng + ok) / 2;
        if (check(mid))
            ok = mid;
        else
            ng = mid;
    }
    ll ret    = 0;
    ll tot    = 0;
    ll border = 0;
    for (int i = 0; i < n; ++i) {
        ll cnt = -distance(a.end(), lower_bound(a.begin(), a.end(), ok - a[i]));
        if (cnt > 0) {
            ll cntupper = -distance(a.end(), upper_bound(a.begin(), a.end(), ok - a[i]));
            if (cntupper == cnt) {
                ret += cnt * a[i];
                ret += cum[n - 1];
                if (n - 1 - cnt >= 0)
                    ret -= cum[n - 1 - cnt];
                tot += cnt;
            } else {
                ret += cntupper * a[i];
                ret += cum[n - 1];
                if (n - 1 - cntupper >= 0)
                    ret -= cum[n - 1 - cntupper];
                tot += cntupper;
                border += cnt - cntupper;
            }
        }
    }
    ret += (m - tot) * ok;
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1792
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 pair<ld, ld> P;
typedef vector<ld> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
ld EPS=0.001;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    cout << fixed << setprecision(10);
    ld a;
    ld b;
    cin>>a>>b;
    ll c=b*100.00+EPS;
    cout<<(ll)(a*c/100)<<endl;
}


Measured memory_bytes: 3768
import java.util.Scanner;

public class Main{
	static int[][] dp=new int[101][10001];
	static int N, W;
    static int[] w=new int[101];
    static int[] v=new int[101];
	static void dp() {
    	for(int i=0; i<=W; i++) {
    		dp[0][i]=0;
    	}
    	for(int i=0; i<N; i++) {
    		for(int j=0; j<=W; j++) {
    			if(j<w[i]) {
    				dp[i+1][j]=dp[i][j];
    			}
    			else {
    				dp[i+1][j]=Math.max(dp[i][j], dp[i][j-w[i]]+v[i]);
    			}
    		}
    	}
    }
	
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N=sc.nextInt();
        W=sc.nextInt();
        for(int i=0; i<N; i++) {
        	v[i]=sc.nextInt();
        	w[i]=sc.nextInt();
        }
        dp();
        System.out.println(dp[N][W]);
        
	}
}


Measured memory_bytes: 30900
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a[200005];
int main()
{
	SPEED;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],a[i]-=i;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		a[i]+=a[i-1];
	a[n+1]=INF;
	ll ans=INF;
	for(int i=0;i<=n;i++)
	{
		ll x=a[n]-2*a[i];
		ll y=2*i-n;
		if(y==0)
		{
			ans=min(ans,x);
			continue;
		}
		ll b=(-x)/y;
		b=max(b,a[i]-a[i-1]);
		while(b<=a[i+1]-a[i]&&b*y+x<0)
			b++,cout<<b<<endl;
		b=min(b,a[i+1]-a[i]);
		if(b*y+x<0)continue;
		ans=min(ans,b*y+x);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);

        int count = 0;
        int N = scanner.nextInt();

        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if (temp % 2 != 0) continue;
            while (temp % 2 == 0 && temp != 0) {
                temp /= 2;
                count ++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 36048
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0);
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];



signed main(){
	IOS
	ll n;
	cin >> n;
	bool ok = true;
	for (int i = 0;i < n;++i) {
		ll a;
		cin >> a;
		if(a % 2 != 0)ok = false;
	}
	
	cout << (!ok ? "first" : "second") << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline 
#define int long long
int n,m,T;long long P,p[200005],f[200005],a,b,c,d,s=1,inv[2000005],jc[2000005],jcinv[2000005];
il int read()
{
	int k=1,re=0;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')k=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();}
	return re*k;
}
il void write(int x)
{
	if(x<0)return write(-x),void();
	if(x<=9)return putchar(x+48),void();
	return write(x/10),write(x%10),void();
}
signed main()
{
	int n;
	n=read()%10;
	if(n==0||n==1||n==6||n==8)puts("pon");
	else if(n==3)puts("bon");
	else puts("hon");
}

Measured memory_bytes: 3600
#G
N,M=map(int,input().split())
A=[[] for i in range(N+1)]
B=[0 for i in range(N+1)]
dp=[0 for j in range(N+1)]

for i in range(M):
    x,y=map(int,input().split())
    A[x].append(y)
    B[y]+=1

st=[]
for i in range(1,N+1):
    if B[i]==0:
        st.append(i)
        dp[i]

while len(st):
    x=st.pop()
    for y in A[x]:
        dp[y]=max(dp[y],dp[x]+1)
        B[y]-=1
        if B[y]==0:
            st.append(y)
print(max(dp))

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

using namespace std;

#define ll long long

int main(){
    int n,x,d=0,c=0;
    cin>>n>>x;
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
        d=d+a[i];
        if(d<=x) c++;
    }
    cout<<c+1<<endl;


}

Measured memory_bytes: 256
/* Greedy Takahashi */

#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  long a,b,k;
  cin >> a >> b >> k;

  if(a>=k)
    cout << a-k << " " << b << endl;
  else{
    if(a+b>=k){
      cout << 0 << " " << a+b-k << endl;
    }
    else{
      cout << 0 << " " << 0 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,k;
    cin>>n>>k;
    vector<long long> num(n);
    vector<long long> zentai(n,0);
    vector<long long> ato(n,0);
    
    for(int i=0;i<n;i++){
        cin>>num.at(i);
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(num.at(i)>num.at(j)){
                zentai.at(i)++;
                if(i<j){
                    ato.at(i)++;
                }
            }
        }
    }
    
    long long ans=0;
    
    for(int i=0;i<n;i++){
        ans+=ato.at(i)*k;
        ans%=1000000007;
        
        long long kake=((k-1)*(k)/2)%1000000007;
        
        ans+=zentai.at(i)*kake;
        ans%=1000000007;
    }
    
    cout<<ans<<endl;
}


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

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            char[] inputs = Console.ReadLine().ToArray();
            string retStr = "Yes";

            if (N == 1 || N % 2 == 1)
            {
                retStr = "No";
            }
            else 
            {

                int i = 0;
                int j = N / 2;
                while (true)
                {
                    if (inputs[i] != inputs[j])
                    {
                        retStr = "No";
                        break;
                    }
                    i++;
                    j++;
                    if (j >= N)
                    {
                        break;
                    }
                }
            }

            Console.WriteLine(retStr);
            Console.ReadKey();
        }

    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
ll n, m;
vector<vl> adj;
vector<bool> vis;
ll ans=0, temp=0;
void dfs(ll node, ll parent)
{
	vis[node]=true;
	temp++;
	for(auto x: adj[node])
	{
		if(!vis[x])
			dfs(x, node);
	}
}
void solve()
{
    cin>>n>>m;
    vis.resize(n, false);
    adj.resize(n);
    forr(i, m)
    {
    	ll u, v;
    	cin>>u>>v;
    	--u, --v;
    	adj[u].pb(v), adj[v].pb(u);
    }
    forr(i, n)
    {
    	if(!vis[i])
    		temp=0, dfs(i, -1);
    	ans=max(ans, temp);
    }
    cout<<ans<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 23460
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> a(N), b(N);
    Rep (i, N) cin >> a[i];
    Rep (i, N) cin >> b[i];

    ll acta = 0;
    Rep (i, N) {
        if (a[i] > b[i]) {
            acta += a[i] - b[i];
            b[i] = a[i];
        } else if (a[i] < b[i]) {
            acta -= (b[i] - a[i]) / 2;
            a[i] += (b[i] - a[i]) / 2;
        }
    }

    if (acta > 0) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int d = in.nextInt();
            int g = in.nextInt() / 100;
            int[] p = new int[d];
            int[] c = new int[d];
            for (int i = 0; i < d; i++) {
                p[i] = in.nextInt();
                c[i] = in.nextInt() / 100;
            }

            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < 1 << d; i++) {
                int cnt = 0;
                int sum = 0;
                for (int j = 0; j < d; j++) {
                    if ((i >> j & 1) == 1) {
                        cnt += p[j];
                        sum += p[j] * (j + 1) + c[j];
                    }
                }
                for (int j = d - 1; j >= 0; j--) {
                    if (sum < g && (i >> j & 1) == 0) {
                        int tmp = Math.min(p[j], (g - sum + j) / (j + 1));
                        cnt += tmp;
                        sum += tmp * (j + 1);
                    }
                }

                ans = Math.min(ans, cnt);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 22996
using System;
using System.Collections.Generic;

namespace ABC089_C_March
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			long mCount = 0;
			long aCount = 0;
			long rCount = 0;
			long cCount = 0;
			long hCount = 0;

			int[] P = new[] {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
			int[] Q = new[] {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
			int[] R = new[] {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

			for (int i = 0; i < n; i++)
			{
				string firstName = Console.ReadLine().Substring(0, 1);

				if (firstName == "M") mCount++;
				if (firstName == "A") aCount++;
				if (firstName == "R") rCount++;
				if (firstName == "C") cCount++;
				if (firstName == "H") hCount++;
			}
			
			List<long> numbers = new List<long>();
			numbers.Add(mCount);
			numbers.Add(aCount);
			numbers.Add(rCount);
			numbers.Add(cCount);
			numbers.Add(hCount);
			
			long result = 0;
			
			for (int i = 0; i < 10; i++)
			{
				result += numbers[P[i]] * numbers[Q[i]] * numbers[R[i]];
			}
			
			Console.WriteLine(result);

			/*numbers.Sort();
			for (int i = 0; i < 3; i++)
			{
				long minNumber = numbers[i];
				result += minNumber;
				for (int j = i + 1; j < 5; j++)
				{
					numbers[j] -= minNumber;
				}
			}
			
			Console.WriteLine(result);*/
		}
	}
}


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N){
        cin >> a.at(i);
    }
    bool b = 0;
    int t = 1;
    int cnt = 0;
    while(cnt<=N){
        t = a.at(t-1);
        ++cnt;
        if(t==2){
            b = 1;break;
        }
    }
    if(b){
        cout << cnt << endl;
    }else{
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	while(n!=0){
		ans++;
		n/=k;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int ma=0,mi=1000000001,n,a;cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a>ma)ma=a;
        if(a<mi)mi=a;
    }
    cout<<ma-mi<<endl;
}


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

int main()
{
double b, c;
int k=0,a;
double x,y,z=0;
vector<double>v;
cin>>a>>b;
for(int i=1;i<=a;i++)
{
 cin>>x;
 v.push_back(x);z+=x;
}
y=1/(4*b);
for(int i=0;i<v.size();i++)
{
 if(v[i]/z>=y)k++;
}
if(k>=b)
cout<<"Yes\n";
else cout<<"No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
using namespace std;

int sdx[] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
int sdy[] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };
int pdx[] = { -2, -2, -2,  2, 2, 2, -1,  0,  1, -1, 0, 1 };
int pdy[] = { -1,  0,  1, -1, 0, 1, -2, -2, -2,  2, 2, 2 };
int park[10][10][10];
int px, py, n, sx[10], sy[10];

int main()
{
	while (true) {
		cin >> px >> py; if (!(px | py)) break;
		cin >> n;
		rep(i, n) cin >> sx[i] >> sy[i];
		rep(i, 10) rep(j, 10) rep(k, 10) park[i][j][k] = 0;
		rep(k, n) rep(i, 9) {
			int x = sx[k] + sdx[i];
			int y = sy[k] + sdy[i];
			if (x < 0 || x > 9 || y < 0 || y > 9) continue;
			park[y][x][k] = 1;
		}

		queue<pair<pair<int, int>, int> > q;
		set<pair<pair<int, int>, int> > s;
		q.push(mp(mp(py, px), -1));

		bool ok = false, loop = false;
		while (!q.empty()) {
			pair<pair<int, int>, int> t = q.front();
			q.pop();
			rep(i, 12) {
				int x = t.first.second + pdx[i];
				int y = t.first.first + pdy[i];
				int z = t.second;
//				if (z == n-1) { z = -1; loop = true; }
				if (z == n-1) { ok = true; break; }
				if (x < 0 || x > 9 || y < 0 || y > 9) continue;
				if (!park[y][x][z+1]) continue;
				if (s.find(mp(mp(y, x), z+1)) == s.end()) {
					s.insert(mp(mp(y, x), z+1));
					q.push(mp(mp(y, x), z+1));
				}
//				else if (loop) { ok = true; break; }
			}
		}

		cout << (ok ? "OK" : "NA") << endl;
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int M = -1000000000;
	int m;
	cin >> m;
	for(int i = 1; i < n; ++i){
		int r;
		cin >> r;
		M = max(M, r - m);
		m = min(m, r);
	}
	cout << M << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	int x[m];
	for(int i=0;i<m;i++) cin >> x[i];
	if(n>=m){
		cout << 0 << endl;
		return 0;
	}
	sort(x,x+m);
	int dist[m-1];
	for(int i=1;i<m;i++){
		dist[i-1]=x[i]-x[i-1];
	}
	sort(dist,dist+(m-1));
	reverse(dist,dist+(m-1));
	int ans=x[m-1]-x[0];
	for(int i=0;i<n-1;i++) ans-=dist[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    V<map<int,int>> a(n);
    V<string> s(n);
    cinf(n,s);
    map<int,int> mp;
    rep(i,n){
        int m=s[i].size();
        rep(j,m){
            a[i][s[i][j]-'a']++;
        }
    }
    rep(i,26) mp[i]=1000000;
    rep(i,26){
        rep(j,n) chmin(mp[i],a[j][i]);
    }
    string t;
    rep(i,26){
        int x=mp[i];
        while(x--){
            t+=i+'a';
        }
    }
    cout<<t<<endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    private final static long MOD = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        Long ans = 1L;

        Integer[] a = new Integer[n];
        LinkedList<Integer> s = new LinkedList<>();
        LinkedList<Integer> t = new LinkedList<>();

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (a[i] < 0) t.add(a[i]);
            else s.add(a[i]);
        }

        int S = s.size(), T = t.size();
        boolean ok = false;

        if (S > 0) {
            if (n == k) ok = (T % 2 == 0);
            else ok = true;
        } else ok = (k % 2 == 0);

        if (!ok) {
            Arrays.sort(a, (x, y) -> (Math.abs(x) - Math.abs(y)));
            for (int i = 0; i < k; i++) {
                ans = mul(ans, a[i]);
            }
        } else {
            Collections.sort(s);
            Collections.sort(t, (x, y) -> (y - x));
            if (k % 2 == 1) {
                ans = mul(ans, s.pollLast());
            }
            ArrayList<Long> p = new ArrayList<>();
            while (s.size() >= 2) {
                long x = s.pollLast();
                x *= s.pollLast();
                p.add(x);
            }
            while (t.size() >= 2) {
                long x = t.pollLast();
                x *= t.pollLast();
                p.add(x);
            }
            Collections.sort(p, (o1, o2) -> Long.compare(o2, o1));
            for (int i = 0; i < k / 2; i++) {
                ans = mul(ans, p.get(i));
            }
        }
        ans = Math.floorMod(ans, MOD);
        System.out.println(ans);

    }

    private static long mul(long a, long b) {
        return (((a + MOD) % MOD) * ((b + MOD) % MOD)) % MOD;
    }
}

Measured memory_bytes: 69820
N = int(input())
A = list(map(int, input().split()))

dic = {i:0 for i in range(1, N + 1)}


for i in range(N):
    a = A[i]
    dic[a] = i + 1

for i in range(1, N + 1):
    print(dic[i], end="")
    if i != N:
        print(" ", end="")

print()

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

int main(){
    double  D,T,S;
    cin >> D >> T >> S;

    double time = 0;

    time = D / S ;
    if(time <= T) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}    

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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            //var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var s = Console.ReadLine().Replace("/", "");
            var date = DateTime.ParseExact(s, "yyyyMMdd", null);
            date = date.AddYears(1);

            Console.WriteLine($"{date:yyyy/MM/dd}");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13408
#include <iostream>

int main()
{
	long N;
	std::cin >> N;

	// Nは100以下なので、総当たりでも間に合うのでは…？
	for ( int x = 0;; x++ )
	{
		for ( int y = 0;; y++ )
		{
			long z = 4 *x + 7 * y;
			if ( z == N )
			{
				std::cout << "Yes" << std::endl;
				goto END;
			}
			else if ( z > N )
			{
				// 金額オーバーなので終了
				break;
			}
		}

		if ( 4 * x > N )
		{
			// ここまでxを増やすまでに、条件を満たすyが存在しなかったので、ダメ
			break;
		}
	}

	std::cout << "No" << std::endl;
END:

	return ( 0 );
}


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

int divisor(int x){
    int count = 0;
    rep(i,x){
        if(x%(i+1)==0) count++;
    }
    return count;
}

void solve(){
    int n;
    cin >> n;
    int c = 0;
    rep(i,n){
        if((i+1)%2==1 && divisor(i+1)==8) c++;
    }
    cout << c << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.print(a / b + " " + a % b + " ");
        double d = (double)a / b;
        System.out.printf("%f", d);

    }

}


Measured memory_bytes: 26592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int a, b, x;
    cin >> a >> b >>x;

    auto sol = [](int a, int x)-> int{
        if(a  <=0)return a;
        return a/x;
    };
    cout << sol(b,x) - sol(a-1, x);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
S = input()
judge = True
for i in range(len(S)):
    if (i+1) % 2 == 0:
        if S[i] not in {"L", "U", "D"}:
            judge = False
            break
    else:
        if S[i] not in {"R", "U", "D"}:
            judge = False
            break
if judge:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if (m == -1 && f == -1 && r == -1) {
                break;
            }

            int t;
            t = m + f;
            if(m==-1 || f==-1){
                System.out.println("F");
        }else if (t >= 80) {
                System.out.println("A");
            } else if (t >= 65 && t < 80) {
                System.out.println("B");
            } else if (t >= 50 && t < 65 || r >= 50) {
                System.out.println("C");
            } else if (t >= 30 ) {
                System.out.println("D");
            }else if(r>=50){
                System.out.println("C");
                } else if (t < 30 ) {
                System.out.println("F");
            }
        }
    }
}



Measured memory_bytes: 26320
L, R = map(int, input().split())

m = 2019

if R - L > 2100:
    print(0)
else:
    tmp_min = 2018
    for i in range(L, R):
        mod_i = i % m
        for j in range(i + 1, R+1):
            mod = (mod_i * j) % m
            if tmp_min > mod:
                tmp_min = mod
    print(tmp_min)

Measured memory_bytes: 41452
#include <iostream>

using namespace std;

int main(void)
{
    int N;

    cin >> N;

    for(int i = 0; i <= 10; i++)
    {
        if(N <= (i * 1000) )
        {
            cout << (i * 1000) - N << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N;
ll X, a[51], p[51], ans;

int main() {
	cin >> N >> X;
	a[0] = p[0] = 1;
	for (int i = 1; i != N + 1; ++i) {
		a[i] = a[i - 1] * 2 + 3;
		p[i] = p[i - 1] * 2 + 1;
	}
	int i = N;
	while (X) {
		if (X >= a[i]) {
			X -= a[i];
			ans += p[i];
		}
		else {
			if (X >= a[i - 1] + 2) {
				X -= a[i - 1] + 2;
				ans += p[i - 1] + 1;
			}
			else
				--X;
			--i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define readvec(vec)    \
  for (auto& e : vec) { \
    cin >> e;           \
  }
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool> > vec2bool;
typedef vector<vector<int> > vec2int;
typedef vector<vector<double> > vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
	using namespace std;
	#define mod 1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define ps push
	#define pll pair<long,long>
	typedef long long ll;
	#define PI 3.14159265
	
	
	const ll INF=(ll)1e16;
	
	
	int main()
	{
		ios::sync_with_stdio(0); 
		cin.tie(0); 
		cout.tie(0);
		
		ll n;
		cin>>n;
		ll s=(n/500)*1000 +((n%500)/5)*5;
		cout<<s;
		
	}		


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main(){
  int s, w;
  cin >> s >> w;
  if (w >= s) cout << "unsafe\n";
  else cout << "safe\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c;cin>>a>>b>>c;
  string result = "Alice";
  if(a==b){
    cout << "Draw";
    return 0;
  }else if(b>a&&a!=1||b==1){
    result = "Bob";
  }
  cout << result;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
if k==0:
    print(n**2);exit()
def f(b):
    return (b-k)*(n//b)+(max(0,1+n-(n//b)*b-k) if n%b else 0)
print(sum(f(i)for i in range(k+1,n+1)))


Measured memory_bytes: 40176
//Refreshment Area
#include <iostream>

using namespace std;

static const int MAX = 100;

bool A[MAX][MAX];

int main() {
    int N, M, D;
    cin >> N >> M >> D;

    char a;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            cin >> a;
            A[i][j] = a == '.';
        }
    }

    int cnt = 0, space;
    for(int i = 0; i < N; i++) {
        space = 0;
        for(int j = 0; j < M; j++) {
            if(A[i][j]) {
                space++;
                if(space >= D) cnt++;
            } else {
                space = 0;
            }
        }
    }

    for(int j = 0; j < M; j++) {
        space = 0;
        for(int i = 0; i < N; i++) {
            if(A[i][j]) {
                space++;
                if(space >= D) cnt++;
            } else {
                space = 0;
            }
        }
    }

    cout << cnt << endl;
}


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

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

string s;
int iter;

ll dfs();

ll dfs2(ll val,int op){
  ll tmp = 0;
  while(true){
    if('0'<=s[iter]&&s[iter]<='9'){
      tmp *= 10;
      tmp += s[iter]-'0';
    }else if(s[iter]=='('){
      ++iter;
      tmp = dfs();
    }else if(s[iter]==')' || s[iter]=='=' || s[iter]=='+' || s[iter]=='-'){
      if(op) val *= tmp;
      else val /= tmp;
      --iter;
      return val;
    }else if(s[iter]=='*' || s[iter]=='/'){
      if(op) val *= tmp;
      else val /= tmp;
      op = s[iter]=='*'?1:0;
      tmp = 0;
    }
    if(iter>=s.size()){
      --iter;--iter;
      return val;
    }
    ++iter;
  }
}

ll dfs(){
  ll val = 0;
  ll tmp = 0;
  int op = 1; // op==1?'+':'-'
  while(true){
    if('0'<=s[iter]&&s[iter]<='9'){
      tmp *= 10;
      tmp += s[iter]-'0';
    }else if(s[iter]=='('){
      ++iter;
      tmp = dfs();
    }else if(s[iter]==')' || s[iter]=='='){
      val += op*tmp;
      tmp = 0;
      return val;
    }else if(s[iter]=='+'){
      val += op*tmp;
      tmp = 0;
      op = 1;
    }else if(s[iter]=='-'){
      val += op*tmp;
      tmp = 0;
      op = -1;
    }else if(s[iter]=='*' || s[iter]=='/'){
      ++iter;
      val += op*dfs2(tmp,s[iter-1]=='*'?1:0);
      tmp = 0;
    }
    if(iter>=s.size()){
      --iter;--iter;
      return val;
    }
    ++iter;
  }
}

int main(){
  int n;
  cin>>n;
  while(n--){
    cin>>s;
    iter = 0;
    cout<<dfs()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b;
  cin>>a>>b;
  if(b%a==0){
    cout<<a+b<<endl;
  }
else cout<<b-a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string name;
    cin>>name;
    int i,k=0;
    for(i=0;i<name.size();i++)
    {
        if(name[i]=='7')
            k++;
    }
    if(k>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int H,W,M; cin >> H >> W >> M;

  vector<int> h(H,0);
  vector<int> w(W,0);
  map<pii,int> m;

  vector<int> x(M), y(M);

  for(int i = 0; i < M; i++){
    int tmp_x, tmp_y; cin >> tmp_x >> tmp_y;
    tmp_x--; tmp_y--;
    h[tmp_x]++;
    w[tmp_y]++;
    x[i] = tmp_x;
    y[i] = tmp_y;
    m[make_pair(tmp_x, tmp_y)]++;
  }

  int h_max = 0, w_max = 0;

  for(int i = 0; i < H; i++){
    h_max = max(h_max, h[i]);
  }
  for(int j = 0; j < W; j++){
    w_max = max(w_max, w[j]);
  }

  vector<int> vec_h, vec_w;

  for(int i = 0; i < H; i++){
    if(h[i] == h_max){
      vec_h.push_back(i);
    }
  }
  for(int j = 0; j < W; j++){
    if(w[j] == w_max){
      vec_w.push_back(j);
    }
  }

  int count = 0;
  for(auto i_h: vec_h){
    for(auto i_w: vec_w){
      if(count > M){
        cout << h_max + w_max << endl;
        return 0;
      }

      if(m[make_pair(i_h, i_w)] == 0){
        cout << h_max + w_max << endl;
        return 0;
      } else {
        count++;
      }
    }
  }

  cout << h_max + w_max -1 << endl;
  return 0;

}


Measured memory_bytes: 30696
#include<iostream>
#include<cstdio>

using namespace std;
char a[2][3];
int main()
{
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<3;j++)
        {
            scanf("%c",&a[i][j]);
        }
        getchar();
    }
    if(a[0][1]==a[1][1])
    {
        if(a[0][0]==a[1][2]&&a[0][2]==a[1][0])
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

unordered_map<LL,int> dp;

int main(){
    unordered_map<LL,vector<P>> G;
    int n,m;cin >> n >> m;
    LL hash = 1e9;
    for (int i = 0; i < m; i++) {
        int a,b,c;cin >> a >> b >> c;
        a--,b--;
        if(dp.find(a*hash+c)==dp.end()){
            dp[a*hash+c]=INF;
            G[a*hash+c].pb({a+n,-1});
            G[(n+a)*hash-1].pb({a,c});
        }
        G[a*hash+c].pb({b,c});
        if(dp.find(b*hash+c)==dp.end()){
            dp[b*hash+c]=INF;
            G[b*hash+c].pb({b+n,-1});
            G[(n+b)*hash-1].pb({b,c});
        }
        G[b*hash+c].pb({a,c});
        if(dp.find((a+n)*hash-1)==dp.end()){
            dp[(a+n)*hash-1]=INF;
        }
        if(dp.find((b+n)*hash-1)==dp.end()){
            dp[(b+n)*hash-1]=INF;
        }
    }
    priority_queue<pair<int,P>,vector<pair<int,P>>,greater<pair<int,P>>> pq;
    pq.push({0,{-1,n}});
    dp[n*hash-1]=0;
    while(!pq.empty()){
        int v=pq.top().second.second;
        int r=pq.top().second.first;
        int d=pq.top().first;
        pq.pop();
        int id=dp[v*hash+r];
        if(id<d) continue;
        if(r==-1){
            for(auto g:G[v*hash+r]){
                int to=g.first;
                int rr=g.second;
                int xd=dp[to*hash+rr];
                if(xd>d+1){
                    dp[to*hash+rr]=d+1;
                    pq.push({d+1,{rr,to}});
                }
            }
        }
        else{
            for(auto g:G[v*hash+r]){
                int to=g.first;
                int rr=g.second;
                int xd=dp[to*hash+rr];
                if(xd>d){
                    dp[to*hash+rr]=d;
                    pq.push({d,{rr,to}});
                }
            }
        }
    }
    int ans=INF;
    for(auto g:G[(2*n-1)*hash-1]){
        ans=min(ans,dp[g.first*hash+g.second]);
    }
    if(ans==INF) cout << "-1" << endl;
    else cout << ans << endl;
    return 0;
}



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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int h, w;
  cin >> h >> w;

  char c[128][128];
  reps(i, 1, h) {
    reps(j, 1, w) {
      cin >> c[i][j];
    }
  }

  reps(i, 0, h+1) {
    reps(j, 0, w+1) {
      if (i == 0 || j == 0 || i == h+1 || j == w+1) cout << '#';
      else cout << c[i][j];
    }
    cout << "\n";
  }

  return 0;
}

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> ac(n, 0), wa(n, 0);
    int ans_ac = 0;
    int ans_wa = 0;
    for (int i = 0; i < m; i++) {
        int t; string s;
        cin >> t >> s;
        t--;
        if (s == "AC") {
            if (ac[t] == 0) {
                ans_ac++;
                ac[t] = 1;
                ans_wa += wa[t];
            }
        } else {
            wa[t]++;
        }
    }
    cout << ans_ac << " " << ans_wa << endl;


    return 0;
}

Measured memory_bytes: 1024
#include   <bits/stdc++.h>
#include   <stdio.h>
#include   <stdlib.h>
#define    mp make_pair
#define    ii   int
#define    ll  long long
#define    ld  long double
#define    pii  pair<ii,ii>
#define    pll  pair<ll,ll>
#define    vcii   vector<ii>
#define    vcll   vector<ll>
#define    vcd     vector<double>
#define    pb push_back
#define    vcs    vector<string>
#define    vpii   vector<pii>
#define    vpll   vector<pll>
#define    scll(x)  scanf("%lld",&x)
#define    pfll(x) printf("%lld\n",x)
#define    scd(x) scanf("%llf",&x)
#define    pfd(x) prinf("%0.5llf\n",x)
#define    pie acos(-1)

using namespace std;



int main()
{
   int a,b,c,d,i;
  // ll  t,n,a,b,d,i,j,c,s,m,test,q,area,area2,x,y,k,f;
   cin>>a>>b>>c>>d;

   for(i=0;(c>0 && a>0);i++)
   {
   	  if((i%2)==0)
	  {
	  	 c=(c-b);
	  	 //cout<<"C"<<c<<endl;
	  	 continue;
	  }
	  else
	  {
	  	 a=(a-d);
	  }
   }

    if(c<=0)
	  {
	  	cout<<"Yes\n";
	  }

    else
    {
   	  cout<<"No\n";
    }

    return 0;
}





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

int N, A, B;

int main() {
    scanf("%d %d %d", &N, &A, &B);

    if(A + B - 1 > N) {
        printf("-1");
        return 0;
    }
    if(N > 1LL * A * B) {
        printf("-1");
        return 0;
    }
    int pos = N;
    for(int i = 0; i < B; i++) {
        int nxt = max(B - i - 1, pos - A);
        for(int j = nxt + 1; j <= pos; j++) {
            printf("%d ", j);
        }
        pos = nxt;
    }
}


Measured memory_bytes: 2176