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

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

		// 入力値の取得
		int N = sc.nextInt();
		int K = sc.nextInt();
		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();
		char[] T = sc.next().toCharArray();
		char[] takahashi = new char[N];

		long sum = 0;
		for (int i = 0; i < N; i++) {
			if (i >= K) {
				if (T[i - K] == T[i]) {
					boolean judge = false;
					switch (T[i]) {
					case 'r':
						if (takahashi[i - K] == 'p') {
							takahashi[i] = 'r';
							judge = true;
						}
						break;
					case 's':
						if (takahashi[i - K] == 'r') {
							takahashi[i] = 's';
							judge = true;
						}
						break;
					case 'p':
						if (takahashi[i - K] == 's') {
							takahashi[i] = 'p';
							judge = true;
						}
						break;
					}
					if (judge) {
						continue;
					}
				}
			}
			switch (T[i]) {
			case 'r':
				sum += P;
				takahashi[i] = 'p';
				break;
			case 's':
				sum += R;
				takahashi[i] = 'r';
				break;
			case 'p':
				sum += S;
				takahashi[i] = 's';
				break;
			}
		}

		// 結果の出力
		System.out.println(sum);

		sc.close();
	}
}


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

int main(){
  char p1[100] = "a";
  scanf("%s", p1);
  char s1[100] = "b";
  scanf("%s", s1);
  char p2[200] = "c";
  strcpy(p2, p1);
  strcat(p2, p1);

  // printf("%s", p2);

  if(strstr(p2, s1) == NULL){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}



Measured memory_bytes: 3244
import java.util.*;

public class Main{
	
  public static void main(String[] args){
  		Scanner s=new Scanner(System.in);
   		int n=s.nextInt();
    	String str = s.next();
    	if(n%2!=0){
        	System.out.println("No");
        }else{
        	for(int i=0;i<n/2;i++){
            	if(str.charAt(i)!=str.charAt(n/2+i)){
                	System.out.println("No");
                  return;
                }
            }
          System.out.println("Yes");
        }
  }
  
}

Measured memory_bytes: 21844
#import <bits/stdc++.h>
using namespace std;
 
int n, q;
long long s;
long long num[100005];
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a; cin >> a;
		num[a]++;
		s += a;
	}
	
	cin >> q;
	for(int i = 0; i < q; i++) {
		int b, c; cin >> b >> c;
		s += (c-b)*num[b];
		cout << s << endl;
		num[c] += num[b];
		num[b] = 0;
	}
}


Measured memory_bytes: 4416
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A_C = Counter(A)
c = 0
A_C_A = {}
Memo = []
for key, value in A_C.items():
    if value % 2 == 0:
        c += 1
        A_C_A[key] = 2
        if len(Memo) <= 2:
            Memo.append(key)
    else:
        A_C_A[key] = 1


if c == 2:
    Memo.sort()
    for i in range(Memo[0]+1, Memo[1]):
        if A_C[i] != 0:
            print(len(A_C_A))
            exit()
    print(len(A_C_A)-1)

elif c % 2 == 0:
    print(len(A_C))
else:
    print(len(A_C)-1)

Measured memory_bytes: 67816
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<double> v(N);
  for(int i=0;i<N;i++) cin>>v[i];

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

  double pre=v[0];
  for(int i=1;i<N;i++){
    pre=(pre+v[i])/2;
  }

  cout<<fixed<<setprecision(10)<<pre<<endl;

  return 0;
}


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

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String S=sc.next();
		Map<Character,Integer>map=new HashMap<Character,Integer>();
		for(int i=0;i<S.length();i++) {
			Character c=S.charAt(i);
			map.put(c,0);
		}
		if(map.size()==2) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22612
S,K = input().split()
A = list(map(len,S.split("0")))
A[0] = 0
A.append(0)
N = len(A)
K = int(K)
K = min(K,S.count("1"))

MOD = 998244353

dp = [[[0]*(K+1) for _ in [0]*(K+1)] for _ in [0]*N]
dp[-1][0][0] = 1

for i in range(1,N):
    i = N-1-i
    for k in range(K+1):
        for n in range(K+1):
            dp[i][k][n] = sum(dp[i+1][k][n:])%MOD
            for a in range(1,A[i]+1):
                if k-a < 0 or n-a < 0: break
                dp[i][k][n] += dp[i+1][k-a][n-a]
                dp[i][k][n] %= MOD
ans = sum(dp[0][k][0] for k in range(K+1))
ans %= MOD
print(ans)

Measured memory_bytes: 97796
import fractions
import sys
from functools import reduce

input = sys.stdin.readline


