akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

template<class T>
vector<pair<T, T>> PrimeFactorization(T n) {
    vector<pair<T, T>> f;
    for (T i = 2; i * i <= n; i++) {
        T cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) f.push_back(make_pair(i, cnt));
    }
    if (n != 1) f.push_back(make_pair(n, 1));
    return f;
}

class Combination {
   public:
    Combination(int n) {
        fac = new ll[n];
        inv = new ll[n];
        finv = new ll[n];
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        REP(i, 2, n) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

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

   private:
    ll *fac, *inv, *finv;
};

int main() {
    int N, M; cin >> N >> M;
    auto factors = PrimeFactorization(M);
    int maximum = 0;
    for (auto f : factors) maximum = max(maximum, f.second);
    Combination comb(maximum + N);

    ll ans = 1;
    for (auto f : factors) {
        if (f.second == 0) continue;
        ans = ans * comb.cnr(f.second + N - 1, N - 1) % MOD;
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans = 999;
  for(int i = 0; i < s.size()-2; i++){
    int x;
    x = (s[i] - '0') *100 + (s[i+1] - '0') * 10 +(s[i+2] - '0');
    int sa = max(x - 753,753 - x);
    ans = min(ans,sa);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
///////////////////////////

int main(){fastio
    ll n;cin>>n;
    string s;cin>>s;
    s='a'+s;
    string dmc="DMC";
    ll q;cin>>q;
    while(q--){
        ll k;cin>>k;
        ll dp[n+1][4];memset(dp,0,sizeof(dp));
        rep(i,1,n){
            rep(j,0,3)dp[i][j]=dp[i-1][j];
            if(i-k>=0){
                if(s[i-k]=='D'){
                    dp[i][0]--;
                    dp[i][2]-=dp[i-1][1]-dp[i-k][1];
                }else if(s[i-k]=='M'){
                    //dp[i][1]--;
                }
            }
            if(s[i]=='D'){
                dp[i][0]++;
            }else if(s[i]=='M'){
                dp[i][1]++;
                dp[i][2]+=dp[i][0];
            }else if(s[i]=='C'){
                dp[i][3]+=dp[i][2];
            }
        }
        /*
        rep(j,0,3){
            rep(i,0,n){
                cout<<dp[i][j]<<" ";
            }cout<<endl;
        }*/
        cout<<dp[n][3]<<endl;
    }
    return 0;
}


Measured memory_bytes: 32584
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

bool is_eempty(str a, str b, str c)
{
	if (a.empty() || b.empty() || c.empty())
		return true;
	else
		return false;
}

int main()
{
	int n = 3;
	vector<str> v(n);
	rep(i, n) cin >> v[i];
	vector<int> vv(n, 0);
	int ttt = 0;
	while (true)
	{
		if (v[ttt].size() == vv[ttt])
		{
			cout << (char)(ttt + 65) << endl;
			return 0;
		}
		int tmp = v[ttt][vv[ttt]++] - 97;
		ttt = tmp;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)


n = int(input())
res = num2alpha(n)
print(res.lower())

Measured memory_bytes: 61588
#include <iostream>
using namespace std;
int a,cou,sum,now;

void dfs(int now){
  if(now==a)cou++;
  if(now+1<=a){
    dfs(now+1);
  }
  if(now+2<=a){
    dfs(now+2);
  }
  if(now+3<=a){
    dfs(now+3);
  }
}

int main(){
  while(1){
    cin >> a;
    if(a==0)break;
    cou=0;
    now=0;
    dfs(now);
    if(cou%10!=0)cou=cou/10+1;
    else cou=cou/10;
    if(cou%365!=0)cou=cou/365+1;
    else cou=cou/365;
    cout <<cou<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
  int hp, total, n, i;
  scanf("%d %d", &hp, &n);
  int attack;
  
  for(i=0; i<n; i++){
    scanf("%d", &attack);
    total += attack;
    if(hp <= total){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  
  return 0;
  
}

Measured memory_bytes: 128
import sys,fractions
a = input()
n = len(a)
t = []
ans = [0] * n
cnt = 0
tmp = a[0]
for i in range(n):
    if a[i] == tmp:
       cnt += 1 
    else:
        t.append(cnt)
        tmp = a[i]
        cnt = 1
t.append(cnt)
N = len(t)
len = 0
for i in range(N)[::2]:
    tmp_len = t[i] + t[i+1]
    #R
    ans[len + t[i] - 1] += int((t[i]+1)/2)
    ans[len + t[i]] += int(t[i]/2)
    #L
    ans[len + t[i] - 1] += int(t[i+1]/2)
    ans[len + t[i]] += int((t[i+1]+1)/2)
    len += tmp_len
L = [str(i) for i in ans]
print(" ".join(L))

Measured memory_bytes: 13752
import sys
sys.setrecursionlimit(10**5)
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
dp=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)

def dfs(s):
  if edge[s]:
    for i in edge[s]:
      if dp[i]:dp[s]=max(dp[s],dp[i]+1)
      else:dp[s]=max(dp[s],dfs(i)+1)
    return dp[s]
  else:return 0
for i in range(n):
  dfs(i)
print(max(dp))

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

int main(){
    long long x;
    cin >> x;
    long long ans = (x / 11) * 2;
    x %= 11;
    if(x){
        if(x <= 6) ans += 1;
            else ans += 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return len(divisors)

N = int(input())
ctr = 0

for i in range(1, N + 1, 2):
    if make_divisors(i) == 8:
        ctr += 1
print(ctr)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b;
    cin >> a >> b;
    (a += 11)%=13;
    (b += 11)%=13;
    string ans = "Alice";
    if (a<b) ans = "Bob";
    else if (a==b) ans = "Draw";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
typedef pair<int,int> ii;
int n;
ii a[200005], V[200005];
ii m_X[200005], m_V[200005];
int dp[200005];
int fw[200005];
void up(int x, int v){
    x++;
    while (x <= 200000){
        fw[x] += v;
        if (fw[x] >= mod) fw[x] -= mod;
        x += x&-x;
    }
}
int sum(int x){
    x++;
    int ret = 0;
    while (x){
        ret += fw[x];
        if (ret >= mod) ret -= mod;
        x -= x&-x;
    }
    return ret;
}
bool cmp(ii a, ii b){
    return (a.second == b.second) ? a.first < b.first : a.second < b.second;
}
int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%d%d",&a[i].first,&a[i].second);
        m_X[i] = ii(a[i].first,i);
        m_V[i] = ii(a[i].second,i);
    }
    sort(m_X,m_X+n);
    sort(m_V,m_V+n);
    for (int i = 0; i < n; i++){
        a[m_X[i].second].first = i;
        a[m_V[i].second].second = i;
    }
    sort(a,a+n);
    //for (int i = 0; i < n; i++) printf("%d %d\n",a[i].first,a[i].second);
    int MX = a[0].second;
    for (int i = 0; i < n; i++){
        V[a[i].second].second = MX = max(MX,a[i].second);
        //printf("considering first %d elements, R[%d] is %d\n",i+1,a[i].second,MX);
        //printf("%d %d\n",a[i].first,a[i].second);
    }
    MX = a[n-1].second;
    for (int i = n-1; i >= 0; i--){
        V[a[i].second].first = MX = min(MX,a[i].second);
        //printf("considering last %d elements, L[%d] is %d\n",i+1,a[i].second,MX);
        //printf("%d %d\n",a[i].first,a[i].second);
    }
    sort(V,V+n,cmp);
    int ans = 0;
    for (int i = n-1; i >= 0; i--){
        if (V[i].second == n-1) dp[i]++;
        dp[i] += sum(V[i].second+1);
        if (dp[i] >= mod) dp[i] -= mod;
        //printf("%d %d %d\n",V[i].first,V[i].second,dp[i]);
        up(V[i].first,dp[i]);
        if (V[i].first == 0) {
            ans += dp[i];
            if (ans >= mod) ans -= mod;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 8064
import sys
Q = int(input())
input = sys.stdin.readline


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


M = [0] * (10**5+1)
for i in range(2, 10**5+1):
    M[i] = M[i-1]
    if len(prime_factorize(i)) == 1 and len(prime_factorize((i+1)//2)) == 1:
        M[i] += 1

for q in range(Q):
    l, r = list(map(int, input().split()))
    print(M[r] - M[l-1])


Measured memory_bytes: 55644
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

signed main() {
    capi(n);
    cout << setprecision(12) << (double)((n + 1) / 2) / (double)(n);

    return 0;
}


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

using namespace std;
#define intMax 2147483647
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repp(i, a, b) for (int i = a; i >= b; i--)
#define be(a) (a.begin(), a.end())
#define rbe(p) (p.rbegin(), p.rend())
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> A;
    rep(i, 0, n)
    {
        int a;
        cin >> a;
        A.pb(a);
    }
    int ans = 0, moves = 0;
    rep(i, 0, n - 1)
    {
        if (A[i + 1] <= A[i])
        {
            moves++;
        }
        else{
            moves = 0;
        }
        ans = max(ans,moves);
    }
    cout << ans;
}

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

typedef long long ll;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)


int main() {
    int n;
    cin >> n;
    vector<int> a(3 * n);
    rep(i, 3 * n) scanf("%d", &a[i]);

    vector<ll> L(3 * n), R(3 * n);
    priority_queue<int, vector<int>, greater<int>> small;
    ll tot = 0;
    rep(i, 3 * n) {
        tot += a[i];
        small.push(a[i]);
        if (i >= n) {
            tot -= small.top();
            small.pop();
        }
        L[i] = tot;
    }

    priority_queue<int> big;
    tot = 0;
    for (int i = 3 * n - 1; i >= 0; i--) {
        tot += a[i];
        big.push(a[i]);
        if (i < 2 * n) {
            tot -= big.top();
            big.pop();
        }
        R[i] = tot;
    }


    ll res = -1145141919810893;
    FOR(i, n - 1, 2 * n) {
        res = max(res, L[i] - R[i + 1]);
    }

    cout << res << endl;

    //for (auto&& i : R) {
    //    cout << i << endl;
    //}

    return 0;
}

Measured memory_bytes: 7288
from math import gcd

k=int(input())

kij=dict()

for i in range(1,k+1):
    for j in range(1,k+1):
        gij=gcd(i,j)
        if gij in kij:
            kij[gij]=kij[gij]+1
        else:
            kij[gij]=1

isum=0
for kk in kij.items():
    for m in range(1,k+1):
        isum=isum+gcd(m,kk[0])*kk[1]

print(isum)        
    

Measured memory_bytes: 9208
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	s := getNextString(scanner)
	seg := newSegment(n)
	for i := 0; i < n; i++ {
		seg.update(i, 1<<uint(s[i]-'a'))
	}
	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		switch getNextInt(scanner) {
		case 1:
			seg.update(getNextInt(scanner)-1, 1<<uint(getNextString(scanner)[0]-'a'))
		case 2:
			fmt.Fprintln(writer, pcount(seg.get(getNextInt(scanner)-1, getNextInt(scanner))))
		}
	}
}
func pcount(x uint32) int {
	ans := 0
	for x > 0 {
		ans += int(x % 2)
		x >>= 1
	}
	return ans
}

type segment [][]uint32

func newSegment(n int) segment {
	seg := make(segment, 0)
	for n > 1 {
		seg = append(seg, make([]uint32, n))
		n = (n + 1) >> 1
	}
	seg = append(seg, make([]uint32, 1))
	return seg
}
func (seg segment) choosemin(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func (seg segment) update(i int, x uint32) {
	seg[0][i] = x
	for h := 1; h < len(seg); h++ {
		i >>= 1
		seg[h][i] = seg[h-1][i<<1] | seg[h-1][seg.choosemin(i<<1+1, len(seg[h-1])-1)]
	}
}
func (seg segment) get(l, r int) uint32 {
	s := seg[0][l]
	for h := 0; h < len(seg) && l < r; h++ {
		if l%2 == 1 {
			s = s | seg[h][l]
			l++
		}
		l >>= 1
		if r%2 == 1 {
			s = s | seg[h][r-1]
		}
		r >>= 1
	}
	return s
}


Measured memory_bytes: 7752
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cmath>

typedef long long ll;

int main() {
	int n;
	ll l = 1;
	std::cin >> n;
	while (l <= n) {
		l *= 2;
	}
	std::cout << l/2 << std::endl;
}

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

class P
{
public:
	int first, second;
	P(int a = 0, int b = 0):first(a),second(b){}

	bool operator < (const P &ano)const{
		return first > ano.first;
	}

};

int n,m;

void solve()
{
	vector<P> vec(n);
	int res = 0;

	for(int i = 0; i < n; i++){
		cin >> vec[i].second >> vec[i].first;
	}

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

	for(int i = 0; i < n; i++){
		while(m > 0 && vec[i].second > 0){
			m--;
			vec[i].second--;
		}

		res += vec[i].first * vec[i].second;
	}
	cout << res << endl;
}
	
		


int main(void)
{
	while(cin >> n >> m, n | m)
		solve();
	return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include <string>
#include<vector>

using namespace std;

int main(){

	int a, b, c;
	cin >> a >> b >> c;
	if(a==5 && b==5 && c==7){
		cout << "YES" << endl;
	}
	else if(a==5 && b==7 && c==5){
		cout << "YES" << endl;
	}
	else if(a==7 && b==5 && c==5){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" <<endl;
	}
	return 0;


}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin >> s >> t;
	sort(all(s));
	sort(t.rbegin(),t.rend());
	cout << (s < t ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    stack < char > st;
    int ans = 0;
    string s;
    cin >> s;
    st.push(s[0]);
    for (int i = 1; i < s.size(); i++) {
        if (st.empty()) st.push(s[i]);
            else
        if (st.top() != s[i]) {
            st.pop();
            ans += 2;
        }
        else {
            st.push(s[i]);
        }
    }
    cout << ans;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

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

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

    int count = 0;
    for (int i = 1; i < n - 1; i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1] || p[i - 1] > p[i] && p[i] > p[i + 1]) {
            count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
N,M=map(int, input().split())
inlist=[list(map(int, input().split())) for _ in range(N)]

res=0
for i in [1, -1]:
    for j in [1, -1]:
        for k in [1, -1]:
            res = max(res, sum(list(reversed(sorted(map(lambda x: i*x[0] + j*x[1] + k*x[2], inlist))))[:M]))
print(res)


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

int main(){
  int x , n ;
  cin >> x >> n ;
  int ans1 = 1200;
  int ans2 = 1200;
  bool hantei1 = true;
  bool hantei2 = true;
  vector<int> a(120);
  for(int i=0;i<n;i++) cin >> a[i];
  
  for(int i=0;i<120;i++){
    hantei1 = true;
    for(int j=0;j<n;j++){
      if((x-i)==a[j]){
        hantei1 = false;
        break;
      }
    }
      if(hantei1) {
        ans1 = x-i;
        break;
      }
    }
  
    for(int i=0;i<120;i++){
      hantei2 = true;
    for(int j=0;j<n;j++){
      if((x+i)==a[j]){
        hantei2 = false;
        break;
      }
    }
      if(hantei2) {
        ans2 = x+i;
        break;
      }
    }
  
  if(abs(ans1-x)<=(ans2-x)) cout << ans1 << endl;
  else cout << ans2 << endl;
  
}

Measured memory_bytes: 3620
#include <iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){

    int A,B;
    cin >>A>>B;
    if(A<=5){
        cout << 0<<endl;;
    }else if(A<=12){
        
        cout << B/2<<endl;;
    }else{
        cout <<B<<endl;
    }
}


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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int q;
  cin >> q;
  rep(i, 0, q) {
    int c, a, n;
    cin >> c >> a >> n;

    int ans = 0;
    while(c > 0 && a > 0 && n > 0) {
      ans++;
      c--;
      a--;
      n--;
    }
    while(c >= 2 && a > 0) {
      ans++;
      c -= 2;
      a--;
    }
    while(c >= 3) {
      ans++;
      c -= 3;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3168
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int count = 0;
    String s1 = s.replaceAll("ABC", "-");

    for(int i=0;i<s1.length();i++) {
    	if(s1.charAt(i)=='-') {
    		count += 1;
    	}
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 23124
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

void tame(int *,int);
int pop(int *);

int top = 1 ;

int main(){

  char M[100];
  int stac[100],a,b,i;
  
  while(scanf("%s",&M) != EOF){

    if(M[0]=='+'){
      a = pop(stac)+pop(stac);
      tame(stac,a);
    }
    else if(M[0]=='-'){
      a = pop(stac);
      b = pop(stac);
      a=b-a;
      tame(stac,a);
    }
    else if(M[0]=='*'){
      a = pop(stac)*pop(stac);
      tame(stac,a);
    }
    
    else {
      a=atoi(M);
      tame(stac,a);
    }
    

  }

  printf("%d\n",pop(stac));
  
  return 0;
}

void tame(int *a,int b){
  a[top]=b;
  top++;
}

int pop(int *a){
  int f;
  f = a[top-1];
  top--;
  return f;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k-1];
}

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

using namespace std;

template <typename T>

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

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

int main(void)
{

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

	lint n=read<lint>();

	lint ans=n*(n+1)/2;
	lint tmp=n/3;
	lint res=tmp*(tmp+1)/2;

	ans-=(res*3);
	tmp=n/5;
	res=tmp*(tmp+1)/2;
	ans-=(res*5);
	tmp=n/15;
	res=tmp*(tmp+1)/2;
	ans+=(res*15);

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

	return 0;

}


Measured memory_bytes: 3776
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll alphabet[26];
    ll alphabetS[26];
    rep(i, 26){
        alphabet[i] = 100;
    }

    string s;
    rep(i, n){
        rep(j, 26){
            alphabetS[j] = 0;
        }
        cin >> s;

        rep(j, s.size()){
            alphabetS[s[j] - 'a']++;
        }
        rep(j, 26){
            alphabet[j] = min(alphabet[j], alphabetS[j]);
        }
    }

    rep(i, 26){
        rep(j, alphabet[i]){
            cout << (char)('a' + i);
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;

int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll n;
	cin >> n;

	if (n % 2)
	{
		cout << 0 << endl;
		ret;
	}

	ll ans = 0;
	ll c = 10;
	while (n/c!=0)
	{
		ans += n / c;
		c *= 5;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
	ll N;
    string S;
    cin>>N>>S;
    ll n=S.size()/2;
    ll flg=1;
    if(N==1||N%2!=0){cout<<"No"<<endl;return 0;}
    rep(i,0,n){
        if(S[i]==S[S.size()-n+i])flg*=1;
        else flg*=0;
    }
    cout<<(flg==1 ? "Yes":"No")<<endl;
	return 0;
}

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

int main()
{
    int a,b;
    scanf("%c %c",&a,&b);
    if(a=='H')
        printf("%c",b);
        else
        {
            if(b=='H')
        printf("D");
        else
            printf("H");
        }
    return 0;
}


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

#define int long long int
#define double long double
#define endl "\n"
#define sz(x) (int)x.size()

using namespace std;

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

  int n;
  cin>>n;

  int a[n];

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

  sort(a, a+n, greater<int>());

  int sum=a[0];

  if(n&1) {
      sum+=a[n/2];
  }

  for(int i=1; i<n/2; i++) {
      sum+=2*a[i];
  }

  cout<<sum;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll h, w;
  in2(h, w);
  bool k;
  vector<vector<char>> c(h, vector<char> (w));
  vector<bool> d(h, true), e(w, true);
  rep(i, h){
    rep(j, w)
      in(c[i][j]);
  }
  rep(i, h){
    k = true;
    rep(j, w){
      if(c[i][j] != '.')
        k = false;
    }
    if(k)
      d[i] = false;
  }
  rep(i, w){
    k = true;
    rep(j, h){
      if(c[j][i] != '.')
        k = false;
    }
    if(k)
      e[i] = false;
  }
  rep(i, h){
    rep(j, w){
      if(d[i]){
        if(e[j]){
          out(c[i][j]);
        }
      }
    }
    memi;
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, x: [usize; 5]);
    let mut ret = 0;
    for i in 0..5 {
        if x[i] == 0 {
            ret = i + 1;
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2144
n = int(input())
s = input()

r = len(s.replace('G','').replace('B',''))
g = len(s.replace('R','').replace('B',''))
b = len(s.replace('G','').replace('R',''))

ans = r*g*b

for i in range(n):
  for j in range(n):
    if i+j+j+2 >= n:
      break
    
    if (not s[i] == s[i+j+1]) and (not s[i+j+1] == s[i+j+j+2]) and (not s[i+j+j+2] == s[i]):
      ans -= 1
      
print(ans)

Measured memory_bytes: 67924
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		
		
		long q = scn.nextLong();
		long h = scn.nextLong();
		long s = scn.nextLong();
		long d = scn.nextLong();
		long n = scn.nextLong();
		h = Math.min(h,  2*q);
		s = Math.min(s, 2*h); d = Math.min(d, 2*s);
		n*=4;
		long w = ((n/8)*d); n %= 8;
		long x = ((n/4)*s); n %=4;
		long y = ((n/2)*h); n %=4;
		long z = ((n/1)*q); n%=1;
		
		System.out.println(w+x+y+z);
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N =  1e5 + 10;
 
struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(8);
  }
}IO;

int32_t main(){
 int n, a, b;
 cin >> n >> a >> b;
 int c = n / (a + b);
 int ans = c * a;
 n %= (a + b);
 ans += min(a, n);
 cout << ans << endl;
}



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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int N;
  cin >> N;
  switch(N % 10) {
    case 3:
      cout << "bon" << endl;
      break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    default:
      cout << "pon" << endl;
      break;
  }

  return 0;
}


Measured memory_bytes: 3636
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int[] a = {10,20,30,40,50,60};
		while(in.hasNext()){
			int n = in.nextInt();
			if(n == 0) return;

			int[] b = new int[7];
			for(int i = 0; i < n; i++) {
				int c = in.nextInt();
				for(int j = 0; j < 6; j++){
					if(c < a[j]) {
						b[j]++;
						break;
					}
					if(j == 5) b[6]++;
				}
			}

			for(int i = 0; i < 7; i++) {
				System.out.println(b[i]);
			}
		}
	}

	
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 080_arc_b / Link: https://abc069.contest.atcoder.jp/tasks/arc080_b?lang=en  ----- */
/* ------問題------

縦 H 行、横 W 列のマス目があります。 すぬけ君は、このマス目を色 1, 2, …, N で塗り分けようとしています。 このとき、次の条件が成り立つようにします。
各 i (1≤i≤N) について、色 i のマスはちょうど ai 個存在する。 ただし、a1+a2+…+aN=HW である。
各 i (1≤i≤N) について、色 i のマスは上下左右に連結である。 すなわち、どの色 i のマスからどの色 i のマスへも、上下左右に隣り合う色 i のマスのみを辿って行き来できる。
条件を満たす塗り分け方をひとつ求めてください。 解は必ず存在することが示せます。

-----問題ここまで----- */
/* -----解説等-----

ぐるーっと回る感じで実装すれば良い。

----解説ここまで---- */

LL H, W, N;
inline void next(int &y, int &x) {
	if (y % 2 == 0) {
		if (x == W - 1) { y++; }
		else { x++; }
	}
	else { // % 2 ==1
		if (x == 0) { y++; }
		else { x--; }
	}
}

void go(VVI &masu, VI &a) {
	int y = 0, x = 0, id = 0;
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			while (a[id] == 0)id++;
			masu[y][x] = id + 1;
			a[id]--;
			next(y, x);
		}
	}
}


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

	cin >> H >> W >> N;
	VI a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	VVI masu(H, VI(W, 0));

	go(masu, a);

	FOR(i, 0, H) {
		FOR(j, 0, W) {
			cout << masu[i][j] << (j != W - 1 ? ' ' : '\n');
		}
	}

	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<TreeMap<Integer, Integer>> list = new ArrayList<>();
		for (int i = 0; i < r; i++) {
		    list.add(new TreeMap<>());
		}
		for (int i = 0; i < k; i++) {
		    int x = sc.nextInt() - 1;
		    int y = sc.nextInt() - 1;
		    int v = sc.nextInt();
		    list.get(x).put(y, v);
		}
		long[][][] dp = new long[4][r][c];
		for (int i = 0; i < r; i++) {
		    for (int j = 0; j < c; j++) {
		        if (i > 0) {
		            dp[0][i][j] = dp[3][i - 1][j];
		        }
		        if (j > 0) {
		            for (int l = 0; l < 4; l++) {
		                dp[l][i][j] = Math.max(dp[l][i][j], dp[l][i][j - 1]);
		            }
		        }
		        for (int l = 1; l < 4; l++) {
		            dp[l][i][j] = Math.max(dp[l][i][j], dp[l - 1][i][j]);
		        }
		        if (list.get(i).containsKey(j)) {
		            dp[3][i][j] = Math.max(dp[3][i][j], dp[2][i][j] + list.get(i).get(j));
		            dp[2][i][j] = Math.max(dp[2][i][j], dp[1][i][j] + list.get(i).get(j));
		            dp[1][i][j] = Math.max(dp[1][i][j], dp[0][i][j] + list.get(i).get(j));
		        }
		    }
		}
		System.out.println(dp[3][r - 1][c - 1]);
	}
}


Measured memory_bytes: 508152
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
	string S;
	cin >> S;
	if (S == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
}

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

#l = list(map(int, input().split()))
#import numpy as np
#arr = np.array([int(i) for i in input().split()])
'''
a,b=[],[]
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

def premf(n):
    #前処理
    #minfactor:複数の素因数分解を高速(O(Q*logA_max))に行う,indexはその整数
    #return resで素数リスト(eratosthenes),MinFactorで前処理用リスト返す
    IsPrime=[False]+[False]+[True]*(n-1)

    res=[]
    for j in range(4,n+1,2):
        IsPrime[j]=False
    for i in range(1,n+1,2):
        if IsPrime[i]:
            for j in range(i*2,n+1,i):
                    IsPrime[j]=False

            if IsPrime[(i+1)//2]:
                res.append(i)
        
                
    
    return res

q=int(input())
n=10**5
res=premf(n)
a=[0]*(10**5+1)#1-index
t=0
#print(res)
for i in range(len(res)):
    t+=1
    a[res[i]]=t
for i in range(10**5):
    if a[i+1]==0:
        a[i+1]=a[i]
#print(a[:20])
for i in range(q):
    l,r=map(int,input().split())
    print(a[r]-a[l-1])

Measured memory_bytes: 10604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NM = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Node[] nodes = new Node[NM[0]];
            for (int i = 0; i < NM[0]; i++)
            {
                nodes[i] = new Node();
            }

            for (int i = 0; i < NM[1]; i++)
            {
                int[] edge = Console.ReadLine().Split(' ').Select(int.Parse).Select(x=>x-1).ToArray();
                nodes[edge[0]].number = edge[0];
                nodes[edge[0]].next.Add(edge[1]);
                nodes[edge[1]].number = edge[1];
                nodes[edge[1]].next.Add(edge[0]);

            }
            Person person = new Person(0, NM[0]);
            person.history[0] = true;
            Queue<Person> people = new Queue<Person>();
            people.Enqueue(person);
            int output = 0;
            while (people.Count > 0)
            {
                Person tuginokata = people.Dequeue();
                bool isFinished = true;
                for (int i = 0; i < tuginokata.history.Length; i++)
                {
                    isFinished = isFinished && tuginokata.history[i];
                }
                if (isFinished) output++;
                else
                {
                    List<int> next_choice = nodes[tuginokata.You_are_here].next;
                    for (int i = 0; i < next_choice.Count; i++)
                    {
                        Person next_generation = tuginokata.Clone();
                        if (next_generation.history[next_choice[i]] == false)
                        {
                            //行ったことがなければ
                            next_generation.history[next_choice[i]] = true;
                            //次行くところに足跡をつけて
                            next_generation.You_are_here = next_choice[i];
                            //移動して
                            people.Enqueue(next_generation);
                            //後ろに並ぶ
                        }
                    }
                }

            }
            ;
            Console.WriteLine(output);
        }



    }
    class Node
    {
        public int number;
        public List<int> next;
        public Node(int number)
        {
            this.number = number;
            this.next = new List<int>();
        }
        public Node()
        {
            this.number = 0;
            this.next = new List<int>();
        }
    }


    class Person
    {
        public int You_are_here;
        public bool[] history;
        public Person(int place, int N)
        {
            this.You_are_here = place;
            this.history = new bool[N];
        }
        public Person Clone()
        {
            Person output = new Person(0,this.history.Length);
            output.You_are_here = this.You_are_here;
            output.history = (bool[])this.history.Clone();
            return output;
        }
    }

}


Measured memory_bytes: 18464
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a;
    cin>>n;
   m=n;
   k=0;
   while(m)
   {
       k+=m%10;
       m/=10;
   }
   if(n%k==0)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
    return 0;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    d = list(map(int, input().split()))
    d = sorted(d)
    if n%2 == 0: #偶数
        ans = d[n//2] - d[n//2 - 1]
    else: #奇数
        ans = 0
    print(ans)
resolve()

Measured memory_bytes: 20684
import java.util.Scanner;

public class Main {

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

    private static void solve(Scanner in) {
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
        int count = 0;
        for (int x = a; x <= b; x++) {
            if (c % x == 0) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 26224
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30

int MOD = 1000000007;



int main(){
    std::ios_base::sync_with_stdio(false);

    int N; ll K; cin >> N >> K;
    std::vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll dp [50][2];

    REP(i,50) REP(j, 2) dp[i][j] = -1;
    dp[49][0] = 0;

    for(int i = 48; i >= 0; --i){

        ll d = 1LL << i;

        int one_cnt = 0;
        REP(i,N) if(d & A[i]) one_cnt++;

        if(dp[i+1][1] >= 0){
            dp[i][1] = max(dp[i][1], dp[i+1][1]+max(one_cnt, N-one_cnt)*d);
        }

        if(dp[i+1][0] >= 0){
            if(d & K){
                dp[i][0] = max(dp[i][0], dp[i+1][0]+d*(N-one_cnt));
                dp[i][1] = max(dp[i][1], dp[i+1][0]+d*one_cnt);
            } else {
                dp[i][0] = max(dp[i][0], dp[i+1][0]+d*one_cnt);
            }
        }

    }

    // REP(i,40) cout << dp[i][0] << " ";
    // cout << '\n';
    // REP(i,40) cout << dp[i][1] << " ";
    // cout << '\n';


    cout << max(dp[0][0], dp[0][1]) << endl;



    return 0;
}


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

using namespace std;

typedef long long ll;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define abs(a) ((a) < (0)? -(a):(a))
#define pb push_back

int main() {
    int d, n; cin >> d >> n;
    rep(i, d) n *= 100;
    if(n==100) n+=1;
    else if(n==10000) n+=100;
    else if(n==1000000) n+=10000;
    cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  int n, x, y;
  cin >> n >> x >> y;

  int counts[n];
  for (int i = 0; i < n; ++i) counts[i] = 0;

  for (int i = 1; i <= n; ++i) {
    int pos = 0;
    for (int j = i+1; j <= n; ++j) {
      if (i <= x && y <= j) {
        pos = x - i + j - y + 1;
      } else if (i <= x && j <= x) {
        pos = j - i;
      } else if (y <= i && y <= j) {
        pos = j - i;
      } else {
        if (abs(x - i) + abs(y - j) + 1 < (j - i)) {
          pos = abs(x - i) + abs(y - j) + 1;
        } else {
          pos = j - i;
        }
      }
      counts[pos] += 1;
    }
  }

  for (int i = 1; i < n; ++i) {
    cout << counts[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#include <iterator>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

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

    if (str == "SUN") {
        cout << 7 << endl;
    } else if(str == "MON") {
        cout << 6 << endl;
    } else if(str == "TUE") {
        cout << 5 << endl;
    } else if(str == "WED") {
        cout << 4 << endl;
    } else if(str == "THU") {
        cout << 3 << endl;
    } else if(str == "FRI") {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main()
{
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;

	return 0;
}



Measured memory_bytes: 256