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

public class Main {

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

        List<Integer> factors = primeFactor(N);

        int count =0;
//        for (int i = 0; i < factors.size() ; i++) {
        for (int pow:factors) {
            int increase=1;
            while(pow-increase>=0){
                pow -= increase;
                increase++;
                count++;
            }
        }


        System.out.println(count);
    }

    static List<Integer> primeFactor(long N){

        List<Integer> res = new ArrayList<>();

        for (long i = 2; i*i <=N ; i++) {
            int count =0;
            while(N%i==0){
                N /= i;
                count++;
            }
            if(count!=0)
            res.add(count);
        }
        if(N!=1){
            res.add(1);
        }
        return res;
   }


}

Measured memory_bytes: 35696
N = int(input())
A = [int(i) for i in input().split()]

ans = 1
inc = 0

if N == 1:
    print(ans)

else:
    for i in range(1, N):
        if inc == 0:
            if A[i-1] < A[i]:
                inc = 1
            elif A[i-1] > A[i]:
                inc = -1
        elif (inc == 1) and (A[i-1] > A[i]):
            inc = 0
            ans += 1
        elif (inc == -1) and (A[i-1] < A[i]):
            inc = 0
            ans += 1
    print(ans)

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

int main() {
	int n;
	int temp;
	vector<int> v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> temp;
		v.push_back(temp);
	}

	temp = v.back();
	v.pop_back();
	printf("%d", temp);
	for (int j = 0; j < n -1 ; j++) {
		temp = v.back();
		v.pop_back();
		printf(" %d", temp);
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 3260
package main

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

type pair struct {
	val int
	idx int
}

func main() {
	N := getStdinInt()
	A := make([]int, N)
	Asort := make([]pair, N)
	for i := 0; i < N; i++ {
		A[i] = getStdinInt()
		Asort[i] = pair{A[i], i}
	}

	sort.Slice(Asort, func(i, j int) bool {
		return Asort[i].val > Asort[j].val
	})

	for i := 0; i < N; i++ {
		for n := 0; n < N; n++ {
			if i == Asort[n].idx {
				continue
			}
			fmt.Printf("%d\n", Asort[n].val)
			break
		}
	}
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll A, B;
    cin >> A >> B;
    ll ans = MAX(A-B*2,0);

    _PR(ans);

    return 0;
}

/*



*/

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;
using P = pair<ll, ll>;

signed main(void)
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	rep(i, k)
	{
		if (a >= b)
			b *= 2;
		else if (b >= c)
			c *= 2;
	}
	if (a < b && b < c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<vector>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn=200005;
const int inf=1<<30;


struct NODE
{
	int u;
	LL cost;
	bool operator<(const NODE&v)
	{
		return cost<v.cost;
	}
}d[maxn];

struct Edge{
	int from,to;
	LL w;
	
	bool operator<(const Edge&v)
	{
		return w<v.w;
	}
};

vector<Edge>g[maxn];
int f[maxn],siz[maxn],rt,tot,cnt,del[maxn],w[maxn];
//f数组存储最大孩子，size是子树大小， 
void Getroot(int x,int fa)
{
	f[x]=0,siz[x]=1;
	for(int i=0;i<g[x].size();i++)
	{
		Edge&e=g[x][i];
		if(del[e.to]||e.to==fa) continue;
		Getroot(e.to,x);
		f[x]=max(f[x],siz[e.to]);
		siz[x]+=siz[e.to];
	}
//	printf("x=%d f=%d sz=%d\n",x,f[x],siz[x]);
	f[x]=max(f[x],tot-siz[x]);//f[0]=0
	if(f[x]<f[rt]) rt=x;
} 


struct MST
{
	Edge edge[maxn*30];
	int p[maxn],ecnt;
	int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
	void Addedge(int u,int v,LL w) { edge[ecnt++]=Edge{u,v,w};}
	bool Union(int x,int y)
	{
		int px=find(x),py=find(y);
		if(px!=py)
			{
				p[px]=py;
				return true;
			}
		else 
			return false;
	}
		
	
LL kruskal(int n)
{
	LL ans=0;
	for(int i=1;i<=n;i++) p[i]=i;
	sort(edge,edge+ecnt);
	for(int i=0;i<ecnt;i++)
	{
		if(Union(edge[i].from,edge[i].to))
			ans+=edge[i].w;
	}
	return ans;
}
	
}mst;


void getnum(int o,int fa,LL D)
{
	d[cnt++]=NODE{o,D+w[o]};
//	printf("cnt=%d\n",cnt);
	for(int i=0;i<g[o].size();i++)
	{
		Edge&e=g[o][i];
		if(del[e.to]||e.to==fa) continue;
		getnum(e.to,o,D+e.w);
	}	
}

void getans(int o)
{
	cnt=0;
	getnum(o,-1,0);
	sort(d,d+cnt);
	for(int i=1;i<cnt;i++)
		{
		mst.Addedge(d[0].u,d[i].u,d[0].cost+d[i].cost);
	//	printf("ecnt=%d\n",mst.ecnt);
		}
		
}

void solve(int o)
{
	del[o]=1,getans(o);
	//printf("f=%d\n",f[o]);
	for(int i=0;i<g[o].size();i++)
	{ 
		Edge&e=g[o][i]; 
		if(del[e.to]) continue;
		tot=siz[e.to],rt=0;
		Getroot(e.to,o);
		//printf("rt=%d\n",rt);
		solve(rt);
	} 	
}



int main(){
    //freopen("C:\\Users\\deii\\Desktop\\test.txt","r",stdin);	
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&w[i]);
	for(int i=0;i<n-1;i++)
	{
		int u,v;
		LL w;
		scanf("%d%d%lld",&u,&v,&w);
		g[u].push_back(Edge{u,v,w});
		g[v].push_back(Edge{v,u,w});	
	}
	f[0]=inf;
	tot=n,rt=0;
	mst.ecnt=0;
	Getroot(1,-1);
	solve(rt);
	printf("%lld",mst.kruskal(n));
	
	return 0;
}


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

#define ll long long

int main(void){

    int a1,a2,a3;

    cin >> a1 >> a2 >> a3;

    if(a1 + a2 + a3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define ld long double
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
ld c[3005];
ld dp[3005][1600];
int n;
int main()
{
	cin>>n;
	fr(i,1,n)
	cin>>c[i];
	dp[1][0]=c[1];
	dp[1][1]=1.0-c[1];
	fr(i,2,n)
	{
		for(int j=0;j<=min(i,n/2);j++)
		{
			if(j==0)
			{
				dp[i][j]=dp[i-1][j]*c[i];
			}
			else
			{
				dp[i][j]=dp[i-1][j-1]*(1.0-c[i])+dp[i-1][j]*c[i];
			}
		}
	}
	ld ans=0.0;
	fr(i,0,n/2)
	ans=ans+dp[n][i];
	cout<<fixed<<setprecision(10)<<ans;
	//cout<<ans;
    return 0;
}





Measured memory_bytes: 64952
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if s=='AC':
    ac += 1
  elif s=='WA':
    wa += 1
  elif s=='TLE':
    tle += 1
  else:
    re += 1
    
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)


Measured memory_bytes: 9196
from collections import deque

n = int(input())
graph = [[] for _ in range(n)]

for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append([b, i])
    graph[b].append([a, i])

ans = [0] * (n - 1)

q = deque([[1, 0, -1]])

while q:
    node, pcol, p_node = q.popleft()
    cnt = 1
    for n_node in graph[node]:
        if n_node[0] == p_node:
            continue
        if cnt == pcol:
            cnt += 1
        ans[n_node[1]] = cnt
        q.append([n_node[0], cnt, node])
        cnt += 1

print(max(ans))
print(*ans, sep="\n")


Measured memory_bytes: 48660
#include<bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0);
#define fore(i, a, b) for(int i = a; i < b; i++)
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define popb pop_back
#define mk make_pair
#define fi first
#define se second
#define endl '\n'
#define MAX 100005
typedef long long int lli;
typedef long double ld;
const double PI = acos(-1.0);
ld eps = 1e-9;

vector<lli> bit(MAX, 0);
void clean() { // O(MAX)
	for(int i = 0; i < MAX; i++) bit[i] = 0;	
}
lli F(lli a, lli b){return a + b;}

void update(int i, lli val) { // O(log(MAX))
	for(i++; i < MAX; i += i & -i) 
		bit[i] = F(bit[i], val);
}
lli query(int i) { // O(log(MAX))
	lli ans = 0;
	for(i++; i; i -= i & -i) ans = F(ans, bit[i]);
	return ans;
}
int main() {
	optimizar_io
	int n; cin >> n;
	lli b, c; 
	vector<lli> v(n);
	vector<int> bucket(MAX);
	fore(i, 0, n) {
		cin >> v[i];
		bucket[v[i]]++;
	}
	fore(i, 0, bucket.size()) {
		lli ele = bucket[i] * i;
		update(i, ele);
	}
	int q; cin >> q;
	fore(i, 0, q) {
		cin >> b >> c;
		lli actual = -b * bucket[b];
		update(b, actual);
		actual = -c * bucket[c];
		update(c, actual);
		bucket[c] += bucket[b];
		bucket[b] = 0;
		lli up = bucket[c] * c;
		update(c, up);
		cout << query(MAX) << endl;
	}
}

Measured memory_bytes: 5272
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

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


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	if (n == 0) {
		cout << 0 << endl; return 0;
	}
	string s = "";
	int i = 1;
	while (n != 0) {
		if (n % (i * (-2)) != 0) {
			s += "1"; n -= i;
		}
		else {
			s += "0";
		}
		i *= (-2);
	}
	reverse(ALL(s));
	cout << s << endl;
	return 0;
}

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

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

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int n = in.nextInt();
            int[][] dp = new int[10][10];
            for (int i = 0; i < 10; i++)
                for (int j = 0; j < 10; j++) dp[i][j] = 0;

            for (int i = 1; i <= n; i++)
            {
                String s = Integer.toString(i);
                dp[s.charAt(0) - '0'][(int) s.charAt(s.length() - 1) - '0'] += 1;

            }
            long ans = 0;
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    ans += (dp[i][j] * dp[j][i]);
                }
            }
            out.print(ans);
        }

    }
}



