akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

const int MAX = 10000;

int main()
{
    vector<bool> check(MAX+1, true);
    for(int i = 2; i * i <= MAX; i++){
        if(check[i]){
            for(int j = 2; i * j <= MAX; j++){
                check[i*j] = false;
            }
        }
    }

    vector<int> prime;
    for(int i = 2; i <= MAX; i++){
        if(check[i]) prime.push_back(i);
    }

    
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;

        queue<int> Q;
        int rest = n;
        int count = 0;

        for(int i = 0; i < prime.size() && n >= prime[i]; i++){
            rest -= prime[i];
            Q.push(prime[i]);

            while(rest <= 0){
                if(rest == 0) count++;
                rest += Q.front();
                Q.pop();
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
"""解説から
1. n以下の整数からxで割り切れる数の数を求めるにはn//xすると良い f(n)
2. b以下の整数からxで割り切れる数の数を求める f(b)
3. a"未満"の整数は除外する必要があるのでf(a-1)を求める
4. f(b)-f(a-1)がa以上b以下の整数からxで割り切れる数の個数となる
5. a==0の時、f(a-1) == -1 となる。f(b) - -1 == f(b) + 1となるので、
    0以上b以下の数のxを求めるときにもきちんと求めることができる
"""
a, b, x = map(int, input().split())
b //= x
a = (a - 1) // x
print(b - a)


Measured memory_bytes: 2940
n=int(input())
L=list(map(int,input().split()))
mod=10**9+7
if n==1:
    if L==[0]:
        print(1)
    else:
        print(0)
elif n%2==0:
    M=[2*i+1 for i in range(n//2)]
    M=M+M
    M.sort()
    L.sort()
    print((2**(n//2))%mod if L==M else 0)
else:
    M=[2*i for i in range(n//2 +1)]
    M=M+M[1:]
    M.sort()
    L.sort()
    print((2**(n//2))%mod if L==M else 0)

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

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define sz(c) int(c.size())
#define clr(v, d)   memset(v, d, sizeof(v))
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF             INT64_MAX
#define NINF            INT64_MIN
#define ROW 1001
#define COL 1001

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
typedef vector<ll> vl;
vi idx_s;
vi idx_t;
int main(void){
    string s;
    cin>>s;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='S')
            idx_s.pb(i);
        else
            idx_t.pb(i);
    }
    int ans=s.size();
    int si=0;
    loop(i,idx_t.size())
    {
        if(idx_t[i]>idx_s[si])
        {
           ans-=2;
           si++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1532
#include <iostream>
using namespace std;
int main() {
	int N, Y;
	int x, y, z, sum;
	x = -1;
	y = -1;
	z = -1;
	bool exist = false;
	cin >> N >> Y;
	for (int mann = 0; mann <= N; ++ mann) { 
		for (int gosenn = 0; gosenn <= N - mann; ++ gosenn) {
		    int senn = N - (mann + gosenn);	
		    	sum = 10000 * mann + 5000 * gosenn + 1000 * senn;
				if (sum == Y) {
				    exist = true;
 				    x = mann;
					y = gosenn;
					z = senn;
			}
		}	
		if (exist) break;
	}
   cout << x << " " << y << " " << z << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  lli X;
  cin >> X;
  vector<lli> A(102+50);
  rep(i, 101+50){
  A[i]=i;
    rep(j, 4){
      A[i]*=i;
    }
  }
  
  rep(i, 101+50){
  rep(j, 101+50){
    if(A[i]-A[j]==X){
    cout << i <<" "<< j << endl;
  return 0;
  }
    
  if(A[i]+A[j]==X){
    cout << i <<" "<< -j << endl;
  return 0;
  }
    
    
  }
  }
}


Measured memory_bytes: 3628
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int n;
	cin >> n;
	vector<ll> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	cout << *min_element(all(v)) << " ";
	cout << *max_element(all(v)) << " ";
	cout << accumulate(all(v), 0LL) << endl;

	return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#define ll long long

using namespace std;

int main(){

  ll n, a;
  cin >> n;
  int ans = 0;
  vector<ll> vec(n);

  for (int i = 0; i < n; i++){
    cin >> a;
    vec.at(i) = a;
  }

  ll now1 = 0, now2 = 0, cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < n; i++) {
    now1 += vec[i];
    now2 += vec[i];
    if(now1 <= 0){
      cnt1 += abs(now1)+1;
      now1 = 1;
    }
    if(now2 >= 0){
      cnt2 += abs(now2)+1;
      now2 = -1;
    }
    swap(now1, now2);
    swap(cnt1, cnt2);
  }

  cout << min(cnt1,cnt2) << endl;

  return 0;
}

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

int main(){
  int a,s=0;
  cin >> a;
  vector<int>b(a);
  for(int i=0;i<a;i++){
    cin >> b.at(i);
  }
  for(int i=0;i<a;i++){
    if(b.at(i)%2==0){
      if(b.at(i)%3!=0 && b.at(i)%5!=0){
        s=s+1;
      }  
    }
  }
  if(s!=0) cout<<"DENIED"<<endl;
  else{
   cout <<"APPROVED"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
int main(){ 
    ll n,k,q;
    cin>>n>>k>>q;
    vector<ll> a(q);
    REP(i,q) cin>>a[i];
    sort(a.begin(),a.end());
    ll b=0,c=0;
    for(int i=1;i<n+1;i++){
       for(int j=c;j<q;j++){
           if(a[j]==i){
               b++;
           }else{
               c=j;
               break;
           }
       }

       if(k>q-b){
       cout<<"Yes"<<endl;
       }else{
           cout<<"No"<<endl;
       }
       b=0;
    }
    return 0;
}


Measured memory_bytes: 1408
from collections import deque

s = input()
q = int(input())
b = deque(s)
swc = 0
for i in range(q):
	a = list(map(str, input().split()))
	if a[0] == "1":
		swc += 1
	elif a[1] == "1":
		if swc%2 == 0:
			b.appendleft(a[2])
		else:
			b.append(a[2])
	else:
		if swc%2 == 0:
			b.append(a[2])
		else:
			b.appendleft(a[2])
ans = ""
if swc%2 == 0:
	ans = "".join(list(b))
else:
	ans = "".join(reversed(list(b)))
print (ans)

Measured memory_bytes: 10356
r,g,b,n=io.read("*n","*n","*n","*n")

counter=0
for i=0,3000 do
    for j=0,3000 do
        rg=r*i+g*j
        if n>=rg and (n-rg)%b==0 then
            counter=counter+1
        end
    end
end
print(counter)

Measured memory_bytes: 760
#include <stdio.h>
#define N 100

int main(){
  int i, j, length, x, A[N], swap_count=0;
  //There is x in this program for storing the value of the element of A.

  scanf("%d",&length);
  for(i = 0; i < length; i++) scanf("%d",&A[i]);

  for(i = 0; i < length; i++){
    for(j = length-1; j > i; j--){
      if( A[j] < A[j-1] ){
	x = A[j];
	A[j] = A[j-1];
	A[j-1] = x;
	swap_count++;
      }
    }
  }

  for(i = 0; i < length; i++){
    if( i == length-1 ) printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",swap_count);
  
  return 0;
}



Measured memory_bytes: 2064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	for (int i = 0; i < 2; i++) {
		int po = 0;
		vector<int> dai(10);
		for (int i = 0; i < 10; i++) {
			cin >> dai[i];
		}
		sort(dai.begin(), dai.end());
		cout << dai[9] + dai[8] + dai[7];
		if (i == 0) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
}


Measured memory_bytes: 3164
using System;

class Program{
    static string X, Y;
    static int[,] memo;

    static int Count(int x, int y){
        if (memo[x, y]!=-1) {
            return memo[x, y];
        }
        if (X[x]==Y[y]) {
            memo[x, y]=Math.Max(Math.Max(Count(x-1, y), Count(x, y-1)), Count(x-1, y-1)+1);
        } else {
            memo[x, y]=Math.Max(Math.Max(Count(x-1, y), Count(x, y-1)), Count(x-1, y-1));
        }
        return memo[x, y];
    }


    public static void Main(){
        var q=int.Parse(Console.ReadLine());
        for (var i=0; i<q; i++) {
            X="^"+Console.ReadLine();
            Y="^"+Console.ReadLine();
            memo=new int[X.Length, Y.Length];
            for (var x=1; x<X.Length; x++) {
                for (var y=1; y<Y.Length; y++) {
                    memo[x, y]=-1;
                }
            }
            Console.WriteLine(Count(X.Length-1, Y.Length-1));
        }
    }
}

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

using namespace std;

const int N = 1e5 + 7;

int n, a[N];

int main() {
	scanf("%d", &n);
	long long ans = 0, minv = 1;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		int delta = (a[i] - 1) / minv;
		ans += delta;
		a[i] -= delta * minv;
		if (delta > 0) {
			a[i] = 1;
		}
		minv = max(minv, a[i] + 1LL);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
use proconio::input;

fn main() {
    input! {
        n: usize
    }

    let con = 1_000_000_007;

    let ans = {
        let mut tbl = vec![1; n+1];
        for i in 2..=n {
            for &(p,e) in &factor(i) {
                tbl[p] += e;
            }
        }
        let mut ans = 1;
        for i in 2..=n {
            ans *= tbl[i];
            ans %= con;
        }
        ans
    };

    println!("{}",ans)
    
}

pub fn factor(n: usize) -> Vec<(usize, usize)> {
    let mut n = n;
    let mut ret = vec![];
    let ps = primes((n as f64).sqrt() as usize + 2);
    for p in ps {
        let mut cnt = 0;
        while n % p == 0 {
            n /= p;
            cnt += 1;
        }
        if cnt > 0 {
            ret.push((p, cnt));
        }
    }
    if n > 1 {
        ret.push((n, 1));
    }
    ret
}

pub fn primes(n: usize) -> Vec<usize> {
    let mut tbl = vec![true; n];
    let mut ps = vec![];
    tbl[0] = false;
    tbl[1] = false;
    for i in 2..n {
        if tbl[i] {
            ps.push(i);
            let mut j = i + i;
            while j < n {
                tbl[j] = false;
                j += i;
            }
        }
    }
    ps
}

Measured memory_bytes: 2112
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(x):
	l = []
	d = {}
	for i in range(-1000,1000):
		zz = i**5
		d[zz] = i
		l.append(zz)
	for a in range(-2000,2000):
		zz = a**5
		if(zz - x in l):
			print(a,d[zz-x])
			return

X = int(stdin.readline())
ans = solve(X)




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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int N,M;
int a[100001];
int b[100001];


struct UnionFind{
    vector<int> par,s;
    UnionFind(int N) : par(N),s(N){
        REP(i,N){
            par[i] = i;
            s[i] = 1;
        }
    }
    int root(int x){
        if(par[x]==x){ return x; }
        else{ 
          par[x]= root(par[x]);
          return par[x];
        }
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if( rx!=ry ){
            par[rx] = ry;
            s[ry] += s[rx];
        }
    }
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return (rx==ry);
    }
    int size(int x){
        int rx = root(x);
        return s[rx];
    }
};

int main(){
    cin >>N>>M;
    UnionFind uf = UnionFind(N+1);
    for(int i=1;i<=M;++i){
        cin >> a[i] >> b[i];
    }
    ll ans[M+1];
    ans[M] = N*(N-1)/2;
    REPR(i,M-1){
        int x = a[i+1];
        int y = b[i+1];
        
        if(uf.root(x)==uf.root(y)){
            ans[i] = ans[i+1];
        }else{
            ans[i] = ans[i+1] - uf.size(x)*uf.size(y);
        }
        uf.unite(x,y);
    }
    
    for(int i=1;i<=M;++i){
        cout << ans[i]-ans[0] << "\n";
    }
}


Measured memory_bytes: 3712
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

layers = [1] * 51
patties = [1] * 51
for i in range(1, 51):
    # レベルiバーガーの総枚数、パティの数を計算
    layers[i] = 3 + layers[i - 1] * 2
    patties[i] = 1 + patties[i - 1] * 2


def count_patties(l, x):
    # レベル0バーガーなら
    if l == 0 and x == 1:
        return 1
    # レベル0以外の場合、x <= 1なら
    if x <= 1:
        return 0
    y = layers[l - 1]
    # もしB(レベルl - 1バーガー)P(レベルl - 1バーガー)B
    #             ↑
    # にxがあれば
    if x <= y + 1:
        # 左端の一枚を除いて
        return count_patties(l-1, max(x - 1, 0))
    else:
        # 一枚目のl - 1バーガーの内部に                # 2枚目のl - 1バーガーのパティの数 + 中央の1枚
        return count_patties(l-1, min(x-y-2, y)) + patties[l-1] + 1

N, X = getNM()
print(count_patties(N, X))

Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

public class Main {

  static long n;
  static Map<Long, Long> pri;
  static long ans;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Long.parseLong(in[0]);

    br.close();

    pri = new HashMap<>();

    long tmp = n;

    for (long i = 2; i * i <= n; i++) {
      long divCnt = 0;
      while(tmp % i == 0){
        divCnt++;
        tmp /= i;
      }

      if(divCnt != 0){
        pri.put(i, divCnt);
      }
    }

    if(tmp != 1L){
      pri.put(tmp, 1L);
    }

    ans = 0;

    for (Map.Entry<Long, Long> e : pri.entrySet()) {
      long t = e.getValue();
      long itr = 1;
      while(t >= itr){
        t -= itr;
        ans++;
        itr++;
      }
    }

    out.println(ans);

    out.flush();
  }
}


Measured memory_bytes: 33108
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    ll sum[n];
    sum[0] = a[0];
    for(ll i = 1; i < n; i++){
        sum[i] = sum[i-1]+a[i];
    }
    map<ll, ll> I{};
    ll ans = 0;
    for(ll i = 0; i < n; i++) I[sum[i]]++;
    for(auto x : I){
        //cout << x.first << " " << x.second << endl;
        if(x.first==0) ans+=x.second;
        ans += (x.second)*(x.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

//bool flag = __builtin_add_overflow(a , b , &tmp);
//bool flag = __builtin_mul_overflow(a , b , &tmp);
//bool flag3= __builtin_sub_overflow(a , b , &tmp);

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 10004, MAXM = 102, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

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

    vector<int> maxL(n);
    maxL[0] = arr[0];
    for (int i = 1; i < n; ++i) {
        maxL[i] = max(arr[i], maxL[i - 1]);
    }

    vector<int> maxR(n);
    maxR[n - 1] = arr[n - 1];
    for (int i = n - 2; i >= 0; --i) {
        maxR[i] = max(arr[i], maxR[i + 1]);
    }

    cout << maxR[1] << '\n';
    for (int i = 1; i < n - 1; ++i) {
        cout << max(maxL[i - 1], maxR[i + 1]) << '\n';
    }
    cout << maxL[n - 2] << '\n';


    return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long qq;
    scanf("%ld", &qq);

    vector<long> a(qq);
    vector<long> b(qq);

    long i;
    for(i=0; i<qq; i++) {
        scanf("%ld %ld", &(a[i]), &(b[i]));
    }

    for(i=0; i<qq; i++) {
        ll x=MIN(a[i],b[i]);
        ll y=MAX(a[i],b[i]);

        ll ans=x-1;
        if(x==y) {
            ans+=(x-1);
        }
        else{
            double s=sqrt((double)x*y);
            ll tmp=(ll)s;
            tmp--;
            if(tmp<=x) tmp=x;
            while(1) {
                ll tmp2=(ll)x*y/tmp;
                if(tmp2*tmp==x*y)
                    tmp2--;
                if(tmp2<tmp) {
                    ans += (tmp-x);
                    ans += (tmp2-1);
                    break;
                }
                tmp++;
            }
        }
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    int n;
    float ans;
    cin>>n;
    ans = 2.0 * 3.14159 * n;
    cout<<fixed<<setprecision(2)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3788
mod = 10**9 + 7

def init(n):
    # 階乗とその逆元をグローバルに定義
    global factorial, inverse
    # 0-indexedでそれぞれ１で初期化
    factorial = [1]*(n+1)
    inverse = [1]*(n+1)

    fact = 1
    for p in range(1,n+1):
        fact *= p
        fact %= mod
        factorial[p] = fact

    inv = pow(fact, mod-2, mod)
    inverse[n] = inv
    for p in range(2,n+1)[::-1]:
        inv *= p
        inv %= mod
        inverse[p-1] = inv

def comb(n,r):
    if n < r:
        return 0
    return factorial[n] * inverse[n-r] * inverse[r] % mod

H,W,A,B = map(int,input().split())
H -= 1
W -= 1
A -= 1
B -= 1

init(10**6)

def cal(i,j):
    return comb(i+j,i)

ans = 0
for i in range(H-A):
    ans += comb(B+i,i) * comb(W-B-1+H-i,H-i)

ans %= mod
print(ans)

Measured memory_bytes: 82164
#include <stdio.h>


int main (void)
{
  int n, a[100], a_r[100], i;

  scanf("%d", &n);

  for(i =0; i< n; i++){
      scanf("%d", &a[i]);
      a_r[(n-1) - i] = a[i];
  }

  for(i =0; i< n; i++){
    printf("%d", a_r[i]);
      if(i == n-1){ printf("\n"); break;}

    printf(" ");
  }
  return 0;
}

Measured memory_bytes: 1824
#include <iostream>
#include <cstring>
using namespace std;
#define INF 1000000000
int heap[2000000]={INF};
int eoh=1;

void maxHeapify(int* A, int i){
  int h = eoh-1;
  int l = 2*i;
  int r = 2*i+1;
  int largest;
  if ( l<= h && A[l] > A[i] )
    largest = l;
  else
    largest = i;

  if ( r<= h && A[r] > A[largest])
    largest = r;

  if (largest != i){
    swap(A[i], A[largest]);
    maxHeapify(A, largest);
  }
}

void insert(int v, int p=-1){
  if (p == -1){
    p = eoh++;
    heap[p] = v;
    insert(v, p);
    return;
  }
  if (p == 1)
    return;
  int parent = heap[p/2];
  if (parent > v)
    return;
  swap(heap[p/2], heap[p]);
  insert(v, p/2);
}

int del(void){
  if (eoh == 1)
    return -1;
  int res = heap[1];
  heap[1] = heap[eoh-1];
  eoh--;
  maxHeapify(heap, 1);
  return res;
}

int main(){
  char inser[10]="insert", extract[10]="extract", end[10]="end";
  char com[20];
  while(1){
    scanf("%s", com);
    if (!strcmp(com,inser)){
      int temp;
      scanf("%d", &temp);
      insert(temp);
    }
    if (!strcmp(com,extract)){
      printf("%d\n", del());
    }
    if (!strcmp(com,end)){
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 7080
import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto N = to!ulong(tokens[0]);

	ulong big, result;
	foreach (i; 0..N)
	{
		auto p = to!ulong(my_readln());
		result += p;
		if (p > big)
		{
			big = p;
		}
	}
	result -= big / 2;

	writeln(result);
	stdout.flush();
/*}catch (Throwable e)
	{
		writeln(e.toString());
	}
readln();*/
}

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

int div(int x) {
    int ret = 0;
    while (x % 2 == 0) {
        ret++;
        x /= 2;
    }
    return ret;
}
int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 1000000000;
    for (int i = 0; i < n; i++) {
        ans = min(ans, div(a[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define dump(x)      cerr << #x << " = " << (x) << endl;


int main() {
    LL N, M;
    cin >> N >> M;
    LL l = 1, r = N;
    REP(i, M) {
        LL ll, rr;
        cin >> ll >> rr;
        if (l < ll) {
            l = ll;
        }
        if (rr < r) {
            r = rr;
        }
    }
    cout << max((LL)0, r - l + 1) << endl;
	
    return 0;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [-1]*(N+1)
path = []
at = 1
count = 0
while True:
    if visited[at] != -1:
        loop = count-visited[at]
        if K < count: # (K-visited[at])//loopが1以上であることを保証
            print(path[K]) # 条件 K < visited[at]なら、(K-visited[at])//loopが0以上であることを保証。どっちでもよさそう。
        else:
            print(path[(K-visited[at])%loop+visited[at]])
        break
    visited[at] = count
    count += 1
    path.append(at)
    at = A[at-1]

Measured memory_bytes: 32304
using System;

namespace ConsoleApplication
{
	public class Program
	{
		public static void Main(string[] args) {
			int n = int.Parse(Console.ReadLine());
			Int64 re = 1;
			for (int i = 2; i <= n; i++) {
				re *= i;
				re %= 1000000007;
			}

			Console.WriteLine(re);
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

int main(){
    string S;
    cin >> S;
    int cnt=0;
    for(int i=0;i<S.size()/2;i++){
        if(S[i]!=S[S.size()-1-i]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
con=set()
wild=0

for p in a:
  if p<=399:
    con.add("灰")
  elif p<=799:
    con.add("茶")
  elif p<=1199:
    con.add("緑")
  elif p<=1599:
    con.add("水")
  elif p<=1999:
    con.add("青")
  elif p<=2399:
    con.add("黄")
  elif p<=2799:
    con.add("橙")
  elif p<=3199:
    con.add("赤")
  else:
    wild +=1
    
mini=max(1,len(con))
maxi=len(con)+wild
print(mini,maxi)

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

s = 0

for i in range(n-1):
    s += b[a[i]-1]
    if a[i+1] == a[i]+1:
        s += c[a[i]-1]

s+=b[a[n-1]-1]

print(s)

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val strs = Array(n) {
        readLine()!!.toCharArray().sorted().fold("") {
            acc: String, c: Char -> acc+c
        }.toString()
    }
    strs.sort()
    var ans = 0L
    val list = Array<Long>(100010) {
        0
    }
    for(i in 2..100005) {
        list[i] = list[i-1] + i - 1
    }

    var s = 0
    var str: String
    while(s < n) {
        str = strs[s]
        var count = 0
        while (s < n && strs[s] == str) {
            s++
            count++
        }
        ans += list[count]
    }
    println(ans)
}

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

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

    for (int i=0; i<n; i++){
        string a;
        cin >> a;
        
        if (a=="Y") {
            cout << "Four" <<endl;
            break;
        }
        if (i == n-1){
            cout << "Three" <<endl;
        }

    }

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
#include <atcoder/dsu>
typedef long long ll;
using namespace std;
using namespace atcoder;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        cin>>t>>u>>v;
        if (t == 0) {
            d.merge(u, v);
        }
        else {
            if (d.same(u, v)) {
                cout << 1 << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
    }

	return 0;
}


Measured memory_bytes: 3992
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    List<String> saidList = new ArrayList<>();
    String ans = "Yes";
    saidList.add(sc.next());
    for (int i = 1; i < N; i++) {
      String currentWord = sc.next();
      if (saidList.contains(currentWord) || !isShiritori(currentWord, saidList.get(i-1))) {
        ans = "No";
        break;
      }
      saidList.add(currentWord);
    }
    System.out.println(ans);
  }
  private static boolean isShiritori(String curWord, String preWord) {
     return curWord.substring(0,1).equals(preWord.substring(preWord.length()-1));
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> s(h, vector<char>(w));
	rep(i, h) rep(j, w) {
		cin >> s[i][j];
	}
	int B = (s[0][0] == '#') ? 1 : 0;
	VV dp(h, V(w, B));
	vector<vector<bool>> visited(h, vector<bool>(w, false));
	visited[0][0] = true;
	rep(i, h) rep(j, w) {
		if (i + 1 != h) {
			int tmp = 0;
			if (s[i][j] == '.' && s[i + 1][j] == '#') tmp++;
			if (!visited[i + 1][j]) dp[i + 1][j] = dp[i][j] + tmp;
			else chmin(dp[i + 1][j], dp[i][j] + tmp);
			visited[i + 1][j] = true;
		}
		if (j + 1 != w) {
			int tmp = 0;
			if (s[i][j] == '.' && s[i][j + 1] == '#') tmp++;
			if (!visited[i][j + 1]) dp[i][j + 1] = dp[i][j] + tmp;
			else chmin(dp[i][j + 1], dp[i][j] + tmp);
			visited[i][j + 1] = true;
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
 
int n,a[2005],z,w;
 
int main(){
	int i;
	cin>>n>>z>>w;
	
	for(i=1;i<=n;i++)
		cin>>a[i];
	a[0]=a[n];
	
	cout<<max(abs(a[n-1]-a[n]),abs(a[n]-w))<<endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    vector<vector<ll>> dp(n, vector<ll>(2, 0));
    dp[1][1] = a[0]+a[1];
    dp[1][0] = -a[0]-a[1];
    for(int i = 1; i < n-1; i++){
        dp[i+1][0] = max(dp[i][0]+2*a[i]-a[i+1], dp[i][1]-2*a[i]-a[i+1]);
        dp[i+1][1] = max(dp[i][0]+a[i+1], dp[i][1]+a[i+1]);
    }
    cout << max(dp[n-1][0], dp[n-1][1]) << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H-h) * (W-w) << endl; 
    
    return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };

signed main() {
	int a, b, c; cin >> a >> b >> c;
	if (a == b&&b == c)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

#define N 10000

int main()
{
  int i,j,hako[N],n,count = 0,flag;
  int r;

  scanf("%d",&n);


  for(i = 0;i < n;i ++)
    {
  scanf("%d", &hako[i]);
    }


  for( j = 0 ;j < n;j ++ ){
    r = (int) sqrt(hako[j]);
    flag = 0;
    for(i = 2;i <= r;i ++){
      if( hako[j]%i == 0 ) {
        flag = 1;
        break;
      }
    }
    if(flag == 0)count ++;
  }


  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 628
using namespace std;
#include <bits/stdc++.h>
#define rep(x,to) for(i=0;i<to;i++)

int main() {
	int n,q,a,time,i,time_s=0;
	string name;
	queue<pair<string,int> > que;
	
	cin>>n>>q;
	
	rep(0,n){
		cin>>name>>time;
		que.push(make_pair(name,time));
	}
	
	while(!que.empty()){
		pair<string,int> t = que.front();
		que.pop();
		if(q < t.second){
			time_s += q;
			que.push(make_pair(t.first,t.second-q));
		}
		else{
			time_s += t.second;
			cout<<t.first<<" "<<time_s<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = a*c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3672
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		LinkedList<Integer> primes=new LinkedList<Integer>();
		for(int i=2;i<=50000;i++){
			boolean isprime=true;
			for(int prime:primes){
				if(i%prime==0){
					isprime=false;
					break;
				}
				if( prime*prime>i){
					break;
				}
			}
			if(isprime){
				primes.add(i);
			}
		}
		boolean[] hash=new boolean[50001];
		for(int prime:primes){
			hash[prime]=true;
		}

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

			int c=0;
			for(int a=2;a<=n/2;a++){
				int b=n-a;
				if(hash[a] && hash[b]){
					c++;
				}
			}
			ln(c);
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 13000
#include<cstdio>
#include<algorithm>
#define _ 0
#define INF 0x7fffffff
#define re register
#define drep(i ,l ,r) for(re int i = (r) ; i >= (l) ; -- i)
#define rep(i ,l ,r) for(re int i = l ; i <= r ; ++ i)
#define Next(u ,i) for(re int i = head[u] ; i ; i = e[i].next)
int n;
int read() {
    char cc = getchar() ; int cn = 0 ,flus = 1;
    while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus ; cc = getchar();}
    while(cc >= '0' && cc <= '9') cn = cn * 10 + cc - '0' ,cc = getchar();
    return flus * cn;
}
signed main() {
    n = read();
    printf("%d" ,n ^ 1);
    return ~~(0^_^0);
}

Measured memory_bytes: 1600
#include<cstdio>
#include<iostream>
using namespace std;
 
int main()
{
    int a,b;
    cin>>a>>b;
    
        if(a<=0&&b>=0)
            cout<<"Zero"<<endl;
        else if(a<0)
        {
            int key=b-a;
            if(key%2!=0)
                cout<<"Positive"<<endl;
            else
                cout<<"Negative"<<endl;
        }
        else
            cout<<"Positive"<<endl;
    
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define FOR(I,A,B) for(register int I=A;I<=B;++I)
using namespace std;
struct node
{
	int num,v;
}ups[100005],dos[100005];
bool operator<(node a,node b){return a.num>b.num;}
bool upn[100005],don[100005];
int n,c,p,q,ap,aq;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>c;
		if(i&1)
		{
			if(upn[c])
			{
				ups[c].num++;
			}
			else
			{
				upn[c]=1;
				ups[c].v=c;
				ups[c].num=1;
				ap++;
			}
		}
		else 
		{
			if(don[c])
			{
				dos[c].num++;
			}
			else
			{
				don[c]=1;
				dos[c].v=c;
				dos[c].num=1;
				aq++;
			}
		}
	}
	sort(ups+1,ups+1+100000);
	sort(dos+1,dos+1+100000);
	//for(int i=1;i<=ap;i++)cout<<ups[i].num<<" ";cout<<endl;
	//for(int i=1;i<=aq;i++)cout<<dos[i].num<<" ";cout<<endl;
	int x=1,y=1;
	while(ups[x].v==dos[y].v)
	{
		((ups[x+1].num+dos[y].num)>(ups[x].num+dos[y+1].num))?++x:++y;
	}
	cout<<n-ups[x].num-dos[y].num;
	return 0;
} 

Measured memory_bytes: 2048
#include <stdio.h>

int main()
{
    int a=0,i=0,b=0,soma=0;
    scanf("%d%d",&a,&b);

    for(i=0;i<2;i++)
    {
        if(a>b)
        {
            soma+=a;
            a--;
        } else if(b>a)
        {
           soma+=b;
           b--;
        }
        else if(b==a)
        {
            soma+=b;
            b--;
        }

    }
    printf("%d\n",soma);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.tri", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i;
	int a, b, c;
	vector <int> side(3,0);

	for (i = 0; i < n; ++i){
		getline (cin, str );
		stringstream ss(str);
		ss >> a >> b >> c;
		side[0] = a; side[1] = b; side[2] = c;		
		sort (side.begin(), side.end() );

		if (side[2] < side[0] + side[1] && side[2]*side[2] == side[1]*side[1] + side[0]*side[0]){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if
	} // end for
		
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int dp[6][3125], n, x[7][5], pp[5] = { 0,0,60,70,80 };
int power4[6] = { 1,4,16,64,256,1024 }, power5[6] = { 1,5,25,125,625,3125 };
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 5; j++) {
			for (int k = 0; k < 5; k++)cin >> x[j][k];
		}
		for (int j = 0; j < 6; j++) { for (int k = 0; k < 3125; k++) { dp[j][k] = -1; } }
		for (int j = 0; j < 256; j++) {
			int bit[4]; for (int k = 0; k < 4; k++)bit[k] = (j / power4[k]) % 4;
			int y[7][5]; for (int k = 0; k < 35; k++)y[k / 5][k % 5] = x[k / 5][k % 5];
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < bit[k]; l++) {
					if (y[0][k] >= 1) { y[0][k]++; if (y[0][k] == 5)y[0][k] -= 4; }
					if (y[1][k] >= 1) { y[1][k]++; if (y[1][k] == 5)y[1][k] -= 4; }
					if (y[0][k + 1] >= 1) { y[0][k + 1]++; if (y[0][k + 1] == 5)y[0][k + 1] -= 4; }
					if (y[1][k + 1] >= 1) { y[1][k + 1]++; if (y[1][k + 1] == 5)y[1][k + 1] -= 4; }
				}
			}
			int W = 0; for (int k = 0; k < 5; k++)W += power5[k] * y[1][k];
			int W2 = 0; for (int k = 0; k < 5; k++)W2 += pp[y[0][k]];
			dp[0][W] = max(dp[0][W], W2);
		}
		for (int j = 1; j <= 3; j++) {
			for (int k = 0; k < 3125; k++) {
				if (dp[j - 1][k] == -1)continue;
				int bit[5]; for (int l = 0; l < 5; l++)bit[l] = (k / power5[l]) % 5;
				for (int l = 0; l < 256; l++) {
					int y[7][5]; for (int m = 0; m < 35; m++)y[m / 5][m % 5] = x[m / 5][m % 5];
					for (int m = 0; m < 5; m++)y[j][m] = bit[m];
					int bit2[4]; for (int m = 0; m < 4; m++) { bit2[m] = (l / power4[m]) % 4; }
					for (int m = 0; m < 4; m++) {
						for (int o = 0; o < bit2[m]; o++) {
							if (y[j + 0][m + 0] >= 1) { y[j + 0][m + 0]++; if (y[j + 0][m + 0] == 5)y[j + 0][m + 0] -= 4; }
							if (y[j + 1][m + 0] >= 1) { y[j + 1][m + 0]++; if (y[j + 1][m + 0] == 5)y[j + 1][m + 0] -= 4; }
							if (y[j + 0][m + 1] >= 1) { y[j + 0][m + 1]++; if (y[j + 0][m + 1] == 5)y[j + 0][m + 1] -= 4; }
							if (y[j + 1][m + 1] >= 1) { y[j + 1][m + 1]++; if (y[j + 1][m + 1] == 5)y[j + 1][m + 1] -= 4; }
						}
					}
					int W = 0; for (int m = 0; m < 5; m++) W += power5[m] * y[j + 1][m];
					int W2 = 0; for (int m = 0; m < 5; m++)W2 += pp[y[j][m]];
					dp[j][W] = max(dp[j][W], dp[j - 1][k] + W2);
				}
			}
		}
		int maxn = 0;
		for (int j = 0; j < 3125; j++) {
			if (dp[3][j] == -1)continue;
			int sum1 = 0; for (int k = 0; k < 5; k++)sum1 += pp[(j / power5[k]) % 5];
			maxn = max(maxn, dp[3][j] + sum1);
		}
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
<?php
    /*
        Problem URL : http://abc059.contest.atcoder.jp/tasks/abc059_b

        Score  :
        Result :
        Time   : ms
        Memory : KB
     */

    ini_set('error_reporting', E_ALL & ~E_NOTICE);

    // define('DEBUG', true);
    define('DEBUG', false);

    if (DEBUG) {
        $start = microtime(true);
    }

    fscanf(STDIN, "%s", $A);
    fscanf(STDIN, "%s", $B);

    $lenA = strlen($A);
    $lenB = strlen($B);

    if ($lenA > $lenB) {
        echo "GREATER\n";
        exit;
    }
    if ($lenA < $lenB) {
        echo "LESS\n";
        exit;
    }
    if ($A == $B) {
        echo "EQUAL\n";
        exit;
    }
    if ($A > $B) {
        echo "GREATER\n";
    } else {
        echo "LESS\n";
    }


Measured memory_bytes: 4728
n,y = map(int,input().split())
c = (y%5000)//1000
y -= c*1000
n -= c
for i in range(100000):
    a = (y-5000*n)//5000
    b = n - a
    if 0 <= a and 0 <= b and 0 <= c:
        print(a,b,c)
        break
    c += 5
    n -= 5
    y -= 5000
    
    if i == 100000 - 1:
        print(-1,-1,-1)


Measured memory_bytes: 9092
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

map<pair<int,int>,long long> dp;
int n,m,k;

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	while (scanf("%d%d%d",&n,&m,&k) && n!=0) {
		dp.clear();
		for (int i=0; i<n; i++) for (int j=0; j<=n*m; j++) dp[make_pair(i,j)] = 0;
		long long p = 1;
		for (int i=0; i<n; i++) p *= (long long)m;
		for (int i=0; i<n; i++) {
			for (int j=0; j<=n*m; j++) {
				for (int t=1; t<=m; t++) {
					if (i==0) dp[make_pair(i,t)] = 1;
					else {
						if (t+j<=m*n) dp[make_pair(i,t+j)] += dp[make_pair(i-1,j)];
					}
				}
			}
		}
		//for (int i=0; i<=m*n; i++) cout<<i<<" "<<dp[make_pair(n-1,i)]<<endl;
		long long ans = 0;
		for (int i=0; i<=k+1; i++) ans += dp[make_pair(n-1,i)];
		for (int i=k+2; i<=n*m; i++) ans += (long long)(i-k)*dp[make_pair(n-1,i)];
		printf("%.12lf\n",(double)ans/p); 
	}

    return 0;

}

Measured memory_bytes: 1848
#include<iostream>
#include<stack>
#include<cstdlib>

using namespace std;

int main()
{
    stack<int> s;
    char c[100];

    while( cin >> c )
    {
        if( c[0] == '+' )
        {
            int a = s.top();
	    s.pop();
	    int b = s.top();
	    s.pop();
	    s.push( a + b );
        }
	else if( c[0] == '-' )
        {
            int a = s.top();
	    s.pop();
	    int b = s.top();
	    s.pop();
	    s.push( b - a );
        }
	else if( c[0] == '*' )
        {
            int a = s.top();
	    s.pop();
	    int b = s.top();
	    s.pop();
	    s.push( a * b );
        }
        else
        {
            s.push( atoi( c ) );
        }
    }

    cout << s.top() << endl;

    return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <fstream>
#include <tuple>

using namespace std;

#define fori(t) for(int i = 0; i < t; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define fork(n) for(int k = 0; k < n; ++k)
#define forai(a) for(auto& i : a)
#define foraj(a) for(auto& j : a)
#define forak(a) for(auto& k : a)
#define forp(s, n, d) for(int p = s; p < n; p += d)
#define fast cin.tie(0); cout.tie(0); std::ios_base::sync_with_stdio(0);
#define pb(a) push_back(a);
#define pob(a) pop_back(a);
#define sorti(a) sort(a.begin(), a.end());
#define sortm(a, n) sort(a, a + n);
#define reversi(a) reverse(a.begin(), a.end());
#define fi first
#define se second
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define ans(a) cout << a << '\n';
#define res(a, n) a.resize(n);
#define read(a, n) a.resize(n); fori(n) cin >> a[i];
//#define int long long
//#define double long double

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<long long, long long> llll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<int, pair<int, int>>> viii;
typedef pair<int, pair<int, int>> iii;
typedef vector<pair<long long, long long>> vllll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef pair<char, char> cc;
typedef pair<pair<char, char>, char> ccc;
typedef vector<char> vc;
typedef pair<int, char> ic;
typedef pair<ii, char> iic;
typedef vector<bool> vb;
typedef set<int> si;
typedef set<ii> sii;

const int INF = 2147483647;
const ll LONGINF = 9223372036854775807;
const ll MOD = 998244353;

string c;

void solve()
{
    int n;
    cin >> n >> c;
    int lastR = n - 1, firstW = 0, counter = 0;
    while (lastR > firstW && lastR >= 0 && firstW < n)
    {
        while (c[firstW] != 'W' && firstW < n) ++firstW;
        while (c[lastR] != 'R' && lastR >= 0) --lastR;
        if (lastR <= firstW || lastR < 0 || firstW >= n) break;
        swap(c[lastR], c[firstW]);
        ++counter;
        --lastR;
        ++firstW;
    }
    ans(counter)
}

signed main()
{
    fast
    bool mult = false;
    if (mult)
    {
        int t;
        cin >> t;
        while (t--) solve();
    }
    else solve();
}


Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    ll ans = 0;
    for(int i=0;i<60;i++){
        ll x = 0;
        for(int j=0;j<n;j++) if(a[j]>>i & 1) x++;
        ll now = x*(n-x)%MOD;
        for(int j=0;j<i;j++) now = now*2%MOD;
        ans += now;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
//In the name of He
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long long maxn = 3e5 + 5 + 1;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

int x,a,b,c,ans;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c >> x;
	for(int i = 0; i <= a; i++){
		for(int j = 0; j <= b; j++){
			for(int k = 0; k <= c; k++){
				int s = i*500 + j*100 + k*50;
				if(s == x){
					ans++;
				}
			}
		}
	}
	cout << ans;
	return 0;
}


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

struct Color{
	int gray = 0;
	int brown = 0;
	int green = 0;
	int lightBlue = 0;
	int blue = 0;
	int yellow = 0;
	int orange = 0;
	int red = 0;
	int any = 0;

	int sum() {
		return gray + brown + green + blue + \
			lightBlue + yellow + orange + red;
	}
};


void judge(int a, Color& color) {
	if (a <= 399) { color.gray = 1; }
	else if (a <= 799) { color.brown = 1; }
	else if (a <= 1199) { color.green = 1; }
	else if (a <= 1599) { color.blue = 1; }
	else if (a <= 1999) { color.lightBlue = 1; }
	else if (a <= 2399) { color.yellow = 1; }
	else if (a <= 2799) { color.orange = 1; }
	else if (a <= 3199) { color.red = 1; }
	else { color.any += 1; }

	return;
}

int main() {
	int n;
	Color color;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		judge(a, color);
	}
	int min_ans, max_ans;

	min_ans = color.sum();
	if (min_ans== 0 && color.any >0) { min_ans = 1; }
	max_ans = color.sum() + color.any;

	cout << min_ans << " " << max_ans << endl;
}

Measured memory_bytes: 3580