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

constexpr ll INF = 1ll<<60;
constexpr ll MAX = 1000001;
ll dpA[MAX], dpB[MAX];

int main(int argc, char **argv)
{
	vector<ll> A, B;

	for (ll i = 1; i*(i+1)*(i+2)<=6000000; ++i)
	{
		A.push_back(i*(i+1)*(i+2)/6);
		if (A.back() & 1) B.push_back(A.back());
	}

	// DEBUG
	// for (ll i = 0; i < 10; ++i)
	// 	std::cout << A[i] << " ";
	// std::cout << std::endl;
	// for (ll i = 0; i < 10; ++i)
	// 	std::cout << B[i] << " ";
	// std::cout << std::endl;	

	fill(dpA, dpA+MAX, INF);
	dpA[0] = 0;
	for (ll i = 0; i < MAX; ++i)
	{
		for (ll j = 0; j < (ll)A.size(); ++j)
		{
			if (i+A[j]<MAX) dpA[i+A[j]] = min(dpA[i+A[j]], dpA[i]+1);
			else break;
		}
	}


	fill(dpB, dpB+MAX, INF);
	dpB[0] = 0;
	for (ll i = 0; i < MAX; ++i)
	{
		for (ll j = 0; j < (ll)B.size(); ++j)
		{
			if (i+B[j]<MAX) dpB[i+B[j]] = min(dpB[i+B[j]], dpB[i]+1);
			else break;
		}
	}

	ll n;
	while (cin >> n, n)
	{
		std::cout << dpA[n] << " " << dpB[n] << std::endl;
	}
	
}


Measured memory_bytes: 18772
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		List<Integer> groupA = Arrays.asList(new Integer[]{1,3,5,7,8,10,12});
		List<Integer> groupB = Arrays.asList(new Integer[]{4,6,9,11});
		List<Integer> groupC = Arrays.asList(new Integer[]{2});

		Scanner sc = new Scanner(System.in);
		final int firstNum = sc.nextInt();
		final int secondNum = sc.nextInt();

		if( 
			isContainGroup(groupA, firstNum, secondNum)
			|| isContainGroup(groupB, firstNum, secondNum)
			|| isContainGroup(groupC, firstNum, secondNum)
		){
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}
	}
	
	private static boolean isContainGroup(List group, int num1, int num2 ){
		return group.contains(num1) && group.contains(num2) ;
	}

}

Measured memory_bytes: 20948
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<P> r(n), b(n);
	rep(i, n) {
		cin >> r[i].first >> r[i].second;
	}
	rep(i, n) {
		cin >> b[i].first >> b[i].second;
	}
	sort(ALL(b));
	int ans = 0;
	rep(i, n) {
		int x = b[i].first; int y = b[i].second;
		int tmp1 = -1, tmp2 = -1;
		rep(j, r.size()) {
			if (r[j].first < x&&r[j].second < y) {
				if (r[j].second > tmp1) {
					tmp1 = r[j].second; tmp2 = j;
				}
			}
		}
		if (tmp2 >= 0) {
			ans++;
			r.erase(r.begin() + tmp2);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
x=100*a/8
y=100/8*(a+1)
z=10*b
w=10*(b+1)
import math
if max(math.ceil(z),math.ceil(x))<min(y,w) :
    print(math.ceil(max(z,x)))
else:
    print(-1)    

Measured memory_bytes: 3064
abcd = list(map(int, input().split()))

a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]

product = a * c

if (product < a * d):
    product = a * d
if (product < b * c):
    product = b * c
if (product < b * d):
    product = b * d

print(product)

Measured memory_bytes: 9184
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    char buf[256];
    fgets(buf, 256, stdin);
    string s(buf);

    auto toupper=[](char c)->char {
        if (c >= 'a' && c <= 'z')
            c &= ~0x20;

        return c;
    };

    transform(s.begin(), s.end(), s.begin(), toupper);

    printf("%s", s.c_str());
    return 0;
}

Measured memory_bytes: 2820
#include <iostream>

using namespace std;

