akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import numpy as np
import copy

def main():
    n, y = map(int, input().split())
    ret = False
    ans = (-1, -1, -1)
    for i in range(0, n+1):
        for j in range(0, n-i+1):
            k = n - i - j
            if 10000*i + 5000*j + 1000*k == y:
                ans = (i, j, k)

    print("%d %d %d" % ans)
    
    return 0

if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 21148
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class ManyMedians {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] x = new int[n];
            int[] sorted = new int[n];
            for (int i = 0; i < n; i++) {
                int xn = in.nextInt();
                x[i] = xn;
                sorted[i] = xn;
            }

            Arrays.sort(sorted);
            int left = sorted[n / 2 - 1];
            int right = sorted[n / 2];

            for (int i = 0; i < n; i++) {
                if (x[i] <= left) {
                    out.println(right);
                } else {
                    out.println(left);
                }
            }
        }

    }
}



Measured memory_bytes: 65544
M,D=map(int,input().split())

sekiday=0
for i in range(2,M+1):
  for j in range(2,D+1):
    d1=j%10
    d2=j//10
    if i==d1*d2 and min(d1,d2)!=1:
#      print (i,j,d1,d2)
      sekiday+=1

print(sekiday)


Measured memory_bytes: 2940
import heapq

def make_adj_list(v):
    adj_list = [[-1 for i in range(v)] for j in range(v)]
    return adj_list

def prim(adj_list, v, s):
    # スタートを0とする
    min_d = 0
    heap = []
    used = []
    for i in range(v):
        used.append(False)
    used[s] = True
    for i in range(v):
        if adj_list[s][i] != -1:
            heapq.heappush(heap, (adj_list[s][i], i))
        #　スタートからつなぐことができる辺をheapに入れる

    while len(heap) != 0:
        cost, to = heapq.heappop(heap)
        if used[to]:
            continue
        min_d += cost
        used[to] = True
        for i in range(v):
            if adj_list[to][i] != -1:
                heapq.heappush(heap, (adj_list[to][i], i)) 
            #集合に入れた頂点からつなぐことができる辺をheapに入れる

    return min_d

def main():
    v = int(input())
    adj_list = make_adj_list(v)
    for i in range(v):
        adj_list[i] = [int(j) for j in input().split()]
    min_d = prim(adj_list, v, 0)
    print(min_d)

if __name__ == "__main__":
    main()


Measured memory_bytes: 6352
/*partition*/
#include<bits/stdc++.h>
#define N 100000
#define MAX 100000
using namespace std;
vector<int> a(N);

int partition(int p,int r){
	int x,i,temp=0;
	x = a.at(r);
	i = p-1;
	for(int j=p;j<r;j++){
		if(a.at(j) <= x){
			i++;
			temp = a.at(i);
			a.at(i) = a.at(j);
			a.at(j) = temp;
		}
	}
	temp = a.at(i+1);
	a.at(i+1) = a.at(r);
	a.at(r) = temp;
	
	return i+1;
}

int main(){
	int n=0,pos=0;
	cin >> n;
	for(int i=0;i<n;i++) cin >> a.at(i);
	pos = partition(0,n-1);
	for(int i=0;i<n;i++){
		if(i == pos) cout << "[" << a.at(i) << "]" << " ";
		else if(i == n-1) cout << a.at(i) << endl;
		else cout << a.at(i) << " ";
	}
}


Measured memory_bytes: 3120
#include<stdio.h>
int main()
{
	int n,d[50],i,j,x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(d[i]*d[j]){
				x+=d[i]*d[j];
			}
		}
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())

S = {0: 1}
sum_ai = 0
for ai in map(int, input().split()):
    sum_ai += ai
    mod_sum_ai = sum_ai % M
    if mod_sum_ai not in S:
        S[mod_sum_ai] = 1
    else:
        S[mod_sum_ai] += 1

