akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc157_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = CIn.ReadInt();
            var M = CIn.ReadInt();
            var s = new int[M];
            var c = new int[M];
            
            for(var i = 0; i < M; i++)
            {
                s[i] = CIn.ReadInt();
                c[i] = CIn.ReadInt();
            }
            for(var ans = N ==1 ? 0 :Math.Pow(10,N - 1); ans < Math.Pow(10,N); ans++)
            {
                var S = ans.ToString();
                var flag = true;
                for (var i = 0; i < M; i++)
                {
                    if (S[s[i] - 1] != c[i] + '0')
                    {
                        flag = false;
                        break;
                    }
                }
                    if (flag == true)
                    {
                        Console.WriteLine(ans);
                        return;
                    }
                
            }
            Console.WriteLine("-1");
        }
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }

            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}


Measured memory_bytes: 13268
N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort()

ans = 0
for i in range(N):
  if M > AB[i][1]:
    ans += AB[i][0] * AB[i][1]
    M -= AB[i][1]
  else:
    ans += AB[i][0] * M
    break
print(ans)

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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define         MAX         262144
int st[4*MAX+100];


void build(int n,int l,int r,int v)
{
    if(l==r)
    {
        st[n]++;

        return;
    }

    int tm = (l+r)/2;

    if(v<=tm)
        build(2*n,l,tm,v);
    else
        build(2*n+1,tm+1,r,v);

    st[n] = st[2*n] + st[2*n+1];


}

int query(int n,int l,int r,int s,int e)
{

    if(s>r || e<l || l>r || s>e)
        return 0;

    if(s<=l && r<=e)
    {
        return st[n];
    }

    int tm = (l+r)/2;

    return query(2*n,l,tm,s,e)+query(2*n+1,tm+1,r,s,e);

}

int main()
{
    int i,j,k,l,m,n,ans=0;

    cin >> n;

    int ar[n+10];

    for(i=1; i<=n; i++)
    {
        cin >> ar[i];

        m = query(1,1,n,1,ar[i]-1);
        // cout << m << endl;
        if(m==0)
            ans++;

        build(1,1,n,ar[i]);
    }

    //  cout<<st[1]<<endl;


    cout << ans << endl;
}



Measured memory_bytes: 5120
import sys

input = sys.stdin.readline
N = int(input())
AB = [tuple(map(int, input().strip().split(' '))) for i in range(N)]
AB.sort(key=lambda x: x[1])
count = 0
for a, b in AB:
    count += a
    if count > b:
        print('No')
        sys.exit()
print('Yes')

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

int main(){
    int n;
    int A[4][3][10];
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10 ;k++) {
                A[i][j][k] = 0;
            }
        }
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        A[b-1][f-1][r-1] += v;
    }
    for (int i = 0; i < 4; i++) {
        if (i != 0) {
            cout << "####################\n";
        }
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10 ;k++) {
                cout << ' ' << A[i][j][k];
            }
            cout << endl;
        }
    }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

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

    int num = 1;
    for (int i = 0; i < N; i++) {
        if (num > K) {
            num += K;
        } else {
            num *= 2;
        }
    }

    cout << num << endl;
    return 0;
}

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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
int dp[22][1<<22];
int32_t main() {
    nitin;
    int n;
    cin>>n;
    int a[n+1][n+1];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            cin>>a[i+1][j+1];
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=1;
        for(int j=1 ;j<(1<<n);j++)
        {
            dp[i][j]=dp[i-1][j];
            if(setbits(j)!=i)
                continue;
            for(int k=1;k<=n;k++)
            {
                int p=j;
                int q=(1<<(k-1));
                if((j&(1<<(k-1)))>0 && a[i][k]==1)
                {
                    int mask=(j^(1<<(k-1)));
                    dp[i][j]=(dp[i][j]+dp[i-1][mask])%mod;
                }
            }
        }
    }
//    for(int i=0;i<=n;i++)
//    {
//        for(int j=0;j<(1<<n);j++)
//            cout<<dp[i][j]<<","<<setbits(j)<<"  ";
//        cout<<endl;
//    }
cout<<dp[n][(1<<n)-1];;
    return 0;
}

Measured memory_bytes: 347768
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    char s1[10],s2[10],s3[10],temp[5];
    int i,j;
    scanf("%s %s %s", &s1, &s2, &s3);
            temp[0]=s1[0];

            temp[1]=s2[0];

            temp[2]=s3[0];

    temp[3]='\0';
    int le=strlen(temp);
    for(j=0; j<le; j++){
        temp[j]=temp[j]-32;
    }
    printf("%s\n", temp);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
