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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//#define int ll
//#define int long long

signed main()
{
  int k,s; cin >> k >> s;
  int res = 0, cnt = 0;
  for(int x = 0;x <= k; ++x){
    for(int y = 0; y <= k; ++y){
      int z = s-x-y;
       if(0 <= z && z <= k) ++cnt;
    }
  }
  
  
  cout << cnt;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

import java.util.Scanner;
 
  
  
  
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			int run = 0;
			int p = 0;
			int out = 0;
			while(out < 3){
				String c = sc.next();
				if(c.equals("HIT")){
					if(run<3)run++;
					else p++;
				}
				else if(c.equals("HOMERUN")){
					p += run+1;
					run = 0;
				}
				else{
					out++;
				}
			}
			System.out.println(p);
		}
	}
}

Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int m = (n - 1) / 2;
//  cout << n << " " << m << " " << (n + 3) / 2 << endl;
  rep(i,n)
  {
//    cout << s[i] << " " << s[n - 1 - i] << endl;
    if (s[i] != s[n - 1 - i]) {
      cout << "No";
      return 0;
    }
  }
//  cout << endl;
  rep(i,m)
  {
//    cout << s[i] << " " << s[m - 1 - i] << endl;
    if (s[i] != s[m - 1 - i]) {
      cout << "No";
      return 0;
    }
  }