def main():
    n, m = input_list()
    if n >= m // 2:
        print(m//2)
    else:
        c = (m-(2*n))//4
        print(n+c)


def input_list():
    return list(map(int, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63980
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define lld double
#define vi vector<ll>
#define pii pair<int,int>
#define piii pair<pii, ll>
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define ppb pop_back
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<x<<" "<<y<<"\n"
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
using namespace std;
const ll mod = 1e9+7;



char c[1000000];
int main()
{
   cin>>(c+500000);

   bool rev=0;
   int l = 499999;
   int r = 500000;
   for(;c[r];r++);

    int Q;cin>>Q;
    while(Q--)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            rev = !rev;
        }
        else
        {
            int f;char cc;
            cin>>f;
            cin>>cc;

            if((f==2&&!rev)||(f==1&&rev))
            {
                c[r++]=cc;
            }
            else
            {
                c[l--]=cc;
            }
        }
    }
    c[r]=0;
    if(rev)
    {
        int l1=l+1;
        int r1=r-1;
        while(l1<r1)
        {
            swap(c[l1],c[r1]);l1++;r1--;
        }
    }
    cout<<(c+l+1)<<endl;
}

Measured memory_bytes: 896
N = int(input())
S = input()
ans_list = []
abc_list = [chr(i) for i in range(97,97+26)]
for i in range(1,N):
    ans = 0
    S1 = list(S[:i])
    S2 = list(S[i:])
    for j in abc_list:
        if(j in S1 and j in S2):
            ans += 1
    ans_list.append(ans)
print(max(ans_list))


Measured memory_bytes: 3060
C = [list(map(int, input().split())) for _ in range(3)]

D = [[0]*3 for _ in range(2)]
for i in range(2):
    for j in range(3):
        D[i][j] = C[i+1][j]-C[i][j]

flag = True
if D[0][0] == D[0][1] and D[0][1] == D[0][2] and D[0][2] == D[0][0]:
    pass
else:
    flag = False

if D[1][0] == D[1][1] and D[1][1] == D[1][2] and D[1][2] == D[1][0]:
    pass
else:
    flag = False

if flag:
    print('Yes')
else:
    print('No')


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

class Program {
  static bool IsTriangle(List<int> a) {
    int i = 1;
    foreach (var item in a) {
      if (item != i++) return false;
    }
    return true;
  }
  static void Main() {
    int n;
    while ((n = int.Parse(Console.ReadLine())) != 0) {
      var lst = Console.ReadLine().Split().Select(int.Parse).ToList();
      int cnt = 0;
      int idx = 10001;
      while (idx-- > 0) {
        if (IsTriangle(lst)) break;
        lst = lst.Select(x => x - 1).ToList();
        lst.Add(lst.Count);
        lst.RemoveAll(x => x == 0);
        cnt++;
      }
      Console.WriteLine(cnt > 10000 ? -1 : cnt);
    }
  }
}


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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    for (int i = sx; i < tx; i++) {
        cout << "R";
    }
    for (int i = sy; i < ty; i++) {
        cout << "U";
    }
    for (int i = sx; i < tx; i++) {
        cout << "L";
    }
    for (int i = sy; i < ty + 1; i++) {
        cout << "D";
    }
    for (int i = sx; i < tx + 1; i++) {
        cout << "R";
    }
    for (int i = sy; i < ty + 1; i++) {
        cout << "U";
    }
    cout << "L" << "U";
    for (int i = sx; i < tx + 1; i++) {
        cout << "L";
    }
    for (int i = sy; i < ty + 1; i++) {
        cout << "D";
    }
    cout << "R" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;

int main()
{
  int a,b,c;
  cin >>a>>b>>c;

  if(a==b&&b==c) cout <<1 <<endl;
    else if(a==b ||b==c|| c==a)cout << 2 <<endl;
    else cout <<3<<endl;
}


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

int N, K;
vector<int> P;
int max_sum;

void input_init(void) {
	cin >> N >> K;
	P.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> P[i];
}

void check_max_sum(void) {
	int sum = 0;
	for (int i = 0; i < K; ++i)
		sum += P[i];
	max_sum = sum;
	for (int i = K; i < N; ++i) {
		sum += P[i];
		sum -= P[i - K];
		if (sum > max_sum)
			max_sum = sum;
	}
}

int main(void) {
	input_init();
	check_max_sum();
	double ans = (double)(max_sum + K) / 2;
	cout << fixed << setprecision(8) << ans << '\n';
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll k;
  cin >> k;
  ll n=50;
 vll a(n); 
 rep(i,0,n) {
   a[i]=i+k/n-(k%n);
   if(i<k%n) a[i]+=(n+1);
 }
  cout << n << endl;
 rep(i,0,n-1) cout << a[i] << " "; 
   cout << a[n-1] << endl;


}



Measured memory_bytes: 256
import java.io.*;

class Main{
    public static void main(String[] a){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            int[] mount = new int [10];
            for(int i = 0;i < 10;i++){
                String str = br.readLine();
                int high = Integer.parseInt(str);
                if(high >= 0 && high <= 10000){
                    mount[i] = high;
                }
                for(int k = 0;k <= i; k++){
                    if(mount[k] < mount[i]){
                        int h = mount[i];
                        mount[i] = mount[k];
                        mount[k] = h;
                    }
                }
            }
            for(int j = 0;j < 3; j++){
                System.out.println(mount[j]);
            }
        }
        catch(IOException e){
        }
    }
}

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