ans = sum(map(lambda x: x * (x - 1) // 2, S.values()))
print(ans)


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

int main()
{
    int a,b,c;
    int Y;
    int N;
    cin>>N>>Y;
    Y=Y/1000;
    for (a=0; 10*a<=Y && a<=N;a++)
    {
        for(b=0; 10*a+5*b<=Y && a+b<=N;b++)
        {
            c=N-a-b;
            if(a+b+c==N && 10*a+5*b+c==Y)
            {
                cout<<a<<" "<<b<<" "<<c<<"\n";
                return 0;
            }
        }
    }

    cout<<-1<<" "<<-1<<" "<<-1<<"\n";
    return 0;
}



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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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 rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;

    int ans = 700 + 100 * count(s.begin(), s.end(), 'o');

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		
		
		if(S.length() == 2) {
			System.out.println(S);
		}else {
			StringBuffer sb = new StringBuffer(S);
			System.out.println(sb.reverse());
			
		}

	}

}


Measured memory_bytes: 23124
#include <stdio.h>

int mdays(int y, int m);
int uruu(int year);

int main(void)
{
	int y1,m1,d1,y2,m2,d2;
	int i,j,days;

	while(scanf("%d%d%d%d%d%d",&y1,&m1,&d1,&y2,&m2,&d2)){
		if(y1<0 || m1<0 || d1<0 || y2<0 || m2<0 || d2<0)
			break;
		for(i=y1,days=0; i<=y2; i++)
			for(j=(i!=y1? 1: m1); j<=(i!=y2? 12: m2); j++)
				days+=mdays(i,j);
		days-=d1;
		days-=(mdays(y2,m2)-d2);
		printf("%d\n",days);
	}

	return 0;
}

int mdays(int y,int m) 
{
	int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	
	if(uruu(y))
		days[1]=29;

	return days[m-1];
}

int uruu(int year)
{
	if(year%400==0)
		return 1;
	else if(year%100==0)
		return 0;
	else if(year%4==0)
		return 1;

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int count = 1;
  for(int i=0;i<N-1;i++)
  {
    if(S[i]!=S[i+1])
    {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 512
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
h = [0] + h

dp = Array.new(n+1, 10**100)
dp[1] = 0

1.upto(n) do |ashiba|
  1.upto(2) do |jump|
    ashiba_index = ashiba + jump
    next if ashiba_index > n
    ashiba_now = h[ashiba]
    ashiba_new = h[ashiba_index]
    jump_cost = (ashiba_now - ashiba_new).abs
    tmp_cost = dp[ashiba] + jump_cost
    dp[ashiba_index] = [dp[ashiba_index], tmp_cost].min
  end
end

p dp.last


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b, c, d, e, f, dp[61][3031];

struct Frac {
	LL p, q;
	Frac() { };
	Frac(LL pp, LL qq) { p = pp; q = qq; }
	bool operator< (const Frac & obj) const { return p * obj.q <  obj.p * q; }
	bool operator> (const Frac & obj) const { return p * obj.q >  obj.p * q; }
	bool operator<=(const Frac & obj) const { return p * obj.q <= obj.p * q; }
	bool operator>=(const Frac & obj) const { return p * obj.q >= obj.p * q; }
	bool operator==(const Frac & obj) const { return p * obj.q == obj.p * q; }
	Frac operator+ (const Frac & obj) const { return Frac(p * obj.q + obj.p * q, q * obj.q); }
	Frac operator- (const Frac & obj) const { return Frac(p * obj.q - obj.p * q, q * obj.q); }
	Frac operator* (const Frac & obj) const { return Frac(p * obj.p, q * obj.q); }
	Frac operator/ (const Frac & obj) const { return Frac(p * obj.q, q * obj.p); }
};

int main() {
	cin >> a >> b >> c >> d >> e >> f;
	
	dp[0][0] = 1;
	incII(i, 0, f / 100 + 1) {
	incII(j, 0, f) {
		if(dp[i][j]) {
			dp[i + a][j] = 1;
			dp[i + b][j] = 1;
			dp[i][j + c] = 1;
			dp[i][j + d] = 1;
		}
	}
	}
	
	Frac ans(0, 1);
	int ai = a, aj = 0;
	incII(i, 0, f / 100 + 1) {
	incII(j, 0, f) {
		Frac v(100 * j, 100 * i + j);
		int total = 100 * i + j;
		if(dp[i][j] && total <= f && j <= i * e) {
			//cout << i << " " << j << " " << dp[i][j] << endl;
			if(ans < v) { ans.p = v.p; ans.q = v.q; ai = i; aj = j; }
		}
	}
	}
	
	cout << 100 * ai + aj << " " << aj << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

int dp[20][20];

int n,ans=0;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);

	for(int i=1,x;i<=n;i++)
	{
		x=i;
		if(x%10==0) continue;
		int s=x%10;
		while(x>=10) x/=10;
		++dp[x][s];
		ans+=dp[s][x]*2;
		if(x==s) --ans;

	}

	printf("%d\n",ans);

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

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

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

    ll answer = 0;
    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                answer += gcd(a, gcd(b, c));
            }
        }
    }
    cout << answer << endl;
}

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