int main(){
	int n;
	while(cin >> n,n){
	int ans = 0;
	int k;
	for(int i=0;i<n*(n-1)/2;i++){
		cin >> k;
		ans += k;
	}
	cout <<  ans/(n-1) << endl;
}
return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int calc(string &s, char x, char y)
{
	int cnt = 0;
	bool mode = 0;
	for(int i = 0; i < s.length(); i++)
	{
		if(s[i]==x&&mode==0)
		{
			cnt++;
			mode^=1;
		}
		else if(s[i]==y&&mode==1)
		{
			cnt++;
			mode^=1;
		}
	}
	return int(s.length())-cnt;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	int n = s.length();
	int x = n;
	if(s[0] == s[n-1])
	{
		for(int i = 0; i < 26; i++)
		{
			x = min(x,calc(s,s[0],i+'a'));
		}
	}
	x = min(x, calc(s,s[0],s[n-1]));
	if(x&1) cout<<"First\n";
	else cout<<"Second\n";
}


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

namespace PrintTestCases
{
    class Class1
    {
        public static void Main()
        {
            int n = 1;
            int i = 0;
            while(n != 0)
            {
                n = int.Parse(Console.ReadLine());
                if (n != 0)
                {
                    i++;
                    Console.WriteLine("Case {0}: {1}", i, n);
                }
            }
        }
    }
}



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

void pushStack(int *, int, int *);
void calc(int *, int *, char*);

main(){
  int stack[100];
  int top=0;
  char tmp[1000000];

  while(scanf("%s", tmp) != EOF){
    if(tmp[0] >= '0' && tmp[0] <= '9') pushStack(stack, atoi(tmp), &top);
    else calc(stack, &top, tmp);
  }

  printf("%d\n", stack[1]);

  return 0;
}

void pushStack(int *stack, int tmp, int *top){
  (*top)++;
  stack[*top] = tmp;

  return;
}

void calc(int *stack, int *top, char *enzanshi){
  //オペランンドを２つpop&計算.計算結果をpush
  int res;

  switch(enzanshi[0]){
  case '+':
    res = stack[*top-1] + stack[*top];
    break;
  case '-':
    res = stack[*top-1] - stack[*top];
    break;
  case '*':
    res = stack[*top-1] * stack[*top];
    break;
  }

  *top = *top - 2; //pop2回分
  pushStack(stack, res, top);

  return;
}

Measured memory_bytes: 556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using VVI = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll mini = 1'000'000'000'000'000;
    for (int tmp = 0; tmp < (1 << n); tmp++)
    {
        bitset<15> bs(tmp);
        if (bs.count() < k || !bs.test(0))
        {
            continue;
        }
        ll top = a[0];
        ll cnt = 0;
        for (int i = 1; i < n; i++)
        {
            if (bs.test(i) && a[i] <= top)
            {
                cnt += (top - a[i] + 1);
                ++top;
            }
            else
            {
                top = max(a[i], top);
            }
        }
        mini = min(mini, cnt);
    }
    cout << mini << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll b,h,c=0,k,i,j,n;
    cin>>h>>k;
    int a[h];
    for(i=0;i<h;i++)
    {
        cin>>a[i];
    }
    sort(a,a+h,greater<int>());
   // reverse(a,a+h);
    for(i=k;i<h;i++)c+=a[i];
    cout<<c<<endl;


    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
ll x,a;
cin>>x>>a;
if(x<a)
    cout<<0<<endl;
else
    cout<<10<<endl;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    string s;
    cin >> s;
    ll n = s.size();

    ll ret = 0;
    REP(i, n) {
        if(i%2==0 && s[i]=='0') ret++;
        else if(i%2 && s[i]=='1') ret++;
    }
    ll ans = ret;

    ret = 0;
    REP(i, n) {
        if(i%2==0 && s[i]=='1') ret++;
        else if(i%2 && s[i]=='0') ret++;
    }
    chmin(ans, ret);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fo(i, a, b) for (int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (int i = (a); i >= (b); --i)
#define edge(i, u) for (int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define mod 1000000007
#define ll long long
#define N 205
#define pb push_back
int n, m, a[N], cnt, x, y;
int main ()
{
    scanf("%d %d", &n, &m);
    fo (i, 1, m)
        scanf("%d", &a[i]);
    if (m == 1)
    {
        printf("%d\n", a[1]);
        if (n > 1)
            printf("2\n%d %d", n - 1, 1);
        else
            printf("1\n1");
    }
    else
    {
        fo (i, 1, m)
            if (a[i] & 1) ++cnt;
        if (cnt >= 3)
        {
            printf("Impossible");
        }
        else
        {
            fo (i, 1, m)
            {
                if (a[i] & 1)
                {
                    if (!x)
                        x = i;
                    else
                        y = i;
                }
            }
            if (x)
                std::swap(a[1], a[x]);
            if (y)
                std::swap(a[m], a[y]);
            fo (i, 1, m) printf("%d ", a[i]);
            printf("\n");
            a[1]--; a[m]++;
            int l = 1;
            if (!a[l]) ++l;
            printf("%d\n", m - l + 1);
            fo (i, l, m)
                printf("%d ", a[i]);
        }
    }
}

Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		int N = new java.util.Scanner(System.in).nextInt();
		int temp = 0;
		boolean possible = false;
		final int MAX_A = N / 4;
		final int MAX_B = N / 7;

		for (int i = 0; i <= MAX_A; ++i) {
			for (int j = 0; j <= MAX_B; ++j) {
				temp = 4 * i + 7 * j;
				if (temp == N) {
					possible = true;
					break;
				}
			}
			if (possible) {
				break;
			}
		}
		if(possible) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
const int MAX_N = 100000;
vector<int> edge [MAX_N];
int par [MAX_N],depth [MAX_N],sz [MAX_N];

void dfs(int curr,int prev = -1)
{
	if(prev == -1){
		depth [curr] = 0;
	}
	else{
		depth [curr] = depth [prev] + 1;
	}
	sz [curr] = 1;
	for(const auto& it : edge [curr]) if(it != prev){
		dfs(it,curr);
		par [it] = curr;
		sz [curr] += sz [it];
	}
}

int main()
{
	scanf("%d",&N);
	FOR(i,0,N - 1){
		int u,v;
		scanf("%d%d",&u,&v);
		edge [u - 1].push_back(v - 1);
		edge [v - 1].push_back(u - 1);
	}

	dfs(0);
	int node = N - 1;
	FOR(i,0,(depth [N - 1] - 1) / 2){
		node = par [node];
	}

	if(N - sz [node] > sz [node]){
		puts("Fennec");
	}
	else{
		puts("Snuke");
	}

	return 0;
}


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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }

int modi(int m,int a){
    return m%a;
}

int func(vector<int> v,int lcm){
    int n = v.size();
    int sum = 0;
    for(int i=0;i<n;i++){
        sum += modi(lcm,v[i]);
    }
    return sum;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        ans += a[i];
    }
    cout << ans - n << endl;

}