int main()
{
  int n, q;
  cin >> n;
  int S[n] = {};
  for(int i=0; i<n; i++)
    cin >> S[i];
  cin >> q;
  int T[q] = {};
  for(int i=0; i<q; i++)
    cin >> T[i];

  int count=0;;
  for(int i=0; i<q; i++){
    for(int j=0; j<n; j++){
      if(T[i]==S[j]){
        count++;
        break;
      }
    }
  }

  cout << count << endl;
}



Measured memory_bytes: 3100
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 

void solve()
{
	long double n,m;
	cin>>n>>m;
	long double ans=0;
	int score=1,c=0;
	for(int i=1;i<=n;i++)
	{
		score=i;
		c=0;
		while(score<m)
		{
			score*=2;
			c++;
		}
		ans+=(long double)1/n*pow(0.5,c);
		
	}
	cout<<fixed<<setprecision(15)<<ans<<endl;
}
 
int main()
{
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll m[200006] = { 0 };
ll s[200006] = { 0 };

void solve_abc() {
	ll n;
	ll ans = 0;

	cin >> n;

	V a(n);
	rep(i, n) {
		cin >> a[i];
		m[a[i]]++;
	}

	ll sum = 0;
	rep(i, 200001) {
		s[i] = m[i] * (m[i] - 1) / 2;
		sum += s[i];
	}

	rep(i, n) {
		ans = sum - s[a[i]] + (m[a[i]] - 1) * (m[a[i]] - 2) / 2;
		cout << ans << "\n";
	}
}

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

	solve_abc();

	return 0;
}

Measured memory_bytes: 6272
def get_length(sentence):
    length = 0

    while True:
        try:
            if sentence[length] is not None:
                length += 1
        except:
            break

    return length


n = int(input())
target = "Hoshino"
target_right = "Hoshina"
length_target = get_length(target)

for __ in range(n):
    sentence = input()
    length = get_length(sentence)
    
    for i in range(length - length_target +1):
        correct = True
        for j in range(length_target):
            if sentence[i+j] != target[j]:
                correct = False
                break
        if correct:
            after = ""
            for j in range(i):
                after += sentence[j]
            after += target_right
            for j in range(i+length_target, length):
                after += sentence[j]
            sentence = after

    print(sentence)


Measured memory_bytes: 5604
#include <iostream>
#include <cstdint>

using namespace std;

int64_t f(int64_t a, int64_t b, int64_t d) {
  return b / d - (a - 1) / d;
}

int64_t gcd(int64_t a, int64_t b) {
  return b == 0 ? a : gcd(b, a % b);
}

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

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

  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;

  int64_t ans = b - a + 1 - f(a, b, c) - f(a, b, d) + f(a, b, lcm(c, d));
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	static String[] hand = {
		"Rock",
		"Gun",
		"Lightning",
		"Devil",
		"Dragon",
		"Water",
		"Air",
		"Paper",
		"Sponge",
		"Wolf",
		"Tree",
		"Human",
		"Snake",
		"Scissors",
		"Fire",
	};

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

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			int[] h = new int[n];
			for(int i=0;i<n;i++){
				h[i] = searchTable(sc.next());
			}

			int ans = -1;
			for(int i=0;i<n;i++){
				int count = 0;
				int lose = 0;
				for(int j=0;j<n;j++){
					if(i == j) continue;
					if(h[i]-7<0 && ((h[i]+15-7)%15<=h[j] || h[j]<h[i]) ||
						 h[i]-7<=h[j] && h[j]<h[i]){
						count++;
					} else if(h[i] != h[j]) {
						lose++;
					}
				}
				if(count > 0 && lose == 0){
					ans = h[i];
					break;
				}
			}

			System.out.println(ans==-1 ? "Draw" : hand[ans]);
		}
	}

	static int searchTable(String s){
		for(int i=0;i<15;i++){
			if(hand[i].equals(s)) return i;
		}
		return -1;
	}
}

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