Measured memory_bytes: 31956
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

bool good(int l,int k,vector<int> &vec)
{
	int now=0;
	
	for(int x: vec)
	{
		now+=(x-1)/l;
		
		if(now>k)
		{
			return false;
		}
	}
	
	return true;
}
	
	

void solve()
{
	int n,k;
	cin>>n>>k;
	
	vector<int>vec(n);
	for(int &x: vec) cin>>x;
	
	int hi=*max_element(vec.begin(),vec.end());
	int lo=1;
	
	int ans=hi;
	
	while(hi>=lo)
	{
		int mid=(hi+lo)/2;
		
		if(good(mid,k,vec))
		{
			ans=mid;
			hi=mid-1;
		}
		else lo=mid+1;
	}
	
	cout<<ans;
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int t=1;
	//cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define BOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int ans=0;
    string s;
    while(cin>>s){
        REP(i,s.size()/2){
            if(s[i]!=s[s.size()-1-i])goto netxf;
        }
        ans++;
    netxf:;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

using namespace std;

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

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 105;

const int M = 1e5 + 5;

int n, k, a[N], dp[N][M], pref[N][M];

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    dp[0][0] = 1;
    for(int j = 0; j <= k; j++) {
        pref[0][j] = dp[0][j];
        if(j >= 1)
            pref[0][j] = (pref[0][j] + pref[0][j - 1]) % mod;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= k; j++) {
            if(j - a[i] - 1 >= 0)
                dp[i][j] = ((pref[i - 1][j] - pref[i - 1][(j - a[i] - 1)]) % mod + mod) % mod;
            else
                dp[i][j] = pref[i - 1][j] % mod;
        }
        for(int j = 0; j <= k; j++) {
            pref[i][j] = dp[i][j];
            if(j >= 1)
                pref[i][j] = (pref[i][j] + pref[i][j - 1]) % mod;
        }
    }
    cout << dp[n][k];
}