long long int w[100005];
long long int v[100005];
int n,t;
long long int dp[100005][100];

long long int solve(int x,int k){
    if(x == n || k<0 )
        return 0;
    if(dp[k][x] != -1)
        return dp[k][x];
    dp[k][x] = (k-w[x] >= 0) ? ( max(v[x]+solve(x+1,k-w[x]), solve(x+1,k)) ) : ( solve(x+1,k) );
    return dp[k][x];
}

int main(){
    cin >> n >> t;
    for(int i=0;i<100005;i++){
        for(int j=0;j<n;j++)
            dp[i][j] = -1;
    }

    for(int i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    cout << solve(0,t) << endl;
}


Measured memory_bytes: 78336
/* maybemaybemaybeno */
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double lld ;
#define f(i,s,n) for(int i=s;i<(int)n;i++) 
// const int MAXN = 2e5+5 ;
#define pb push_back 
#define X first 
#define Y second 
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define pli pair<ll,int> 
#define pil pair<int,ll> 
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(10) ;
#define is(x) cout<<#x<<" : "<<x<<endl ;
// #define DEBUG
ll po[205] ;
int main()
{
    fio ;
    /* ======================Start of code ================ */
    ll x;cin>>x ;
    f(i,0,204)
    {
        po[i] = 1LL*i*i*i*i*i ;
    }
    f(i,0,204)
    {
        f(j,0,i)
        {
            if(po[i]-po[j]==x)
            {
                return cout<<i<<" "<<j<<"\n",0 ;
            }
            if(po[i]+po[j]==x) return cout<<i<<" "<<-j<<"\n",0 ;
        }
    }
    int z=0 ;
    /* ======================End of code ================== */
}

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

int main() {
  int n,mx=0,mn=1919;
  cin>>n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin>>a;
    mx=max(a,mx);
    mn=min(a,mn);
  }
  cout<<mx-mn<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}

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

using namespace std;

vector<string> revA(vector<string> vs){
	vector<string> res = vs;
	for(int i=0;i<5;i++)
		reverse(res[i].begin(), res[i].end());
	return res;
}

vector<string> revB(vector<string> vs){
	vector<string> res = vs;
	for(int i=0;i<5;i++)
		for(int j=0;j<5;j++)
			res[4-i][j] = vs[i][j];
	return res;
}

vector<string> rot90(vector<string> vs){
	vector<string> res = vs;
	for(int i=0;i<5;i++)
		for(int j=0;j<5;j++){
			res[4-j][i] = vs[i][j];
			if(res[4-j][i]=='-') res[4-j][i] = '|';
			else if(res[4-j][i]=='|') res[4-j][i] = '-';
		}
	return res;
}

vector<string> rot270(vector<string> vs){
	return rot90(rot90(rot90(vs)));
}

int getNum(vector<string> vs){
	string num[5] = {
		".......-....-.........-....-....-....-....-..",
		"...|....|....|..|.|..|....|......|..|.|..|.|.",
		".......-....-....-....-....-.........-....-..",
		"...|..|......|....|....|..|.|....|..|.|....|.",
		"..-....-....-.........-....-.........-....-.."
	};
	for(int i=0;i<10;i++){
		bool ok = true;
		for(int j=0;j<5;j++)
			if(vs[j]!=num[j].substr(5*i,5)) ok = false;
		if(ok) return (i+1)%10;
	}
	return -1;
}