Measured memory_bytes: 256
inv=lambda x:pow(x, m - 2, m)

N = int(input())
A = [int(x) for x in input().split()]
f = [1, 1]
m = 10**9+7

for i in range(2, N + 1):
  f+=[f[-1] * i % m]
s = [0]
for i in range(1, N + 1):
  s+=[(s[-1]+f[N]*inv(i))%m]
a = 0
for i in range(N):
  a+=(s[i+1]+s[N-i]-f[N])*A[i]
  a%=m
print(a)


Measured memory_bytes: 15080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Main.run();
	}

	@SuppressWarnings("resource")
	private static void run() {
		Scanner scan = new Scanner(System.in);
		int c;
		while ((c = scan.nextInt()) != 0) {
			int x = 0, xTotal = 0, y = 0, yTotal = 0;
			for (int i = 0; i < c; i++) {
				x = scan.nextInt();
				y = scan.nextInt();
				if (x == y) {
					xTotal += x;
					yTotal += y;
					continue;
				}
				if (x > y)
					xTotal += (x + y);
				else
					yTotal += (x + y);
			}
			System.out.println(xTotal + " " + yTotal);
		}
		System.exit(0);

	}
}

Measured memory_bytes: 58372
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(int i=p;i<n;i++)
#define tam 2234567
#define offset 1000000000
using namespace std;
typedef int ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    vector<iii> v;
    int num1,num2;
    forr(i,0,n)
    {
        cin>>num1>>num2;
        v.pb(iii(num1+num2,ii(num1,num2)));
    }
    sort(v.begin(),v.end());
    map<ll,ll> dp;
    dp[0]=0;
    ll hi,pi,za,mival;
    forr(i,0,n)
    {
        hi=v[i].se.fi;
        pi=v[i].se.se;
        //cout<<hi+pi<<" "<<hi<<" casi "<<pi<<endl;
        map<ll,ll>::iterator ite2=dp.upper_bound(hi);
        map<ll,ll> ::iterator auxite;
        do
        {
            ite2--;
            //cout<<ite2->first+pi<<" "<<dp[ite2->first+pi]<<" "<<ite2->second+1<<endl;
            map<ll,ll> ::iterator ite=dp.upper_bound(ite2->first+pi);
            auxite=ite;auxite--;
            if (ite!=dp.end())
            {
                if (ite->second<=ite2->second+1)
                    dp.erase(ite);
            }
            ite=auxite;
            if (ite->second<ite2->second+1)
            dp[ite2->first+pi]=ite2->second+1;
        }while(ite2!=dp.begin());
    }
    //cout<<dp.size()<<endl;
    int maxx=0;
    map<ll,ll> ::iterator ite=dp.end();ite--;
    cout<<ite->se<<"\n";
    
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

bool ok(int i,string l,string r,string a){
	replace(l.begin(),l.end(),'X',(char)('0'+i));
	replace(r.begin(),r.end(),'X',(char)('0'+i));
	replace(a.begin(),a.end(),'X',(char)('0'+i));
	if(i == 0){
		if(l.length() != 1 && l[0] == '0') return false;
		if(r.length() != 1 && r[0] == '0') return false;
		if(a.length() != 1 && a[0] == '0') return false;
	}
	string out;
	bool up = false;
	for (int i = 0; i < (int)max(l.length(),r.length()); i++){
		int add = up;
		add += ((int)l.length() > i) ? (l[l.length() - i - 1] - '0') : 0;
		add += ((int)r.length() > i) ? (r[r.length() - i - 1] - '0') : 0;
		if(add >= 10){
			add -= 10;
			up = true;
		} else {
			up = false;
		}
		out.insert(out.begin(),((char)add + '0'));
	}
	if(up)
		out.insert(out.begin(),'1');

	return out == a;
}