Measured memory_bytes: 160000
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N;
	cin >> N;
	vl H(N, 0);
	rep(i, N) {
		cin >> H[i];
		if (i > 0) {
			if (H[i] > H[i - 1])
				H[i]--;
		}
		else
			H[i]--;
	}
	string ans = "Yes";
	rep(i, N - 1) {
		if (H[i + 1] < H[i])
			ans = "No";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if (a < b){
			System.out.println("a < b");
			}
		else if (a > b){
			System.out.println("a > b");
			}
		else if (a == b){
			System.out.println("a == b");
			}
	}
}

Measured memory_bytes: 26124
#include <iostream>
#include <string>
#include <map>

int main() {
    int n, q;

    while(1) {
        std::cin >> n >> q;
        if(n * q == 0) {
            return 0;
        }

        std::map<int, std::pair<int, std::string>> m;
        for(int i = 0; i < n; ++i) {
            std::string  name;
            int b , w;
            std::cin >> name >> b >> w;

            m[w - b + 1] = {w, name};
        }

        for(int i = 0; i < q; ++i) {
            int k;
            std::cin >> k;

            std::string contained = "";
            int year;
            for(auto&& p : m) {
                if(p.first <= k && p.second.first >= k) {
                    if(contained != "") {
                        std::cout << "Unknown" << std::endl;
                        goto END;
                    }

                    contained = p.second.second;
                    year = k - p.first + 1;
                }
            }

            if(contained == "") {
                std::cout << "Unknown" << std::endl;
            }else {
                std::cout << contained << " " << year << std::endl;
            }
            END:;
        }
    }
}