long double pi=3.14159265358979323846;
long double absdiff(long double a,long double b)
{
	if(a>b)return a-b;
	else return b-a;
}
int main()
{
	long double a,b,H,M;
	cin>>a>>b>>H>>M;
	long double ang1=(H*30)+(M/2);
	long double ang2=(M*6);
	long double ang=absdiff(ang1,ang2);
	if(ang==0)cout<<absdiff(a,b)<<endl;
	else
	{
		long double sq=pow(a,2)+pow(b,2)-2*a*b*cos(ang*pi/180);
		long double ans=pow(sq,0.5);
		printf("%0.20Lf\n",ans);
	}
	return 0;
}


Measured memory_bytes: 3552
//
//  main.cpp
//  CP-C++
//
//  Created by ALOK KUMAR THAKUR on 05/05/20.
//  Copyright © 2020 ALOK KUMAR THAKUR. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define tc() ll T;cin>>T;while(T--)
#define pb push_back

struct cmp {
    bool operator() (const ll& a, const ll& b){
        return a < b;
    }
};

int main() {
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    ll x,k,d; cin>>x>>k>>d;
    ll mark = abs(x)/d;
    ll ans;
    if(k >= mark+1){
        if(k%2 == mark%2) ans = abs(abs(x) - (d*mark));
        else ans = abs(abs(x) - (d*(mark+1)));
    }
    else ans = abs(abs(x) - (k*d));
    cout<<ans;
    
    /*------------------Code Ends Here-------------------*/
    
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root = NIL;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;
}

Node treeSearch(Node u, int k){
  Node i=u;
  while(i!=NIL){
    if(i->key==k)return i;
    else if(i->key<k)i=i->right;
    else i=i->left;
    
  }
  return NIL;
}

Node treeSuccessor(Node x){
  if(x->right!=NIL)return treeMinimum(x->right);
  Node y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);
  
  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->parent=y->parent;
  
  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;

  if(y!=z)z->key=y->key;
  
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;
  
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
import java.util.Scanner;
public class Main {
   public static void main(String args[]){
      Scanner keyboard = new Scanner(System.in);
      int x = keyboard.nextInt();
      int y = keyboard.nextInt();
      int z, w;
      z = x * y;
      w = 2 * (x + y);
      System.out.print(z);
      System.out.print(" ");
      System.out.println(w);
   }   
}