int main(){
	string str[21];
	int x[] = { 0, 7, 7, 7, 7, 14 };
	int y[] = { 7, 0, 7, 14, 21, 7 };
	while(cin >> str[0]){
		if(str[0]=="0") break;
		for(int i=1;i<21;i++) cin >> str[i];
		int num[2][6];
		for(int i=0;i<2;i++){
			for(int j=0;j<6;j++){
				vector<string> vs(5);
				for(int k=0;k<5;k++)
					vs[k] = str[x[j]+k+1].substr(y[j]+29*i+1, 5);
				if(j==5) vs = revB(vs);
				vs = revA(vs);
				if(j==1) vs = rot90(vs);
				if(j==3) vs = rot270(vs);
				num[i][j] = getNum(vs);
			}
		}
		int win = 0;
		for(int i=0;i<6;i++){
			for(int j=0;j<6;j++){
				if(num[0][i] > num[1][j]) win++;
				if(num[0][i] < num[1][j]) win--;
			}
		}
		cout << (win < 0 ? "LOW" : "HIGH") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
main(){
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?')break;
    if(op=='+'){
      printf("%d\n",a+b);
    }
    else if(op=='-'){
      printf("%d\n",a-b);
    }
    else if(op=='*'){
      printf("%d\n",a*b);
    }
    else{
      printf("%d\n",a/b);
    }
  }
  return 0;
}

Measured memory_bytes: 600
import sys
import re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
    N = i_input()
    A = i_list()

    cumulative_sum = list(accumulate(map(lambda x:x%MOD,A)))

    sum = 0

    for i in range(1,N):
        sum = (sum + A[i-1] * (cumulative_sum[N-1]-cumulative_sum[i-1]))%MOD

    print(sum)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 33400
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split()) #高橋君
B1,B2 = map(int,input().split()) #青木君

D1,D2 = (A1-B1)*T1, (A1-B1)*T1+(A2-B2)*T2

if D1*D2 > 0:
    print(0)
elif D2 == 0:
    print("infinity")