Measured memory_bytes: 3104
#include<cstdio>
main(){int h,b,i,j;char r[5],a[5];while(scanf("%s%s",r,a),r[1]!='\0'&a[1]!='\0'){for(h=b=i=0;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])i==j?h++:b++;printf("%d %d\n",h,b);}}

Measured memory_bytes: 0
l, r = map(int, input().split())
if r-l >= 2018:
	print(0)
else:
	ll, rr = l%2019, r%2019
	if ll < rr:
		val = 2019*2019
		for i in range(ll,rr+1):
			for j in range(i+1,rr+1):
				val = min(val, i*j%2019)
		print(val)
	else:
		print(0)


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

int main(int argc, char *argv[]) {
  long long n,k,s;
  cin >> n >> k >> s;
  vector<long long> data(n,1e9);
  if(s == 1e9){
    for(int i=0; i<n; i++){
      data.at(i) = 1e9-1;
    }
  }
  
  for(int i=0; i<k; i++){
    data.at(i) = s;
  }
  
  for(int i=0; i<n-1; i++){
    cout << data.at(i) << ' ';
  }
  cout << data.at(n-1) << endl;
}

Measured memory_bytes: 2048
//
// Created on 2019-01-27.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    string a, b, c;
    int N;
    cin >> N >> a >> b >> c;

    int ans = 0;
    int cnt, n;
    REP(i,N){
        cnt = 0;
        if (a[i] == b[i])cnt++;
        if (b[i] == c[i])cnt++;
        if (a[i] == c[i])cnt++;
        n = 3-cnt;
        if (n == 2) ans += 1;
        else if (n == 3) ans += 2;

    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n, y;cin>>n>>y;
    ll a,b,c;
    REP(i,n+1)REP(j,n+1){
        int k=n-i-j;
        if(10000*i+5000*j+1000*k==y && k>=0){
            cout<<i<<" "<<j<<" "<<k<<endl;
            return 0;
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}


Measured memory_bytes: 3592
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define prinrynl(a) printf(a ? "yes\n" : "no\n")
#define prinryn(a) printf(a ? "Yes\n" : "No\n")
#define prinrYN(a) printf(a ? "YES\n" : "NO\n")
#define prinrin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)
#define all(x) (x).begin(), (x).end()

using ll = long long;

const int INF = 2147483647;
const ll LINF = ll(9223372036854775807);
const ll MOD = 1000000007;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>

using namespace std;

int ggd(int number1, int number2) {
	int m = number1;
	int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}

	while (m != n) {
		int temp = n;
		n = m - n;
		m = temp;
	}

	return m;
}

int lcm(int number1, int number2) {
	return number1 * number2 / ggd(number1, number2);
}

bool is_prime(int64_t x) {
	for (int64_t i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

/*-----------------------------------------ここまでライブラリとか-----------------------------------------*/



int main() {

	ll n, k, an, b;
	ll i;
	scanf("%lld%lld", &n, &k);
	vector<ll> a(1000010);
	rep(i, n) {
		scanf("%lld%lld", &an, &b);
		a[an] += b;
	}
	for (i = 1; k > 0; ++i) {
		k -= a[i];
	}
	printf("%lld\n", i - 1);

	return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e){ll ans=1;GG(e<0);while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    int n,k,ans;vc<int> son[N];
    int dep[N];
    int solve(int x,int fa)
    {
        dep[x]=dep[fa]+1;
        int mx=0;
        fo(t,0,sz(son[x])-1)
        {
            int y=son[x][t];
            chmax(mx,solve(y,x)+1);
        }
        if(mx+dep[x]>k and mx+1==k){ans++;mx=-1;}return mx;
    }
    void main()
    {
        n=qread(),k=qread();ans=qread()!=1;fo(i,2,n) son[qread()].PB(i);
        dep[0]=-1;solve(1,0);write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

int main()
{
	string s,t;
	char c;
	cin>>s>>t;
	if (s==t) {
		cout<<"Yes";
		return 0;
	}
	int l=s.length();
	for (int i=0;i<l;i++){
		c=s[s.length()-1];
		s=s.substr(0,s.length()-1);
		s=c+s;
		if (s==t) {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <math.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
 
 
 
int main(){
  int x, y, turtle;
  cin >> x >> y;
  if(4*x<y || y%2==1){
    cout << "No" << endl;
    exit(0);
  }
  turtle=(y/2)-x;
  if(turtle>=0){
    cout<<"Yes"<<endl;
    exit(0);
  }else{
    cout << "No" << endl;
    exit(0);
  }
  
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void)
{
	int high[10],i,j,t;
	for(i=0;i<10;i++)
		scanf("%d",&high[i]);
	for(i=0;i<10;i++)
		for(j=i;j<10;j++)
			if(high[j]>high[i]){
				t=high[i];
				high[i]=high[j];
				high[j]=t;
			}
	for(i=0;i<3;i++)
		printf("%d\n",high[i]);
		return 0;
}

Measured memory_bytes: 1760
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        long g = sc.nextLong();
        int[] p = new int[d];
        int[] c = new int[d];
        for (int i = 0; i < d; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        sc.close();

//        System.out.println(list);

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < pow(2, d); i++) {
            String str = toBinaryString(i, d);
//            System.out.println(str);
            int num = 0;
            long sum = 0;
            for (int j = 0; j < str.length(); j++) {
                if (str.charAt(j) == '1') {
                    num += p[j];
                    sum += 100 * (j + 1) * p[j] + c[j];
                }
            }

//            System.out.println("sum=" + sum + ", num=" + num);
            if (sum >= g && num <= ans) {
                ans = num;
            }

            int lastZeroIndex = str.lastIndexOf('0');
            if (lastZeroIndex >= 0) {
                for (int j = 0; j < p[lastZeroIndex]; j++) {
                    sum += 100 * (lastZeroIndex + 1);
                    num++;
                    if (sum >= g && num <= ans) {
                        ans = num;
                    }
                }
            }
        }
        System.out.println(ans);
    }

    static long sum(List<Long> list) {
        long ret = 0;
        for (Long l : list) {
            ret += l;
        }
        return ret;
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

    // intをlength桁のbit文字列に変換
    static String toBinaryString(int input, int length) {
        return toBinaryString(input).substring(29 - length);
    }

    // intを29桁のbit文字列に変換
    static String toBinaryString(int input) {
        String ret = "";
        int max = 0x10000000;
        for (int i = 0; i < 29; i++) {
            int tmp = input / max;
            ret += tmp;
            input %= max;
            max /= 2;
        }
        return ret;
    }

}


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

using namespace std;

const int MAX_N=7.4*1e6;
int primes[MAX_N+1];//i????´???°??????true

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

  while(true){
      int m,n;cin>>m>>n;
      if(m==0&&n==0) break;
      for(int i=0;i<MAX_N;i++) primes[i]=true;
      int count=0;
      primes[0]=primes[1]=false;
      for(int i=m;i<=MAX_N;i++){
          if(primes[i]){
              for(int j=2*i;j<=MAX_N;j+=i) primes[j]=false;
              count++;
              if(count>n){
                  cout<<i<<endl;
                  break;
              }
          }
      }
  }
}

Measured memory_bytes: 31972
#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 5005
#define in(x)  cin>>x
#define o(x)  cout<<x
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<ll>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS],vis[AS];
vc v[AS];
void solve(ll x,ll ind)
{
    vis[x]=1;
    p+=br[ar[x]];
    v[ind].pb(p);
    if(vis[ar[x]]==0)solve(ar[x],ind);
}
int main()
{
    fast;
    in(n>>k);
    fr(i,1,n)in(ar[i]);
    fr(i,1,n)in(br[i]);
    fr(i,1,n)
    {
        p=0;memset(vis,0,sizeof(vis));
        solve(i,i);
    }
    m=-M;
    fr(i,1,n)
    {
        l=v[i].size();
        ll mx=-M;
        fr(j,0, l-1)
        {
            if(j>=k)break;
            x=v[i][j];mx=max(mx,x);
            y=k-(j+1);y/=l;
            x+=y*v[i][l-1];mx=max(mx,x);
        }
        m=max(m,mx);
    }
    o(m);
}


Measured memory_bytes: 218892
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define vi vector<int>
#define vb vector<bool>
#define lli long long int
#define vvi vector<vector<int>>
#define loop(n) for (int i = 0; i < n; i++)
using namespace std;

auto SpeedUp = []() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

int arr[100005], dp[100005];
int n, k;
int solve()
{
    memset(arr, 0, sizeof(arr));
    memset(dp, 0, sizeof(dp));
    cin >> n >> k;
    loop(n) cin >> arr[i];

    vi dp(n, 0);
    for (int i = n - 2; i >= 0; i--)
    {
        dp[i] = 1e9;
        for (int jump = 1; jump <= k; jump++)
        {
            if (i + jump < n)
                dp[i] = min(dp[i], dp[i + jump] + abs(arr[i + jump] - arr[i]));
            else
                break;
        }
    }

    // for(int ele :dp)
    //     cout << ele << " ";
    return dp[0];
}

int main()
{
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 4496
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const int maxm=100050;
const int mod=1e9+7;
struct nod{
	int a[4][4];
	inline void clear(){
		memset(a,0,sizeof(a));
	}
	inline void st1(){
		clear();
		a[0][0]=a[0][2]=a[1][1]=a[2][2]=1;
		a[1][2]=1;
		a[0][1]=2;
	}
	inline void st(){
		clear();
		a[0][0]=a[0][2]=a[1][1]=a[1][2]=1;
		a[2][0]=1;
		a[2][1]=a[2][2]=a[0][1]=2;
	}
};
int n,m;
int x[maxm];
nod ans,tmp;
inline nod operator * (nod x,nod y){
	nod c;
	c.clear();
	for(register int i=0;i<3;i++){
		for(register int j=0;j<3;j++){
			for(register int k=0;k<3;k++){
				c.a[i][j]=(c.a[i][j]+((ll)x.a[i][k]*(ll)y.a[k][j])%mod)%mod;
			}
		}
	}
	return c;
}
inline nod ksm(nod a,int x){
	nod cheng;
	cheng.st();
	int st[50],top=0;
	while(x){
		st[++top]=x&1;
		x>>=1;
	}
	while(top){
		a=a*a;
		if(st[top--]){
			a=a*cheng;
		}
		x>>=1;
	}
	return a;
}
int main(){
	tmp.st1();
	ans.clear();
	ans.a[0][0]=ans.a[0][2]=1;
	ans.a[0][1]=2;
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=m;i++)scanf("%d",&x[i]);
	x[++m]=n;
	//cout<<ans.a[0][0]<<' '<<ans.a[0][1]<<' '<<ans.a[0][2]<<endl;
	for(register int i=1;i<=m;i++){
		int dis=x[i]-(x[i-1]+1);
		nod fuck;
		fuck.clear();
		fuck.a[0][0]=fuck.a[1][1]=fuck.a[2][2]=1;
		fuck=ksm(fuck,dis);
		// for(register int j=0;j<3;j++){
		// 	for(register int k=0;k<3;k++){
		// 		cout<<fuck.a[j][k]<<' ';
		// 	}
		// 	cout<<endl;
		// }
		ans=ans*fuck;
		//cout<<x[i]-(x[i-1]+1)<<' '<<ans.a[0][0]<<' '<<ans.a[0][1]<<' '<<ans.a[0][2]<<endl;
		if(i!=m)ans=ans*tmp;
	}
	printf("%d\n",ans.a[0][2]);
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int n,r,l,p;
void f(char *s)
{
	char x;
	r=strlen(s)-1,l=0;
	for(;r>l;r--,l++)
	{
		x=s[r];s[r]=s[l];s[l]=x;
	}
}
int main()
{
	char a[10000],b[100000],s[10000];
	for(scanf("%d\n",&n);n--;)
	{
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		memset(s,0,sizeof(s));
		gets(a);
		f(a);
		gets(b);f(b);
		for(s[0]=a[0]+(b[0]-'0'),p=1;a[p]||b[p];p++)
		{
			if(!a[p]||!b[p])
				s[p]=a[p]+b[p]+(s[p-1]-'0')/10;
			else
				s[p]=a[p]+(b[p]-'0')+(s[p-1]-'0')/10;
		}
		if(s[p-1]>'9')
			s[p]='1';
		f(s);
		if(s[80])
			printf("overflow");
		else
			for(p=0,l=strlen(s);p<l;p++)
				printf("%d",(s[p]-'0')%10);
		puts("");
	}
	return 0;
}

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

class Quaternion {
public:
    int x_, y_, z_, w_;

    Quaternion(int x, int y, int z, int w) {
        x_ = x;
        y_ = y;
        z_ = z;
        w_ = w;
    }

    friend Quaternion operator* (const Quaternion &q1, const Quaternion &q2) {
        return Quaternion(q1.x_ * q2.x_ - q1.y_ * q2.y_ - q1.z_ * q2.z_ - q1.w_ * q2.w_,
                          q1.x_ * q2.y_ + q1.y_ * q2.x_ + q1.z_ * q2.w_ - q1.w_ * q2.z_,
                          q1.x_ * q2.z_ - q1.y_ * q2.w_ + q1.z_ * q2.x_ + q1.w_ * q2.y_,
                          q1.x_ * q2.w_ + q1.y_ * q2.z_ - q1.z_ * q2.y_ + q1.w_ * q2.x_);
    }

    friend ostream& operator<< (ostream &os, const Quaternion &q) {
        return (os << q.x_ << " " << q.y_ << " " << q.z_ << " " << q.w_);
    }
};

int main() {
    int n;
    while (cin >> n, n) {
        for (int i = 0; i < n; i++) {
            int x1, y1, z1, w1, x2, y2, z2, w2;
            cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
            cout << Quaternion(x1, y1, z1, w1) * Quaternion(x2, y2, z2, w2) << endl;
        }
    }
}

Measured memory_bytes: 1160
using System;

namespace ABC048_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            long a = sss[0];
            long b = sss[1];
            long x = sss[2];
            var up = b / x + 1;
            var down = (a - 1) / x + 1;
            if(a==0)
            {
                Console.WriteLine(b / x + 1);
            }
            else
            {
                Console.WriteLine(up - down);
            }
            
        }
    }
}


Measured memory_bytes: 13140
import qualified Data.ByteString.Char8 as BS

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

calc :: String -> String
calc [] = []
calc [s]
  | s == 'P' || s == 'D' = [s]
  | otherwise = "D"
calc (s1 : s2 : ss)
  | s1 == 'P' && (s2 == 'D' || s2 == '?') = "PD" ++ calc ss
  | s1 == 'P' = 'P' : calc (s2 : ss)
  | s1 == 'D' = 'D' : calc (s2 : ss)
  | otherwise = calc ('D' : s2 : ss)

main = do
  [t] <- getString
  putStrLn $ calc t


Measured memory_bytes: 5224
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m=0,s=1000000000,a,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<0){
            m++;
        }
        if(s>abs(a))
            s=abs(a);
        ans+=abs(a);
    }
    if(m%2==0){
        cout<<ans<<endl;
    }
    else{
        cout<<ans-s*2<<endl;
    }
    return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

bool isPrime(int x) {
  if(x == 2) return true;
  if(x < 2 || !(x % 2)) return false;
  int i = 3;
  while(i <= sqrt(x)) {
    if (!(x % i)) return false;
    i += 2;
  }
  return true;
}

int main(void) {
  int A[10000],n;
  cin >> n;
  for(int i=0;i<n;i++) cin >> A[i];
  int prime = 0;
  for(int i=0;i<n;i++)
    if(isPrime(A[i])) prime++;
  cout << prime << '\n';

  return 0;
}

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

int main()
{
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	const double PI = acos(-1);
	const double cir = 360.0;

	double thetaA = cir * ((H / 12.0) + (M / (12.0 * 60.0)));
	double thetaB = cir * (M / (60.0));

	double deltaDeg = min(abs(thetaA - thetaB), abs(thetaA - thetaB));

	double rad = deltaDeg * PI / 180.0;

	//cout << cos(rad) << "\n";
	
	double result = sqrt(pow(A, 2) + pow(B, 2) - 2.0 * A * B * cos(rad));

	// coutだと小数点6桁しかでない
	printf("%.10f", result);

	return 0;
}

Measured memory_bytes: 4164
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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

Measured memory_bytes: 384
#include <iostream>
#include<map>

using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    int ans = 0;
    string S,SS;
    cin >> S >> SS;
    ans = (S[0] == SS[0]) +
          (S[1] == SS[1]) +
          (S[2] == SS[2]);
    fin(ans);
    return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
using namespace std;
const int inf = 0x3f3f3f3f;
int C[20];
long long A[20][20];
bool plan[20];
long long res;
int n, m, x;
bool has_res;
void dfs(int index){
    if(index == n){
        long long pay = 0;
        long long sum[20];
        memset(sum, 0, sizeof(sum));
        for(int i=0; i<n; i++){
            if (plan[i]) {
                pay += C[i];
                for(int j=0; j<m; j++){
                    sum[j] += A[i][j];
                }
            }
        }
        bool flag = true;
        for(int i=0; i<m; i++){
            if(sum[i] < x){
                flag = false;
                break;
            }
        }
        if(flag){
            has_res = true;
            res = min(res, pay);
        }
        return;
    }
    plan[index] = true;
    dfs(index+1);
    plan[index] = false;
    dfs(index+1);
}

int main(){
    cin>>n>>m>>x;
    for(int i=0; i<n; i++){
        cin>>C[i];
        for(int j=0; j<m; j++){
            cin>>A[i][j];
        }
    }
    memset(plan, 0, sizeof(plan));
    has_res = false;
    res = inf;
    dfs(0);
    if(has_res){
        cout<<res<<endl;
    }else{
        cout<<"-1\n";
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<string, pii> > v;

    rep(i, n) {
        string s;
        int p;
        cin >> s >> p;
        v.push_back(MP(s, MP(-p, i + 1)));
    }
    sort(all(v));
    for (auto p : v) {
        cout << p.second.second << endl;
    }
    return 0;
}



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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  for (int i = 0; i < n; ++i) {
    cin >> w[i];
  }
  auto sum = accumulate(w.begin(), w.end(), 0LL);
  auto sumh = sum / 2;
  int c = 0;
  int s = 0;
  while (s < sumh) {
    s += w[c++];
  }
  auto sum1 =  abs(sum - accumulate(w.begin(), w.begin() + c, 0LL) * 2 );
  auto sum2 =  abs(sum - accumulate(w.begin(), w.begin() + c-1, 0LL) * 2 );
  auto sum3 =  abs(sum - accumulate(w.begin(), w.begin() + c-2, 0LL) * 2 );
  int a = min(min(sum1, sum2), sum3);
  cout << a << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    sort(l.begin(),l.end());
    for(int i=0;i<=n-3;i++){
        for(int j=i+1;j<=n-2;j++){
            for(int k=j+1;k<=n-1;k++){
                if(l[i]!=l[j]&&l[j]!=l[k]&&l[i]+l[j]>l[k]) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

c=[input() for i in range(2)]
ans="YES"
if c[0][0]!=c[1][2]:
    ans="NO"
if c[0][1]!=c[1][1]:
    ans="NO"
if c[0][2]!=c[1][0]:
    ans="NO"
print(ans)

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

#define mod 1000000007
#define ll long long
#define ld long double
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sp(x) setprecision(x)
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define deb(x) cout<<#x <<x <<endl
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m;
    cin>>n>>m;
  cout<<n*m<<endl;
    
}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	rs := []rune(s)
	r := rs[0]
	if 'a' <= r && r <= 'z' {
		fmt.Println("a")
		return
	}
	if 'A' <= r && r <= 'Z' {
		fmt.Println("A")
		return
	}
}


Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std ;
int main()
{ long long  int a,b;
cin>>a>>b;
long long int  ans=0;
if(a==1||b==1)
cout<<1<<endl;
else if(a==2||b==2)
{
cout<<max(a,b)<<endl;
}
else
{
ans=ans+(((a+1)/2)*((b+1)/2));
ans=ans+((a/2)*(b/2));
cout<<ans<<endl;
}
}


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

L = [X[i + 1] - X[i] for i in range(M - 1)]
L = sorted(L, reverse=True)
result = X[-1] - X[0] - sum(L[:N - 1])
print(result)


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

main()
{
	int array[12347];
	priority_queue<int> q;
	int n,k,m,i,j,len;
	int flag=0;
	int cou=0;
	int max=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&array[i]);
		cou+=array[i];
	}
	
	printf("%d",cou-n);
	
}

Measured memory_bytes: 256