template<typename T>
using Matrix = vector<vector<T>>;

// g: 隣接行列。自分から自分への距離は0。到達できない場合はINF
// INF: gのINF値
// return: iからjへの最短経路におけるiの1つ後の点(経路復元に用いる)
template<typename T>
vector<vector<int>> warshall_floyd(Matrix<T>& g, const T INF) {
    vector<vector<int>> next(g.size(), vector<int>(g.size()));
    for (int i = 0; i < g.size(); ++i) {
        for (int j = 0; j < g.size(); ++j) {
            next[i][j] = j;
        }
    }
    for (int k = 0; k < g.size(); ++k) {
        for (int i = 0; i < g.size(); ++i) {
            for (int j = 0; j < g.size(); ++j) {
                if (g[i][k] == INF || g[k][j] == INF) continue;
                if (g[i][k] + g[k][j] < g[i][j]) {
                    g[i][j] = g[i][k] + g[k][j];
                    next[i][j] = next[i][k];
                }
            }
        }
    }
    return next;
}

void Main()
{
	// 頂点数, 辺の数
    int V, E;
    cin >> V >> E;
    // 隣接行列構築
    const int INF = 1e9;
    Matrix<int> g(V, vector<int>(V, INF));
	vector<pair<int, int>> p;
    for (int i = 0; i < E; ++i) {
        int from, to, cost; cin >> from >> to >> cost;
        // if 1-indexed
        --from, --to;
		p.push_back(make_pair(from, to));
        g[from][to] = cost;
        // 無向
        g[to][from] = cost;
    }
    for (int i = 0; i < V; ++i) {
        g[i][i] = 0;
    }
    // ワーシャルフロイド
    auto next = warshall_floyd(g, INF);
	vector<vector<bool>> incl(V, vector<bool>(V, false));
	rep(i, V) {
		rep(j, V) {
			for (int cur = i; cur != j; cur = next[cur][j]) {
				incl[cur][next[cur][j]] = true;
			}
		}
	}
	int res = 0;
	for (auto _p : p) {
		if (incl[_p.first][_p.second] || incl[_p.second][_p.first]) continue;
		++res;
	}
	cout << res << endl;
}

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


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] p = new int[n];
		
		for (int i = 0; i < n; i++) {
			p[i] = scan.nextInt();
		}
		
		int[] three = new int[3];
		int count = 0;
		for (int i = 1; i < n - 1; i++) {
			three[0] = p[i - 1];
			three[1] = p[i];
			three[2] = p[i + 1];
			
			if (three[1] >= three[0] && three[1] < three[2]) count++;
			if(three[1] < three[0] && three[1] >= three[2]) count++;
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
#include<stdio.h>
void preParse(int,int);
void print(int);

typedef struct{
  int parent,child,sibling;
}node;

node tree[200000];
int depth[200000];

int main(){
  int n,i,j,l,r;
  int id,degree,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    tree[i].parent=-1;
    tree[i].child=-1;
    tree[i].sibling=-1;
  }
   for(i=0;i<n;i++){
     scanf("%d",&id);
     scanf("%d",&degree);
     for(j=0;j<degree;j++){
       scanf("%d",&c);
       if(j==0)
	 tree[id].child=c;
       else tree[l].sibling=c;
       l=c;
       tree[c].parent=id;
     }
  }

   for(i=0;i<n;i++){
     if(tree[i].parent==-1)
       r=i;
   }

   preParse(r,0);
   
   for(i=0;i<n;i++){
     print(i);
   }
  return 0;
}

void preParse(int u,int p){
  depth[u]=p;
  if(tree[u].sibling!=-1)
    preParse(tree[u].sibling,p);
  if(tree[u].child!=-1)
    preParse(tree[u].child,p+1);
}

