akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int black = 0;
        char map[][] = new char[h][w];
        char searchmap[][] = new char[h][w];
        for (int y = 0;y < h;++y){
            String s = sc.next();
            for (int x = 0;x < w;++x){
                map[y][x] = s.charAt(x);
                if(map[y][x] == '#')++black;
                searchmap[y][x] = map[y][x];
            }
        }
        searchmap[0][0] = '!';
        int ser = search(w, h, searchmap);
        if(ser == -1){
            System.out.println(ser);
        }
        else System.out.println((w * h - 1 - ser) - black);
    }

    public static int search(int w,int h,char map[][]){
        int count = 0;
        while (true){
            for (int x = 0;x < w;++x){
                for (int y = 0;y < h;++y){
                    if(map[y][x] == '.'){
                        if(x > 0&&map[y][x - 1] == '!'){
                            map[y][x] = '?';
                        }
                        else if(x < w - 1&&map[y][x + 1] == '!'){
                            map[y][x] = '?';
                        }
                        else if(y > 0&&map[y - 1][x] == '!'){
                            map[y][x] = '?';
                        }
                        else if(y < h - 1&&map[y + 1][x] == '!'){
                            map[y][x] = '?';
                        }
                    }
                }
            }
            if(map[h - 1][w - 1] == '?'){
                return count + 1;
            }
            boolean flag = false;
            for (int y = 0;y < h;++y) {
                for (int x = 0; x < w;++x) {
                    if(map[y][x] == '?'){
                        map[y][x] = '!';
                        flag = true;
                    }
                }
            }
            if(!flag){
                return -1;
            }
            ++count;
        }
    }


}

Measured memory_bytes: 24276
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	vector<int>a;
	vector<int>b;
	vector<int>c;
	int n, k, s;
	int x, y, z;
	int ans;
	scanf("%d %d", &n, &k);
	if ((2 * k) > (n + 1)) {
		printf("-1\n");
		return 0;
	}
	if (n % 2 == 0) {
		s = n / 2;
		a.push_back(k);
		b.push_back(k+(2 * s));
		c.push_back(k+(4 * s));
		f(i, s) {
			a.push_back(k + i + 1);
			b.push_back(k + (3 * s) + i);
			c.push_back(k + (4 * s) + (2 * i) + 1);
		}
		f(i, s-1) {
			a.push_back(k + s + i + 1);
			b.push_back(k + (2 * s) + i + 1);
			c.push_back(k + (4 * s) + (2 * i) + 2);
		}
	}
	else {
		s = n / 2;
		s++;
		f(i, s) {
			a.push_back(k + i);
			b.push_back(k + (3 * s) + i - 2);
			c.push_back(k + (4 * s) + (2 * i) - 2);
		}
		f(i, s - 1) {
			a.push_back(k + s + i);
			b.push_back(k + (2 * s) + i - 1);
			c.push_back(k + (4 * s) + (2 * i) - 1);
		}
	}
	f(i, n) {
		printf("%d %d %d\n", a[i], b[i], c[i]);
}


	return 0;
}

Measured memory_bytes: 3692
#include<stdio.h>
int main(void){
	int i;
	int a[7], b[7];

	for (i = 0; i < 7; i++)
		scanf("%d%d", &a[i], &b[i]);

	int x = 0;
	for (i = 0; i < 7; i++){
		x = a[i] - b[i];
		printf("%d\n", x);
	}
}


Measured memory_bytes: 2704
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <cctype>

using namespace std;
int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    for (int i = 0; i < k;i++)
    {
        if(a>=b)
        {
            b = b * 2;
          
        }
        else if(b>=c)
        {
            c = c * 2;
          
        }

    }
    if(a<b&&b<c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

        return 0;
}

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

int const N = 1e5+5;
long long const MOD = 1e9+7;
long long dp[N];
bool b[N];
int n,m,i,j;