Measured memory_bytes: 26176
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t X;

    std::cin >> X;

    int64_t v = 100;
    int64_t count = 0;

    while (v < X) {
        v += static_cast<int64_t>(v * 0.01);
        count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include "math.h"

using namespace std;

int main() {
  	int n;
  	long k;
  	cin >> n >> k;
  	int a[n], t[n];
  	for (int i = 0; i < n; i++) {
      	cin >> a[i];
      	t[i] = -1;
    }
  	int pos = 1;
  	for (long i = 0; i < k; i++) {
      	if (t[pos-1] >= 0) {
          	int loop = i - t[pos-1];
          	loop = (k - i) % loop;
          	for (long j = 0; j < loop; j++) {
      			pos = a[pos-1];
            }
          	break;
        }
      	t[pos-1] = i;
      	pos = a[pos-1];
    }
  	cout << pos << endl;
  
  	return 0;
}

Measured memory_bytes: 5200
toInt :: (String -> Int)
toInt x = read x ::Int

getInts :: IO [Int]
getInts = do
  x <- getLine
  let y = (map$toInt)$words x
  return y



solve :: Int -> [Int] -> Bool
solve h []
  | h <= 0    = True
  | otherwise = False
solve h (a:as)
  | h <= 0    = True
  | otherwise = solve (h-a) as



main = do
  n <- getInts
  a <- getInts
  let h = head n
  putStrLn (if solve h a then "Yes" else "No")


Measured memory_bytes: 18812
N, Y = map(int, input().split())

flg = 0
for a in range(N+1):
  for b in range(N-a+1):
    c = (N-a-b)
    if (a+b+c) == N and a *10000 + b *5000 + c *1000 == Y:
      print(a,b,c)
      flg = True
      break
  if flg:
    break
if flg == 0:
  print(-1, -1, -1)

Measured memory_bytes: 3064
#include<iostream>
#include<map>
using namespace std;
map<char,int>M;
int a[100];
string s;
main()
{
	M['I']=1;M['V']=5;M['X']=10;M['L']=50;M['C']=100;M['D']=500;M['M']=1000;
	while(cin>>s)
	{
		for(int i=0;i<s.size();i++)a[i]=M[s[i]];
		for(int i=0;i+1<s.size();i++)if(a[i]<a[i+1])a[i]*=-1;
		int ans=0;
		for(int i=0;i<s.size();i++)ans+=a[i];
		cout<<ans<<endl;
	}
}


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

using namespace std;

#define ll long long

int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i = 0;i < N;++i)    cin >> h[i];

    int ans = 0;

    for(int i = 0;i < N;++i){
        if(h[i] >= K){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
def main(h):
    lst=[list(map(int,input().split())) for _ in range(h)]

    check=1
    sm=0
    while check:
        check=0
        for i in range(h):
            for j in range(3):
                if lst[i][j]==0 : continue
                if lst[i][j+1]!=lst[i][j] : continue
                if lst[i][j+2]!=lst[i][j] : continue
                sm+=3*lst[i][j]
                for k in range(j+3,5):
                    if lst[i][k]==lst[i][j]:
                        lst[i][k]=0
                        sm+=lst[i][j]
                    else : break

                lst[i][j:j+3]=[0,0,0]
                check=1
        for i in range(h-1,0,-1):
            for j in range(5):
                if lst[i][j]==0:
                    for k in range(i-1,-1,-1):
                        if lst[k][j]==0 : continue
                        lst[i][j]=lst[k][j]
                        lst[k][j]=0
                        break
    
    print(sm)
    #print(lst)

while 1:
    h=int(input())
    if h==0 : break
    main(h)     



Measured memory_bytes: 5632
//  -- ILSH -- //
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define viii vector < vii >
#define vlll vector < vll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=200000+6;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    if ( n%2==1)
        cout<<0<<'\n';
    else
    {
        ll total=n/10;
        n=total;
        ll val=5;
        while ( n/val!=0)
        {
            total=total+n/val;
            val=val*5;
        }
        cout<<total<<'\n';
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N,ar[110],Cnt;
int main()
{
	cin>>N;
	for(int x=0; x<N; x++) cin>>ar[x];
	for(int x=0; x<N-1; x++)
	{
		if(ar[x]==ar[x+1])
		{
			Cnt++;
			x++;
		}
	}
	cout<<Cnt;
}

Measured memory_bytes: 256
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12

void dp(int pos, li concatenation, li sum, li &ans, string &s) {
  if (pos == s.size()) {
    ans += sum;
    return;
  }
  concatenation = concatenation * 10 + s[pos] - '0';
  dp(pos + 1, 0, sum + concatenation, ans, s);
  if (pos < s.size() - 1)
    dp(pos + 1, concatenation, sum, ans, s);
}

void _main(int tc) {
  string s;
  cin >> s;
  li ans = 0;
  dp(0, 0, 0, ans, s);
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
pro_list = input().split()
circle_distance = int(pro_list[0])
house_num = int(pro_list[1])

house_distance_list = [int(i) for i in input().split()]
max = -1
max_index = 0
for i in range(house_num):
  if i == house_num-1:
    distance_gap = (circle_distance - house_distance_list[i]) + house_distance_list[0]
  else:
    distance_gap = house_distance_list[i+1] - house_distance_list[i]
  if max < distance_gap:
    max = distance_gap
    max_index = i
print(circle_distance - max)

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

using namespace std;
using nagai = long long;
using ll = long long;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin >> n;
    map<int, int> a, b;
    for (int i = 0; i < n; ++i)
    {
         int x;
         cin >> x;
         if (i & 1)
             ++b[x];
         else
             ++a[x];
    }
    a[-228] = b[-228] = 0;
    vector<pair<int, int>> a1, b1;
    for (auto& p : a)
        a1.emplace_back(p.second, p.first);
    for (auto& p : b)
        b1.emplace_back(p.second, p.first);
    sort(a1.rbegin(), a1.rend());
    sort(b1.rbegin(), b1.rend());
    int ans = 1e9;
    for (int i = 0; i < min((int)a1.size(), 3); ++i)
        for (int j = 0; j < min((int)b1.size(), 3); ++j)
        {
            if (a1[i].second == b1[j].second)
                continue;
            ans = min(ans, n - a1[i].first - b1[j].first);
        }
    cout << ans << '\n';

	return 0;
}



Measured memory_bytes: 6140
D = int(input())

c = list(map(int,input().split()))

S = []
for i in range(D):
  s = list(map(int,input().split()))
  S.append(s)

T = []
for i in range(D):
  t = int(input())
  T.append(t)

rh = [[0]*26 for i in range(D)]

ans = 0
for i in range(1,D+1):
  m = S[i-1][T[i-1]-1]
  tot = 0
  rh[i-1][T[i-1]-1] += 1 
  for j in range(26):
    last = 0
    for k in range(D):
        if rh[k][j] == 1:
          last = (k+1)
    tot += (c[j]*(i - last))
  ans += m-tot
  print(ans)

Measured memory_bytes: 9256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define pc(n) printf("%c\n",n) == 0
#define rep(i, begin, end) for (decltype(begin) i = begin; i < end; i++)
#define ss(n) scanf("%s",n) == 0

#define ps(x) printf("%s", x)

using namespace std;


char arr[100001];
bool abc[26];
int main() {
	ss(arr);

	rep(i, 0, 100001) {
		if (arr[i] == 0) break;
		abc[arr[i] - 'a'] = 1;
	}

	rep(i, 0, 26) {
		if (abc[i]) continue;
		pc(i + 'a');
		return 0;
	}
	ps("None");
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(250000)
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].append(b)
  g[b].append(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])

Measured memory_bytes: 244420
N = int(input())
dic = {}
for _ in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

num = 0
for key in dic:
    num = max(num, dic[key])

ans = []
for key in dic:
    if dic[key] == num:
        ans.append(key)

ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 35396
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
ans = [[0 for _ in range(W)] for _ in range(H)]
S = []
for i,a in enumerate(A):
  S+=[i+1]*a

for i in range(H):
  if i%2==0:
    for j in range(W):
      ans[i][j]=S.pop()
      
  else:
    for j in range(W-1,-1,-1):
      ans[i][j]=S.pop()
      
for a in ans:
  print(' '.join(map(str,a)))

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

#define INF 0x3f3f3f3f
#define int long long
#define pii pair<int, int>

const int N = 100005;

int n, k;
vector<int> stones;
int dp[N][2];

int solve(int remain, int turn) {
    if(!remain)
        return !turn;
    if(remain < 0)
        return !turn;
    if(dp[remain][turn] != -1)
        return dp[remain][turn];
    int i = 0;
    while(i < n and stones[i] <= remain) {
        if(solve(remain-stones[i], !turn) == turn)
            return dp[remain][turn] = turn;
        i++;
    }
    return dp[remain][turn] = !turn;
}

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

    int i, x;
    memset(dp, -1, sizeof(dp));
    cin >> n >> k;
    for(i = 0 ; i < n ; i++) {
        cin >> x;
        stones.push_back(x);
    }
    sort(stones.begin(), stones.end());
    if(solve(k, 1))
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}


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

int main(){
	int n, m;
	scanf("%d %d",&n,&m);
	if (n == 1 && m == 1){
		printf("1\n");
		return 0;
	}
	if (n == 1){
		printf("%d\n", m - 2);
		return 0;
	}
	if (m == 1){
		printf("%d\n", n - 2);
		return 0;
	}
	printf("%lld\n", 1LL * (n - 2) * (m - 2));
	return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n, b[maxn], a[maxn];

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

  cin>>n;
  for (int i=0; i<n-1; i++) {
    cin>>b[i];
  }

  a[n-1]=b[n-2];
  for (int i=n-2; i>=0; i--) {
    a[i+1] = min(b[i], a[i+1]);
    a[i] = b[i];
  }
  int ans = 0;
  for (int i=0; i<n; i++) {
    ans += a[i];
  }
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    stack<int> x;
    cin >> s;
    x.push(s[0]);
    for(int i = 1;i < s.size();i++){
        if(!x.empty() && x.top() != s[i])x.pop();
        else x.push(s[i]);
    }
    cout << s.size() - x.size() << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

vi to[100005];
int n;

vi dist;
void dfs(int v, int d=0, int p=-1) {
  dist[v] = d;
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u,d+1,v);
  }
}
vi calcDist(int s) {
  dist = vi(n);
  dfs(s);
  return dist;
}

