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

int main() {
	int D;
	cin >> D;
	if (D == 25) {
		puts("Christmas");
	}
	else if (D == 24) {
		puts("Christmas Eve");
	}
	else if (D == 23) {
		puts("Christmas Eve Eve");
	}
	else {
		puts("Christmas Eve Eve Eve");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int K, S;

int main()
{
    scanf("%d %d", &K, &S);

    long long answer = 0;
    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            int z = S - x - y;
            if(0 <= z && z <= K){
                answer++;
            }
        }
    }
    printf("%lld\n", answer);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define INF 1000000
int graph[101][101],n,c,d;
void warshall_floyd(void);
int min(int,int);

int main(){
  int k,i,j,x,e,a,b;

  while(scanf("%d %d",&n,&k),n,k){
    for(i=1;i<=n;i++)
      for(j=1;j<=n;j++)
	graph[i][j]=i==j?0:INF;
    
    for(i=0;i<k;i++){
      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);

	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }else{
	scanf("%d %d",&a,&b);
	printf(graph[a][b]>=INF?"-1\n":"%d\n",graph[a][b]);
      }
    }
  }
  return 0;
}

void warshall_floyd(){
  int i,j;
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
}

int min(int x,int y){
return x<y?x:y;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define f(i,s,n)for(register int i=s;i<=n;++i)
#define f2(i,s,n)for(register int i=n;i>=s;--i)
#define N 100010
using namespace std;
int a[N];
int main(){
	ios::sync_with_stdio(false);
	int n,ans=0;
	cin>>n;
	f(i,1,n){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	f(i,2,n){
		if(a[i]==a[i-1])ans++;
	}
	if(ans%2==1)ans++;
	cout<<n-ans<<"\n";
	return 0;
}


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

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

  int N;
  cin >> N;
  vector<int> p(N);
  for(int i = 0; i < N; i++){
    cin >> p.at(i);
  }
  int count = 0;
  for(int i = 1; i < N-1; i++){
    if(p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1)){
      count++;
    }
    if(p.at(i+1) < p.at(i) && p.at(i) < p.at(i-1)){
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
cd = [list(map(int,input().split())) for i in range(m)]
for i in ab:
    l = []
    for j in cd:
        l.append(abs((j[0]-i[0])) + abs((j[1]-i[1])))
    print(l.index(min(l)) + 1)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

from collections import Counter

def solve(N, A):
    flag = False
    A_counter = Counter(A)

    if(N%2==1):
        if(A_counter[0]==1 and all(A_counter[i]==2 for i in range(2, N, 2))):
            flag = True
    else:
        if(all(A_counter[i]==2 for i in range(1, N, 2))):
            flag = True
    
    print(pow(2, N//2, 10**9+7) if flag else 0)

if __name__ == '__main__': 
    N = int(input())
    A = [int(a) for a in input().split()]
    
    solve(N, A)

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

int coin[] = {1, 5, 10, 50, 100, 500};
int remain, in;
int main()
{
  while(cin >> in, in){
    remain = 1000 - in;
    int ans = 0;
    for(int i = 0; i < 6; i++){
      ans += remain / coin[5 - i];
      remain %= coin[5 - i];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      char[] S = sc.next().toCharArray();
      int result = 0;
      for (int i = 0; i < S.length; i++) {
        if (S[i] == '+') {
          result++;
        } else {
          result--;
        }
      }

      System.out.println(result);
    }
  }
}


Measured memory_bytes: 21972
#include <iostream>

using namespace std;

char data[12][12];
bool visited[12][12];
int dx[]={0, 1, 0, -1};
int dy[]={-1, 0, 1, 0};

void dfs(int, int);

main(){
  while(1){
    bool end=false;
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	if(scanf("%c", &data[i][j])==EOF){
	  end=true;
	  return 0;
	}
      }
      getchar();
    }
    getchar();
    int ans=0;
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	visited[i][j]=false;
      }
    }
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	if(data[i][j]=='1' && !visited[i][j]){
	  ans++;
	  dfs(i, j);
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

void dfs(int y, int x){
  visited[y][x]=true;
  for(int i=0;i<4;i++){
    int ty=y+dy[i];
    int tx=x+dx[i];
    if(ty>=0 && ty<12){
      if(tx>=0 && tx<12){
	if(data[ty][tx]=='1' && !visited[ty][tx]){
	  dfs(ty, tx);
	}
      }
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  string s;
  cin >> s;
  if(s=="RRR"){
    cout << 3 << endl;
  }
  else if(s=="RRS" || s=="SRR"){
    cout << 2 << endl;
  }
  else if(s=="SSS"){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3620
import copy

def partition(p, r):
    i = p
    for j in range(p, r):
        if A[r][1] >= A[j][1]:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[r], A[i] = A[i], A[r]
    return i

def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)

def correct_same_num_suits(l, num):
    suits = []
    for card in l:
        if num == card[1]:
            suits.append(card[0])
    return suits

def is_stable():
    idx = 0
    while idx < N-1:
        idx_incr_flg = True
        if A[idx][1] == A[idx+1][1]:
            num = A[idx][1]
            sorted_suits = correct_same_num_suits(A, num)
            orig_suits = correct_same_num_suits(orig_list, num)
            if sorted_suits != orig_suits:
                return False
            idx += len(sorted_suits)
            idx_incr_flg = False
        if idx_incr_flg:
            idx += 1
    return True


N = int(input())
A = []
for _ in range(N):
    suit, num = input().split()
    num = int(num)
    A.append([suit, num])
orig_list = copy.deepcopy(A)

quick_sort(0, N-1)

is_stable = is_stable()
if is_stable:
    print("Stable")
else:
    print("Not stable")

for card in A:
    print("%s %d" % (card[0], card[1]))


Measured memory_bytes: 39508
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] a  = new int[n];
      	int max = 0;
      	for(int i=0;i<n;i++){
          a[i] = sc.nextInt();
        }
      	int q = sc.nextInt();
      	int[] b = new int[q];
      	int[] c = new int[q];
      	for(int i=0;i<q;i++){
          b[i] = sc.nextInt();
          c[i] = sc.nextInt();
        }
      	long[] tmp = new long[100001];
      	for(int i=0;i<a.length;i++){
          tmp[a[i]] += 1;
        }
      	long sum = 0;
      	for(int i=0;i<tmp.length;i++){
          sum += tmp[i]*i;
        }
      	
      	for(int i=0;i<b.length;i++){    
          sum -= tmp[b[i]]*b[i];
          sum -= tmp[c[i]]*c[i];
          tmp[c[i]] += tmp[b[i]];
          tmp[b[i]] = 0;
          sum += tmp[c[i]]*c[i];
          System.out.println(sum);
        }
	}
}
  /*
        if( (int)s.charAt(0)-48 >= 0 && (int)s.charAt(0)-48 <=48 ){
*/

Measured memory_bytes: 61120
#include <stdio.h>

int main(void) {
    int tm;
    int h, m, s;
    scanf("%d", &tm);
    h = tm / 3600;
    m = tm % 3600 / 60;
    s = tm % 3600 % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


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

int main() {
    cin >> ans;
    if (ans[0] == ans[1] && ans[0] == ans[2]){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=60,	MOD=1e9+7;

int n;
long long int resp,k;

struct matriz
{
	long long int m[MAXN][MAXN];

	void clean(int id)
	{
		for(int i=0;i<MAXN;i++)
			for(int j=0;j<MAXN;j++)
				m[i][j]=(i==j) ? id : 0; 
	}

	matriz operator * (matriz other)
	{
		matriz r;
		r.clean(0);

		for(int i=0;i<MAXN;i++)
			for(int j=0;j<MAXN;j++)
				for(int k=0;k<MAXN;k++)
				{
					r.m[i][j]+=m[i][k]*other.m[k][j];
					if(r.m[i][j]>MOD)	r.m[i][j]%=MOD;
				}	

		return r;
	}
};

matriz A,ID;

matriz fe(matriz a,long long int pot)
{
	if(pot==0)	return ID;
	if(pot==1)	return A;

	matriz aux;
	aux.clean(0);
	aux = fe(a,pot/2);
	aux = aux*aux;

	if(pot%2==0)	return aux;

	aux = aux*a;
	return aux;
}

void see(matriz a)
{
	printf("\n");
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)	printf("%lld ",a.m[i][j]);
		printf("\n");
	}
	printf("\n");
}

int main ()
{
	scanf("%d %lld",&n,&k);

	ID.clean(1);
	A.clean(0);

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			scanf("%lld",&A.m[i][j]);

	A=fe(A,k);

	for(int i=0;i<MAXN;i++)
		for(int j=0;j<MAXN;j++)
		{
			resp+=A.m[i][j];
			if(resp>MOD)	resp%=MOD;
		}

	printf("%lld\n",resp);
}

Measured memory_bytes: 10112
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long double n, m, d;
    cin >> n >> m >> d;
    if (d == 0) {
        cout << fixed<<setprecision(12)<<(m-1)*(1/n)  << endl;
    }
    else {
        cout << fixed<<setprecision(12)<<(m-1)*(2*(n-d)/(n*n)) << endl;
    }
}

Measured memory_bytes: 256
a, b, h, m = map(int, input().split())

import math

t = 60 * h + m
a_angle = t * (1/2)
b_angle = t * 6
diff_angle = abs(a_angle - b_angle)

x = a**2 +b**2 - 2 * a * b * math.cos(math.radians(diff_angle))


print(math.sqrt(x))

Measured memory_bytes: 9408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

	int K;
	string S;

	cin>>K;
	cin>>S;

	if(S.length() <= K)
		cout<<S<<endl;

	else
	{
		string res = "";

		for(int i = 0;i<K;i++)
			res = res + S[i];

		res = res + "...";

		cout<<res<<endl;
	}

	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const ll MOD = 998244353;

ll ex(ll x, ll e) {
	if (e == 0) {
		return 1;
	}
	if (e == 1) {
		return x;
	}
	ll y = ex(x, e / 2);
	if (e % 2 == 0) {
		return y * y % MOD;
	}
	return y * y % MOD * x % MOD;
}

int main() {
	#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	#endif
	ll n, a, b, k, wyn = 0;
	cin >> n >> a >> b >> k;
	vector<ll> npo(n + 1), fact(n + 1);
	fact[0] = 1;
	rep (i, 1, n + 1) {
		fact[i] = fact[i - 1] * i % MOD;
		DBG(i, fact[i]);
	}
	rep (i, 0, n + 1) {
		npo[i] = fact[n] * ex(fact[i] * fact[n - i] % MOD, MOD - 2) % MOD;
		DBG(npo[i], ex(fact[i] * fact[n - i] % MOD, MOD - 2));
	}
	rep (x, 0, n + 1) {
		if (k - a * x < 0 or (k - a * x) % b != 0) {
			continue;
		}
		ll y = (k - a * x) / b;
		if (y > n) {
			continue;
		}
		DBG(x, y);
		wyn = (wyn + npo[x] * npo[y]) % MOD;
	}
	cout << (wyn + MOD) % MOD;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

int main() {
    long long n, a = 0;
    cin >> n;
    vector<int> as(n);
    for (int i = 0; i < n; i++){
        cin >> as[i];
        if (as[i] % 2 == 0){
            if (as[i] % 3 == 0|| as[i] % 5 == 0){
                continue;
            }else{
                a++;
            }
        }
    }
    if (a > 0){
        cout << "DENIED" << endl;
    }else{
        cout << "APPROVED" << endl;
    }
}

Measured memory_bytes: 256
import sys

a = []
for line in sys.stdin:
    a.append(list(map(int,line.split())))
t = [0 for i in range(3)]
for i in range(len(a)):
    a[i].sort()
    if a[i][2] >= a[i][0] + a[i][1]:
        break
    b = a[i][2] ** 2
    c = a[i][0] ** 2 + a[i][1] ** 2
    if b > c:
        t[2] += 1
    elif b < c:
        t[1] += 1
    else:
        t[0] += 1
print("{0} {1} {2} {3}".format(sum(t), t[0], t[1], t[2]))



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  unordered_set<char> us;
  char c;
  rep(i, n) {
    cin >> c;
    if (us.find(c) == us.end()) us.emplace(c);
  }
  int cnt = us.size();
  string ans = "Three";
  if (cnt == 4) ans = "Four";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
using namespace std;
 
typedef long long ll;

int main(){
	ll n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
	int a, b, c;
  cin >> a >> b >> c;
 int ans = a + b + c;
  if(ans >=22) cout << "bust" << endl;
  else cout << "win" << endl;
}

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

const ll mod = 1000000007;

int main() {
    int N; cin >> N;
    string S1, S2; cin >> S1 >> S2;
    ll ans = 1;
    rep(i, N){
        if(i == 0){
            if(S1[i] == S2[i]){
                ans *= 3;
                ans %= mod;
            } else {
                ans *= 6;
                ans %= mod;
            }
        } else {
            if(S1[i] != S2[i] && S1[i-1] == S1[i]){
                continue;
            } else if(S1[i] != S2[i] && S1[i-1] != S2[i-1]){
                ans *= 3;
                ans %= mod;
            } else if(S1[i] != S2[i]){
                ans *= 2;
                ans %= mod;
            } else if(S1[i] == S2[i] && S1[i-1] == S2[i-1]){
                ans *= 2;
                ans %= mod;
            } else {
                continue;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;


int main() {
   long long  n , a , b;
   cin >> n >>a >> b;
   long long ans= (n/(a+b))*a;

   if(n%(a+b)<a)ans+=(n%(a+b));
   else ans+=a;
   
   cout<<ans<<endl;




}



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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    int res = 0;
    for (int i : h) {
        if (i >= K) res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
using namespace std;

int H,W;
int main (){
    cin >> H >> W;
    string C;
    for(int i=0; i<H; i++){
        cin >> C;
        for(int j=0; j<2; j++){
            cout << C << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

// {{{ Bitwise
#define F(name) \
    template<class T, typename enable_if<is_integral<T>::value>::type* = nullptr> \
    constexpr int name(T x) { return sizeof(T) <= sizeof(int) ? __builtin_ ## name(x) : __builtin_ ## name ## ll(x); }

F(clz) F(ctz) F(ffs) F(parity) F(popcount)

#undef F
#define popcnt popcount

template<class T>
T has_bit(T x, int i) { return (x >> i) & 1; }

template<class T>
constexpr int lg2(T x) { return sizeof(T) * CHAR_BIT - 1 - clz(x); }
// }}}
inline int two( int x ) { return 1<<x; }

const int N=2e5+10;
int n,dp[1<<26];
char s[N];
void main() {
    memset(dp,0x3F,sizeof(dp));
    R(s);
    n=strlen(s);
    int x=0;
    REP(i,n) {
        x^=two(s[i]-'a');
        if ( popcnt(x)<=1 ) {
            chkmin(dp[x],1);
        } else {
            int mi=INT_MAX;
            chkmin(mi,dp[x]);
            REP(j,26) chkmin(mi,dp[x^two(j)]);
            chkmin(dp[x],mi+1);
        }
    }
    W(dp[x]);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 262528
q = int(input())

lr = [list(map(int, input().split())) for _ in range(q)]

def primes(n):
    # 1であれば素数であるリスト
    primes = [1] * (n+1)
    primes[0] = 0
    primes[1] = 0

    for i in range(2, int(n**0.5) + 1):
        if not primes[i]:
            continue
        for j in range(i * 2, n + 1, i):
            primes[j] = 0
    return primes

MAX = 100000
prime_list = primes(MAX)

# 2017に似た数値かどうかを求めるための累積和用のリスト作成
ans_list = [0] * (MAX + 1)
now = 0
for i in range(MAX):
    if prime_list[i] == 1 and prime_list[(i+1)//2] == 1:
        now += 1
    ans_list[i+1] = now

for i in range(q):
    print(ans_list[lr[i][1]+1] - ans_list[lr[i][0]])

Measured memory_bytes: 29824
#include<iostream>

using namespace std;

int main(){
  int in;
  while(cin >> in){
    if(in == 0) break;
    int ohajiki = 32;

    int data[in];
    for(int i = 0; i < in; i++){
      cin >> data[i];
    }

    int j = 0;

    while(1){
      ohajiki -= (ohajiki-1) % 5;
      if(ohajiki <= 0) break;
      cout << ohajiki << endl;
      ohajiki -= data[j];
      if(ohajiki <= 0) break;
      cout << ohajiki <<endl;
      j++;
      if(j == in) j = 0;
    }
    cout << "0" << endl; 
  }

  return 0;
}

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

int main() {
    int h, n;
    cin >> h >> n;
    vector<vector<ll>> dp(n+1, vector<ll>(h+1, INF));
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    dp[0][0] = 0;
    rep(i,n){
        rep(j,h+1){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            int mn = min(h, j+a[i]);
            dp[i+1][mn] = min(dp[i+1][mn], dp[i+1][j]+b[i]);
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  cpp_int res = 1;
  vector<cpp_int> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  sort(all(a));
  if (a[0] == 0) {
    cout << 0 << endl;
    return 0;
  }
  rep(i,n) {
    res *= a[i];
    if (res > 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6476
#include <iostream>
#include <cstdio>


constexpr int MAXN = 250;
int Heap[MAXN + 1];

int parent(int i) {return i / 2;}
int left(int i) {return i * 2;}
int right(int i) {return i * 2 + 1;}

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
int n;

void ShowHeap(int* Heap) {
    FOR(i, 1, n + 1) {
        std::printf("node %d: key = %d, ", i, Heap[i]);
        if (parent(i)) std::printf("parent key = %d, ", Heap[parent(i)]);
        if (left(i) <= n) std::printf("left key = %d, ", Heap[left(i)]);
        if (right(i) <= n) std::printf("right key = %d, ", Heap[right(i)]);
        std::cout << std::endl;
    }
}


int main() {
    std::cin >> n;
    FOR(i, 0, n) std::cin >> Heap[i + 1];
    ShowHeap(Heap);
}


Measured memory_bytes: 3236
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    reverse(all(H));

    int m, ans;
    m = ans = 0;
    for (int i = 0; i < N-1; i++) {
        if (H[i] <= H[i+1]) ans++;
        else {
            if (ans > m) m = ans;
            ans = 0;
        }
    }

    cout << max(m, ans) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long n;
int ans=0;
void calc(long long x){
	long long a=n;
	while(a%x==0){
		a/=x;
	}
	if(a%x==1){
		ans++;
	}
}
int main(){
	cin>>n;
	for(int i=1;(long long)i*i<n;++i){
		if((n-1)%i==0){
			if(i>1){
				ans++;
			}
			if((n-1)/i!=i){
				ans++;
			}
		}
	}
	for(int i=1;(long long)i*i<=n;++i){
		if(n%i==0){
			if(i>1){
				calc(i);
			}
			if(i!=n/i){
				calc(n/i);
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll a,b;
	cin>>a>>b;

	cout << a * b;


#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


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

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

    int takahashi, aoki;
    if (a%d==0){
        takahashi = a / d;
    } else {
        takahashi = a / d + 1;
    }
    if (c%b==0) {
        aoki = c / b;
    } else {
        aoki = c / b + 1;
    }

    if (takahashi>=aoki) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli a, b, n;
	cin >> a >> b >> n;
	lli t = Min(n, b-1);
	lli ans = (a*t)/b - a*(t/b);
	cout << ans << endl;
	return 0;
}

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

int main() {
  // 入力
  int N, K;
  cin >> N >> K;
  string p[N];
  for (int i = 0; i < N; i++) cin >> p[i];

  int cnt[26];
  fill(cnt, cnt + 26, 0);
  for (int i = 0; i < N; i++) cnt[p[i][0]-'A']++;

  int ans = 0;
  while (1) {
    sort(cnt, cnt + 26);
    int i;
    for (i = 25; i >= 0; i--) {
      if (cnt[i] == 0 || i == 26 - K - 1) break;
      cnt[i]--;
    }
    if (i > 26 - K - 1) break;

    ans++;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define endl '\n'
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long 
using namespace std;
const int N = 1e5+10;
const int M = 1e9+7;

int main(){
	FIO;
	int n , we;
	cin >> n >> we;
	int w[n+1],val[n+1];
	for (int i = 1; i <= n; ++i)
	{
		cin >> w[i] >> val[i];
	}
	long long  dp[n+1][we+1];
	memset(dp,0,sizeof(dp));
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <= we; ++j)
		{
			if(i == 0 || j == 0)
				dp[i][j] = 0; 
			else if(j >= w[i])
				dp[i][j] = max(dp[i-1][j],val[i] + dp[i-1][j-w[i]]);
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	// for (int i = 1; i <= n; ++i)
	// {
	// 	for (int j = 0; j <= we; ++j)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }

	cout << dp[n][we] << " ";
}

Measured memory_bytes: 79232
#include<stdio.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int a[30];

void f(int d, int b, int n)
{
    int i;
    if(!n)for(i = 0; i != d; i++) printf("%d%c", a[i], i + 1 == d ? '\n' : ' ');
    for(i = MIN(b, n); i; i--) a[d] = i, f(d + 1, i, n - i);
}

int main(void)
{
    int n;
    while(1){
        scanf("%d", &n);
        if(!n) return 0;
        f(0, n, n);
    }
}

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

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

    vector<int> A(N);
    vector<ll> sum(N + 2);
    rep(i, N) {
        cin >> A[i];
        sum[i + 1] = A[i];
        sum[i + 1] += sum[i];
    }
    sum[N + 1] = __LONG_LONG_MAX__;

    ll ans = __LONG_LONG_MAX__;
    for (int i = 0; i < N; i++) {
        if (i < 2) continue;
        if (i > N - 1) continue;
        
        ll X = sum[i];
        int l = 0;
        int r = i + 1;
        while (r - l >= 1) {
            int mid = (r + l) / 2;
            if (2 * sum[mid] >= X) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }

        // r, r - 1が候補
        ll P, Q;
        ll p1 = sum[r]; ll q1 = X - p1;
        ll p2 = sum[r - 1]; ll q2 = X - p2;
        if (abs(q1 - p1) > abs(q2 - p2)) {
            P = p2; Q = q2;
        } else {
            P = p1; Q = q1;
        }

        ll Y = sum[N] - sum[i];
        l = i + 1;
        r = N + 1;
        while (r - l >= 1) {
            int mid = (r + l) / 2;
            if (2 * (sum[mid] - sum[i]) >= Y) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }

        ll R, S;
        ll r1 = sum[r] - sum[i]; ll s1 = Y - r1;
        ll r2 = sum[r - 1] - sum[i]; ll s2 = Y - r2;
        if (abs(s1 - r1) > abs(s2 - r2)) {
            R = r2; S = s2;
        } else {
            R = r1; S = s1;
        }

        ans = min(ans, max(P, max(Q, max(R, S))) - min(P, min(Q, min(R, S))));
    }

    cout << ans << endl;
}

Measured memory_bytes: 5556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  if (2 * c < a && 2 * c < b) {
    cout << 2 * c * max(x, y) << endl;
    return 0;
  }
  int pay = 0;
  if (2 * c < a + b) {
    int m = min(x, y);
    pay += 2 * c * m;
    x -= m;
    y -= m;
  }
  if (x) {
    pay += x * min(2 * c, a);
  }
  if (y) {
    pay += y * min(2 * c, b);
  }

  cout << pay << endl;
  return 0;
}



Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }

    let mut sum = 0;
    for i in 1..n {
        if a[i] < a[i - 1] {
            sum += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }

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


Measured memory_bytes: 5620
import heapq

h, w = map(int, input().split())
i0, j0 = map(lambda x: int(x) - 1, input().split())
i1, j1 = map(lambda x: int(x) - 1, input().split())
S = [input() for i in range(h)]
inf = 10**10
D = [[inf] * w for i in range(h)]
D[i0][j0] = 0
Q = [(0, (i0, j0))]
heapq.heapify(Q)
while Q:
    _, (i, j) = heapq.heappop(Q)
    for di in range(-2, 3):
        for dj in range(-2, 3):
            ii, jj = i + di, j + dj
            if 0 <= ii < h and 0 <= jj < w and S[ii][jj] == ".":
                nex = int(abs(di) + abs(dj) != 1)
                if D[i][j] + nex < D[ii][jj]:
                    D[ii][jj] = D[i][j] + nex
                    heapq.heappush(Q, (D[ii][jj], (ii, jj)))
if D[i1][j1] >= inf:
    print(-1)
else:
    print(D[i1][j1])


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

int main()
{
    int n;
    int a[200000];
    bool dp[1000001];
    for (int i = 0; i < 1000001; i++) {
        dp[i] = true;
    }

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int amax = a[n - 1];

    for (int i = 0; i < n; i++) {
        for (int j = 2; a[i] * j <= amax; j++)
            dp[a[i] * j] = false;
        if (i < n - 1 && a[i] == a[i + 1])
            dp[a[i]] = false;
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (dp[a[i]]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 5324
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    x,k,d = map(int, input().split())

    x = abs(x)
    if x > k*d:
        print(x-k*d)
    else:
        tmp = k - x//d
        if tmp%2 ==0:
            print(abs(x-x//d*d))
        else:
            print(abs(x-(x//d+1)*d))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62700
n, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - a[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - a[i][0]] + a[i][1])
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][w])


Measured memory_bytes: 121068
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <limits>
using namespace std;

double inf = numeric_limits<double>::infinity();

int a[100001];

int main() {
    int n, m;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> m;
        a[m]++;
    }
    
    int odd = 0, even = 0;
    
    for (int i = 0; i < 100001; i++) {
        if (a[i]) {
            if (a[i] % 2 == 0) {
                even++;
            } else {
                odd++;
            }
        }
    }
    
    if (even % 2 == 0) {
        cout << odd + even << endl;
    } else {
        cout << odd + even - 1 << endl;
    }
}

Measured memory_bytes: 640
#include <stdio.h>

	int N,M,x[100000],y[100000];
	int c[100000],r[100000];
	int i,ans;
	int j;


int main(void){
	scanf("%d %d",&N,&M);

	for(i=0;i<M;i++){
		scanf("%d %d",&x[i],&y[i]);
	}

	for(i=0;i<N;i++){
		c[i] = 1;
		r[i] = 0;
	}
	r[0]= 1;

	for(i=0;i<M;i++){

		if(r[x[i]-1] == 1){
			r[y[i]-1] = 1;
			if(c[x[i]-1]==1){
				r[x[i]-1]=0;
			}
		}
		c[x[i]-1]--;
		c[y[i]-1]++;
	}

	ans=0;
	for(i=0;i<N;i++){

		if(r[i]==1){ans++;}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
import bisect
from collections import defaultdict as dd
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
N = int(input())
f = factorize(N)
dic=dd(int)
for val in f:
    if val!=1:
        dic[val] += 1
res = 0
ls = [1,3,6,10,15,21,28,36,45,55,66]
for val in dic.values():
    tmp = bisect.bisect_right(ls,val)
    res += tmp
print(res)



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

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

typedef long long ll;
using namespace std;

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

  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if (M1 != M2) {
    cout << '1' << endl;
  } else {
    cout << '0' << endl;
  }

  return 0;
}


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

int main(){
    long long N, K;
    long long c = 0;
    scanf("%lld%lld", &N, &K);
    if(K == 0){
        c = N*N;
    }
    else{
        for(int i = K; i <= N; i++){
            c += ((N+1)/i)*(i-K);
            if((N+1)%i >= K){
                c += (N+1)%i - K;
            }
        }
    }
    printf("%lld\n",c);
    return 0;
}


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

if N > M:
    print(0)
    exit(0)

gap = []
for i in range(M-1):
    gap.append(X[i+1] - X[i])

gap.sort()
gap.reverse()
t = sum(gap)
for i in range(N-1):
    t -= gap[i]

print(t)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 2;i < (n);i++)
using namespace std;

int main(){
    int x;
    cin >> x;
    while(1){
        bool ok = true;
        rep(i,x){
            if(x%i == 0){
                ok = false;
            }
        }
        if(ok) break;
        x++;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Text;

public class Program{
    public static void Main(){
        var watch = new Stopwatch();
        watch.Start();
        var isTest = false;
        var stream = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
        Console.SetOut(stream);
        TextReader reader;
        string filename="";
        
        if(filename.Length!=0){
            reader = new StreamReader(filename);
        }else{
            reader = Console.In;
        }

        var n = int.Parse(reader.ReadLine());
        var a = reader.ReadLine().Split().Select(int.Parse).ToArray();
        var cnt = 0;
        var abure = 0;
        bool[] bls = new bool[8];
        foreach (var x in a){
            if(x<=399){
                if(bls[0]==false)bls[0]=true;
            }else if(x<=799){
                if(bls[1]==false)bls[1]=true;
            }else if(x<=1199){
                if(bls[2]==false)bls[2]=true;
            }else if(x<=1599){
                if(bls[3]==false)bls[3]=true;
            }else if(x<=1999){
                if(bls[4]==false)bls[4]=true;
            }else if(x<=2399){
                if(bls[5]==false)bls[5]=true;
            }else if(x<=2799){
                if(bls[6]==false)bls[6]=true;
            }else if(x<=3199){
                if(bls[7]==false)bls[7]=true;
            }else abure++;
        }
        cnt = bls.Count(b=>b==true);
        //愚直に取ったぶんがcntで最小値
        //3200以上のものはcntと足して最大値が8
        //と思ったけど全員が3200以上のときは一種類にできるので
        //なぜかコケた
        Console.WriteLine($"{cnt==0 ? 1 : cnt} {cnt+abure}");
        watch.Stop();
        if(isTest){
            Console.WriteLine($"実行時間{watch.ElapsedMilliseconds}ミリ秒");
        }
        Console.Out.Flush();
    }
}


Measured memory_bytes: 13396
mod = 10 ** 9 + 7
kkai = [1]
for i in range(1, 3 * 10 ** 5):
    kkai.append(kkai[-1] * i % mod)


def kai(x, p=mod):
    return kkai[x]


def comb(a, b, p=mod):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = 1
    c *= kai(a, p)
    c *= pow(kai(b, p), p - 2, p)
    c *= pow(kai(a - b, p), p - 2, p)
    return c % p


n, m, k = [int(i) for i in input().split()]

ans = 0
for i in range(1, n):
    ans += (n - i) * i * comb(n * m - 2, k - 2) * m ** 2
    ans %= mod
for i in range(1, m):
    ans += (m - i) * i * comb(n * m - 2, k - 2) * n ** 2
    ans %= mod
print(ans)


Measured memory_bytes: 58864
#include <stdio.h>
#include <iostream>
using namespace std;

#define N_MAX 100
#define W_MAX 10000

int v_i[N_MAX + 1];
int w_i[N_MAX + 1];
int dp[N_MAX + 1][W_MAX + 1];

int main(void){
    int N, W;
    scanf("%d %d", &N, &W);

    for(int i = 1; i <= N; i++){
        scanf("%d %d", &v_i[i], &w_i[i]);
    }

    for(int i = 0; i <= N; i++){
        dp[i][0] = 0;
    }
    for(int j = 0; j <= W; j++){
        dp[0][j] = 0;
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= W; j++){
            if(j - w_i[i] < 0){
                dp[i][j] = dp[i - 1][j];
            }else{
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w_i[i]] + v_i[i]);
            }
        }
    }

    printf("%d\n", dp[N][W]);
}



Measured memory_bytes: 7140
/* SmartCoder Apr 7, 2019 */
#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end();i++)
#define present(c,x)  ( (c).find(x) !=(c).end())
#define cpresent(c,x) (find(all(c),x)!= (c).end() )
#define minei(x)  min_element(x.begin(),x.end())-(x).begin()
#define maxei(x)  max_element(x.begin(),x.end())-(x).begin()

#define uns(v)     sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define acusum(x)  accumulate(x.begin(),x.end(),0)
#define acumul(x)  accumulate(x.begin(),x.end(),1, multiplies<int>());
#define bits(x)     __builtin_popcount( x )
#define oo INT_MAX
#define inf 1000000000

const double pi = acos(-1.0);
const double eps = 1e-11;
#define MAXN 100007
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
void fastIO() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll W[MAXN], V[MAXN];
ll dp[2][MAXN];
void copyOver(int r) {
	for (int i = 0; i < MAXN; i++) {
		dp[r % 2][i] = dp[1 - (r % 2)][i];
	}
}
int main() {
	fastIO();
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++) {
		cin >> W[i] >> V[i];
	}
	for (int i = 0; i <= MAXN; i++) {
		dp[0][i] = dp[1][i] = -1;
	}
	dp[1][0] = 0;
	for (int i = 0; i < n; i++) {
		copyOver(i);
		for (int j = MAXN - 1; j >= 0; j--) {
			if (dp[i % 2][j] == -1 || V[i] + j >= MAXN || W[i] + dp[i % 2][j] > w)
				continue;
			if (dp[i % 2][j + V[i]] == -1)
				dp[i % 2][j + V[i]] = W[i] + dp[i % 2][j];
			else
				dp[i % 2][j + V[i]] = min(dp[i % 2][j + V[i]], W[i] + dp[i % 2][j]);
		}
	}
	for (int i = MAXN - 1; i >= 0; i--) {
		if (dp[(n - 1) % 2][i] != -1) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


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

//??????????????????????????????
void show_array(int a[],int n){
  for(int i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
}

void insertionSort(int a[],int n){
  for(int i=1;i<n;i++){
    int temp=a[i],j=i-1;
    while(j>=0 && a[j]>temp){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=temp;
    show_array(a,n);
  }
}

int main(){
  int n;
  scanf("%d",&n);
  int num_list[n];
  for(int i=0;i<n;i++){
    scanf("%d",&num_list[i]);
  }
  show_array(num_list,n);
  insertionSort(num_list,n);
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define For(i,n) for(int i=0;i<n;i++)
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define MAXN 1000001

int a[MAXN], b[MAXN];
int dp[MAXN];
int fen[MAXN];
int n;
void update(int i, int add)
{
	while (i <= n)
	{
		fen[i] = max(fen[i], add);
		i = i + (i & (-i));
	}
}

int query(int i)
{
	int s = 0;
	while (i > 0)
	{
		s = max(s, fen[i]);
		i = i - (i & (-i));
	}
	return s;
}
int32_t main()
{


	cin >> n;

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

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

	for (int i = 0; i < n; i++)
	{
		dp[i] = query(a[i] - 1) + b[i];
		update(a[i], dp[i]);
		//cout << query(a[i] - 1) << " ";
		// for (int j = 0; j < i; j++) {

		// 	if (a[i] > a[j])
		// 		dp[i] = max(dp[i], b[i] + dp[j]);
		// }
	}
	cout << *max_element(dp, dp + n);

}

Measured memory_bytes: 14080
def main():
    sx,sy,tx,ty = map(int,input().split())

    root = ""

    # first
    for n in range(tx - sx):
        root += "R"
    for n in range(ty - sy):
        root += "U"

    # first back
    for n in range(tx - sx):
        root += "L"
    for n in range(ty - sy):
        root += "D"

    # first
    root += "D"
    for n in range(tx - sx + 1):
        root += "R"
    for n in range(ty - sy + 1):
        root += "U"
    root += "L"

    # first back
    root += "U"
    for n in range(tx - sx + 1):
        root += "L"
    for n in range(ty - sy + 1):
        root += "D"
    root += "R"

    print(root)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
//ベルマンフォード法(負の閉路の検出)
//AOJ GRL_1_B
#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repr(i,a,b) for(int i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int,int> P;
const int INF=1<<29;

//辺についての情報を3つ持たせておく
struct edge{int from,to,cost;};
edge es[100010];//辺の隣接リスト表示
int d[10010];//各頂点への最短距離
int N,E;//Nは頂点数、Eは辺の数

//負の経路が存在するかもbool値で返す
bool bellman_ford(int s){
    //まず各頂点への最短距離をINFに初期化
    rep(i,0,N)d[i]=INF;
    //開始地点を0に設定
    d[s]=0;
    int cnt=0;
    while(1){
        cnt++;
        bool update=false;//更新があるかどうか
        rep(i,0,E){
            edge e=es[i];
            if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                update=true;
            }
        }
        //N回目も更新があるなら負の経路が存在する
        if(cnt==N-1){
            return true;
        }
        //辺の更新が起こらなくなったら終わり
        if(!update)break;
    }
    return false;
}

int main(){
    int r;
    cin>>N>>E>>r;
    
    rep(i,0,E){
        int a,b,c;
        cin>>a>>b>>c;
        es[i]={a,b,c};
    }
    
    if(bellman_ford(r)){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    
    rep(i,0,N){
        if(d[i]==INF)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
    
    return 0;
}


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

int main() {
    //
    int num;
    int Max = 0;
    int sum = 0;

    cin >> num;

    for (int i = 0; i < num; i++) {
        int tmp;
        cin >> tmp;
        Max = max(Max, tmp);
        sum += tmp;
    }

    sum -= Max;
    if (Max < sum) cout << "Yes";
    else cout << "No";
    //
}


Measured memory_bytes: 3640