bool solve()
{
	string s;
	if(!(cin>>s)) return false;
	replace(s.begin(),s.end(),'+',' ');
	replace(s.begin(),s.end(),'=',' ');
	istringstream iss(s);
	string l,r,a; iss>>l>>r>>a;
	for (int i = 0; i <= 9; i++){
		if(ok(i,l,r,a)){
			printf("%d\n",i);
			return true;
		}
	}
	puts("NA");
	return true;
}

int main(){
	while(true){
		if(!solve()) break;
	}

	return 0;
}

Measured memory_bytes: 0
x, n = map(int, input().split())
if n != 0:
  p = list(map(int, input().split()))
  pp = set(p)
  ans = 200
  cnt = 0
  for i in range(102):
    if i in pp:
      continue
    if ans > abs(x-i):
      ans = abs(x-i)
      cnt = i
  print(cnt)
else:
  print(x)
  

Measured memory_bytes: 9064
#include<iostream>
using namespace std;
int main()
{
	int n;
	int k, p, ans;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> k >> p;
		ans = k%p;
		if (ans == 0){
			cout << p << endl;;
		}
		else{
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, k;
int main(){
    cin >> n >> k;
    ll ans = 0;
    if(k == 0){
        cout << ll(n) * n << '\n';
        return 0;
    }
    for(int b = k + 1; b <= n; b++){
        ans += ll(b-k) * (n/b) + max(0, (n%b)-k+1);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>

int cont=0;
int check(long long int num)
{
    int i,j,index=0;
    for(j=2;j*j<=num;j++)
    {
                         if(num%j == 0)
                         index = 1;
    }
    if(index == 0)
    cont = cont+1;
    return 0;
}

int main()
{
    int size,i;
    scanf("%d",&size);
    long long int arr[size];
    for(i=0;i<size;i++)
    {
                       scanf("%lld",&arr[i]);
                       check(arr[i]);
    }
    printf("%d\n",cont);
    return 0;
}
                   

Measured memory_bytes: 672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

template<class Key>
using ordered_set = __gnu_pbds::tree<Key, __gnu_pbds::null_type, less<Key>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

// multisetではないので注意．適当にindex貼ったりする必要がある．あと定数倍重い．
// find_by_order(idx)
// order_of_key(key)  ... lower_bound

int solve(){
    int n;
    string s;
    cin >>n >>s;
    int S = s.size();

    int ans = 0;
    rep(i,S+2){
        int x = n-1;
        int T = S;

        int g = 0, b = 0;
        rep(j,S){
            if(s[j]=='G') ++g;
            else ++b;
        }

        ordered_set<int> alive;
        rep(j,S) alive.insert(j);

        int p = 0;
        rep(j,S){
            if(g==0 || b==0) break;

            int death = (p+x+(i==j))%T;

            auto itr = alive.find_by_order(death);
            if(s[*itr]=='G') --g;
            else --b;

            // dbg(*itr);
            alive.erase(alive.find(*itr));

            p = death;
            if(death == T-1) p = 0;
            --T;
        }

        ans = max(ans,b);
    }
    return ans;
}

int main(){
    int T;
    cin >>T;
    rep(i,T) cout << solve() << "\n";
    return 0;
}



Measured memory_bytes: 3188
*a, = map(int, list(input())[::-1])
n = len(a)

b = [[0]*k for k in range(n+1)]
for k in range(n+1):
    for i in range(k):
        b[k][i] = sum([10**j * a[i+j] for j in range(k-i)])
# b[k][i]は整数"a[k-1]a[k-2] ... a[i]"

dp = [0]*n
for k in range(n):
    dp[k] = sum([b[k+1][0]] + [b[k+1][i+1]*2**i + dp[i] for i in range(k)])

print(dp[n-1])


Measured memory_bytes: 38384
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;	

const int nmax = 100;
int scmax , scmin;

int cal(int score[], int count)
{
   long sum = 0; 
   bool cmax = false, cmin = false;
   for (int i = 0; i < count; i++) 
   {	
    if ((score[i] == scmin) && (cmin == false))
       {cmin = true; 
        continue;}
    if ((score[i] == scmax) && (cmax == false)) 
       {cmax = true; 
	continue;}
    sum += score[i];
   }
   return(sum/(count-2));	
}

int main(void) 
{
do{
  int n;
  cin >> n;
  if ( n == 0 ) break;
  int score[nmax];
  scmax = 0; 
  scmin = 1000;
  for (int i = 0; i < n; i++)
     {
	cin >> score[i];	
	if (scmax < score[i]) scmax = score[i];
	if (scmin > score[i]) scmin = score[i];
     }
  cout << cal(score,n) << endl; 
} while(1);
}

Measured memory_bytes: 1160
// ------------------------------------
// Date:2018/ 2/27
// Problem:ABC 079 TrainTicket c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

using ll = long long;

#define MOD 1000000007

int main()
{
  int A, B, C, D;
  string inputStr;
  cin >> inputStr;
  A = inputStr[0] - '0';
  B = inputStr[1] - '0';
  C = inputStr[2] - '0';
  D = inputStr[3] - '0';
  
  int sum1,sum2;
  sum1 = sum2 = 0;
  REP(op1, 2) {
    if (op1 == 0) sum1 = A + B;
    else          sum1 = A - B;
      REP(op2, 2) {
        if (op2 == 0) sum2 = sum1 + C;
        else          sum2 = sum1 - C;
      
        // op3 == '+'
        if (sum2  == 7 - D) {
          cout << A << (op1==0?"+":"-") << B << (op2==0?"+":"-") << C << "+" << D << "=7" << endl;
          return 0;
        }
        // op3 == '-'
        if (sum2  == 7 + D) {
          cout << A << (op1==0?"+":"-") << B << (op2==0?"+":"-") << C << "-" << D << "=7" << endl;
          return 0;
        }
      }
  }
  return 0;
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()

	if (a - b) < 0 {
		fmt.Println("a < b")
	} else if (a - b) == 0 {
		fmt.Println("a == b")
	} else {
		fmt.Println("a > b")
	}
}



Measured memory_bytes: 1088
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    string s;
    cin >> s;

    int s_len = s.length();

    bool ans = true;
    int count = 0;

    if(s[0] != 'A'){
        ans = false;

    }else{
        for(int i = 1;i < s_len;i++){
            
            if(isupper(s[i])){

                if(i == 1 || i == s_len-1 || s[i] != 'C'){
                    ans = false;
                }
                count++;
            }

        }
    }
    if(count != 1){
        ans = false;
    }

    if(ans){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    } 

    return 0;
}

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

int main(){
	string S;
	cin >> S;
	reverse(S.begin(), S.end());
	int N = S.length();
	int i = 0;
	bool JD = true;
	
	while(i < N){
		if(S.substr(i, 5) == "maerd" || S.substr(i, 5) == "esare")i += 5;
		else if(S.substr(i, 6) == "resare")i += 6;
		else if(S.substr(i, 7) == "remaerd")i += 7;
		else{
			JD = false;
			break;
		}
	}
	
	cout << ((JD) ? "YES" : "NO") << '\n';
}

Measured memory_bytes: 512
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = list(map(int, sys.stdin.readline().split()))
    B = 0
    for l in L:
        B +=  1 / l

    print(1 / B)


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

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 main(){
    ll n;
    cin >> n;
    vector<ll> c(3);
    ll ans = 0;
    ll tmp = 0;

    for(ll i = 1; i <= n ; i++){
        for(ll j = i; j <= n; j++){
            for(ll k = j; k <= n ; k++){
                c[0] = i;
                c[1] = j;
                c[2] = k;

                do {
                    tmp = gcd(c[0],c[1]);
                    ans += gcd(tmp,c[2]);
                } while (next_permutation(c.begin(), c.end()));
                
            }
        }
    }

    cout << ans << endl;

    return 0;
}  


Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string A,B;
  cin>>A>>B;
  string ans="EQUAL";
  if(A.size()>B.size())ans="GREATER";
  else if(A.size()<B.size())ans="LESS";
  else{
    REP(i,A.size()){
      if(A[i]>B[i]){
        ans="GREATER";
        break;
      }
      else if(A[i]<B[i]){
        ans="LESS";
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int n, m, k;
vector<VI> ps;
VI ls;

int calc(VI pp) {
	int sum = 0;
	rep (i, ls.size()) {
		bool flag = false;
		rep (j, pp.size()) {
			if (ls[i] == pp[j]) {
				flag = true;
				break;
			}
		}
		sum += flag;
	}
	return sum;
}

int solve() {
	VI cs(ps.size() + 1);
	REP (i, 1, ps.size()) {
		cs[i] = calc(ps[i]);
	}
	int ans = -1;
	REP (i, 1, cs.size()) {
		if (cs[i] == k) {
			if (ans != -1) return -1;
			else ans = i;
		}
	}
	return ans;
}

int main(void) {
	while (1) {
		ps.clear();
		ls.clear();
		cin >> n;
		if (n == 0) break;
		ps.resize(n + 1);
		REP (i, 1, n + 1) {
			int m;
			cin >> m;
			rep (j, m) {
				int p;
				cin >> p;
				ps[i].PB(p);
			}
		}
		cin >> k;
		rep (i, k) {
			int l;
			cin >> l;
			ls.PB(l);
		}
		cout << solve() << endl;
	}
    return 0;
}

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

using namespace std;
typedef long long ll;
const int N=1e4+10;

int mp[N];

int a[15][15];
int c[15];
int n,m,x;
int ans;
int us[15];
void dfs(int cou,int A[]){
    if(cou==n+1){
        int sum[15];
        memset(sum,0,sizeof(sum));
        int ans1=0;
        //for(int i=1;i<=n;i++) cout<<A[i]<<" ";
        //cout<<endl;
        for(int i=1;i<=n;i++){
            if(A[i]==1){
                    ans1+=c[i];
                for(int j=1;j<=m;j++) sum[j]+=a[i][j];
            }
        }
        int flag=1;
        for(int i=1;i<=m;i++){
            if(sum[i]<x){
                flag=0;
                break;
            }
        }
        if(flag) ans=min(ans,ans1);
        return ;
    }
    A[cou]=1;
    dfs(cou+1,A);
    A[cou]=0;
    dfs(cou+1,A);
}
int main()
{
    memset(us,0,sizeof(us));
    ans=1e9;
    cin>>n>>m>>x;
    for(int i=1;i<=n;i++){
            cin>>c[i];
        for(int j=1;j<=m;j++) cin>>a[i][j];
    }
    dfs(1,us);
    if(ans==1e9) cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1000005],b[1000005],c[1000005],d[1000005];
int main()
{
    ll i,ans1=1,ans2,w,t=1,flag=0,j=1,n,k,l,r;
    scanf("%lld %lld",&n,&k);
    for(i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
        b[i]=0;
    }
    while(k--)
    {
        flag=1;
        for(i=1; i<=n; i++)
        {
            c[i]=a[i];
            d[i]=0;
        }
        for(i=1; i<=n; i++)
        {

            l=max(t,i-a[i]); r=min(n,i+a[i]);
           d[l]+=1;
           d[r+1]-=1;
        }
         for(i=1; i<=n; i++)
        {
            b[i]=b[i-1]+d[i];
        }
        for(i=1; i<=n; i++)
        {
            a[i]=b[i];
            b[i]=0;
        }
       /* for(i=1; i<=n; i++)
        {
            printf("%lld ",a[i]);
        }*/
        for(i=1; i<=n; i++)
        {
            if(c[i]!=a[i])
            {
                flag=0;
                break;
            }

        }
        //printf("k=%lld\n",ans1++);
        if(flag==1)
            break;

    }

    for(i=1; i<=n; i++)
    {
        printf("%lld ",a[i]);

    }
    printf("\n");

}


Measured memory_bytes: 10084
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

//////////////////////////

int main() {
    
    ll N;
    cin >> N;
    vector<ll> A(N + 1);
    repn(i, N) cin >> A[i];

    vector<vector<ll>> dp(N + 1, vector<ll>(2, 0));

    dp[1][1] = A[1];
    for(ll i=2; i<=N; i++) {
        if (i % 2 == 0) {
            dp[i][0] = max(dp[i - 1][0], dp[i - 2][0] + A[i]);
            dp[i][1] = max(dp[i - 1][1], dp[i - 2][1] + A[i]);
        }
        if (i % 2 == 1) {
            dp[i][0] = max(dp[i - 1][1], dp[i - 2][0] + A[i]);
            dp[i][1] = dp[i - 2][1] + A[i];
        }
    }

    if (N % 2 == 1) { cout << dp[N][0]; }
    else { cout << dp[N][1]; }

    system("PAUSE");
}

Measured memory_bytes: 16004
a = int(input())
l = [6**i for i in range(10) if 6**i < 10**5]
l += [9**i for i in range(10) if 9**i < 10**5]
l = sorted(list(set(l)))

ans = [10 ** 9 for i in range(a+1)]
ans[0] = 0

for i in range(a):
  for j in l:
#    print(j)
    if i + j <= a:
      ans[i+j] = min(ans[i] + 1, ans[i+j])

print(ans[a])

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

const int mod = 998244353;

long long binpow(long long b, int e) {
  long long res = 1;
  while (e) {
    if (e & 1) res *= b, res %= mod;
    e >>= 1;
    b *= b;
    b %= mod;
  }
  return res;
}

long long inv(long long x) {
  return binpow(x, mod - 2);
}

const int N = 20;
int x[N][N], y[N][N], a[N];

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < a[i]; j++) cin >> x[i][j] >> y[i][j], --x[i][j];
  }
  int ans = 0;
  for (int mask = 0; mask < 1 << n; mask++) {
    int ok = 1;
    for (int i = 0; i < n; i++) {
      if (mask >> i & 1) {
        for (int j = 0; j < a[i]; j++) {
          if ((mask >> x[i][j] & 1) != y[i][j]) {
            ok = 0;
            break;
          }
        }
      }
      if (!ok) break;
    }
    if (ok) ans = max(ans, __builtin_popcount(mask));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define dl 1000000007

  int main(){
   int n,m;
      cin>>n;
      vector<double> d(n);
      for(int i=0;i<n;i++)cin>>d[i];
      m=n/2+2;
      vector<vector<double>> a(n+1,vector<double>(n+1,0));
      a[1][0]=1-d[0];
      a[1][1]=d[0];
      for(int i=2;i<=n;i++){
          a[i][0]=a[i-1][0]*(1-d[i-1]);
          //cout<<a[i][0]<<" ";
          for(int j=1;j<=n;j++){
              a[i][j]=a[i-1][j]*(1-d[i-1])+a[i-1][j-1]*d[i-1];
             // cout<<a[i][j]<<" ";
          }
      }
      double ans=0;
      for(int j=n/2+1;j<=n;j++){
          ans=ans+a[n][j];
      }
      cout.precision(10);
      cout<<ans<<endl;
     
  }

Measured memory_bytes: 70784
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func main() {
	H, Count := readInt(), readInt()
	loop(0, Count, func(i int) {
		H -= readInt()

		if H <= 0 {
			fmt.Println("Yes")
			os.Exit(0)
		}
	})
	fmt.Println("No")
}

func loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func readInt() int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}

Measured memory_bytes: 1152
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=LONG_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i,idx1,idx2,idx3,idx4;
ll w,g[101],v[101],a[101],b[101],c[101],d[101],tw,tmp1,tmp2,tmp3,tmp4,ans,mn=llinf;
map<ll,int>mp;
int main()
{
	//freopen("sol.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>w;
	for(i=1;i<=n;i++)
	{
		cin>>g[i]>>v[i];
		mp[g[i]]++;
		mn=min(mn,g[i]);
	}
	for(i=1;i<=n;i++)
	{
		if(g[i]==mn)a[++idx1]=v[i];
		else if(g[i]==mn+1)b[++idx2]=v[i];
		else if(g[i]==mn+2)c[++idx3]=v[i];
		else d[++idx4]=v[i];
	}
	if(mp[mn])sort(a+1,a+mp[mn]+1);
	if(mp[mn+1])sort(b+1,b+mp[mn+1]+1);
	if(mp[mn+2])sort(c+1,c+mp[mn+2]+1);
	if(mp[mn+3])sort(d+1,d+mp[mn+3]+1);
	for(idx1=tmp1=0;idx1<=mp[mn];idx1++)
	{
		tmp1+=a[mp[mn]-idx1+1];
		for(idx2=tmp2=0;idx2<=mp[mn+1];idx2++)
 	    {
 	    	tmp2+=b[mp[mn+1]-idx2+1];
		    for(idx3=tmp3=0;idx3<=mp[mn+2];idx3++)
	        {
	           tmp3+=c[mp[mn+2]-idx3+1];
		       for(idx4=tmp4=0;idx4<=mp[mn+3];idx4++)
	           {
	           	   tw=mn*idx1+(mn+1)*idx2+(mn+2)*idx3+(mn+3)*idx4;
		           if(tw>w)break;
		           tmp4+=d[mp[mn+3]-idx4+1];
		           ans=max(ans,tmp1+tmp2+tmp3+tmp4);
	           }
       	    }
	    }
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s,t;
bool make(){
  for(int i=0;i<t.size();i++){
    if(t[i]==s[0]){
      for(int j=i+1;j<t.size();j++){
	if(t[j]==s[1]){
	  int d = j - i;
	  int l = j;
	  int k;
	  for(k=2;k<s.size();k++){
	    l+=d;
	    if(l>=t.size()||s[k]!=t[l]) break;
	  }
	  if(k==s.size()) return true;
	}
      }
    }
  }
  return false;
}
int main(){
  int N;
  cin >> N;
  cin >> s;
  int count=0;
  for(int i=0;i<N;i++){
    cin >> t;
    if(make()) count++;
  }
  cout << count << endl;
  return 0;
} 
  

Measured memory_bytes: 1208
N,M = map(int, input().split())
A = []

for i in range(N):
    a_num = list(map(int,input().split()))
    A.append(a_num)

b = [int(input()) for _ in range(M)]

for i in range(N):
    answer = 0
    for j in range(M):
        answer += A[i][j] * b[j]
    print(answer)



Measured memory_bytes: 5976
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,k,i,j;
    cin>>n;
    int *arr=new int[n];
    for(i=0;i<n;i++) cin>>arr[i];
    int *dp=new int[n]; //whether the person who starts it wins it or not
    dp[n-1]=0;
    dp[n-2]=abs(arr[n-1]-arr[n-2]);
    for(i=n-3;i>=0;i--)
    {
        dp[i]=min(dp[i+1]+abs(arr[i]-arr[i+1]),dp[i+2]+abs(arr[i]-arr[i+2]));
    }
    cout<<dp[0];
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{  
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st)) 
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st)) 
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);

  char c;
  int sum = 0;  // 水たまりの総水量

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
    	push(i,&st1);
   
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
    	
    	int j = pop(&st1);
    	
      	sum += i-j;
    	
      // st2_j と st2_a を用いて水たまりの水量を更新 
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
    
      	pop(&st2_j);
      	a+=pop(&st2_a);
      	
      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
    	push(j,&st2_j);
    	push(a,&st2_a);
    	
    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++) 
    printf(" %d", st2_a.S[i]);  
  printf("\n");

  return 0;
}