int main () {
  cin >> n;
  int u, v;
  cin >> u >> v;
  --u, --v;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    to[a].pb(b);
    to[b].pb(a);
  }

  vi distS = calcDist(u);
  vi distT = calcDist(v);

  int mx = 0;
  rep(i,n) {
    if (distS[i] < distT[i]) {
      mx = max(mx, distT[i]);
    }
  }
  int ans = mx - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10744
#include<stdio.h>
#include<math.h>

int n,m;
const int maxn = 11;
int ks[maxn];
int ss[maxn][maxn];
int ps[maxn];

int s[maxn] = {0};

bool check() {
    for(int i=0; i < m; i++) {
        int c = 0;
        for (int j = 0; j<ks[i]; j++) {
            if (s[ss[i][j] - 1]) c++;
        }
        if (c % 2 != ps[i]) return false;
    }
    return true;
}

int main() {
    scanf("%d %d", &n,&m);
    for(int i=0; i<m;i++) {
        scanf("%d", &ks[i]);
        for (int j=0; j<ks[i];++j) {
            scanf("%d", &ss[i][j]);
        }
    }
    for(int i=0; i<m;i++) {
        scanf("%d", &ps[i]);
    }

    int solution = 0;
    for (int i =0; i<pow(2, n); i++) {
        int carry=1;
        for(int j=0; j<n;j++) {
            s[j] += carry;
            carry = 0;
            if(s[j] > 1) {s[j] = 0; carry++;}
        }
        if(check()) solution++;
    }
    printf("%d", solution);
}


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