else:
    if -D1%D2 == 0:
        print(-D1//D2*2)
    else:
        print(-D1//D2*2+1)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    String t = sc.next();
    int n = 0;
    
    for (int i = 0; i < 3; i ++) {
     if( s.charAt(i) == t.charAt(i)){
       n ++;
     }
    }
    System.out.println(n);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const long long MOD = 1e9+7;
typedef long long ll;

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

	string s; cin >> s;
	ll a = 0, ab = 0, abc = 0, bunki = 1;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A')
			a = (a+bunki) % MOD;
		else if(s[i] == 'B')
			ab = (ab+a) % MOD;
		else if(s[i] == 'C')
			abc = (abc+ab) % MOD;
		else if(s[i] == '?'){
			abc = (3*abc + ab) % MOD;
			ab = (3*ab + a) % MOD;
			a = (3*a + bunki) % MOD;
			bunki = (3*bunki) % MOD;
		}
	}
	cout << abc << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    ll res=0;
    for(ll i=1; i<=n; i++){
        if(i%2==0) continue;
        ll num=0;
        for(ll j=1; j<=i; j++){
            if(i%j==0) num++;
        }
        if(num==8) res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> v[30];

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
 
using ordered_set = tree<
  int,
  null_type,
  greater<int>,
  rb_tree_tag,
  tree_order_statistics_node_update>;

ordered_set bl, br;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int qpar = -1;
	vector<pair<int, int> > p;
	for(int i = 0; i < s.size(); i++){
		v[s[i] -'a'].push_back(i);
	}

	for(int i = 0; i < 26; i++){
		if(v[i].size() % 2 == 1){
			if(qpar != -1){
				cout << "-1\n";
				return 0;
			}
			qpar = v[i][v[i].size() / 2];
		}
		for(int j = 0; j <= (int)v[i].size() - j - 1; j++)
			p.push_back({v[i][j], v[i][v[i].size() - j - 1]});
	}

	sort(p.begin(), p.end());
	reverse(p.begin(), p.end());
	long long ans = 0;
	for(auto &u : p){
		ans += bl.order_of_key(u.second);
		if(u.first != u.second)
			ans += br.order_of_key(u.second);

		bl.insert(u.first);
		if(u.second != u.first)
		br.insert(u.second);
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 11440
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    string s;
    cin >> s;
    if(s == "KIHBR" ||
       s == "KIHBRA" ||
       s == "KIHBAR" ||
       s == "KIHBARA" ||

       s == "KIHABR" ||
       s == "KIHABRA" ||
       s == "KIHABAR" ||
       s == "KIHABARA" ||

       s == "AKIHBR" ||
       s == "AKIHBRA" ||
       s == "AKIHBAR" ||
       s == "AKIHBARA" ||

       s == "AKIHABR" ||
       s == "AKIHABRA" ||
       s == "AKIHABAR" ||
       s == "AKIHABARA")cout << "YES" << endl;
       else cout << "NO" << endl;
       
    
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc043.contest.atcoder.jp/tasks/abc043_b

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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> b.at(i);
    }

    long long sum_nega = 0;
    int cnt = 0;
    vector<long long> posi;
    for (int i = 0; i < n; i++) {
        long long d = a.at(i) - b.at(i);
        if (d > 0) posi.push_back(d);
        else {
            sum_nega += -d;
            cnt++;
        }
    }

    if (sum_nega == 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(posi.rbegin(), posi.rend());

    long long s = 0;
    for (int i = 0; i < (int)posi.size(); i++) {
        s += posi.at(i);
        if (sum_nega <= s) {
            cout << cnt + i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=1e5+5;
int a[maxm];
int d[66];
int n;
void add(int x){
    for(int i=60;i>=0;i--){
        if(x>>i&1){
            if(d[i]){
                x^=d[i];
            }else{
                d[i]=x;
                break;
            }
        }
    }
}
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    int sum=0;
    for(int i=1;i<=n;i++)sum^=a[i];
    for(int j=0;j<=60;j++){
        if(sum>>j&1){//去掉奇数个的
            for(int i=1;i<=n;i++){
                if(a[i]>>j&1)a[i]^=(1LL<<j);
            }
        }
    }
    for(int i=1;i<=n;i++){
        add(a[i]);
    }
    int ans=0;
    for(int i=60;i>=0;i--){
        if((ans^d[i])>ans)ans^=d[i];
    }
    cout<<ans+(ans^sum)<<endl;
    return 0;
}

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

using namespace std;

int main() {
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;

	int N;
	cin >> N;

	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		if (s == "AC") {
			ac++;
		} else if (s == "WA") {
			wa++;
		} else if (s == "TLE") {
			tle++;
		} else if (s == "RE") {
			re++;
		}
	}

	cout << "AC x " << ac << endl
		<< "WA x " << wa << endl
		<< "TLE x " << tle << endl
		<< "RE x " << re << endl;

	return 0;
}


Measured memory_bytes: 3224
/*
 * https://atcoder.jp/contests/abc144/tasks/abc144_b
 */
#include <bits/stdc++.h>
 
using namespace std;

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll long long


/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
// `chmax(a, b)` aがbより小さければ、aをbに上書きする。chminは逆
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; }

const int MOD = 1e9 + 7;
int main() {
    INIT();

    string k;
    cin >> k;
    for(auto&& s : k) {
        if(s == '7') {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstdint>
#include <deque>
#include <algorithm>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::deque<int> b;
  for (size_t i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    if (i % 2 == 0) {
      b.push_back(a);
    } else {
      b.push_front(a);
    }
  }
  if (n % 2 == 1)
    std::reverse(b.begin(), b.end());

  for (size_t i = 0; i < n; ++i)
    printf("%d%c", b[i], i+1<n? ' ':'\n');
}


Measured memory_bytes: 2944
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new Test_100().doIt();
	}
	class Test_100{
		void doIt() {
			String str[] = sc.next().split(",");
			System.out.println(str[0]+" "+str[1]+" "+str[2]);
		}
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
char memo[16434825];
class Data {
	public:
	vii status;
	pii zero;
	int cnt;
	Data(){}
	Data(vii status, pii zero,int cnt) : status(status), zero(zero), cnt(cnt){}
};
int to_s(vector<vi> s) {
	int ret = 0;
	int r = 1;
	rep(i, 8) {
		ret += s[i/4][i%4] * r;
		r *= 8;
	}
	return ret;
}
void solve() {
	memset(memo, -1, sizeof(memo));
	vii ans = {{0,1,2,3},{4,5,6,7}};
	queue<Data> Q;
	Q.push(Data(ans,make_pair(0, 0), 0));
	while(!Q.empty()) {
		auto d = Q.front(); Q.pop();
		int tmp = to_s(d.status);
		if(memo[tmp] != -1) continue;
		memo[tmp] = d.cnt;
		auto z = d.zero;
		rep(i, 4) {
			int nx = dx[i] + z.first, ny = dy[i] + z.second;
			if(nx < 0 || nx >= 4 || ny < 0 || ny >= 2) continue;
			auto p = d.status;
			swap(p[z.second][z.first], p[ny][nx]);
			Q.push(Data(p,make_pair(nx,ny), d.cnt + 1));
		}
	}
}
int main() {
	vii v = vii(2, vi(4, 0));
	solve();
	while(1) {
		cin >> v[0][0];
		if(cin.eof()) break;
		reps(i,1,8) cin >> v[i/4][i%4];
		printf("%d\n", memo[to_s(v)]);
	}
	return 0;
}

Measured memory_bytes: 18140
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	x := getNextInt64(scanner)

	for prime(x) == false {
		x++
	}
	fmt.Println(x)
	writer.Flush()
}

func prime(x int64) bool {
	var i int64
	for i = 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i=0; i<n; i++)
		cin >> a[i];
	ll mx = a[0];
	ll tot = 0;
	for(int i=0; i<n; i++){
		if(a[i] < mx){
			tot += mx-a[i];
		}
		else{
			mx = a[i];
		}
	}
	cout << tot << endl;
	return 0;
}


Measured memory_bytes: 4780
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    ll a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        printf("0\n");
    }
    else {
        printf("%lld\n", MIN(MIN(a*b, b*c), c*a));
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


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


int main(){
  vector<char> v;
  rep(i, 4){
    char c;
    cin >> c;
    v.push_back(c);
  }

  sort(all(v));

  if(v[0] == v[1] && v[2] == v[3] && v[0] != v[2]) cout << "Yes" << endl;
  else                                             cout << "No" << endl;


  return 0;
}


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

class Program
{
    public static void Main(string[] args) {
        string[] s = Console.ReadLine().Split().ToArray();
        int ab = int.Parse(s[0]+s[1]);
        Console.WriteLine(judge(ab) ? "Yes" : "No");
    }
    public static bool judge(int a) {
        for (int i = 1; Math.Pow(i,2) <= a; i ++) {
            if (a/i == i && a%i == 0) return true;
        }
        return false;
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    bool ar[n][m];
    for(int i=0;i<n;i++)for(int j=0;j<m;j++){
        char x;cin>>x;
        ar[i][j]= x == '#';
    }
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<(1<<m);j++){
            int cnt=0;
            for(int x=0;x<n;x++){
                for(int y=0;y<m;y++){
                    if(ar[x][y]&&(i&(1<<x))&&(j&(1<<y)))cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
string moji;
  cin>>moji;
  string mojimoji;
  cin>>mojimoji;
  if(moji.at(0)==mojimoji.at(2) && moji.at(1)==mojimoji.at(1) && moji.at(2)==mojimoji.at(0)){
  cout<<"YES";
  }
  else{
  cout<<"NO";
  }

}

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

int main() {
  int N,K;
  cin >> N >> K;
  
  priority_queue<int, vector<int>, greater<int>> X;
  for(int i=0;i<N;i++){
    int L;
    cin >> L;
    X.push(L);
  }
  
  int Ans=0;
  for(int i=0;i<K;i++){
    Ans += X.top();
    X.pop();
  }
  
  cout << Ans << endl;

}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, M;
VI v;


int solve(){
	repif(i, 1, i*i <= M){
		if(M%i == 0){
			v.pb(i);
			if(M%i != i) v.pb(M/i);
		}
	}
	sort(ALL(v), greater<int>());
	for(int g : v)
		if(N <= M/g) return g;
	return 1;
}


signed main(){
	cin >> N >> M;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

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

#define MAX 200005
#define MOD 998244353

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

ll fac[MAX], inv[MAX], finv[MAX];
void COMinit(ll n)
{
    rep(i,n+1) {
        if (i < 2) {
            fac[i] = finv[i] = inv[i] = 1;
        } else {
            fac[i] = fac[i-1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i-1] * inv[i] % MOD;
        }
    }
}

ll COM(ll n, ll k)
{
    ll res;
    if (n < k || n < 0 || k < 0) return 0;
    res = fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
    return res;
}

ll POW(ll a, ll n)
{
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main(int, char**)
{
    ll n, m, k;
    cin >> n >> m >> k;

    COMinit(n);

    ll ans = 0;
    rep(i,k+1) {
        ll c = COM(n-1, i) % MOD;
        ll p = POW(m-1, n-i-1) % MOD;

        ans += (c * m % MOD) * p % MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8320
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


int dp[1000001]={};
int dp2[1000001]={};
int main(){
	for(int i = 0 ; i < 1000001 ; i++) dp[i] = 1e9;
	for(int i = 0 ; i < 1000001 ; i++) dp2[i] = 1e9;
	dp[0] = dp2[0] = 0;
	
	for(int i = 1 ; i*(i+1)*(i+2) / 6 <= 1000000 ; i++){
		int s = i*(i+1)*(i+2)/6;
		for(int j = 0 ; j+s <= 1000000 ; j++){
			dp2[j+s] = min(dp2[j+s],dp2[j]+1);
		}
	}
	for(int i = 1 ; i*(i+1)*(i+2) / 6 <= 1000000 ; i++){
		int s = i*(i+1)*(i+2)/6;
		if( s%2 == 0 ) continue;
		for(int j = 0 ; j+s <= 1000000 ; j++){
			dp[j+s] = min(dp[j+s],dp[j]+1);
		}
	}
	int a,b;
	while(cin >> a && a){
		cout << dp2[a] << " " << dp[a] << endl;
	}
}

Measured memory_bytes: 8564
import java.util.*;
import java.math.BigInteger;

public class Main{
	static int w,h;
	static int di[]={0,1}, dj[]={1,0};
	static char[][] map;
	static BigInteger max;
	static String[][] dp;

	public static String dfs(int i,int j){
		if(dp[i][j] != null) return dp[i][j];

		String s = Character.toString(map[i][j]);
		List<String> res = new ArrayList<String>();
		for(int k=0;k<2;k++){
			int ni = i + di[k];
			int nj = j + dj[k];

			if(ni>=0 && ni<h && nj>=0 && nj<w && Character.isDigit(map[ni][nj])) res.add(dfs(ni,nj));
		}

		if(res.isEmpty()) return (dp[i][j]=s);
		else if(res.size() == 1) return (dp[i][j]=s+res.get(0));
		else{
			if(res.get(0).length() > res.get(1).length()) return (dp[i][j]=s+res.get(0));
			else if(res.get(0).length() < res.get(1).length()) return (dp[i][j]=s+res.get(1));
			else{
				if(new BigInteger(res.get(0)).compareTo(new BigInteger(res.get(1)))>0) return (dp[i][j]=s+res.get(0));
				else return (dp[i][j]=s+res.get(1));
			}
		}
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		BigInteger res;

		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w==0 && h==0) break;
			map = new char[h][w];
			dp = new String[h][w];
			max = BigInteger.ZERO;

			for(int i=0;i<h;i++) map[i] = sc.next().toCharArray();

			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(Character.isDigit(map[i][j])){
						res = new BigInteger(dfs(i,j));
						if(max.compareTo(res) < 0) max = res;
					}
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 14000
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A + 1):
    for b in range(B + 1):
        if 0 <= (X - 500 * a - 100 * b) // 50 <= C:
            ans += 1
print(ans)


Measured memory_bytes: 2940
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000005;

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

vector<int> graph[NMAX];
vector<int> dp(NMAX);
int in_degree[NMAX];
bool visited[NMAX];

int ans = 0;

void dfs(int node)
{
    visited[node] = true;
    for(auto &child : graph[node])
    {
        dp[child] = max(dp[child],dp[node] + 1);
        --in_degree[child];
        if(in_degree[child] == 0)
        {
            dfs(child);
        }
    }
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;

    for(int i= 0; i < m; ++i)
    {
        int x,y;
        cin >> x >> y;
        x--;y--;
        graph[x].push_back(y);
        ++in_degree[y];
    }

    for(int i = 0; i< n; ++i)
    {
        if(!visited[i] && in_degree[i] == 0)
            dfs(i);
    }

    for(int i  =0; i< n; ++i)
    {
        ans = max(ans, dp[i]);
    }

    cout << ans<< '\n';
    return 0;
}

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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll r,g,b;
    cin>>r>>g>>b;
    ll k;
    cin>>k;
    int flag=0;
    for(int i=0;i<=7;i++)
    {
      for(int j=0;j<=7;j++)
      {
        for(int a=0;a<=7;a++)
        {
          if(a+i+j <= k)
          {
            int tempr=power(2,i)*r;
            int tempg=power(2,j)*g;
            int tempb=power(2,a)*b;
            if(tempb>tempg && tempg>tempr)
            {
              flag=1;
            }
          }
        }
      }
    }
    if(flag) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3608
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
      	for (int i = 0; i<n; i++){
          a[i] = sc.nextInt();
        }
		int min = 10000;
      	int f = 0;
      	int l = 0;
      	int i = 0;
		for(int j = 0; j < n; j++){
          for (int k = 0; k<j; k++){
            f += a[k];
          }
          for (int m = j; m<n; m++){
            l += a[m];
          }
          if(min > Math.abs(f-l)){
            min = Math.abs(f-l);
          }
          f = 0;
          l = 0;
        }
		System.out.println(min);
	}
}

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

using namespace std;

int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        if(h==0&&w==0){
            break;
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout << "#";
            }
            cout << endl;
        }
        
        cout << endl;
    }
    return 0;
}


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

int n;
double a[100];

void solve(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    double sum=0;
    for(int i=0; i<n; i++){
        sum+=1.0/a[i];
    }
    printf("%.8f\n", 1.0/sum);
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
#include<stdio.h>

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t




int main(){
    ll N; string S; cin >> N >> S;
    ll ans = 0;

    for(int num = 0; num < N; num++){
        string T = S.substr(num);
        //cout << T << endl;
        vector<ll> A(N);
        A[0] = T.size();
        int i = 1, j = 0;
        while (i < T.size()) {
            while (i+j < T.size() && T[j] == T[i+j]) ++j;
            A[i] = j;
            if (j == 0) { ++i; continue;}
            int k = 1;
            while (i+k < T.size() && k+A[k] < j) A[i+k] = A[k], ++k;
            i += k; j -= k;
        }
        for(int i1 = 1; i1 < T.size(); i1++) {
            if(A[i1] <= i1) ans = max(ans, A[i1]);
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5005;
const int mod = 1000000007;
const int mod1 = 1000000009;
const ll p = 401;
const ll p1 = 101;

int n;
ll hsh[N][N],hsh1[N][N];
string s;

bool ok(int l){
    map <ll,bool> bio,bio1;
    for(int i = l; i+l <= n; i++){
        ll hespr = hsh[i-l+1][i],hespr1 = hsh1[i-l+1][i];
        bio[hespr] = 1;
        bio1[hespr1] = 1;
        ll hespo = hsh[i+1][i+l],hespo1 = hsh1[i+1][i+l];
        if(bio.count(hespo) && bio1.count(hespo1)){
            return 1;
        }
    }
    return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    cin >> s;
    for(int i = 1; i <= n; i++){
        hsh[i][i] = hsh1[i][i] = s[i-1]-'a'+1;
        for(int j = i+1; j <= n; j++){
            hsh[i][j] = ((hsh[i][j-1]*p)%mod+s[j-1]-'a'+1)%mod;
            hsh1[i][j] = ((hsh1[i][j-1]*p1)%mod1+s[j-1]-'a'+1)%mod1;
        }
    }
    int l = 1,r = n/2,ans = 0;
    while(l <= r){
        int mid = l+(r-l)/2;
        if(ok(mid)){
            ans = mid;
            l = mid+1;
        }
        else{
            r = mid-1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 392064