Measured memory_bytes: 2776
#include<stdio.h>
#include<stdlib.h>
#define SIZE 14

int main(){
	int i,j;
	int x,y,s,ink,blank;
	int **paper;
	paper=(int**)calloc(SIZE,sizeof(int*));
	for(i=0;i<SIZE;i++){
		paper[i]=(int*)calloc(SIZE,sizeof(int));
	}
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		paper[x+2][y+2]+=1;
		paper[x+3][y+2]+=1;
		paper[x+2][y+1]+=1;
		paper[x+1][y+2]+=1;
		paper[x+2][y+3]+=1;
		if(s>=2){
			paper[x+3][y+1]+=1;
			paper[x+1][y+1]+=1;
			paper[x+1][y+3]+=1;
			paper[x+3][y+3]+=1;
		}
		if(s>=3){
			paper[x+4][y+2]+=1;
			paper[x+2][y]+=1;
			paper[x][y+2]+=1;
			paper[x+2][y+4]+=1;
		}
	}
	ink=blank=0;
	for(i=2;i<SIZE-2;i++){
		for(j=2;j<SIZE-2;j++){
			if(paper[i][j]==0) blank++;
			else if(paper[i][j]>ink) ink=paper[i][j];
		}
	}
	printf("%d\n%d\n",blank,ink);
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    long long int sumN = 0;
    for(int i=1; i<=n; i++){
      if(i%3 != 0 && i%5 != 0){
        sumN += i;
      }
    }
    cout << sumN << endl;
    return 0;
}