int main()
{
    long long X;
    cin >> X;
    long long ans = 100;
    long long cnt = 0;
    while (true)
    {
        ans = ans * 1.01;
        ++cnt;
        if( X <= ans ){
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
const main = (input) => {
    input = input.split(" ");
    const W = Number(input[0]);
    const H = Number(input[1]);
    const x = Number(input[2]);
    const y = Number(input[3]);

    const min_area = (W * H) / 2;
    console.log(min_area.toFixed(6));

    const straightY = -(H / W) * x + H

    if (straightY == y) {
        console.log("1");
    } else {
        console.log("0");
    }
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22208
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {

	int N;
	cin >> N;
	vector<ll> A(N), B(N + 1, 0);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i + 1] = A[i] + B[i];
	}
	map<ll, ll> C;
	for (int i = 0; i < N + 1; i++)C[B[i]]++;

	ll ans = 0;
	for (auto itr = C.begin(); itr != C.end(); itr++) {
		if (itr->second < 2)continue;
		ans += itr->second*(itr->second - 1) / 2;
	}

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

Measured memory_bytes: 15872
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,c,i,j,t,a[500],b[500];
ll p[500][500],f[500][500],k,cur[500];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>c;
    for(i=1;i<=n;i++)cin>>a[i];
    for(i=1;i<=n;i++)cin>>b[i];
    for(i=1;i<=400;i++)cur[i]=1,p[0][i]=i;
    for(i=1;i<=400;i++)
	{
		for(j=1;j<=400;j++)
		{
			cur[j]=(cur[j]*j)%mod;
			p[i][j]=(cur[j]+p[i][j-1])%mod;
		}
	}
	f[0][0]=1;
    for(i=1;i<=n;i++)
	{
		for(j=0;j<=c;j++)
		{
			for(t=0;t<=j;t++)
			{
				k=(p[t][b[i]]-p[t][a[i]-1]+mod)%mod;
				f[i][j]=(f[i][j]+f[i-1][j-t]*k)%mod;
			}
		}
	}
	cout<<f[n][c]<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

string s;

bool even(int x){
    int k = (x+1)/2;
    for(int i=0; i<k; i++){
        if(s[i] != s[i+k]) return 0;
    }
    return 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    cin >> s;
    int n = s.size();
    int mx = 0;
    for(int i=1; i<n-1; i+=2){
        if(even(i)) mx = i;
    }
    cout << mx+1;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val H = readLine()!!.split(" ").map { it.toInt() }
    
    var count = 0
    var maxH = 0
    H.forEach { 
        if (maxH <= it) {
            count++
            maxH = it
        }
    }
    println(count)
}

Measured memory_bytes: 37688
S=str(input())
s1=S[0:1]
s2=S[1:2]
s3=S[2:3]
s4=S[3:4]
if s1==s2:
    print('Bad')
elif s2==s3:
    print('Bad')
elif s3==s4:
    print('Bad')
else:
    print('Good')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] temp = scanner.nextLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int k = Integer.parseInt(temp[1]);

		String[] numb      = scanner.nextLine().split(" ");
		int ans = 0;

		for(String x : numb) {

			ans += k <= Integer.parseInt(x) ? 1 : 0;


		}



		System.out.println(ans);

		}

}


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