int main() {
	// your code goes here
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>j;
		b[j] = true;
	}
	dp[0] = 1;
	dp[1] = (b[1]==false);
	
	for(i=2;i<=n;i++){
		if(b[i]==true) continue;
		dp[i] = dp[i-1]+dp[i-2];
		dp[i] %= MOD;
	}
	
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  auto upd = [] (const vector<int>& v) {
    vector<int> imos((int) v.size() + 2);
    for (int i = 1; i <= (int) v.size(); i++) {
      int l = max(0, i - v[i - 1]);
      int r = min((int) v.size() + 1, i + v[i - 1] + 1);
      imos[l]++;
      imos[r]--;
    }
    for (int i = 1; i < (int) imos.size(); i++) {
      imos[i] += imos[i - 1];
    }
    vector<int> res((int) v.size());
    for (int i = 1; i <= (int) v.size(); i++) {
      res[i - 1] = imos[i];
    }
    return res;
  };
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < min(50, k); i++) {
    a = upd(a);
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 5580
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

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

    if (n > 9 || m > 9 || n < 1 || m < 1) {
        cout << -1 << '\n';
        return 0;
    }
    else {
        cout << n * m << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 256
main = getLine >>= print . compute . read

{-
1からnのそれぞれのkについて、arrのkの倍数全てに+1する
それに対して、sum $ map k * arr k する
ということは、
arrのkの倍数全てに +k して、sum $ elems arr する、でもいい。
+kとsumの順序を逆にすると、
1からnのそれぞれのkについて、[k,k+k..n] の和を求める、の和を求める、
というダケ！で、このリストは k * [1..div n k] だからループする必要もなかった
-}

compute :: Int -> Int
compute n = sum [ k * f (div n k) | k <- [1..n] ]
f m = m * succ m `div` 2


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

int main () {
  int n;
  cin >> n;
  
  vector<int> a(n); //社員iの上司がa[i]
  a[0] = -1;
  for (int i = 1; i < n; i++)
    cin >> a[i];
  
  vector<vector<int>> b(n, vector<int>(0)); //社員iの部下はb[i]
  for (int i = 0; i < n; i++) {
    if (i == 0) continue;
    
    b[a[i] - 1].push_back(i);
  }
  
  for (int i = 0; i < n; i++) {
    cout << b[i].size() << endl;
  }
}

Measured memory_bytes: 14872
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		char Character[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
				'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

		ArrayList<String> strInput = new ArrayList<String>();
		Scanner scanner = new Scanner(System.in);

		int intLineNum = 0;
		while (scanner.hasNext()) {
			String strLine = scanner.nextLine();

			//if (strLine.length() == 0) {
			//	break;
			//}

			strInput.add(strLine);
			intLineNum++;
		}

			for (int intI = 0; intI < 26; intI++) {
				int intCounter = 0;
				for (int intJ = 0; intJ < intLineNum; intJ++) {
					for (int intK = 0; intK < strInput.get(intJ).length(); intK++) {
						char charLine = strInput.get(intJ).charAt(intK);
							String strMoji = String.valueOf(charLine);
							String strChar = String.valueOf(Character[intI]);
							if (strMoji.equalsIgnoreCase(strChar)) {
								intCounter++;
							}
					}
				}
				System.out.println(Character[intI] + " : " + intCounter);
			}
	}

}



Measured memory_bytes: 30584
N, C, K = map(int, input().split())
T = []
for i in range(N):
    t = int(input())
    T.append(t)
T.sort()

cnt = 0
res = 1
time = T[0]
for i in range(N-1):
    cnt += 1
    if cnt == C or time + K < T[i+1]:
        res += 1
        cnt = 0
        time = T[i+1]
print(res)

Measured memory_bytes: 50904
#include<stdio.h>
long long int n, a[100010], b[100010];
int main(){
    long long int s=1,i,max=0,max1=0,y1=0,y2=0;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",a+i);
        if(max<a[i])max=a[i],y1=i;
    }
    for(i=0;i<n;i++){
        scanf("%lld",b+i);
        if(max1<=b[i])max1=b[i],y2=i;
        
    }
    if(max!=max1||y1>y2){
        printf("0");
        return 0;
    }
    max=0;
    for(i=0;i<=y1;i++){
        if(max>=a[i]){
            s=(s*a[i])%1000000007;
        }else{
            max=a[i];
        }
    }
    for(i=y1+1;i<y2;i++){
        s=(s*a[i])%1000000007;
    }
    max=0;
    for(i=n-1;i>=y2;i--){
        if(max>=b[i]){
            s=(s*b[i])%1000000007;
        }else{
            max=b[i];
        }
    }
    printf("%lld",s);
}

Measured memory_bytes: 1664
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
ll n,k,a,b,ans;
vector<P>v;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    ll i=0;
    while(k){
        ll l=min(v[i].second,k);
        ans+=v[i].first*l;
        k-=l;
        i++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define apo ios::sync_with_stdio(false);cin.tie(0)
#define MAX 1000
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}

ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