//  cout << endl;
  for (int i = (n + 3) / 2 - 1, j = 0; i < n; ++i, j++) {
//    cout << s[i] << " " << s[n - 1 - j] << endl;
    if (s[i] != s[n - 1 - i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
int n,k;cin>>n>>k;
int x[n];rep(i,n)cin>>x[i];

int count=0;
rep(i,n){
    if(k-x[i]<x[i])count+=k-x[i];
    else if(k-x[i]>x[i])count+=x[i];
    else count+=x[i];
}
cout << count*2 << endl;
return 0;
}
        
    


 


Measured memory_bytes: 256
/*input
10 10 10
1 6
2 9
4 5
4 7
4 7
5 8
6 6
6 7
7 9
10 10
1 8
1 9
1 10
2 8
2 9
2 10
3 8
3 9
3 10
1 10
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int cnt[505][505];
pii a[maxn];
int main()
{
	IOS;
	int n,m,q;
	cin>>n>>m>>q;

	REP(i,m){
		int x,y;
		cin>>x>>y;
		x=n-x;
		y--;
		cnt[x][y]++;
	}
	REP(i,n) REP(j,n){
		if(i==0&&j==0);
		else if(i==0) cnt[i][j]+=cnt[i][j-1];
		else if(j==0) cnt[i][j]+=cnt[i-1][j];
		else{
			cnt[i][j]+=cnt[i][j-1]+cnt[i-1][j]-cnt[i-1][j-1];
		} 
	}
	while(q--){
		int x,y;
		cin>>x>>y;
		x=n-x;y--;
		cout<<cnt[x][y]<<'\n';
	}


	return 0;
}


Measured memory_bytes: 1920
import sys
input = sys.stdin.readline


def main():
    x = int(input())
    ans = 2 * (x//11)
    r = x % 11
    if r > 6:
        ans += 2
    elif r > 0:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let left = get!();
    let right = get!();
    let diff = right - left;
    
    if diff > 2019 {
        println!("0");
        return;
    }
    
    let mut ans = left * right % 2019;
    for i in left .. right {
        for j in i+1 .. right+1 {
            let tmp = i * j % 2019;
            ans = std::cmp::min(ans, tmp);
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
time = 1
def dfs(node):
    global time
    if visited[node] != -1:
        return
    visited[node] = 0
    d[node] = time
    time += 1
    for v in edge[node]:
        dfs(v)
    f[node] = time
    time += 1

if __name__ == "__main__":
    n = int(input())
    edge = []
    for i in range(n):
        u,k,*v_li = map(int,input().split())
        for j in range(len(v_li)):
            v_li[j] -= 1
        u-=1
        edge.append(v_li)
    d = {}
    f = {}
    visited = [-1]*n
    
    for i in range(n):
        dfs(i)
    for i in range(n):
        print(i+1,d[i],f[i])




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

using namespace std;

typedef long long int ll;

void solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int flag = 1;
	while(1)
	{
		if(flag)
			c = c - b, flag = 0;
		else 
			a = a - d, flag = 1;
		if(c <= 0)
		{
			cout << "Yes";
			return;
		}
		if(a <= 0)
		{
			cout << "No";
			return;
		}
	}
}

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



Measured memory_bytes: 3636
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [Double] -> [Double]
solve [a, b, theta] = [area, circum, height] where
    height = b*sin (theta/180*pi)
    area   = height*a/2
    circum = sqrt ((a - b*cos (theta/180*pi))^2+ height^2) + a + b

readLine:: IO [Double]
readLine = fmap (map read . words) getLine

main :: IO() 
main = do
    l <- readLine
    mapM_ print (solve l)



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

int tablica[201][201];
int odl [10][10];
int licz,wynik=0;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int h,w;
    cin >> h >> w;
    for (int i=0;i<10;i++){
        for (int j=0;j<10;j++){
            cin >> odl[i][j];
        }
    }
   // int V = 9;
    //int dist = 9*9;
    for(int k=0;k<=9;k++)
        {for(int j = 0;j<=9;j++){
            for(int i = 0;i<=9;i++){
                if(odl[i][j]>odl[i][k] + odl[k][j])
                    odl[i][j]=odl[i][k] + odl[k][j];
            }
        }

        }

    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            cin >> licz;
            if(licz!=-1)wynik += odl[licz][1];
        }
    }
    cout << wynik;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef unsigned char uc;
struct R {
  uc notes[1024];
  int num;
  void push(const uc& note) {
    notes[num++] = note;
  }
};

R rolls[8];
char hexmap[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

int gcd_of(int a, int b) {
  while (a != b) {
    if (a > b)
      a -= b;
    else
      b -= a;
  }
  return a;
}

int lcm_of(const int& a, const int& b) {
  return a * b / gcd_of(a, b);
}

int main() {
  int t;
  cin >> t;
  while (t --) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      // load
      char buff[2049];
      cin >> buff;
      char* p = buff;
      auto& r = rolls[i];
      r.num = 0;
      while (*p != 0) {
        r.push((*p - '0') * 16 + (*(p + 1) - '0'));
        p += 2;
      }

      // comp
      int gcd = r.num;
      int clen = 1;
      for (int j = 1; j < r.num; j++) {
        if (r.notes[j] == 0) {
          clen++;
        } else {
          gcd = gcd_of(gcd, clen);
          clen = 1;
          if (gcd == 1) break;
        }
      }
      gcd = gcd_of(gcd, clen);
      if (gcd != 1) {
        r.num /= gcd;
        for (int j = 0; j < r.num; j++) r.notes[j] = r.notes[j * gcd];
      }
    }
    int lcm = rolls[0].num;

    for (int i = 1; i < n; i++) {
      lcm = lcm_of(lcm, rolls[i].num);
      if (lcm > 1024) break; // for overflow
    }

    if (lcm > 1024) {
      cout << "Too complex.";
    } else {
      // combine
      int m[8];
      for (int i = 0; i < n; i++) m[i] = lcm / rolls[i].num;
      for (int i = 0; i < lcm; i++) {
        uc v = 0;
        for (int j = 0; j < n; j++) {
          if (i % m[j] == 0) v |= rolls[j].notes[i / m[j]];
        }
        cout << hexmap[v / 16] << hexmap[v % 16];
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n, m = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]

dp = [0 for i in range(0, n + 1)]
s = [0 for i in range(0, n + 1)]
b = [0 for i in range(0, n + 1)]

c = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
a.sort()
a = a[::-1]

for i in range(1, n + 1):
    l = -1
    argl = 0
    pl = 0
    for j in range(0, m):
        p = i - c[a[j]]
        if p >= 0 and dp[p] > l:
            l = dp[p]
            argl = j
            pl = p
    if l < 0:
        dp[i] = -1
    else:
        dp[i] = l + 1
        s[i] = a[argl]
        b[i] = pl

bi = n
u = ""
while bi > 0:
    u += str(s[bi])
    bi = b[bi]

print(u)

Measured memory_bytes: 3828
#include <stdio.h>

int main(){
  int i,d=0,s=1,n,data[251];
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&data[i]);
for(i=1;i<=n;i++){
printf("node %d: key = %d, ",i,data[i]);
if(i/2)
printf("parent key = %d, ",data[i/2]);
if(2*i<=n)
printf("left key = %d, ",data[2*i]);
if(2*i+1<=n)
printf("right key = %d, ",data[2*i+1]);
printf("\n");
}

return 0;
}


Measured memory_bytes: 2044
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
	cin>>s;
	if(s.substr(0, 4)=="YAKI") cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

using P = pair<double, int>;

int64_t D, G;
vector<int64_t> p, c, sum;

int64_t po(int n, vector<bool> vec){
    if(n == D){
        int64_t now = 0;
        int ans = 0;
        for(int i = 0; i < D; ++i){
            if(vec[i]){
                now += sum[i];
                ans += p[i];
            }
        }
        if(now >= G){
            return ans;
        }
        int mi = 1 << 30;
        for(int i = 0; i < D; ++i){
            if(!vec[i] && now + sum[i] >= G){
                int mon = (G - now) / (100 * (i+1));
                if((G - now) % (100 * (i+1)) != 0) ++mon;
                mi = min(mi, mon);
            }
        }
        return ans + mi;
    }
    auto off = po(n+1, vec);
    vec[n] = true;
    auto on = po(n+1, vec);
    return min(off, on);
}

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

    p.resize(D);
    c.resize(D);
    sum.resize(D);
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
        sum[i] = 100 * (i+1) * p[i] + c[i];
    }

    vector<bool> vec(D);
    cout << po(0, vec) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

string s, t, ans;

void reconstruct(int i, int j, vv<vll>& dp) {
	if (i <= 0 || j <= 0)
		return;
	if (s[i] == t[j]) {
		ans = s[i] + ans;
		reconstruct(i - 1, j - 1,dp);
	} else {
		if (dp[i - 1][j] > dp[i][j - 1])
			reconstruct(i - 1, j, dp);
		else
			reconstruct(i, j - 1, dp);
	}
}

int main() {
	fastio;
	cin >> s >> t;
	ll n, m;
	n = s.size(), m = t.size();
	s = '@' + s;
	t = '#' + t;
	/* s[i] == t[j]
		dp[i][j] = 1+dp[i-1][j-1];
		else
		dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
	*/

	// dp[i][j] is the length of maxsubsequence of strings
	// s(0...i) and t[0..j]

	vv<vll> dp(n + 1, vll(m + 1, 0));

	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= m; j++) {
			if (s[i] == t[j])
				dp[i][j] = 1 + dp[i - 1][j - 1];
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	// for(ll i=0; i<n; i++){
	// 	for(ll j=0; j<m; j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	// cout<<dp[0][0];
	reconstruct(n,m,dp);
	// ll i = n, j = m;
/* 	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j - 1] + 1) {
			ans.push_back(s[i]);
			i--;
			j--;
		} else if (dp[i - 1][j] > dp[i][j - 1])
			i--;
		else
			j--;
	}
 */	
	// LG(ans)
	// if (ans.size() < dp[n - 1][m - 1]) {
	// 	if (i == 0) {
	// 		ans.push_back(s[0]);
	// 	} else if (j == 0)
	// 		ans.push_back(t[0]);
	// }
	// reverse(all(ans));
	cout << ans << endl;
}

Measured memory_bytes: 74352
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	double  ans = 0;
	double x;
	string u;
	for (int i = 0; i < n; i++) {
		cin >> x >> u;
		if (u == "JPY")ans += x;
		else ans += (x*380000);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

ans = 0

N.times do |i|
  ans += B[i]

  if i != 0 && A[i-1] +1 == A[i]
    ans += C[A[i-1]-1]
  end
end

puts ans


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    int n;
    cin>>n;
    vi a(n);
    vi b(n);
    for (int i = 0;i < n;++i)
    	cin>>a[i]>>b[i];
    if (a == b)
    	return puts("0") * 0;
    vector < pii > s;
    int mx = 0;
    ll ans = 0;
    for (int i = 0;i < n;++i)
    	if (a[i] <= b[i])
    		ans += a[i];
    	else
    	if (a[i] > b[i]) {
    		if (!mx)
    			mx = 2e9;
    		smin(mx,b[i]);
    		ans += a[i];
    	}
    ans -= mx;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};
const int p = 2019;
int main() {
  ll L, R;
  cin >> L >> R;
  ll right = min(L + 2019, R);
  int ans = 2020;
  for (int i = L; i <= right; i++) {
    for (int j = i + 1; j <= right; j++) {
      ans = min(ans, ((i % p) * (j % p)) % p);
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int result = 0;
    
    for(int i = 1; i <= n; i++){
      
      int sum = 0;

      // 各桁のループ
      for(char num : String.valueOf(i).toCharArray()){
        sum += Integer.parseInt(String.valueOf(num));
      }
      
      if(sum >= a && sum <= b){
        result += i;
      }
      
    }
    
    System.out.println(result);

  }

}

Measured memory_bytes: 25684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 100000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int nCr(int n, int r) {
	int ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
bool is_even(ll x) { return x % 2 == 0 ? 1 : 0; }
bool is_odd(ll x) { return x % 2 == 1 ? 1 : 0; }
int main() {
	int n,m;
	cin >> n >> m;
	int i;
	string s[110000];
	int a[110000];
	bool flag[110000] = { 0 };
	int sum[110000];
	for (i = 0; i < m; i++) {
		cin >> a[i] >> s[i];
	}
	int ac = 0;
	int wa = 0;
	for (i = 0; i < m; i++) {
		if (flag[a[i]]) continue;
		if (s[i] == "WA") {
			sum[a[i]]++;
		}
		else {
			ac++;
			wa += sum[a[i]];
			flag[a[i]]++;
		}
	}
	cout << ac << " " << wa;
	return(0);
}

Measured memory_bytes: 6656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,T,cas=0;
    cin>>n;
    string s;
    set<string> st;
    for(int i=0;i<n;++i) {
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 19208
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
struct SCC{
	vector<vector<int>> g;
	int n, k;
	vector<int> cmp, ord, low, visited;
	int num;
	void dfs(int x){
		ord[x]=low[x]=num++;
		visited.push_back(x);
		for(auto y:g[x]){
			if(ord[y]==-1){
				dfs(y);
				low[x]=min(low[x], low[y]);
			}else{
				low[x]=min(low[x], ord[y]);
			}
		}
		if(ord[x]==low[x]){
			while(1){
				int v=visited.back();
				visited.pop_back();
				cmp[v]=k;
				ord[v]=n;
				if(v==x) break;
			}
			k++;
		}
	}
	SCC(const vector<vector<int>> &g):g(g), n(g.size()), cmp(n), ord(n, -1), low(n){
		num=0, k=0;
		for(int x=0; x<n; x++){
			if(ord[x]==-1) dfs(x);
		}
		for(int x=0; x<n; x++){
			cmp[x]=k-1-cmp[x];
		}
	}
};
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	vector<vector<int>> g(n);
	for(int i=0; i<m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		g[a].push_back(b);
	}
	SCC scc(g);
	printf("%d\n", scc.k);
	vector<vector<int>> v(scc.k);
	for(int i=0; i<n; i++) v[scc.cmp[i]].push_back(i);
	for(auto w:v){
		printf("%d", w.size());
		for(auto x:w) printf(" %d", x);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 81420
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    long long X;
    cin >> X;
    long long val = 100, year = 0;
    while (val < X) {
        long long buf = val * 0.01;
        buf = floor(buf);
        val += buf;
        year++;
    }
    cout << year << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
    int x;
    cin>>x;
    if(x>1799)
    cout<<1;
    else if(x>1599)
    cout<<2;
    else if(x>1399)
    cout<<3;
    else if(x>1199)
    cout<<4;
    else if(x>999)
    cout<<5;
    else if(x>799)
    cout<<6;
    else if(x>599)
    cout<<7;
    else cout<<8;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int N;
    while(cin>>N,N)
    {
        int w[202]={0};
        int h[202]={0};
        int n[202];
        int d[202];
        int lenwl=0;
        int lenwu=0;
        int lenhl=0;
        int lenhu=0;
        int t;
 
        for(int i=1;i<N;i++)
        {
            cin>>n[i]>>d[i];
            if(d[i]==0)
            {
                t=w[n[i]];
                w[n[i]]--;
                w[i]=w[n[i]];
                w[n[i]]=t;
                h[i]=h[n[i]];
            }
            else if(d[i]==1)
            {
                t=h[n[i]];
                h[n[i]]--;
                h[i]=h[n[i]];
                h[n[i]]=t;
                w[i]=w[n[i]];
            }
            else if(d[i]==2)
            { 
                t=w[n[i]];
                w[n[i]]++;
                w[i]=w[n[i]];
                w[n[i]]=t;
                h[i]=h[n[i]];
            }
            else
            {
                t=h[n[i]];
                h[n[i]]++;
                h[i]=h[n[i]];
                h[n[i]]=t;
                w[i]=w[n[i]];
            }
        }
        for(int i=0;i<=N;i++)
        {
            lenwl=min(lenwl,w[i]);
            lenwu=max(lenwu,w[i]);
            lenhl=min(lenhl,h[i]);
            lenhu=max(lenhu,h[i]);
        }
        cout<<lenwu-lenwl+1<<" "<<lenhu-lenhl+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
x = input()
x1 = int(x[0:2])
x2 = int(x[2:4])

if 0 < x1 <= 12 and 0 < x2 <= 12:
    print("AMBIGUOUS")
elif 0 < x1 <= 12:
    print("MMYY")
elif 0 < x2 <= 12:
    print("YYMM")
else:
    print("NA")
    

Measured memory_bytes: 2940
num1 = int(input())
numArray = [[0]*2]*num1

for index1 in range(num1):
    numArray[index1] = [j for j in input().split()]
    numArray[index1].append(index1+1)
    numArray[index1][1] = int(numArray[index1][1])

numArray.sort(key=lambda x:(x[0],-x[1]))

for index2 in range(num1):
    print(numArray[index2][2])


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d\n",&a,&b);
    if((a==1&&b==2)||(a==2&&b==1))
    {
        printf("3\n");
    }
    else if((a==2&&b==3)||(a==3&&b==2))
    {
        printf("1\n");
    }
    else
    {
        printf("2\n");
    }
    return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		scan.close();

		if (a <= 10) {
			System.out.println(a + (a * a) + (a * a * a));
		}
	}
}

Measured memory_bytes: 35468
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

template <class T>void Rd(T &x){
	x=0;
	char c;
	while(c=getchar(),!isdigit(c));
	do{
		x=(x<<3)+(x<<1)+(c^'0');
	}while(c=getchar(),isdigit(c));
}

#define M 100005

int A[M],n;

long long calc(){
	if(A[n]!=2)return -1;
	long long l=1,r=1;
	for(int i=n-1;i>=1;i--){
		l=(l*A[i+1]+A[i]-1)/A[i];
		r=((r+1)*A[i+1]-1)/A[i];
	}
	if(l>r)return -1;
	printf("%lld %lld\n",l*A[1],(r+1)*A[1]-1);
	return 0;
}

int main(){
	Rd(n);
	for(int i=1;i<=n;i++)Rd(A[i]);
	long long ans=calc();
	if(ans==-1)puts("-1");
	return 0;
}

Measured memory_bytes: 640
import java.awt.Point;
import java.util.Scanner;

public class Main{
	static Scanner s=new Scanner(System.in);
	
	//ldru
	static int[] dx={-1,0,1,0},dy={0,-1,0,1};
	public static void main(String[] __){
		while(true){
			int n=s.nextInt();
			if(n==0) return;
			
			Point[] ps=new Point[n];
			ps[0]=new Point(0,0);
			int u=0,d=0,l=0,r=0;
			for(int i=1;i<n;i++){
				ps[i]=(Point)ps[s.nextInt()].clone();
				int dir=s.nextInt();
				ps[i].translate(dx[dir],dy[dir]);
				
				u=Math.max(u,ps[i].y);
				d=Math.min(d,ps[i].y);
				r=Math.max(r,ps[i].x);
				l=Math.min(l,ps[i].x);
			}
			
			System.out.printf("%d %d\n",r-l+1,u-d+1);
		}
	}
}

Measured memory_bytes: 42192
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int q = scanner.nextInt();

        final Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n - 1; i++) {
            final int parent = scanner.nextInt() - 1;
            final int child = scanner.nextInt() - 1;

            map.put(child, parent);
        }

        final long[] answers = new long[n];

        for (int i = 0; i < q; i++) {
            final int node = scanner.nextInt() - 1;
            final int operation = scanner.nextInt();

            answers[node] += operation;
        }

        for (int i = 1; i < n; i++) {
            answers[i] += answers[map.get(i)];
        }

        for (final long answer : answers) {
            System.out.print(answer + " ");
        }
    }
}


Measured memory_bytes: 188832
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<string> g;

int main() {

    
    ll n;
    cin >> n;
    
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n; ++i)
    {
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    
    ll ret = 0;
    for (int i = 0; i < n; ++i)
    {
        auto itr1 = lower_bound(a.begin(), a.end(), b[i]);
        auto itr2 = upper_bound(c.begin(), c.end(), b[i]);
        ll ac = itr1 - a.begin();
        ll cc = c.end() - itr2;
        ret += ac * cc;
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
a, b, k = map(int,input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 != 0:
            a -= 1
        b += a // 2
        a -= a // 2
    else:
        if b % 2 != 0:
            b -= 1
        a += b // 2
        b -= b // 2
    #print(a, b)
print(a, b)


Measured memory_bytes: 2940
#include <stdio.h>

#define NUMBER 200000

void swap (int *x,int *y)
{
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

int partition (int h[],int left,int right)
{
    int i,j,pivot;
    i = left;
    j = right + 1;
    pivot = left;
    
    do{
        do {i++;} while (h[i] < h[pivot]);
        do {j--;} while (h[pivot] < h[j]);
        if (i < j) {swap(&h[i],&h[j]);}
    } while (i < j);
    
    swap (&h[pivot],&h[j]);
    return j;
}

void quick_sort (int h[],int left,int right)
{
    int pivot;
    
    if(left < right){
        pivot = partition(h,left,right);
        quick_sort(h,left,pivot-1);
        quick_sort(h,pivot+1,right);
    }
}
int main(void)
{
    int n,k;
    int h[NUMBER];
    int i;
    
    scanf("%d %d",&n,&k);
    for (i = 0;i < n;i++){
        scanf("%d",&h[i]);
    }
    quick_sort (h,0,n-1);
    
    long c = 0;
    
    if (n > k){
        for (i = 0;i < n-k;i++){
            c = c + h[i];
        }
    }
    printf("%ld\n",c);
    return 0;
}



Measured memory_bytes: 896
/////////////////////////////////////////Info/////////////////////////////////////////////////
//Problem:
//Date:
//Skill:
//Bug:
/////////////////////////////////////////Definations/////////////////////////////////////////////////
//循环控制
#define CLR(a) memset((a),0,sizeof(a))
#define F(i,a,b) for(int i=a;i<=int(b);++i)
#define F2(i,a,b) for(int i=a;i>=int(b);--i)
#define RE(i,n)  for(int i=0;i<int(n);i++)
#define RE2(i,n) for(int i=1;i<=int(n);i++)
//简化敲击
#define PII pair<int,int>
#define PLL pari<long long ,long long>
#define PB push_back
#define ENDL '\n'
#define x first
#define y second
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
////////////////////////////////////////Options//////////////////////////////////////////////////////
#define stdcpph
#define CPP_IO

#ifdef stdcpph
#include<bits/stdc++.h>
#else
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>
#ifdef CPP_IO
#include<iostream>
#include<iomanip>
#include<string>
#else
#include<stdio.h>
#endif
#endif
////////////////////////////////////////Basic Functions//////////////////////////////////////////////
template<typename INint> inline void IN(INint &x)
{
	x = 0; int f = 1; char c; cin.get(c);
	while (c<'0' || c>'9') { if (c == '-')f = -1; cin.get(c); }
	while (c >= '0'&&c <= '9') { x = x * 10 + c - '0'; cin.get(c); }
	x *= f;
}
template<typename INint> inline void OUT(INint x)
{
	if (x > 9)OUT(x / 10); cout.put(x % 10 + '0');
}
////////////////////////////////////////Added Functions//////////////////////////////////////////////
const int maxn = int(3010);
ll dp[maxn];
int a[4], N;
////////////////////////////////////////////Code/////////////////////////////////////////////////////
int main()
{
	//freopen("C:\\Users\\VULCAN\\Desktop\\data.in", "r", stdin);
	int T(1), times(0);
#ifdef CPP_IO// CPP_IO
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//cin >> T;
#else
	//IN(T);
#endif 
	/////////////////////////////////////////////////////////////////////////////////////////////////
	while (++times, T--)
	{
		dp[0] = 1;
		RE2(i, 3)cin >> a[i]; cin >> N;
		RE2(i, 3)
		{
			int cnt = a[i];
			for (int des = cnt; des <= N; ++des)
			{
				dp[des] += dp[des - cnt];
			}

		}
		cout << dp[N] << endl;
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 100 + 5;
 
int main(){
	string s;
	cin >> s;
	if(s == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n,k;
    cin>>n>>k;
    lli i,a[n+1],tot=0,l,r;
    
    for(i=1;i<=n;i++) 
    {
        cin>>a[i];
        if(a[i]==n) tot++;
    }
    if(tot==n)
    {
        for(i=1;i<=n;i++) cout<<n<<" ";
        return 0;
    }
    while(tot!=n)
    {
        if(k==0)
        {
            for(i=1;i<=n;i++) cout<<a[i]<<" ";
            return 0;
        }
        k--;
        tot=0;
        lli b[n+2]={0};
        
        for(i=1;i<=n;i++)
        {
            l=max(i-a[i], 0LL);
            r=min(i+a[i]+1, n+1);
            b[l]++;
            b[r]--;
        }
        
        for(i=1;i<=n;i++) 
        {
            b[i]+=b[i-1];
            a[i]=b[i];
            if(a[i]==n) tot++;
        }
    }
    for(i=1;i<=n;i++) cout<<n<<" ";
    return 0;
}

Measured memory_bytes: 6764
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	c=a*b;
	if(1<=a && a<=9 && 1<=b && b<=9){
	printf("%d\n",c);
	}
	else{
	printf("%d\n",-1);
	}
	return 0;
}

Measured memory_bytes: 1732
N = int(input())
W = [input() for x in range(N)]
S = set(W)
flg = 0
if len(W) != len(S):
    flg = 1
else:
    for i in range(1, N):
        if W[i][0] != W[i-1][-1]:
            flg = 1
            break
if flg == 1:print("No")
else:print("Yes")


Measured memory_bytes: 3060
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def same(self, x, y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False


def kruskal(n, edges):
    uf = UnionFind(n)
    edges.sort()
    res = 0
    for c, s, t in edges:
        if not uf.same(s, t):
            res += c
            uf.unite(s, t)
    return res

while True:
    n = int(input())
    if n == 0: break

    x = [0] * n
    y = [0] * n
    z = [0] * n
    r = [0] * n
    for i in range(n):
        x[i], y[i], z[i], r[i] = map(float, input().split())
    
    edges = []
    for i in range(n):
        for j in range(n):
            if i == j: continue
            c = max(((x[i]-x[j])**2 + (y[i]-y[j])**2 + (z[i]-z[j])**2)**(1/2) - (r[i]+r[j]), 0)
            edges.append((c, i, j))
    
    print("{:.3f}".format(kruskal(n, edges)))



Measured memory_bytes: 6880
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int P = 1e9+7; 
	int A[100010] = {}; 
	for(int i = 0; i < N; i++){
		int a; 
		cin >> a; 
		A[a] ++; 
	}
	int ans = 1; 
	if(N % 2 == 0){	
		for(int i = 0; i < N; i++){
			if(i % 2 == 0 && A[i] != 0){ans = 0;}
			else if(i % 2 == 1 && A[i] != 2){ans = 0;}
			else if(i % 2 == 1){ans = (ans * 2) % P;}
		}
	}
	else if(N % 2 == 1){	
		for(int i = 0; i < N; i++){
			if(i % 2 == 1 && A[i] != 0){ans = 0;}
			else if(i == 0 && A[i] == 1){ans *= 1;}
			else if(i == 0 && A[i] != 1){ans = 0;}
			else if(i > 0 && i % 2 == 0 && A[i] != 2){ans = 0;}
			else if(i > 0 && i % 2 == 0){ans = (ans * 2) % P;}
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int seg_len = 1;
int SEG_MAX = 10000000;
vector<map<char, int>> seg(SEG_MAX);

void seg_update(int pos, char c){
	pos += seg_len;
	while(pos > 0){
		seg[pos][c]++;
		pos /= 2;
	}
}

void seg_erase(int pos, char c){
	pos += seg_len;
	while(pos > 0){
		seg[pos][c]--;
		if(seg[pos][c] <= 0)seg[pos].erase(c);
		pos /= 2;
	}
}

int res(int l, int r){
	l += seg_len;
	r += seg_len;
	map<char,int> ret;
	while(l < r){
		if(l % 2 == 1){
			for(auto x:seg[l])ret[x.first] += x.second;
			++l;
		}
		if(r % 2 == 1){
			for(auto x:seg[r-1])ret[x.first] += x.second;
			--r;
		}
		l /= 2; r /= 2;
	}
	return ret.size();
}

int main(){
	int N, Q, i, l, r, tp;
	char c;
	string s;
	cin >> N >> s >> Q;
	while(seg_len < N)seg_len *= 2;
	rep(i,N)seg_update(i, s[i]);
	rep(_,Q){
		cin >> tp;
		if(tp == 1){
			cin >> i >> c;
			--i;
			seg_update(i,c);
			seg_erase(i,s[i]);
			s[i] = c;
		}else{
			cin >> l >> r;
			cout << res(l-1, r) << endl;
		}
	}
	//for(auto x: seg){
	//	for(auto y:x)cout << y.first << ' ';
	//	cout << endl;
	//}
	return 0;
}


Measured memory_bytes: 611096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int s = sc.nextInt();
		int w = sc.nextInt();

		if (s <= w){
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	}
}

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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    vector<ll> v;
    queue<ll> q;
    q.push(0);
    while(q.size()){
        ll now=q.front();
        if(now>n) break;
        q.pop();
        ll p=now*10 + 2;
        if(n%p==0) v.push_back(p);
        q.push(p);
        p = now*10 + 8;
        if(n%p==0) v.push_back(p);
        q.push(p);
    }
    // cerr << v.size() << endl;
    // for(auto i:v){
    //     cerr << i << endl;
    // }
    map<ll,ll> mp;
    mp[n]=0;
    mp[1] = -1;
    for(int i=0;i<v.size();i++){
        ll now=v[i];
        for(auto j:mp){
            ll a = j.first;
            while(a%now == 0){
                mp[a/now] = max(mp[a/now],mp[a]+1);
                a/=now;
            }
        }        
    }
    cout << mp[1] << endl;
    
}


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

int main() {
    vector<int> data = {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};

    int k;
    cin >> k;
    cout << data.at(k - 1) << endl;
}

Measured memory_bytes: 256
function Main(input){
    var inputList = input.split(" ");
    var result = inputList[0] * inputList[1];

    if(result % 2 !== 0){
        console.log("Odd");
    }else{
        console.log("Even")
    }
}

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

Measured memory_bytes: 9420
#include <stdio.h>

int main(){
    int n,a[100];
    int i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&a[n-1-i]);
    for(i=0;i<n;i++){
        printf("%d",a[i]);
        printf(i-n+1? " ":"\n");
    }
}

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

using namespace std;
using ll=long long;

// when range [l, r), has property P~notP, want last P.
// when return l-1, means not found.
template <typename T>
T bs_last(T l, T r, function<bool (T)> f) {
    assert(l < r);
    T mid;
    while (l != r) {
        mid = l + (r-l)/2;
        if (f(mid)) {
            l = mid + 1;
        }else {
            r = mid;
        }
    }
    return r-1;
}

void solve() {
    int n;
    ll m, v;
    int p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end(),greater<ll>());
    
    auto ck = [&](int i){
        ll tot = m*v;
        const ll X = a[i] + m; tot -= m;
        int cnt = 0;
        vector<ll> reso;
        for (int j = 0; j < n; j++) {
            if (j!=i) {
                //if (tot <= 0) break;
                if (a[j] > X) {
                    ll dx = min(m, tot);
                    tot -= dx;
                    cnt++;
                } else {
                    ll dx = min({X-a[j], m, tot});
                    tot -= dx;
                    if (dx < m) {
                        reso.push_back(m - dx);
                    }
                }
            }
        }
        sort(reso.begin(), reso.end(), greater<ll>());
        int j = 0;
        while (tot > 0) {
            tot -= reso[j++];
            cnt++;
        }
        return cnt < p;
    };
    int res = bs_last<int>(0, n, ck);
    res++;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL rec(int n, LL x);

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

    int n;
    LL x;
    cin >> n >> x;

    cout << rec(n, x) << endl;
    return 0;
}

LL rec(int n, LL x) {
    if(n == 0) {
        return 1;

    }
    LL len, num;
    len = (1ll << (n + 1)) - 3;
    num = (1ll << n) - 1;

    if(x == 1) {
        return 0;

    }
    if(x <= len + 1) {
        return rec(n - 1, x - 1);

    }
    if(x == len + 2) {
        return num + 1;

    }
    if(x <= (len + 1) * 2) {
        return num + 1 + rec(n - 1, x - len - 2);

    }
    return num * 2 + 1;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a;
    cin>>a;
    for(int i=1;i<=3;i++){
    if(a%10==7){
    cout<<"Yes";return 0;
    }
  else a=a/10;
  }
  cout<<"No";//如果没有输出no
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
int a[110*110],grid[110][110];
int main(){
	int R,C,N;
	scanf("%d%d%d",&R,&C,&N);
	for(int i=1;i<=N;i++){
		scanf("%d",a+i);
	}
	int cur=1;
	for(int i=1;i<=R;i++){
		for(int j=i&1?1:C;i&1?j<=C:j>=1;i&1?j++:j--){
			if(a[cur]==0) cur++;
			grid[i][j]=cur;
			a[cur]--;
		}
	}
	for(int i=1;i<=R;i++)
		for(int j=1;j<=C;j++)
			printf("%d%c",grid[i][j],j==C?'\n':' ');
	return 0;
}

Measured memory_bytes: 384
a,b,c,d = map(int,input().split())
x = c-a
y = d-b

print('U'*y + 'R'*x + 'D'*y + 'L'*x + 'L' + 'U'*(1+y) + 'R'*(1+x) + 'D' + 'R' + 'D'*(1+y) + 'L'*(1+x) + 'U')

Measured memory_bytes: 3060
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
li = list(map(int,input().split()))

for i in range(n-1):
    li[i+1] += li[i] 

ans = li.count(0) #0だったらそこまでの和が1つの正解
c = list(collections.Counter(li).values())
for i in c:
    if i > 1:
        ans += cmb(i,2)

print(ans)


Measured memory_bytes: 37240
/* ex_6-2. nknm */

#include <stdio.h>
#include <string.h>

int main(void){
    
    int word_num, i;
    char imput[100];

    scanf("%s", imput);     //文字列を入力

    word_num = strlen(imput);       //文字数を計算

    printf("%c%d%c\n", imput[0], word_num - 2, imput[word_num - 1]);        //頭文字、(文字数-2)、最後の文字を出力

    return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<string> S(N);
	REP(i, N) cin >> S[i];

	ll res{0};
	ll s_a{0}, s_b{0}, s_ab{0};
	
	REP(i, N)
	{
		ll M= S[i].size();
		string &s = S[i];
		
		if (s.front() == 'B' && s.back() != 'A') ++s_b;
		else if (s.back() == 'A' && s.front() != 'B') ++s_a;
		else if (s.back() == 'A' && s.front() == 'B') ++s_ab;
		for (ll k = 0; k < M-1;)
		{
			if (s[k] == 'A' && s[k+1] == 'B')
			{
				++res;
				k+=2;
			}
			else
				++k;
		}
	}

	if (s_ab == 0)
		std::cout << res + min(s_a, s_b) << std::endl;
	else if (s_a + s_b > 0)
		std::cout << res + min(s_a, s_b) + s_ab << std::endl;
	else
		std::cout << res + s_ab - 1 << std::endl;
}


Measured memory_bytes: 768
import Data.Vector hiding (map)
import qualified Data.Vector as V

main :: IO ()
main = do
  l1 <- getLine
  let [n, m, k] = map read $ words l1 :: [Integer]
  print $ modp $ f n m k

p :: Integral a => a
p = 998244353
modp :: Integral a => a -> a
modp n = mod n p

pow a 0 = 1
pow a n
  | odd n = modp $ a * modp (pow a (n `div` 2)^2)
  | otherwise = modp (pow a (n `div` 2)^2)

inv n = pow n (p - 2)

div' n m = modp $ n * inv m

facts = generate (2 * 10^5 + 1) fact
fact :: Integral a => a -> a
fact 0 = 1
fact n = modp $ n * fromIntegral (facts ! (fromIntegral n - 1)) --(n * fact (n - 1)) `mod` p

factinvs = V.map inv facts

-- npr _ 0 = 1
-- npr n r = (n * npr (n - 1) (r - 1)) `mod` p
npr n r = modp $ fact n * fromIntegral (factinvs ! fromIntegral (n - r))

ncr n r = modp $ npr n r * fromIntegral (factinvs ! fromIntegral r) --npr n r `div'` fact r

f n m 0 = m * ((m - 1) `pow` (n - 1)) 
f n m k = (m * ((m - 1) `pow` (n - k - 1)) * ncr (n - 1) k) `mod` p + f n m (k - 1)


Measured memory_bytes: 47584