template<class T> void mkmin(T& a, const T b) { a = min(a, b); }
template<class T> void mkmax(T& a, const T b) { a = max(a, b); }

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

#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define ferrari ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int ll

const ll mod = 1e9 + 7; // 998244353
const ll OO = 1e18;
const int oo = 2e9;
const int N = 85;

int n, a[N], ans;
vector<pii> pairs;

signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	bool buy = true;
	int cur = 1000, stocks = 0, last;
	for (int i = 1; i <= n; i++) {
		if (buy) {
			while (i + 1 <= n && a[i + 1] <= a[i]) i++;
			if (i == n) break;
			stocks = cur / a[i];
			cur %= a[i];
			buy = false;
		} else {
			while (i + 1 <= n && a[i + 1] >= a[i]) i++;
			cur += a[i] * stocks;
			last = cur;
			stocks = 0;
			buy = true;
		}
	}	
	if (!buy) cur = last;
	cout << cur;
}


Measured memory_bytes: 3620
X=int(input())
def ans165(X:int):
    cash=100#当初の預金額
    count=0
    while True:
        # cash=int(cash*1.01) #元本に１パーセントの利子をつけ小数点以下切り捨て
        cash += cash // 100 # 元本に100で割った整数部を足す
        count += 1#利子をつける回数だけcountを増やす
        if cash>=X:#cashがXの値以上になったらループ終了
            break
    return count
print(ans165(X))

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

int main(){
  string S;
  long long K;
  cin>>S>>K;
  bool ok=1;
  for(int i=0;i<K;++i){
  if(S.at(i)!='1'){
     cout<<S.at(i)<<endl;
     ok=0;
     break;
  }
}
if(ok)cout<<1<<endl;
}//int main

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

int main(){
  int dice1[6],dice2[6];
  int pos[6][6] = {{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
  int a,b;
  
  for(int i=0;i<6;i++) cin>>dice1[i];
  for(int i=0;i<6;i++) cin>>dice2[i];

  bool flg=false;
  for(int j=0;j<6;j++){
    if(dice1[0]==dice2[j]){
      a=j;
      for(int k=0;k<6;k++){
	if(dice1[1]==dice2[k] && k!=a && pos[a][k]!=0){
	  b=k;
	  if(dice1[2]==dice2[pos[a][b]-1] && dice1[3]==dice2[5-(pos[5-a][5-b]-1)] && dice1[4]==dice2[5-b] && dice1[5]==dice2[5-a]) flg=true;
	}
	if(flg) break;
      }
    }
    if(flg) break;
  }
  if(flg) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

  

Measured memory_bytes: 1160
N = int(input())
H = list(map(int, input().split()))
c = 0
m = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    c +=1
  else:
    m = c if c>m else m
    c = 0
m = c if c>m else m
print(m)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[10];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  int sum=0;
  for(int i=0;i<n;i++){
    if(i==0)sum+=a[i]/2;
    else sum+=a[i];
  }
  cout<<sum<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	vector<string>str = { "dream","dreamer","erase","eraser" };
	rep(i, 0, 4)reverse(all(str[i]));
	reverse(all(s));
	bool ans = true;
	rep(i, 0, s.size()) {
		if (s[i] == 'r') {
			if (s.substr(i, str[1].size()) == str[1]) {
				i += str[1].size() - 1;
			}
			else if (s.substr(i, str[3].size()) == str[3]) {
				i += str[3].size() - 1;
			}
			else {
				ans = false;
				break;
			}
		}
		else if (s[i] == 'm' && s.substr(i, str[0].size()) == str[0]) {
			i += str[0].size() - 1;
		}
		else if (s[i] == 'e' && s.substr(i, str[2].size()) == str[2]) {
			i += str[2].size() - 1;
		}
		else {
			ans = false;
			break;
		}
	}
	cout << (ans ? "YES" : "NO") << "\n";

	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B)
{
}

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second)
    {
        return a.second < b.second;
    }
    else
    {
        return a.first < b.first;
    }
}
int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    vector<pair<ll, ll>> pairs(N);
    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    SORT(pairs);
    priority_queue<int, vector<int>> que;

    int index = 0;
    ll ans = 0;
    for (int i = 1; i <= M; i++)
    {
        while (pairs[index].first <= i && index < N)
        {
            que.push(pairs[index].second);
            index++;
        }

        if (!que.empty())
        {
            ans += que.top();
            que.pop();
        }
    }

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


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