int main(){
	apo;
	ll t;
	cin>>t;
	ll rem=t%1000;
	if(rem==0){
		cout<<0;
	}
	else{
		cout<<1000-rem;
	}
}

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


int main() {
    int N,M;
    cin >> N >> M;
    int all = N + M;
    int ans;
    rep(i,N){
        ans += N-i-1;
    }
    rep(i,M){
        ans += M-i-1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a = [1,3,5,7,8,10,12]; b = [4,6,9,11]; c = [2]
x, y = gets.split.map &:to_i
if a.any? { |e| e == x } && a.any? {|e| e == y}
	puts "Yes"
elsif b.any? {|e| e == x} && b.any? {|e| e == y}
	puts "Yes"
elsif x == c[0] && y == c[0]
	puts "Yes"
else
	puts "No"
end


Measured memory_bytes: 1788
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000000000000001
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,x,y;
    ll n;
    cin>>x>>n;
    ll a[n];
    ll f=INT_MAX;
    ll z=INT_MAX;
    set<ll>s;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    for(i=0;i<=300;i++)
    {
        if(s.find(i)==s.end())
        {
            if(abs(i-x)<f)
            {
                f=abs(i-x);
                z=i;
            }
            else if(abs(i-x)==f)
            {
                z=min(z,i);
            }
        }
    }
    cout<<z;
    return 0;

}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return a.first*b.second<a.second*b.first;
}

const ll mod = 1e9+7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}