void print(int u){
  int i,c;
  
  printf("node %d: ",u);
  printf("parent = %d, ",tree[u].parent);
  printf("depth = %d, ",depth[u]);

  if(tree[u].parent==-1)
    printf("root, ");
  else if(tree[u].child==-1)
    printf("leaf, ");
  else
    printf("internal node, ");

  printf("[");
  for(i=0,c=tree[u].child;c!=-1;i++,c=tree[c].sibling){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}



Measured memory_bytes: 7312
# E - Max-Min Sums

N, K = map(int, input().split())
A = list(map(int, input().split()))

if K == 1:
    print(0)
    exit()

A.sort()

MOD = 10**9 + 7

def make_table(n, mod = MOD):
    # 元テーブル
    g1 = [0] * (n + 1)
    g1[0] = 1
    g1[1] = 1

    # 逆元テーブル
    g2 = [0] * (n + 1)
    g2[0] = 1
    g2[1] = 1

    # 逆元計算用テーブル
    inverse = [0] * (n + 1)
    inverse[0] = 0
    inverse[1] = 1

    for i in range(2, n + 1):
        g1[i] = (g1[i - 1] * i) % mod
        inverse[i] = (-inverse[mod % i] * (mod // i)) % mod
        g2[i] = (g2[i - 1] * inverse[i]) % mod

    return tuple(g1), tuple(g2), tuple(inverse)

g1, g2, inverse = make_table(N)

def cmb_from_table(n, r, mod = MOD):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

ans = 0
for i in range(1, N+1):
    ans += A[i-1] * (cmb_from_table(i-1, K-1) - cmb_from_table(N-i, K-1))
    if ans > 0:
        ans %= MOD

print(ans)

Measured memory_bytes: 21208
n, k = map(int, input().split())

# N: N面サイコロ
# K: 得点

p = max(0, (n - k + 1))

for x in range(1, min(n + 1, k)):
    m = 0
    y = x
    while True:
        y = y * 2
        m = m + 1
        if y >= k:
            break
    p += ((1 / 2) ** m)

print(p / n)


Measured memory_bytes: 3060
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  double l;
  cin >> l;

  cout << fixed << setprecision(10) << (l / 3) * (l / 3) * (l / 3);

  return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    string N; cin >> N;
    int sum = 0;
    for (auto c : N) {
        sum += c - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int cnt=0, ans=0;
    for(int i=0; i<s.length(); i++) {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') cnt++;
        else {
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    ans = max(ans,cnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
  int n;cin >> n;
  vector< vector<int> > a (2, vector<int>(n) );

  rep(i,2){
    rep(j,n){
      cin >> a[i][j];
    }
  }
  int su=0;
  vector<int> sum(n);
  rep(i,n){
    su+=a[0][i];
    sum[i] = su;
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    int an = sum[i];
    for(int j=i;j<n;j++){
      an+=a[1][j];
    }
    ans = max(ans,an);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayDeque<Integer> deq = new ArrayDeque<>();
		for (int i = 0; i < n; i++) {
		    if (n % 2 == 0 ^ i % 2 == 0) {
		        deq.push(sc.nextInt());
		    } else {
		        deq.add(sc.nextInt());
		    }
		}
		boolean flag = false;
		StringBuilder sb = new StringBuilder();
		while (deq.size() > 0) {
		    if (flag) {
		        sb.append(" ");
		    }
		    flag = true;
		    sb.append(deq.pop());
		}
	    System.out.println(sb);
	}
}


Measured memory_bytes: 93456
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
  
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
int dp[3003][3003];
int lcss(string X,string Y,int n,int m)
{   int i=0,j=0;
    for (i = 0; i <= n; i++)  
    {  
        for (j = 0; j <= m; j++)  
        {  
        if (i == 0 || j == 0)  
            dp[i][j] = 0;  
      
        else if (X[i - 1] == Y[j - 1])  
            dp[i][j] = dp[i - 1][j - 1] + 1;  
      
        else
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);  
        }  
    }  
    return 0;
}
 int lcs(string s, string t, int n, int m )  
{  
    if (m == 0 || n == 0)  
        return dp[n][m]=0;  
        if(dp[n][m]!=-1)
        return dp[n][m];
    if (t[m-1] == s[n-1])  
        return dp[n][m]=(1 + lcs(s, t, n-1, m-1));  
    else
        return dp[n][m]=max(lcs(s, t, n, m-1), lcs(s, t, n-1, m));  
}  
int32_t main()
{
    c_p_c();
     string s,t;
     cin>>s;
     cin>>t;
     memset(dp,0,sizeof(dp));
     
     lcss(s,t,s.size(),t.size());
      
      string ans="";
      int i=s.size();
      int j=t.size();
     // cout<<dp[i][j];
      while(i>0 and j>0){
              if(s[i-1]==t[j-1])
              {  ans=ans+s[i-1];
                  i--;
                  j--;
                   
              }
              else
              {
                  if(dp[i-1][j]>dp[i][j-1])
                  {
                      i--;
                  }
                  else
                  j--;
              }
      }
       
          reverse(ans.begin(),ans.end());
      cout<<ans;
     
    
    return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;

const int INF = 1e18 + 100;
const int MOD1 = 998244353;
const int MOD = 1e9 + 7;
const int N = 10001;
const int nul = 0;
const int SIZE = 1e6 * 3;


signed main() {
#ifdef parasha
    freopen("A.in.txt", "r", stdin);
#endif // parasha
    fast;
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int &i : a) cin >> i;
    vector<int> prefMin(n), sufMax(n), minn(n), maxx(n);
    int cur = a[0];
    prefMin[0] = 1;
    minn[0] = a[0];
    for (int i = 1; i < n; i++) {
        if (a[i] < cur) {
            prefMin[i] = 1;
            cur = a[i];
        } else if (a[i] == cur) {
            prefMin[i] = prefMin[i - 1] + 1;
        } else prefMin[i] = prefMin[i - 1];
        minn[i] = cur;
    }
    cur = a[n - 1];
    sufMax[n - 1] = 1;
    maxx[n - 1] = cur;
    for (int i = n - 2; i >= 0; i--) {
        if (a[i] > cur) {
            sufMax[i] = 1;
            cur = a[i];
        } else if (a[i] == cur) sufMax[i] = sufMax[i - 1] + 1;
        else sufMax[i] = sufMax[i - 1];
        maxx[i] = cur;
    }
    int now = 0;
    int ans = 0;
    map<pair<int, int>, int> smth;
    for (int i = 0; i < n - 1; i++) {
        int curmin = minn[i], curmax = maxx[i + 1];
        if (curmax - curmin > now) {
            smth.clear();
            smth[{curmin, curmax}] = max(smth[{curmin, curmax}], min(prefMin[i], sufMax[i + 1]));
            now = curmax - curmin;
        } else if (curmax - curmin == now) {
            smth[{curmin, curmax}] = max(smth[{curmin, curmax}], min(prefMin[i], sufMax[i + 1]));
        }
    }
    for (auto i : smth) ans += i.second;
    cout << ans << endl;
}


Measured memory_bytes: 10292
import std.stdio;
import std.string;
import std.conv;
import std.bigint;

void main()
{
	int a = to!int(chomp(readln()));
	for (uint i = 0; i < a * 2; i += 2) {
		BigInt left = chomp(readln()),
		       right = chomp(readln());
//		auto sum = format("%s", left + right);
		auto sum = to!string(left + right);
		if (sum.length > 80) {
			writeln("overflow");
		} else {
 			writeln(sum);
		}
	}
}

Measured memory_bytes: 1112
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()

if sum(s)%10==0:
    for i in range(n):
        if s[i]%10!=0:
            s.pop(i)
            print(sum(s))
            break
    else:
        print(0)
else:
    print(sum(s))

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

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

    if (n < 1200){
        cout << "ABC" << endl;
    }
    else if (n < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N_MAX 100
#define W_MAX 100000
#define ll long long
using namespace std;
int N,W;
ll w[N_MAX],v[N_MAX];
ll dp[N_MAX+1][W_MAX+1];
int main(){
  cin>>N>>W;
  for(int i=0;i<N;i++) cin>>w[i]>>v[i];
  for(int i=1;i<=N;i++){
    for(int j=0;j<=W;j++){
      if(j>=w[i-1]) dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
      else dp[i][j] = dp[i-1][j];
    }
  }
  /*
  for(int i=0;i<=N;i++){
    for(int j=0;j<=W;j++){
      printf("%2lld ",dp[i][j]);
    }
    cout<<endl;
  }
  */
  cout<<dp[N][W]<<endl;
  return 0;
}


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


int main(){
    int a,b;
    cin>>a>>b;
    if(a<6){
        cout<<0<<endl;
    }
    else if(5<a&&a<13){
        cout<<b/2<<endl;
    }
    else{
        cout<<b<<endl;
    }
}

Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



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

int main() {
    int n, m;
    string s;
    cin >> n >> m >> s;
    vector<int> ans;
    for(int i = n; i > 0; --i) {
        for(int j = i - m; j < i; ++j) {
            if(j <= 0) {
                ans.push_back(i);
                i = -1;
                break;
            } else if (s[j] == '0') {
                ans.push_back(i - j);
                i = j+1;
                break;
            }
            if(j == i-1 && s[i-1] == '1') {
                cout << -1 << '\n';
                return 0;
            }
        }
    }
    for(int i = ans.size()-1; i >= 0; --i) cout << ans[i] << ' ';
    cout << '\n';
    return 0;
}

Measured memory_bytes: 1144
#include <stdio.h>
 
int main(void){
	
	int a,x;
	x = 0;
	
	scanf("%d",&a);
	
	if(a/100==1) x = x + 1;
	if((a/10)%10==1) x = x + 1;
	if(a%10==1) x = x + 1;
	
	printf("%d\n",x);
	return 0;
}

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

int main() {
    long long int n;
    cin >> n;
    long long int x[n];
    for(int i = 0; i < n; i++) cin >> x[i];

    long long int ans = 1e9;
    for(int i = 0; i <= 100; i++) {
        long long int sum = 0;
        for(int j = 0; j < n; j++) sum += pow(x[j]-i, 2);
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int x, y;

	while (true) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x < y) cout << x << ' ' << y << endl;
		else cout << y << ' ' << x << endl;
	}




	return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng {
    using namespace boost;
    using namespace boost::range;
    using namespace boost::adaptors;
}

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    int s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe" << nl;
    } else {
        cout << "safe" << nl;
    }
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	//n = 5
	//1 2 3 4 5 6
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int x = scanner.nextInt();
		int[] a = new int[m + 1];
		
		for (int i = 1; i <= m; i++) {
			a[i] = scanner.nextInt();
		}
		
		int ans1 = 0;
		
		for (int i = x; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (i == a[j]) {
					ans1 += 1;
				}
			}
			
		}
		
		int ans2 = 0;
		for (int i = x; i >=  0; i--) {
			for (int j = 1; j <= m; j++) {
				if (i == a[j]) {
					ans2 += 1;
				}
			}
		}
		
		int ans3 = Math.min(ans1, ans2);
		System.out.println(ans3);
		scanner.close();

	}

}


Measured memory_bytes: 24020
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef  long long ll;

int open[10]={0};
int N;
int F[100][5][2], P[100][11], cnt[100]={0};
ll max_bene=-10000000000;
void cal(int n){
  if(n < 10){
    open[n]=0;
    cal(n+1);
    open[n]=1;
    cal(n+1);
  }
  else{
    int benefit=0;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < 5; j++){
        if(open[2*j] && F[i][j][0])
          ++cnt[i];
        if(open[2*j+1] && F[i][j][1])
          ++cnt[i];
      }
    }
    for(int i = 0; i < N; i++){
      
      benefit+=P[i][cnt[i]];
    }
    int flag = 0;

    for(int i = 0; i < 10; i++){
      if(open[i])
        flag = 1;
    }
    if((max_bene < benefit) && flag)
      max_bene = benefit;
    for(int i = 0; i < N; i++)
      cnt[i]=0;
  }
}