int main(){
  char s[55],t[55];
  int sn,tn,p=100;
  scanf("%s",s);
  scanf("%s",t);
  sn=strlen(s);
  tn=strlen(t);
  for(int i=0;i<=sn-tn;i++){
    for(int j=0;j<tn;j++){
      if(s[i+j]!='?'&&t[j]!=s[i+j]){
        break;
      }
      else if(j==tn-1)
        p=i;
    }
  }
  if(p==100)
    printf("UNRESTORABLE\n");
  else{
    for(int i=0;i<sn;i++){
      if(i>=p&&i<p+tn)
        printf("%c",t[i-p]);
      else if(s[i]=='?')
        printf("a");
      else
        printf("%c",s[i]);
    }
    printf("\n");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
const int MAX_N = 100;

void trace(vector<int> a, int n){
    rep(i,0,n){
        if(i>0) cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    return;
}

int main() {
    int n; cin>>n;
    vector<int> a(n); rep(i,0,n) cin>>a[i];

    trace(a, n);
    rep(i,1,n){
        int v = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v; 
        trace(a, n);
    }

    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <ostream>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template <typename T, typename U>
std::ostream& operator << (std::ostream& out, std::pair<T, U> p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T>
std::ostream& operator << (std::ostream& out, std::vector<T> v) {
  out << "[";
  for (int i = 0; i < v.size(); ++i) {
    out << v[i] << (i == (v.size() - 1) ? "" : ", ");
  }
  out << "]";
  return out;
}

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

  if (D == 25) {
    cout << "Christmas " << endl;
  }
  else if (D == 24) {
    cout << "Christmas Eve " << endl;
  }
  else if (D == 23) {
    cout << "Christmas Eve Eve " << endl;
  }
  else {
    cout << "Christmas Eve Eve Eve " << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        SegTree segTree = new SegTree(n);
        for (int i = 0; i < q; i++) {
            int com = in.nextInt();
            int x = in.nextInt() - 1;
            int y = in.nextInt();
            if (com == 0) {
                long cur = segTree.query(x, x + 1);
                segTree.update(x, cur + y);
            } else {
                y--;
                System.out.println(segTree.query(x, y + 1));
            }
        }
    }
}

class SegTree {

    private int N;
    private long[] seg;

    public SegTree(int M) {
        N = Integer.highestOneBit(M) * 2;
        seg = new long[N * 2];
        Arrays.fill(seg, 0);
    }

    public void update(int k, long value) {
        seg[k += N - 1] = value;
        while (k > 0) {
            k = (k - 1) / 2;
            seg[k] = seg[k * 2 + 1] + seg[k * 2 + 2];
        }
    }

    //[a, b)
    public long query(int a, int b) {
        return query(a, b, 0, 0, N);
    }

    long query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return 0;
        }
        if (a <= l && r <= b) {
            return seg[k];
        }
        long x = query(a, b, k * 2 + 1, l, (l + r) / 2);
        long y = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return x + y;
    }
}

Measured memory_bytes: 106960
c=[0]*101
for i in range(1,int(input())+1):
    for j in range(2,i+1):
        while i%j==0:
            c[j]+=1
            i//=j
def f(n):
    return sum(i>n-2 for i in c)
print(f(75)+f(25)*(f(3)-1)+f(15)*(f(5)-1)+f(5)*(f(5)-1)*(f(3)-2)//2)

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

const int M = 1e9+7;

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

	vector<int> arr(1001);

	for(int i=2;i<=n;i++){
		if(arr[i]==0){
			for(int j=i+i;j<=n;j+=i) arr[j] = 1;
		}
	}

	int res = 1;
	for(int i=2;i<=n;i++){
		if(arr[i]==0){
			int t = 0;
			for(int j=i;j<=n;j*=i) t+=n/j;
				res = 1ll*res*(t+1)%M;
		}
	}
	cout<<res;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


vll edge[MAX];
ll deg[MAX], val[MAX];
ll idx = 0;
vll c;

void dfs(ll cur,ll par) {
  val[cur] = c[idx];
  idx++;
  rep(i, edge[cur].size()) {
    ll to = edge[cur][i];
    if (to == par) continue;
    dfs(to, cur);
  }
}


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



  cin >> n;
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    edge[a].pb(b);
    edge[b].pb(a);
    deg[a]++;
    deg[b]++;
  }
  rep(i, n) {
    cin >> tmp;
    c.pb(tmp);
  }
  sort(rall(c));
  FOR(i, 1, n + 1) ma = max(ma, deg[i]);
  FOR(i, 1, n + 1) {
    if (ma == deg[i]) {
      dfs(i, -1);
      break;
    }
  }
  ans = accumulate(all(c), 0LL) - c[0];
  cout << ans << endl;
  FOR(i, 1, n + 1) cout << val[i] << " ";
  cout << endl;



  return 0;
}

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

struct rst {
    int id, p;
    string s;
    rst(int id, string s, int p) :id(id), s(s), p(p){}
    bool operator<(const rst& r) {
        if (s == r.s) return p > r.p;
        return s < r.s;
    }
};


int main() {
    int n; cin >> n;
    vector<rst> R;
    for (int i = 1; i <= n; i++) {
        string s;
        int p; cin >> s >> p;
        R.emplace_back(i, s, p);
    }

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

    for (auto r : R) {
        cout << r.id << endl;
    }

    return 0;
}


Measured memory_bytes: 256
a=[0,0,0,0,0,0]
a[0],a[1] = map(int,input().split())
a[2],a[3] = map(int,input().split())
a[4],a[5] = map(int,input().split())

n1=a.count(1)
n2=a.count(2)
n3=a.count(3)
n4=a.count(4)

if n1<3:
    if n1>0:
        if n2<3:
            if n2>0:
                if n3<3:
                    if n3>0:
                        if n4<3:
                            if n4>0:
                                print("YES")
                                exit()
print("NO")
                                


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int r,c,i=0,j=0,a[101][101],b=0,d=0;
  scanf("%d %d",&r,&c);
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      printf("%d ",a[i][j]);
      b+=a[i][j];
    }
    printf("%d\n",b);
    b=0;
  }  
  for(j=0;j<c;j++){
    for(i=0;i<r;i++){
      b+=a[i][j];
    }
    printf("%d ",b);
    d+=b;
    b=0;
  }
    printf("%d\n",d);
    return 0; 
}
 