Measured memory_bytes: 3620
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let b: Vec<usize> = (0..m).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut sa: Vec<usize> = vec![0; n + 1];
    for i in 0..n {
        sa[i + 1] = sa[i] + a[i];
    }

    let mut sb: Vec<usize> = vec![0; m + 1];
    for i in 0..m {
        sb[i + 1] = sb[i] + b[i];
    }

    let mut ans: usize = 0;
    for i in 0..(n + 1) {
        if sa[i] > k {
            continue;
        }
        let t = k - sa[i];
        let mut ok: isize = 0;
        let mut ng: isize = sb.len() as isize;
        while (ng - ok).abs() > 1 {
            let mid = (ok + ng) / 2;
            if sb[mid as usize] <= t {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ans = max(ans, i + ok as usize);
    }

    return ans.to_string();
}


Measured memory_bytes: 12536
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,ma[1111][1111]={};
  cin>>n;
  for(int i=0;i<n;i++){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    ma[x1][y1]++;
    ma[x1][y2]--;
    ma[x2][y1]--;
    ma[x2][y2]++;
  }
  for(int i=0;i<=1001;i++)
    for(int j=1;j<=1001;j++)
      ma[i][j]+=ma[i][j-1];

  int ans=0;
  for(int i=0;i<=1001;i++)
    for(int j=1;j<=1001;j++){
      ma[j][i]+=ma[j-1][i];
      ans=max(ans,ma[j-1][i]);
    }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 7932
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
	cin >> n;
	char c;
	rep(i,n){
		cin >> c;
		if(c=='Y') {
			puts("Four");
			return;
		}
	}
	puts("Three");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())
th = abs(X) / D
# print(th)
# 足りない場合
if th >= K:
    print(abs(X) - K * D)
# 足りる場合
else:
    curX = abs(X) - int(th) * D
    # print(curX)
    if (K - int(th)) % 2 == 0:
        print(curX)
    else:
        print(abs(curX - D))


Measured memory_bytes: 9168
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        sc.close();
        Map<String, Integer> map = new HashMap<>();
        map.put("SUN",7);
        map.put("MON",6);
        map.put("TUE",5);
        map.put("WED",4);
        map.put("THU",3);
        map.put("FRI",2);
        map.put("SAT",1);
        System.out.println(map.get(s));
    }
}


Measured memory_bytes: 20564