int main(){
    //clock_t tm = clock();
    fastio;
    int n,h,w;
    cin>>h>>w>>n;
    if(h>w){
        cout<<ceil((n*1.0)/h)<<endl;
    }
    else{
        cout<<ceil((n*1.0)/w)<<endl;
    }
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

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

using namespace std;

const string DREAM   = "dream";
const string DREAMER = "dreamer";
const string ERASE   = "erase";
const string ERASER  = "eraser";

string str;
string target = "";

bool concat(int from, int to) {
    if (target == str) return true;
    if (to >= str.length()) return false;
    for (int i = from; i < to; i++) if (target[i] != str[i]) return false;

    target += DREAM;
    bool dream = concat(to , to + 5);
    for (int i = 0; i < 5; i++) target.pop_back();

    target += DREAMER;
    bool dreamer = concat(to, to + 7);
    for (int i = 0; i < 7; i++) target.pop_back();

    target += ERASE;
    bool erase = concat(to, to + 5);
    for (int i = 0; i < 5; i++) target.pop_back();

    target += ERASER;
    bool eraser = concat(to, to + 6);
    for (int i = 0; i < 6; i++) target.pop_back();

    if (dream || dreamer || erase || eraser) return true;
    else                                     return false;
}

int main() {
    cin >> str;

    if (concat(0, 0)) cout << "YES" << endl;
    else                  cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<" "
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()

int main()
{
    ll n,x=0,y=0;
    string s;
    cin >> n >> s;
    fr(i,0,n)
    {
        if(s[i]=='R') x++;
        else y++;
    }
    if(x>y)
        cout << "Yes";
    else
        cout << "No";
}

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

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vll> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpl;
typedef unordered_set<ll> usl;
typedef set<ll> sl;
typedef unordered_map<ll, ll> uml;
typedef map<ll, ll> ml;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

#define all(v) v.begin() , v.end()
#define ceil(a, b) (a + b - 1) / b
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll inf = 1e9 + 7;
const double pie = 3.14159265358979323846;
const char nl = '\n';
const char spc = ' ';

template<typename Type>
istream &operator>>(istream &in, vector<Type> &v)
{
    ll n = v.size();
    for (int i = 0; i < n; i++)
        in >> v[i];
    return in;
}

template<typename Type>
ostream &operator<<(ostream &out, vector<Type> &v)
{
    for (auto value : v)
        out << value << ' ';
    out << nl;
    return out;
}

bool isPrime (ll n)
{
    if (n < 4)
        return true;
    if (n % 2 == 0)
        return false;
    ll i = 3;
    while (i * i <= n)
    {
        if (n % i == 0)
            return false;
        i += 2;
    }
    return true;
}

void solve ()
{
    ll n;
    cin >> n;
    vvl a(n, vll (3));
    for (auto &v : a)
    {
        for (ll &i : v)
            cin >> i;
    }
    vvl dp(n, vll(3));
    dp[0][0] = a[0][0], dp[0][1] = a[0][1], dp[0][2] = a[0][2];
    for (ll i = 1; i < n; ++i)
    {
        dp[i][0] = a[i][0] + max (dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = a[i][1] + max (dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = a[i][2] + max (dp[i - 1][0], dp[i - 1][1]);
    }
    cout << max ({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << nl;
}

int main()
{
    IOS
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t;
    t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 14184
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    if (n%2==0) cout << fixed << setprecision(12) <<  n/2/(double)n << '\n';
    else cout << fixed << setprecision(12) <<  (n/2+1)/(double)n << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int h,w,i,j;
    for(;;){
        scanf("%d %d\n",&h,&w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main()
{
    int n;
    int a[101];
    double max, sum;

    int i;


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

    sum = 0.0;
    for(i=0;i<n;i++){
        sum += max / a[i];
    }

    cout << max / sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    if(e - a > f){
        cout << ":(" << endl;
        return 0;
    }
    cout << "Yay!" << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    while(--n >= 0){
        int r, t;
        cin >> r >> t;

        vector<int> v;
        if(r % 100 == 0){
            if(t % 30 == 0){
                v.push_back(t / 30 * 5 + r / 100);
            }
            else{
                v.push_back(t / 30 * 5 + r / 100);
                v.push_back((t / 30 + 1) * 5 + r / 100);
            }
        }
        else{
            if(t % 30 == 0){
                v.push_back(t / 30 * 5 + r / 100);
                v.push_back(t / 30 * 5 + r / 100 + 1);
            }
            else{
                v.push_back(t / 30 * 5 + r / 100);
                v.push_back((t / 30 + 1) * 5 + r / 100);
                v.push_back(t / 30 * 5 + r / 100 + 1);
                v.push_back((t / 30 + 1) * 5 + r / 100 + 1);
            }
        }

        sort(v.begin(), v.end());
        cout << v[0];
        for(unsigned i=1; i<v.size(); ++i)
            cout << ' ' << v[i];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3136
#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	 //INFILE();
	 
	 float t, x;
	 cin >> t >> x;

	 cout << t / x << endl;

	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}


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

typedef long long ll;
int main(){
	ll n;
	ll a,b;

	cin>>n>>a>>b;

	ll ans = n+1;
	if((b - a) % 2 == 0)
		ans = min(ans,(b - a)/2);
	else{
		//make the parity same and meet at the meet point
		ll p = min(a-1,n-b); //either make one of them reach the end
		p = p + 1; //1 step more for change of parity
		//meet tat middle

		p = p + (b - a -1) /2;

		ans = min(ans,p);
	}
	cout<<ans;
	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);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int p1 = 0;
			int p2 = 0;
			while(n--!=0){
				int a = sc.nextInt();
				int b = sc.nextInt();
				if(a>b)p1+=a+b;
				else if(a<b)p2+=a+b;
				else {
					p1+=a;
					p2+=b;
				}
			}
			System.out.println(p1 + " " + p2);
		}
	}
}

Measured memory_bytes: 51704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//const int INF = 100100100;
const int INF = INT_MAX;
int dis(vector<int> &h, int index1, int index2){//h.at(index1) と h.at(index2)の距離
  return abs(h.at(index1) - h.at(index2));
}

int cost_i(vector<int> &h, vector<int> &cost, int index, int K){//DPでdp[i]を求める関数
  for(int i=1; i<=K; i++){
    if(index - i >= 0){//out of rangeを防ぐ
      cost.at(index) = min(cost.at(index), cost.at(index-i)+dis(h, index-i, index));
      //if(cost.at(index) == 0) cout << "0になっている! なぜだ!!!" << "i :" << i << endl;
      //cout << "index: " << index << " i: " << i << " cost.at(index): " << cost.at(index) << endl;
    }
  }
  return  cost.at(index);//0になっている!なぜだ!!!の原因はこの行を書いてなかったら、でした．
}


int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N), cost(N,INF);
  for(int i=0; i<N; i++) cin >> h.at(i);
  
  cost.at(0) = 0;//初期化
  
  //cost.at(1) = cost_i(h, cost, 1, K);
  //cost.at(2) = cost_i(h, cost, 2, K);
  for(int i=1; i<=N-1; i++) cost.at(i) = cost_i(h, cost, i, K);//dp[1]から順に求めるforループ
  
  cout << cost.at(N-1) << endl;
  
  /*
  //////////////////////答えがちゃんと出ないので， 以下　関数の確認してみる
  for(int i=0; i<N-1; i++) cout << dis(h, i, i+1) << " ";
  cout << endl;
  cout << "dp:: " << endl;
  for(int i=0; i<N; i++) cout << cost.at(i) << " ";
  cout << endl;
  
  cout << "dis(h, 0, 2) : " << dis(h, 0, 2) << endl;
  cout << "dis(h, 1, 3) : " << dis(h, 1, 3) << endl;
  //cost.at(index) = min(cost.at(index), cost.at(index-i)+dis(h, index-i, index));
  cost.at(1) = min(cost.at(1), cost.at(1-1)+dis(h, 1-1, 1));//index=1, i=1
  cout<< min(cost.at(1), cost.at(1-1)+dis(h, 1-1, 1)) << endl;
  cost.at(2) = min(cost.at(2), cost.at(2-1)+dis(h, 2-1, 2));//index=2, i=1
  cout <<  min(cost.at(2), cost.at(2-1)+dis(h, 2-1, 2)) << endl;
  cost.at(2) = min(cost.at(2), cost.at(2-2)+dis(h, 2-2, 2));//index=2, i=2
  cout << min(cost.at(2), cost.at(2-2)+dis(h, 2-2, 2)) << endl;
  cout << "INF : " << INF << endl;
  cout << " cost.at(1) :" << cost.at(1) << endl;
  cout << " cost.at(2) :" << cost.at(2) << endl;
  
  cout << " cost_i(h, cost, 1, K) :" << cost_i(h, cost, 1, K) << endl;
  cout << " cost_i(h, cost, 2, K) :" << cost_i(h, cost, 2, K) << endl;
  */
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    long long N;
    cin >> N;
    //    long long A, B, C, D, E;
    //cin >> N >> A >> B >> C >> D >> E;
    std::vector<long long> v;
    // int iBottleNeck;
    long long cBottleNeck = 1e16;
    long long tmp;

    long long ans;
    for (int i = 0; i < 5; ++i)
    {
        cin >> tmp;
        //        v.push_back(tmp);
        if (tmp < cBottleNeck)
        {
            cBottleNeck = tmp;
            //              iBottleNeck = i;
        }
    }
    // for (int i = 0; i < 5; ++i)
    // {
    //     //cout << v[i] << endl;
    // }

    //cout << cBottleNeck << endl;
    // // if (cBottleNeck > N)
    // // {
    // //     ans = 5;
    // // }
    // else
    // {
    ans = ceil(N / (double)cBottleNeck) + 4;
    // }

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

Measured memory_bytes: 256
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, p=0, s=0, h, f=0;
    cin>>n;
    ll a[n+1];
    for(i=1; i<=n; i++){
        cin>>a[i];
    }
    sort(a+1, a+n+1);
    p=a[1];
    for(i=2; i<=n; i++){
        if(p*2<a[i]){
            f=i-1;
        }
        p+=a[i];
    }
    cout<<n-f<<endl;
    return 0;
}



Measured memory_bytes: 4312
#include<iostream>
#include<string>
using namespace std;
int main(){
    int dh,dm,ds;
    int eh,em,es;
    int a,b,c;
    for(int i=0;i<3;i++){
        cin>>eh>>em>>es;
        cin>>dh>>dm>>ds;
        if(i==0)
        a=dh*3600+dm*60+ds-eh*3600-em*60-es;
        if(i==1)
        b=dh*3600+dm*60+ds-eh*3600-em*60-es;
        if(i==2)
        c=dh*3600+dm*60+ds-eh*3600-em*60-es;
    }
    cout<<a/3600<<" "<<(a-a/3600*3600)/60<<" "<<a-a/3600*3600-(a-a/3600*3600)/60*60<<endl;
    cout<<b/3600<<" "<<(b-b/3600*3600)/60<<" "<<b-b/3600*3600-(b-b/3600*3600)/60*60<<endl;
    cout<<c/3600<<" "<<(c-c/3600*3600)/60<<" "<<c-c/3600*3600-(c-c/3600*3600)/60*60<<endl;
    return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m=sc.nextInt();
		int n=sc.nextInt();
		int[][] a=new int[m+1][n+1];
		for(int i=0; i<m; i++){
			for(int j=0; j<n; j++){
				a[i][j]=sc.nextInt();
				a[i][n]+=a[i][j];

			}
		}
		for(int j=0; j<=n; j++){
			for(int i=0; i<m; i++){
				a[m][j]+=a[i][j];
			}
		}
		printintMat(a);



	}
	public static void printintMat(int A[][]){
		//行列のプリントアウト
		for(int i=0; i<A.length; i++){
			for(int j=0; j<A[0].length-1; j++){
				System.out.print(A[i][j]+" ");
			}
			System.out.print(A[i][A[0].length-1]);
			System.out.println();
	}

		}


}


Measured memory_bytes: 45032
/*
	记录状态不太好搞
	考虑计算每个数被计算多少次
	分制 + 递归 
*/
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <ctime>
#define N 20
#define inf 1234567898765431LL

using namespace std;

typedef long long LL;

int n;
int a[N];

// 复杂度不会证，但好像比 n! 小很多 
LL solve(int l, int r, int x, int y) {
	if(l + 1 == r) return 0;
	LL res = inf;
	for(int i = l + 1; i < r; ++i) {
		LL re = 1LL * (x + y) * a[i] + 
			    solve(l, i, x, x + y) +
		 	    solve(i, r, x + y, y);
		if(re < res) res = re;
	}
	return res;
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	printf("%lld\n", a[1] + solve(1, n, 1, 1) + a[n]);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Int> idx(N + 1);
	for (int i = 0; i < N; ++i) {
		int p;
		cin >> p;
		idx[p] = i;
	}

	multiset<Int> st;
	st.insert(-1);
	st.insert(-1);
	st.insert(N);
	st.insert(N);
	Int ans = 0;
	for (Int i = N; i > 0; --i) {
		auto r = st.upper_bound(idx[i]);
		Int r1 = *r;
		Int r2 = *next(r);
		auto l = prev(st.lower_bound(idx[i]));
		Int l1 = *l;
		Int l2 = *prev(l);

		ans += i * ((l1 - l2)*(r1 - idx[i]) + (idx[i] - l1)*(r2 - r1));
		st.insert(idx[i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5760
S=input()
if S=="SAT":
  print(1)
elif S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)

Measured memory_bytes: 2940
from bisect import bisect_left, bisect_right

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()

ans = 0
for m in b:
    idx_a = bisect_left(a, m)
    idx_c = bisect_right(c, m)
    ans += idx_a * (n - idx_c)
print(ans)

Measured memory_bytes: 105444
//Meri hr baat bs yaad hai tumhari , mera apna koi kissa nhi!!
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);

using namespace std;


int main()

{
    char c;
    cin>>c;
    if(c<='z' && c>='a')cout<<'a'<<endl;
    else cout<<"A"<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> dp(3);
    for(int day=1;day<=n;++day){
        vector<int> c(3);
        vector<int> new_dp(3);
        for(int j=0;j<3;++j){
            scanf("%d",&c[j]);
        }
        for(int i=0;i<3;++i){
            for(int j=0;j<3;++j){
                if(i!=j){
                    new_dp[j]=max(new_dp[j],dp[i]+c[j]);
                }
            }
        }
        dp=new_dp;
    }
    printf("%d\n",max({dp[0],dp[1],dp[2]}));
    // while(1);
    return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A = LI()

    if sum(A) >= 22:
        print('bust')
    else:
        print('win')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10044
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cmath>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

#define SZ(x) ((int)x.size())
#define debug

struct TTriple {
	int a, b, c;
	TTriple(int _a, int _b, int _c) : a(_a), b(_b), c(_c) {}
	bool operator<(const TTriple &other) const {
		return a - b > other.a - other.b;
	}
};

const int N = (int)1e5+5;
int n, x, y, z;
vector<TTriple> a;
vector<ll> lf, rt;

int main() {
	scanf("%d%d%d", &x, &y, &z);
	n = x + y + z;
	ll sum_c = 0;
	for (int i = 1, u, v, k; i <= n; ++i) {
		scanf("%d%d%d", &u, &v, &k);
		a.push_back(TTriple(u, v, k));
		sum_c += (ll)k;
	}
	sort(a.begin(), a.end());
	ll res = 0;
	lf.resize(n), rt.resize(n);
	priority_queue<int, vector<int>, greater<int> > pq;
	ll cur = 0;
	for (int i = 0; i < n; ++i) {
		pq.push(a[i].a - a[i].c);
		cur += (ll)(a[i].a - a[i].c);
		if (SZ(pq) < x) lf[i] = -(ll)1e18-7ll;
		else {
			if (SZ(pq) > x) {
				cur -= (ll)pq.top();
				pq.pop();
			}
			lf[i] = cur;
		}
	}
	while (SZ(pq)) pq.pop();
	cur = 0;
	for (int i = n - 1; i >= 0; --i) {
		pq.push(a[i].b - a[i].c);
		cur += (ll)(a[i].b - a[i].c);
		if (SZ(pq) < y) rt[i] = -(ll)1e18-7ll;
		else {
			if (SZ(pq) > y) {
				cur -= (ll)pq.top();
				pq.pop();
			}
			rt[i] = cur;
		}
		if (i > 0) {
			res = max(res, lf[i - 1] + rt[i] + sum_c);
		}
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define N 10001
#define INF 1e9
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int n,m,X,C[N];
vector<P> G[N];

int D[N][201][3];
bool used[N][201][3];

int dijkstra(){
  for(int i=0;i<N;i++)
    for(int j=0;j<201;j++)
      for(int k=0;k<3;k++) D[i][j][k]=INF;

  priority_queue<PP,vector<PP>,greater<PP> >Q;
  Q.push(PP(P(0,0),P(0,0)));
  D[0][0][0]=0;

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int cost=t.f.f,pos=t.f.s;
    int x=t.s.f,sta=t.s.s;
    if(pos==n-1) return cost;
    if(D[pos][x][sta]<cost) continue;
    used[pos][x][sta]=1;
    for(int i=0;i<G[pos].size();i++){
      int ncost=G[pos][i].s+cost;
      int npos=G[pos][i].f;
      int nx=min(X,x+G[pos][i].s);
      int nsta=C[npos];
      if(abs(sta-nsta)==2){
	if(nx<X) continue;
	nx=0;
      }
      if(nsta==1) nsta=sta;
      else if(nsta==sta) nx=0;
      if(D[npos][nx][nsta]<=ncost)continue;
      if(used[npos][nx][nsta])continue;
      Q.push(PP(P(ncost,npos),P(nx,nsta)));
      D[npos][nx][nsta]=ncost;
    }
  }
  assert(0);
}

int main(){
  cin>>n>>m>>X;
  for(int i=0;i<n;i++) cin>>C[i];

  for(int i=0,a,b,d;i<m;i++){
    cin>>a>>b>>d;
    a--,b--;
    G[a].push_back(P(b,d));
    G[b].push_back(P(a,d));
  }
  cout<<dijkstra()<<endl;
  
  return 0;
}

Measured memory_bytes: 32752
import java.util.Scanner;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println((N/2)*((N+1)/2));
        sc.close();
    }
}

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



// 深さ優先探索なのでqueueを使う
int main(){
  queue<int64_t> q;
  for(int64_t i=1;i<=9;i++)
    q.push(i);
  int K;
  cin>>K;
  int64_t a=0;
  for(int i=0;i<K-1;i++){
    a=q.front();
    if(a%10!=0)
      q.push(10*a+(a%10)-1);
    q.push(10*a+(a%10));
    if(a%10!=9)
      q.push(10*a+(a%10)+1);
    q.pop();
  }
  cout<<q.front()<<endl;
}

Measured memory_bytes: 1792
n, w = map(int, input().split())
x = []
y = []

for i in range(n):
  a,b = map(int, input().split())
  x.append(b)
  y.append(a)

dp = [[0] * (w + 1) for i in range(n + 1)]

for i in range(n):
  for j in range(w + 1):
    if(j >= y[i]):
      dp[i + 1][j] = max(dp[i][j], dp[i][j - y[i]] + x[i])
    else:
      dp[i + 1][j] = dp[i][j]

print(dp[n][w])


Measured memory_bytes: 120300
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<int>vec(n+1);
  for(int i = 1; i<=n;i++){
    auto p=prime_factorize(i);
    for(auto j:p){
      vec[j.first]+=j.second;
    }
  }
  ll res = 0;
  rep(i,n+1){
    if(vec[i]>=74)res++;
  }
  rep(i,n+1){
    rep(j,n+1){
      if(i==j)continue;
      if(vec[i]>=2 && vec[j]>=24)res++;
    }
  }
  rep(i,n+1){
    rep(j,n+1){
      if(i==j)continue;
      if(vec[i]>=4 && vec[j]>=14)res++;
    }
  }
  int num=0;
  rep(i,n+1){
    rep(j,n+1){
      rep(k,n+1){
        if(i==j || j==k || k==i)continue;
        if(vec[i]>=2 && vec[j]>=4 && vec[k]>=4)num++;
      }
    }
  }
  cout << res+num/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  int sum = 0, mini=1e9;
  for (int i = 0; i < n; i++) {
    cin >> m[i];
    sum += m[i];
    mini = min(mini, m[i]);
  }
  x -= sum;
  cout << n + floor(x / mini) << endl;
  return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

int N;
string S;

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

	ll ans = 0;
	for(int mask = 0;mask < 1 << (N - 1);mask++){
		ll sum = S [0] - '0';
		FOR(i,0,N - 1){
			if(mask & (1 << i)){
				ans += sum;
				sum = 0;
			}
			else{
				sum *= 10;
			}
			sum += S [i + 1] - '0';
		}
		ans += sum;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 1000100
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans;
}
ll inv(ll a)
{
    return power(a,MOD-2,MOD);
}
//code begins
ll b[N];
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    ll ans[33]={-1,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    while(t--)
    {
        ll n;cin>>n;
        cout<<ans[n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {

			int n = sc.nextInt();
			if (n == 0)
				break;
			int map[][][] = new int[n][n][2];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					map[i][j][0] = sc.nextInt();
					map[i][j][1] = sc.nextInt();
				}
			}
			UnionFind uf = new UnionFind(n * n);
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int pos = pos(j, i, n);
					int jump_x = map[i][j][0];
					int jump_y = map[i][j][1];
					int jump = pos(jump_x, jump_y, n);
					uf.unite(pos, jump);
				}
			}
			Set<Integer> set = new HashSet<Integer>();
			for (int i = 0; i < uf.par.length; i++) {
				uf.find(i);
				set.add(uf.par[i]);
			}
			System.out.println(set.size());
		}
	}

	public static void main(String[] args) {
		new Main().run();

	}

	int pos(int x, int y, int w) {
		return x + y * w;
	}
}

class UnionFind {
	public int par[];
	public int rank[];

	UnionFind(int n) {
		par = new int[n];
		rank = new int[n];
		for (int i = 0; i < n; i++) {
			par[i] = i;
		}
	}

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

	public void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)
			return;

		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y])
				rank[x]++;
		}
	}

	public boolean same(int x, int y) {
		return find(x) == find(y);
	}
}