Measured memory_bytes: 2036
K = int(input())
mod = K

if K % 2 == 0:
  print(-1)
  quit()
if K % 5 == 0:
  print(-1)
  quit()
  

ans = 0
x = 7
T = True
while T:
  ans += 1
  #print(x)
  if x % K == 0:
    print(ans)
    quit()
  x = x * 10 + 7
  x %= mod
    
    

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

int main() {

int N;
cin >> N;
vector<int>modulo(N);
for(int i = 0; i < N; i++){
  cin >> modulo.at(i);
}
int sum = 0;

for(int i = 0; i < N; i++){
  sum += modulo.at(i) - 1;
}
cout << sum << endl;

}
  
  

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

	int N, A, B;
	cin >> N >> A >> B;
	
	if (A == 0 || B == 0) cout << 0 << " " << 0 << endl;
	else if (N >= A + B)cout << min(A, B) << " " << 0 << endl;
	else cout << min(A, B) << " " << abs(N - A - B) << endl;

	return 0;
}

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



public class Test
{
	public static void Main( )
	{
		string region = Console.ReadLine().Trim();
		
		int n = region.Length;
		int isHorizon;
		char c;
		List<int> area = new List<int>();

		for( int i=0; i<n; i++ ) {
			c = region[i];
			if( '\\' == c ) {

				isHorizon = 0;
				for( int j=i; j<n; j++ ) {
					c = region[j];
					if( '\\' == c ) {
						isHorizon--;
					} else if( '/' == c ) {
						isHorizon++;
						if( 0 == isHorizon ) {
							int height;
							int sum;
							
							sum = height = 0;
							for( int k=i; k<=j; k++ ) {
								c = region[k];
								if( '\\' == c ) {
									height--;
									sum += height;
								} else if( '/' == c ) {
									height++;
									sum += height;
									if( 0 == height ) {
										area.Add( sum*(-1) );
									}
								} else if( '_' == c ) {
									sum += height;
								}
							}
							
							i = j;
							break;
						}
					}
				}
			}

		}
		
		
		Console.WriteLine( area.Sum() );
		Console.Write( "{0}", area.Count );
		if( area.Count > 0 ) {
			Console.WriteLine( " {0}", String.Join( " ", area.ToArray() ) );
		} else {
			Console.WriteLine();
		}
		return;
	}
}


Measured memory_bytes: 20244