int main(){
  

  cin >> N;

  for(int i = 0; i < N; i++){
    for(int j = 0; j < 5; j++){
      for(int k = 0; k < 2; k++){
        cin>>F[i][j][k];
      }
    }
  }

  for(int i = 0; i < N; i++){
    for(int j=0; j < 11; j++){
      cin >> P[i][j];
    }
  }

  cal(0);

  cout << max_bene << endl;

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;


namespace AtCoderDotNetCore
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int k = array[0];
			int x = array[1];

			for (var i = x - k + 1; i < x + k; ++i) {
				Console.Write($"{i}");
				if (i < x + k - 1) {
					Console.Write($" ");
				}
			}

			Console.WriteLine($"");
		}
	}
}

Measured memory_bytes: 28296
#include<bits/stdc++.h>
#define f i].first
#define s i].second
using namespace std;pair<long,long>p[1<<18];long I,A,n,r,b,d,t,i,S;main(){I=b=1e9;for(cin>>n;i<n;i++){cin>>p[f>>p[s;if(p[f>p[s)swap(p[f,p[s);I=min(I,p[f),A=max(A,p[s),r=max(r,p[f),b=min(b,p[s);}i=~0;sort(p,p+n);t=(r-I)*(A-b);b=p[1+f,r=p[n+f;S=A-I;t=min(t,S*(r-b));for(d=A;++i<n;t=min(t,S*(r-b)))b=min(min(p[s,i-n+1?p[1+f:A),d),d=min(d,p[s),r=max(r,p[s);cout<<t;}

Measured memory_bytes: 4352
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n = int(input())
    px = py = pt = 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        d = abs(x - px) + abs(y - py)
        if d > t - pt or d % 2 != (t - pt) % 2:
            print("No")
            exit()
        pt, px, py = t, x, y
    print("Yes")

main()


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

//エラトステネスの篩
void eratosthenes(int num, map<int,int> &prime){
    for(int i = 2; i * i <= num; i++){
        while(num%i==0){
            prime[i]++;
            num/=i;
        }
    }
    if(num!=1) prime[num]++;
}

int N;
ll dp[100][76];
map<int, int> factoring;
vector<int> primes;
int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) eratosthenes((int) i+1, factoring);
    for(auto x: factoring) primes.pb(x.second);
    
    dp[0][1] = 1;
    REP(i, primes.size()) {
        FOR(j, 1, 76) {
            FOR(k, 1, 76) {
                if (j * k <= 75 && primes[i]+1 >= k) {
                    dp[i+1][j*k] += dp[i][j];
                }
            }
        }
    }
    
    cout << dp[primes.size()-1][75] << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	. "fmt"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	n := int64(r())
	s := n * (n + 1) * (n + 2) / 6
	for m := int(n - 1); m > 0; m-- {
		v, w := int64(r()), int64(r())
		if v > w {
			v, w = w, v
		}
		s -= v * (n - w + 1)
	}
	Print(s)
}


Measured memory_bytes: 1832
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int N, P; string S;
vector<pair<pair<string, int>, int>> v;
int main() {
  cin >> N;
  for(int i = 1; i <= N; ++i) {
    cin >> S >> P;
    v.push_back({{S, -P}, i});
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < N; ++i) {
    cout << v[i].second << endl;
  }
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

int main() {
  priority_queue<int,vector<int>,greater<int>> PQ;
  int n,k; cin>>n>>k;
  int p,ans=0,t;
  rep(i,n) {
    cin>>p;
    PQ.push(p);
  }
  rep(i,k) {
    t=PQ.top();
    PQ.pop();
    ans+=t;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int dp[10001];
int v[100], w[100];
int main() {
	int N, W;
	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = W; j >= w[i]; j--) {
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	}
	int ans = 0;
	for (int i = 0; i <= W; i++) ans = dp[i];
	cout << ans << endl;
}


Measured memory_bytes: 3132
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static int[] ans;
//	 static int mod = 998244353;
   public static void main(String[] args) {
	          
	   Scanner sc = new Scanner(System.in);
       int  N = sc.nextInt();
       long  H = sc.nextLong();
       long[][] a = new long[N][2];
       long max=0;
       for (int i=0 ; i<N; i++) {
           a[i][0] = Long.parseLong(sc.next());
           a[i][1] = Long.parseLong(sc.next());
           max=Math.max(max, a[i][0]);
       }
       Arrays.sort(a, (b, c) -> Long.compare(b[1], c[1])); 
       
       long cnt=0;
       
       for(int i=a.length-1;i>=0;i--) {
    	   if(a[i][1]<max) {
    		   break;
    	   }
    	   H=H-a[i][1];
    	   cnt++;
    	   if(H<=0) {
    		   System.out.println(cnt);
    		   return;
    	   }
       }
	   if(H%max==0)cnt--;
       cnt=cnt+H/max+1;
       System.out.println(cnt); 
       return;
   }

}

Measured memory_bytes: 65396
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<long long> a(n);
	for (auto & e : a) cin >> e;
	sort(a.begin(), a.end());

	if (a[n - 2] < 0) {
		cout << a[n - 1] - accumulate(a.begin(), a.end() - 1, 0) << endl;
		for (int i = n - 1; i > 0; --i) {
			cout << a[i] <<" "<< a[i - 1] << endl;
			a[i - 1] = a[i] - a[i - 1];
		}
	}
	else {
		long long sum = -a[0];
		int neg = 0;
		for (int i = 1; i < n; ++i) {
			if (a[i]< 0) neg = max(neg, i);
			sum += abs(a[i]);
		}
		cout << sum << endl;
		for (int i = neg; i <n-2; ++i) {
			cout << a[i] << " "<<a[i + 1] << endl;
			a[i + 1] = a[i] - a[i + 1];
		}
		cout << a[n-1] <<" "<< a[n-2] << endl;
		a[neg] = a[n-1] - a[n-2];
		for (int i = neg; i >0; --i) {
			cout << a[i] <<" "<< a[i-1] << endl;
			a[i-1] = a[i] - a[i-1];
		}

	}

}

Measured memory_bytes: 2688
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int S,W;
signed main(){
    scanf("%lld %lld",&S,&W);
    if(W>=S)printf("unsafe\n");
    else printf("safe\n");
    return 0;
}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> vec(n);
  int i,sum=0;
  for(i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    vec.at(i)=make_pair(a,b);
    sum+=vec.at(i).second-vec.at(i).first+1;
  }
  cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

 
    int n;
    cin>>n;

    vector<vi> v(100,vi(100,0));

    int k;
    forn(i,0,n)
    {
        cin>>k;
        v[i][0] += 1;
        if(k < 100) v[i][k] -= 1;
    }

    forn(i,0,100)
    {
        forn(j,1,100)
        {
            v[i][j] += v[i][j-1];
        }
    }

    int count = 0;
    forn(i,0,100)
    {
        bool val = true;
        forn(j,0,100)
        {
            if(v[j][i] == 1 && val)
            {
                count++;
                val = false;
            }
            else if(v[j][i] == 0)
            {
                val = true;
            }
        }
    }

    cout<<count;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

void solve() {
	ll x; cin >> x;
	if (x >= 30) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

int main(int argc, char * argv[]) 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif

	//int t; cin >> t; while(t--)
	solve();

    return 0;
}

Measured memory_bytes: 3632