Measured memory_bytes: 63576
#include <bits/stdc++.h>
#define ll long long
#define int ll
#define endl '\n'
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)
using namespace std;
 
int32_t main(){
	ios::sync_with_stdio(0);cin.tie(0);
	map<int,pair<int,int>> map;
	vector<vector<bool>> set(3,vector<bool>(3,false));
	int aux,n;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> aux;
			map[aux] = mp(i,j);
		}
	}
	cin >> n;
	while(n--){
		cin >> aux;
		if(map.count(aux)){
			pair<int,int> aux2 = map[aux];
			set[aux2.first][aux2.second] = true;
		}
	}
	bool ok = ((set[0][0])&&(set[0][1])&&(set[0][2])) ||((set[1][0])&&(set[1][1])&&(set[1][2])) ||((set[2][0])&&(set[2][1])&&(set[2][2]));
	ok = ok|| ((set[0][0])&&(set[1][0])&&(set[2][0])) ||((set[0][1])&&(set[1][1])&&(set[2][1])) ||((set[0][2])&&(set[1][2])&&(set[2][2]));
	ok = ok|| ((set[0][0])&&(set[1][1])&&(set[2][2])) ||((set[2][0])&&(set[1][1])&&(set[0][2]));
	
	cout << (ok?"Yes":"No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
using namespace std;

#include <iostream>

int main() {
  int S; cin >> S;
  int v[4];
  for (int i = 0; i < 4; i++) {
    v[i] = S % 10;
    S /= 10;
  }
  
  for (int i = 1; i < 4; i++) {
    if (v[i-1] == v[i]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 504
#include<stdio.h>

int main(){
    
    int a, b;

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

    if (a < b) {
      printf("a < b\n");
    }
    else if (a > b) {
      printf("a > b\n");
    }
    else {
      printf("a == b\n");
    }

    return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 100005, mod = 1000000007;
int n;
ll dp[MX][2];
string s;

ll obtRes (int i, int f) {
	if (i == n) return 1;
	ll &res = dp[i][f];
	if (res != -1) return res;
	res = obtRes(i + 1, f || s[i] == '1');
	if (s[i] == '1' || f)
		res += 2 * obtRes(i + 1, f);
	return res %= mod;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(dp, -1, sizeof(dp));
	
	cin >> s;
	n = s.size();
	cout << obtRes(0, 0) << endl;

	return 0;
}


Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int r,D,x;
    cin >> r >> D >> x;
    int A = r*x-D;
    cout << A << endl;
    REP(i,9){
        A = r*A-D;
        cout << A << endl;
    }

    return 0;
}

Measured memory_bytes: 256