akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
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;

int main(){
    string s;
    cin>>s;
    int l=s.length();
    int count=0;
    REP(i, l/2){
        if(s[i]!=s[l-i-1]){
            count++;
        }
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 256
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


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


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a, b = inls()

if a==b:
    print('H')
else:
    print('D')



Measured memory_bytes: 3568
N=int(input())
A=[]
for i in range(0,N):
    a=int(input())
    A.append(a)

A.sort()

if N%2==0:
    k=N//2
    ans=2*sum(A[k:N])-A[k]-(2*sum(A[0:k])-A[k-1])
    print(ans)
else:
    k=N//2
    ans1=2*sum(A[k+1:N])-2*(sum(A[0:k+1]))+A[k]+A[k-1]
    ans2=2*sum(A[k:N])-A[k]-A[k+1]-2*sum(A[0:k])
    print(max(ans1,ans2))

Measured memory_bytes: 55384
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_str():
    return readline().strip()


def slv(N, X):
    C = X.count('1')
    cmr = 0
    cpr = 0
    for b in X:
        b = int(b)
        cpr = ((cpr * 2) + b) % (C+1)
        if C-1 != 0:
            cmr = ((cmr * 2) + b) % (C-1)

    ans = []
    for i in range(N):
        t = 0
        if X[i] == '0':
            x = (cpr + pow(2, N-i-1, C+1)) % (C+1)
            t += 1
        elif X[i] == '1' and C-1 != 0:
            x = (cmr - pow(2, N-i-1, C-1)) % (C-1)
            t += 1
        else:
            x = 0

        while x != 0:
            x = x % bin(x).count('1')
            t += 1

        ans.append(t)

    return ans


def main():
    N = read_int()
    X = read_str()
    print(*slv(N, X), sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 94636
#include <bits/stdc++.h>
using namespace std;
#define INF 0X3f3f3f3f
#define M 1000000007
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define mp make_pair
#define pb push_back 
#define fi first
#define se second
#define endl "\n"
#define PI acos(-1)
#define fastcin ios_base::sync_with_stdio(false);
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> ii;
typedef complex<double> base;

const int N = 100005;
int k;
int a[N];

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

	for(int i = 0; i < k; i++){
		scanf("%d", &a[i]);
	}

	reverse(a, a+k);

	ll l = 2, r = 2;
	for(int i = 0; i < k; i++){
		// printf("l = %lld, r = %lld\n", l, r);
		if(r < a[i]){
			printf("-1\n");
			return 0;
		}

		ll nl = l - l%a[i];
		if(nl < l) nl += a[i];
		if(!(nl >= l and nl <= r)){
			printf("-1\n");
			return 0;
		}

		ll nr = r - r%a[i];// + (a[i]-1);
		if(!(nr >= l and nr <= r)){
			printf("-1\n");
			return 0;
		}
		nr += (a[i]-1);

		if(nl > nr){
			printf("-1\n");
			return 0;
		}

		l = nl, r = nr;
	}

	printf("%lld %lld\n", l, r);	


	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef priority_queue <int> pi;
typedef priority_queue <int, vector<int>, greater<int>> pg;
typedef unsigned long long int ulli;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int money[M];
    int temp;
    for(int i = 0; i < M; ++i) {
        cin >> temp;
        money[i] = temp;
    }
    int ans = 0;
    for(int i = X ; i < N; ++i) {
        for (int j = 0; j< M; ++j) {
            if (i == money[j]) ++ans;
        }
    }
    temp = 0;
    for(int i = X ; i > 0; --i) {
        for(int j = 0; j < M; ++j) {
            if(i == money[j]) ++temp;
        }
    }

    ans = min(ans,temp);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define MM(arr,x) memset(arr,x,sizeof(arr))
#define INF 0x3f3f3f3f
#define Maxn 1e5+10;
using namespace std;
int a[200050],n,k;
bool check(int mid)
{
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>mid) ans+=a[i]/mid;
		if(ans>k) return 0;
	}
	return 1;
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>k;
	int l=1,r=-1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		r=max(a[i],r);
	}
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			r=mid;
		}
		else l=mid+1;
	}
	cout<<l;
	return 0;
} 


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

using namespace std;

int n, k;
int d[105], dd[105];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    int x;
    for (int i = 1; i <= k; i++)
    {
        cin >> d[i];
        for (int j = 1; j <= d[i]; j++)
        {
            cin >> x;
            dd[x] = 1;
        }
    }
    cout << count(dd + 1, dd + n + 1, 0);
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
    int n,k,p,i,m;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%d %d",&k,&p);
		m=k%p;
		if (k<=p){
		    printf("%d\n",k);
		}
		else if(m==0){
		    printf("%d\n",p);
		}
		else {
		    printf("%d\n",m);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
/*
  AtCoder Beginner Contest 099
  C - Strange Bank
*/

#include<iostream>
#include<vector>
#include<limits>
using namespace std;

int MAX_INT = numeric_limits<int>::max();
int N;
vector<int> vec6, vec9;

int getMinTimes(int n, int idx6, int idx9) {
  if (n < 6) return n;

  while (1) {
    if (idx6 == -1) break;
    if (vec6[idx6] <= n) break;
    idx6 -= 1;
  }
  
  while (1) {
    if (idx9 == -1) break;
    if (vec9[idx9] <= n) break;
    idx9 -= 1;
  }

  int buf6 = MAX_INT, buf9 = MAX_INT;
  if (idx6 != -1) buf6 = getMinTimes(n - vec6[idx6], idx6, idx9);
  if (idx9 != -1) buf9 = getMinTimes(n - vec9[idx9], idx6, idx9);
  
  if (buf6 < buf9) return buf6 + 1;
  else return buf9 + 1;
}

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

  base = 1;
  while (base * 6 <= N) {
    base *= 6;
    vec6.push_back(base);
  }

  base = 1;
  while (base * 9 <= N) {
    base *= 9;
    vec9.push_back(base);
  }

  int idx9 = vec9.size() - 1, idx6 = vec6.size() - 1;
  printf("%d\n", getMinTimes(N, idx6, idx9));

  return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

int main() {
	int N, P; cin >> N >> P;
	vector<int> a(N + 1), b(N + 1);
	rep(i, N) cin >> a[i] >> b[i];
	a[N] = 0; b[N] = P + 1; N++;
	vector<vector<int> > dp(N + 1, vector<int>(N + 1, -1));
	dp[0][0] = P;
	rep(l, N) for (int r = l + 1; r <= N; r++) {
		int prev = 0;
		ll sum = 0;
		for (int i = l; i < r - 1; i++) {
			int x = max(0, a[i] - prev);
			int t = max(0, b[i] - x);
			prev = t;
			sum += t;
		}
		for (int x = 0; x + (r - l - 1) <= N; x++) {
			int _x = x + (r - l - 1);
			if (sum <= dp[l][x])
				dp[r][_x] = max((ll)dp[r][_x], dp[l][x] - sum);
		}
	}
	int ma = 0;
	for (int x = 0; x <= N; x++)
		if (dp[N][x] != -1)
			ma = max(ma, x);
	cout << ma << endl;
}

Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;

int main()
{
	long long a,b,c,num;
	scanf("%lld%lld%lld",&a,&b,&c);
	num=b/c-a/c;
	if(a%c==0) num++;
	printf("%lld\n",num);
}

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


int main() {
  string S; cin >> S;
  char p = S.at(0);
  if(p == 'R') cout << "Sunny" << endl;
  if(p == 'S') cout << "Cloudy" << endl;
  if(p == 'C') cout << "Rainy" << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int A, B, C;
    std::cin >> A >> B >> C;

    int ans = A * B;
    if (A > B && A > C) ans = B * C;
    else if (B > A && B > C) ans = A * C;

    std::cout << (ans/2) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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;
}

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

    int N, A, B;
    cin >> N >> A >> B;

    int diff = B - A - 1;
    if (diff % 2 == 0) {
        std::cout << "Borys" << '\n';
    } else {
        std::cout << "Alice" << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void READ() {
#define R READ();
#define INFI 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MEMX(x,num) memset(x,num,sizeof(x))
#define prln(x) cout<<#x<<"="<<x<<endl
#define sz(x) int(x.size())
#define PB(x) push_back(x)
#define LINK(x,y) G[x].PB(y),G[y].PB(x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#ifndef ONLINE_JUDGE
    freopen("A.in", "r", stdin);
#endif
    std::ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(6);
}
///////////////////////////
const int N = 5 + 1e5;

int n;
LL a,b,c,k;
int main() {
    
    cin>>a>>b>>c>>k;
    if(k%2==0)cout<<a-b;
    else cout<<b-a;



    return 0;
}



Measured memory_bytes: 256
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

    N = int(input())
    H = list(map(int, input().split()))

    if N == 1:
        print('Yes')
        exit()

    H[0] -= 1
    for i in range(N - 1):
        if H[i] < H[i + 1]:
            H[i + 1] -= 1

    ans = 'Yes'
    for i in range(N - 1):
        if H[i] <= H[i + 1]:
            continue
        else:
            ans = 'No'
            break

    # print(H)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////

int n,m,a[310][310];
int cnt[310];bool used[310];
bool j(int x){
  P mx;rep(i,310)used[i] = false;
  while(true){
    rep(i,m)cnt[i] = 0;
    rep(i,n){
      rep(j,m){
        if(!used[a[i][j]]){
          cnt[a[i][j]]++;
          break;
        }
      }
    }
    mx = P(-1, -1);
    rep(i,m)if(mx.first < cnt[i])mx = P(cnt[i], i);
    if(mx.first <= x)return true;
    used[mx.second] = true;
    bool r = false;rep(i,m)if(!used[i])r = true;
    if(!r)return false;
  }
}

signed main(){
  cin>>n>>m;
  rep(i,n)rep(j,m){
    cin>>a[i][j];a[i][j]--;
  }

  int ok = n, ng = 0;
  while(ok - ng > 1){
    int mid = (ok+ng)/2;
    if(j(mid))ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}


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

typedef struct{
    int x,y;
} square;

square data[200];

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

int main(){
    while(1){
        int N,left=0,right=0,up=0,down=0;
        cin>>N;
        if(N == 0) break;

        for(int i=1; i<N; i++){
            
            int n,d;
            cin>>n>>d;

            data[i].x = data[n].x+dx[d];
            data[i].y = data[n].y+dy[d];

            left = min(left,data[i].x);
            right = max(right,data[i].x);
            up = max(up,data[i].y);
            down = min(down,data[i].y);
         }

        cout<<right-left+1<<" "<<up-down+1<<endl;
    }


    return 0;
}


Measured memory_bytes: 3008
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, a;

  std::cin >> N >> M;

  std::set<int> set;

  for (int i = 0; i < M; i ++) {
    std::cin >> a;

    set.insert(a);
  }

  long long dp[111111];

  memset(dp, 0, sizeof(dp));

  dp[0] = 1;

  for (int i = 0; i < N; i ++) {
    if (set.count(i + 1) == 0)
      (dp[i + 1] += dp[i]) %= MOD;
  
    if (set.count(i + 2) == 0)
      (dp[i + 2] += dp[i]) %= MOD;
  }

  std::cout << dp[N] << std::endl;

  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main()
{
    ll N, M;   cin >> N >> M;
    ll nmax = min(M, 2000000LL);
    ll ans = 1;
    if(M%N==0)  ans = M/N;
    else{
        for(ll i=1; i<nmax; i++){
            if(M % i == 0 && M / i * N <= M){
                ans = M/i;
                break;
            }
            if(M % i == 0 && i * N <= M)    ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> h(n),dp(n+2,INT_MAX);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  dp[0]=0;
  for (int i = 0; i < n; i++){
    chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
  }
  cout << dp[n-1] << '\n';
  return 0;
}

Measured memory_bytes: 4000
#include <stdio.h>
#include <string.h>

#define MOD 100000

int dp[17712][20][20]; //1(JOª é)ÍA±µÄÍ¢¯È¢->fib(21) = 17711Êè
int x, y;
char map[20][21];
int mask;
short check[1 << 20];

int solve(int place, int bit)
{
    int res;
    int nx, ny;
    
    if (place == y * x){
        return (1);
    }
    
    ny = place / x;
    nx = place % x;
    
    res = dp[(int)check[bit]][ny][nx];
    if (res == -1){
        int temp = 0;
        
        // u©êéÌªJ
        if (map[ny][nx] == '?' || map[ny][nx] == 'J'){
            int nextbit = bit;
            if (nextbit & 1){
                nextbit = ((nextbit - 1) << 1) | 1; //Jðu¢½_Å, »±ÍJOªA±µÈ¢
            }
            else {
                nextbit = (nextbit << 1) | 1;       //ãÆ¯¶.
            }
            nextbit &= mask;
            temp += solve(place + 1, nextbit);
            temp %= MOD;
        }
        
        //u©êéÌªO
        if (map[ny][nx] == '?' || map[ny][nx] == 'O'){
            int nextbit = bit;
            nextbit <<= 1;
            nextbit &= mask;
            temp += solve(place + 1, nextbit);
            temp %= MOD;
        }
        
        //u©êéÌªI
        if (map[ny][nx] == '?' || map[ny][nx] == 'I'){
            if (((1 << (x - 1)) & bit) == 0 || nx == x - 1){ //¡Ìêª, sÌ[©, ¿å¤ÇãÌêÉJOªÈ¯êÎ
                int nextbit = bit;
                if (nextbit & 1){
                    nextbit = (nextbit - 1) << 1;
                }
                else {
                    nextbit <<= 1;
                }
                nextbit &= mask;
                temp += solve(place + 1, nextbit);
                temp %= MOD;
            }
        }
        res = temp;
    }
    return (dp[(int)check[bit]][ny][nx] = res);
}

int main(void)
{
    int i, j;
    int q;
    int ans;
    int temp, num, flag;
    
    scanf("%d%d", &y, &x);
    getchar();
    q = 1;
    for (i = 0; i < y; i++){
        for (j = 0; j < x; j++){
            scanf("%c", &map[i][j]);
            
            if (map[i][j] == '?'){
                q = (q * 3) % MOD;
            }
        }
        getchar();
    }
    
    memset(check, -1, sizeof(check));
    num = 0;
    for (i = 0; i < 1 << x; i++){
        flag = 1;
        temp = i << 1;
        while (temp != 0){
            if ((temp >> 1) & 1 && (temp >> 2) & 1){
                flag = 0;
                break;
            }
            temp >>= 1;
        }
        if (flag){
            check[i] = num++;
        }
    }
    mask = (1 << x) - 1;
    memset(dp, -1, sizeof(dp));
    ans = solve(0, 0);
    
    printf("%d\n", (q - ans + MOD) % MOD);
    
    return (0);
}

Measured memory_bytes: 0
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] one = s.nextLine().split(" ");
		QueueImpl qqq = new Main().new QueueImpl();
		for(int i=0 ; i<new Integer(one[0]).intValue() ; i++){
			String[] two = s.nextLine().split(" ");
			Process p = new Main().new Process(two[0], new Integer(two[1]).intValue());
			qqq.enqueue(p);
		}

		int quon = new Integer(one[1]).intValue();
		int totalTime = 0;
		while(! qqq.isEmpty()) {
			Process p = qqq.dequeue();
			if(quon >= p.time) {
				totalTime += p.time;
				System.out.println(p.name + " " + totalTime);
			}else {
				p.time = p.time - quon;
				qqq.enqueue(p);
				totalTime += quon;
			}
		}
	}

	public class QueueImpl {
		Process[] array;
		int head;
		int tail;
		public QueueImpl() {
			array = new Process[100000];
			head = -1;
			tail = -1;
		}

		public void enqueue(Process obj) {
			if(tail == 99999)
				tail = -1;
			tail++;
			array[tail] = obj;
		}

		public Process dequeue() {
			if(head == 99999)
				head = -1;
			head++;
			Process tmp = array[head];
			array[head] = null;
			return tmp;
		}

		public boolean isEmpty(){
			return this.head == this.tail;
		}
	}

	public class Process {
		String name;
		int time;
		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}
	}
}

Measured memory_bytes: 98936
#include<stdio.h>  
   
int a[105][105],b[10000+50];  
   
int main ()  
{  
    int h,w;  
    while(scanf("%d %d",&h,&w)!=EOF)  
    {  
        int i,j,t,k=0;  
        scanf("%d",&t);  
        for(i=0;i<t;i++)  
            scanf("%d",&b[i]);  
        for(i=0;i<h;i++)  
        {  
            if(i%2==0)  
                for(j=0;j<w;j++)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
            if(i%2==1)  
                for(j=w-1;j>=0;j--)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
        }  
        for(i=0;i<h;i++)  
        {  
            for(j=0;j<w-1;j++)  
                printf("%d ",a[i][j]);  
            printf("%d\n",a[i][w-1]);  
        }  
    }  
}  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>

typedef long long ll;

const int maxn = 2e5 + 7;
const int maxm = 4e5 + 7;

using namespace std;

int a[maxn];
int to[maxm];
int val[maxm];
int nex[maxm];
int last[maxn], k;
int rt, now, pos;
ll mn;
int sz[maxn];
int son[maxn];
int vis[maxn];
int fa[maxn];
struct edge {
	int x, y;
	ll z;
	inline int operator < (const edge &a) const {
		return z < a.z;
	}
};
vector <edge> e;
int cnt;

inline int read()
{
	int X = 0; char ch = getchar();
	while (ch < '0' || ch > '9') ch = getchar();
	while (ch >= '0' && ch <= '9') X = X * 10 + ch - '0', ch = getchar();
	return X;
}

inline void add_edge(int x, int y, int z)
{
	to[++k] = y; val[k] = z; nex[k] = last[x]; last[x] = k;
}

void getg(int x, int f)
{
	son[x] = 0;
	sz[x] = 1;
	for (int i = last[x]; i; i = nex[i]) {
		int y = to[i];
		if (vis[y] || y == f) continue;
		getg(y, x);
		sz[x] += sz[y];
		if (sz[y] > son[x]) son[x] = sz[y];
	}
	if (now - sz[x] > son[x]) son[x] = now - sz[x];
	if (son[x] < son[rt]) rt = x;
}

void get_min(int x, int f, ll dis)
{
	if (a[x] + dis < mn) mn = a[x] + dis, pos = x;
	for (int i = last[x]; i; i = nex[i])
		if (!vis[to[i]] && to[i] != f) get_min(to[i], x, dis + val[i]);
}

void add(int x, int f, ll dis)
{
	e.push_back((edge){x, pos, a[x] + a[pos] + dis});
	for (int i = last[x]; i; i = nex[i])
		if (!vis[to[i]] && to[i] != f) add(to[i], x, dis + val[i]);
}

void solve(int x)
{
	mn = 1e18;
	get_min(x, 0, 0);
	add(pos, 0, 0);
	vis[x] = 1;
	for (int i = last[x]; i; i = nex[i]) {
		int y = to[i];
		if (vis[y]) continue;
		now = sz[y];
		rt = 0;
		getg(y, x);
		solve(rt);
	}
}

int find(int x)
{
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}

inline ll kruskal()
{
	ll ans = 0;
	sort(e.begin(), e.end());
	for (vector<edge>::iterator it = e.begin(); it != e.end(); it++) {
		int x = find((*it).x), y = find((*it).y);
		if (x != y) fa[x] = y, ans += (*it).z;
	}
	return ans;
}

int main(void)
{
	int n = read();
	for (int i = 1; i <= n; i++) a[i] = read(), fa[i] = i;
	for (int i = 1; i < n; i++) {
		int x = read(), y = read(), z = read();
		add_edge(x, y, z);
		add_edge(y, x, z);
	}
	now = n;
	son[0] = 1e9;
	getg(1, 0);
	solve(rt);
	cout << kruskal() << endl;
	
	return 0;
}

Measured memory_bytes: 86240
K=int(input())
S=input()
M=10**9+7
#----------------------------------------------------------------
f=1
Fact=[f]
for i in range(1,len(S)+K+1):
    f=(f*i)%M
    Fact.append(f)

Inv=[0]*(len(S)+K+1)
g=pow(f,M-2,M)
Inv=[0]*(len(S)+K+1)
Inv[-1]=g
for j in range(len(S)+K-1,-1,-1):
    Inv[j]=(Inv[j+1]*(j+1))%M

def nCr(n,r):
    if 0<=r<=n:
        return (Fact[n]*Inv[r]*Inv[n-r])%M
    else:
        return 0

A=len(S)

T=0
for i in range(K+1):
    T=(T+nCr(A+K-1-i,K-i)*pow(25,K-i,M)*pow(26,i,M))%M
print(T)


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

void solve()
{
    long long t,n,m,i,j,k=0,kk=0,x,y,z=0,mn=0,mx,a[10],cnt=0;

    cin >> n;

    z = n%500;
    x = n/500;
    y = z/5;

    cout << ((x*1000)+(y*5)) << endl;

}

int main()
{
     long long t,n,m,i,j,k=0,kk=0,x,y,z=0,mn,mx;

     ios_base::sync_with_stdio(false);
     cin.tie(NULL);

     //cin >> t;

     //while(t--)
     solve();

}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    bool card[4][13];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            card[i][j] = false;
        }
    }

    for(int i = 0; i < n; i++){
        char c;
        scanf("\n%c",&c);
        int x;
        scanf("%d",&x);
        switch(c){
            case 'S':
                card[0][x - 1] = true;
                break;
            case 'H':
                card[1][x - 1] = true;
                break;
            case 'C':
                card[2][x - 1] = true;
                break;
            case 'D':
                card[3][x - 1] = true;
                break;
        }
    }

    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(card[i][j] == false){
                switch(i){
                    case 0:
                        printf("S %d",j+1);
                        break;
                    case 1:
                        printf("H %d",j+1);
                        break;
                    case 2:
                        printf("C %d",j+1);
                        break;
                    case 3:
                        printf("D %d",j+1);
                        break;
                }
                printf("\n");
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2724
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    s = input()
    for i in range(len(s)-1):
        ans = s[i]+s[i+1]
        if ans == 'AC':
            print('Yes')
            sys.exit()
    print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

int main() {
  lint n;
  cin >> n;
  lint count = 0;
  if (n % 2 == 0) {
    lint div = 10;
    while(div <= n) {
      count += n / div;
      div *= 5;
    }
  }
  cout << count << endl;
}

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

int len,p;
string S;
bool flag;

int compute();

int getNum(){
  if(p>=len){
    flag=true;
    return 0;
  }
  
  if(S[p]=='-'){
    p++;
    return -getNum();
  }else if(S[p]=='0'){
    p++;
    return 0;
  }else if(S[p]=='1'){
    int res=0;
    while(p<len && (S[p]=='0'||S[p]=='1') ){
      res*=2;
      res+=(S[p]-'0');
      p++;
    }
    return res;
  }else if(S[p]=='('){
    p++;
    int res=compute();
    if(S[p-1]!=')')flag=true;
    return res;
  }else{
    flag=true;
    return 0;
  }
}

int compute(){
  if(p>=len){
    flag=true;
    return 0;
  }
  
  stack<int> st;
  st.push( getNum() );
  
  while(p<len){
    char ch=S[p];p++;
    if(ch==')')break;

    int num=getNum();
    if(ch=='+'){
      st.push(num);
    }else if(ch=='-'){
      st.push(-num);
    }else if(ch=='*'){
      int x=st.top();
      st.pop();
      st.push(x*num);
    }else{
      flag=true;
      break;
    }
  }
  int res=0;
  while(st.size()>0){
    res+=st.top();
    st.pop();
  }
  return res;
}

int check(string str){

  string le,ri;
  
  int cnt=0,index;
  for(int i=0;i<(int)str.size();i++)
    if(str[i]=='=')cnt++, index=i;

  
  if(cnt!=1)return 0;
  if(index==0 || index+1==(int)str.size())return 0;

  
  flag=false;
  S=str.substr(0,index);
  p=0;
  len=S.size();
  le=S;
  int lv=compute();
  int ca=0,cb=0;
  
  for(int i=0;i<S.size();i++)
    if(S[i]=='(')ca++;
    else if(S[i]==')')cb++;
  if( ca!=cb || flag || p<len)return 0;
  
  flag=false;
  S=str.substr(index+1);
  ri=S;
  p=0;
  len=S.size();
  int rv=compute();
  ca=0,cb=0;
  for(int i=0;i<S.size();i++)
    if(S[i]=='(')ca++;
    else if(S[i]==')')cb++;
  if( ca!=cb || flag || p<len)return 0;

  
  if(lv==rv){
    //    cout<<le<<' '<<ri<<endl;
    return 1;
  }else return 0;
}


int solve(string str){

  string tmp="01+-*()=";
  sort(tmp.begin(),tmp.end());
  
  map<string,bool> used;
  int res=0;
  do{
    map<char,char> mp;
    string s=str;
    for(int i=0;i<(int)s.size();i++){
      if( ('A'<=s[i]&&s[i]<='Z') || ('a'<=s[i]&&s[i]<='z') ){
        if(mp.count( s[i] )>0){
          s[i]=mp[ s[i] ];
        }else{
          int id=mp.size();
          mp[ s[i] ]=tmp[id];
          s[i]=tmp[id];
        }
      }
    }
    if(!used[s]){
      used[s]=true;
      res+=check(s);
    }
  }while(next_permutation(tmp.begin(),tmp.end()));
    return res;
}

int main(){
  string str;
  cin>>str;
  cout<<solve(str)<<endl;
  return 0;
}

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

int descending_compare(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}

int ascending_compare(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}


int main(void){
    char input[4];
    int i;
    int cnt = 0;
    scanf("%s", input);

    for (i = 0; i<3; i++){
        if (input[i] == '1'){
            cnt++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = 0;
		int b = 0;
		int c, d, e;
		while(sc.hasNext()){
			String s = sc.next();
			int i=0;
			int start=0;
			while(s.substring(i,i+1).compareTo(",")!=0)i++;
			c = Integer.valueOf(s.substring(start,i));
			i++;
			start=i;
			while(s.substring(i,i+1).compareTo(",")!=0)i++;
			d = Integer.valueOf(s.substring(start,i));
			e = Integer.valueOf(s.substring(i+1,s.length()));
			if(c*c + d*d == e*e)a++;
			if(c==d)b++;
		}
		System.out.println(a);
		System.out.println(b);
		
	}	
}

Measured memory_bytes: 17132
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<cctype>
#include<climits>
#include<bitset>
#include<stack>

using namespace std;

typedef long long ll;

const int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int MAX = 23;
int W, H, fld[10][10];
int P, sx, sy;
map<pair<pair<int, int>, int>, int> memo;

inline int CountBit(int s)
{
	int res = 0;
	for (int i = 0; i < P; i++) res += (s >> i) & 1;
	return res;
}

inline bool IsInside(int x, int y)
{
	return 0 <= x && x < W && 0 <= y && y < H;
}

inline bool CanDown(int x, int y, int s, int noBits)
{
	if (x == sx && y == sy && noBits == P) return true;
	if (fld[y][x] == -1) return false;
	return ((s >> fld[y][x]) & 1) == 0;
}

int DFS(int x, int y, int s)
{
	int cnt = CountBit(s);
	if (x == sx && y == sy && cnt == P) return 1;
	pair<pair<int, int>, int> state = make_pair(make_pair(x, y), s);
	if (cnt < MAX)
	{
		map<pair<pair<int, int>, int>, int>::iterator itr = memo.find(state);
		if (itr != memo.end()) return itr->second;
	}
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i], ny = y + dy[i];
		while (IsInside(nx, ny) && !CanDown(nx, ny, s, cnt))
			nx += dx[i], ny += dy[i];
		if (!IsInside(nx, ny)) continue;
		sum += DFS(nx, ny, s | (1 << fld[ny][nx]));
	}
	if (cnt < MAX && !(cnt >= 18 && sum == 0)) memo[state] = sum;
	return sum;
}

signed main()
{
	while (cin >> W >> H, W || H)
	{
		memo.clear();
		P = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> fld[i][j];
				if (fld[i][j] == 0) fld[i][j] = -1;
				else if (fld[i][j] == 1) fld[i][j] = P++;
				else sx = j, sy = i, fld[i][j] = -1;
			}
		}
		printf("%d\n", DFS(sx, sy, 0));
	}
	return 0;
}

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

int main() {
	int H, W, ans = 0;
	cin >> H >> W;
	vector<string> S(H);
	for (string& i : S) cin >> i;
	vector<vector<int>> b(H, vector<int>(W)), c(H, vector<int>(W));
	for (int i = 0; i < H; ++i) {
		if (S[i][0] == '.') b[i][0] = 1;
		for (int j = 1; j < W; ++j) {
			if (S[i][j] == '.') b[i][j] = 1 + b[i][j - 1];
		}
		for (int j = W - 2; j >= 0; --j) {
			if (S[i][j] == '.') b[i][j] = max(b[i][j], b[i][j + 1]);
		}
	}
	for (int i = 0; i < W; ++i) {
		if (S[0][i] == '.') c[0][i] = 1;
		for (int j = 1; j < H; ++j) {
			if (S[j][i] == '.') c[j][i] = 1 + c[j - 1][i];
		}
		for (int j = H - 2; j >= 0; --j) {
			if (S[j][i] == '.') c[j][i] = max(c[j][i], c[j + 1][i]);
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) ans = max(ans, b[i][j] - 1 + c[i][j]);
	}
	cout << ans;
}

Measured memory_bytes: 35712
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True


ans=0

n=I()
g,c=GI(n,n-1)


v=[-1]*n
v[0]=1
v[n-1]=0

def dfs(x,s):
    r=[]
    for i in x:
        for nb in g[i]:
            if v[nb]==-1:
                r.append(nb)
                v[nb]=s
    return r

F=[0]
S=[n-1]
while F or S:
    F=dfs(F,1)
#    show('F',v,F,S)
    S=dfs(S,0)
#    show('S',v,F,S)

if sum(v)>n//2:
    ans='Fennec'
else:
    ans='Snuke'
    
print(ans)    


Measured memory_bytes: 70556
//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

typedef long double ld;
typedef long long ll;
ld dice[23][23*6];

struct Mat{
  ld val[2][2];
  
  Mat operator* (const Mat &b) const{
    Mat res;
    
    for(int i=0;i<2;i++){
      for(int j=0;j<2;j++){
        res.val[i][j] = 0;
        for(int k=0;k<2;k++)
          res.val[i][j] += val[i][k] * b.val[k][j];
      }
    }

    return res;
  }
};

ld pow(ld X, ld Y, ld q, ll n){
  Mat t = {X, Y, 0, 1};
  Mat res = {1,0,0,1};
  
  while(n){
    if(n%2) res = res * t;
    t = t*t;
    n/=2;
  }

  return q * res.val[0][0] + res.val[0][1]; 
}

bool solve(){
  ll n, m;
  
  scanf("%lld%lld", &n, &m);
  if(n == 0) return false;
  
  ld q = 0; ll i = 0;

  while(i < m){
    ll l = i+1, r = m;
    ld X = 0, Y = 0;
    
    for(int j=0;j<=n*6;j++){
      if(j <= q) X += dice[n][j];
      else Y += dice[n][j] * j;
    }
    
    while(l<r){
      ll mid = (l+r)/2;
      
      if(pow(X, Y, q, mid-i) >= floor(q) + 1){
        r = mid;
      }else{
        l = mid + 1;
      }
    }
    
    q = pow(X, Y, q, l-i);
    i = l;
  }

  printf("%.5Lf\n", q);
  
  return true;
}



int main(){
  dice[0][0] = 1;

  for(int i=0;i<20;i++){
    for(int j=0;j<=i*6;j++){
      for(int k=1;k<=6;k++)
        dice[i+1][j+k] += dice[i][j] / 6;
    }
  }
  
  while(solve());
}




Measured memory_bytes: 3300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int d,r = 0;
		double f = 0;

		d = a / b;
		r = a % b;
		f = (double)a / (double)b;

		System.out.println(d + " " + r + " " + String.format("%.5f", f));
	}

}


Measured memory_bytes: 26624
import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    //人数
    int n = sc.nextInt();
    //身長
    long[] h = new long[n];
    
    for(int i = 0;i < n;i++){
      h[i] = sc.nextLong();
    }
    
    
    
    long[] step = new long[n];
    for(int i = 0;i < n;i++){
      step[i] = 0;
    }
    long ans = 0;
    for(int i = 1;i < n;i++){
      if(h[i - 1] > h[i]){
        step[i] = h[i - 1] - h[i];
        h[i] += step[i];
      }
    }
    
    for(int i = 0;i < n;i++){
      ans += step[i];
    }
    System.out.print(ans);
  }
}

Measured memory_bytes: 61576
let () =
  let a, b = Scanf.scanf "%d %d " (fun a b -> a, b) in
  let a = if (a = 1) then 14 else a in
  let b = if (b = 1) then 14 else b in
  Printf.printf "%s\n" 
  (if a > b then "Alice" else (if a = b then "Draw" else "Bob")
  )

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,k,a[30000],j=1;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		j+=min(j,k);
	}
	cout<<j<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
# import itertools
Q = int(input())
LR = [[int(x) for x in input().split()] for _ in range(Q)]
LR = np.array(LR)

# MAX = 10**5
# is_prime = [True] * MAX
# is_prime[0] = is_prime[1] = False
# for i in range(2, int(MAX**.5)+1):
#     if is_prime[i]:
#         for j in range(i*i, MAX, i):
#             is_prime[j] = False

# NUM = [0] * MAX
# for p in range(MAX):
#     if is_prime[p] and is_prime[(p+1)//2]:
#         NUM[p] += 1
# NUMcum = [0] + list(itertools.accumulate(NUM))
# for l, r in LR:
#     print(int(NUMcum[r+1] - NUMcum[l]))

## エラトステネスの篩
MAX = 10**5
is_prime = np.full(MAX, True)
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX**.5)+1):
    if is_prime[i]:
        is_prime[i*i::i] = False
        
NUM = np.zeros(MAX)
for p in range(MAX):
    if is_prime[p] and is_prime[(p+1)//2]:
        NUM[p] += 1

NUMcum = NUM.cumsum()

for l, r in LR:
    print(int(NUMcum[r] - NUMcum[l-1]))

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

int main() {
    int N;
    cin >> N;
    vector<int> flag(101);
    for (int i = 0; i < N; i++)
    {
        int d;
        cin >> d;
        flag.at(d) = 1;
    }
    int ans = 0;
    for (int i = 0; i < 101; i++)
    {
        ans += flag.at(i);
    }
    cout << ans << endl;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        struct Pond_t
        {
            internal int pos;
            internal int area;
        }

        static void Main(string[] args)
        {
            string data = Console.ReadLine();

            Stack<int> downMap = new Stack<int>();
            Stack<Pond_t> ponds = new Stack<Pond_t>();

            int sumArea = 0;
            int len = data.Length;

            for (int i = 0; i < len; i++)
            {
                if (data[i] == '\\')
                {
                    downMap.Push(i);
                }
                else if (data[i] == '/' && downMap.Count > 0)
                {
                    int tempPos = downMap.Pop();
                    int tempArea = i - tempPos;
                    sumArea += tempArea;

                    while (ponds.Count > 0 && ponds.Peek().pos > tempPos)
                    {
                        tempArea += ponds.Pop().area;
                    }

                    Pond_t willPush;
                    willPush.pos = tempPos;
                    willPush.area = tempArea;
                    ponds.Push(willPush);
                }
            }

            Console.WriteLine(sumArea);
            Console.Write(ponds.Count);
            
            StringBuilder sb = new StringBuilder();
            var a = ponds.Select(p => p.area).ToArray();
            for(int i = a.Length - 1; i >= 0; i--)
            {
                sb.Append(" " + a[i]);
            }
            Console.WriteLine(sb);
        }
    }
}

Measured memory_bytes: 10640
#include<bits/stdc++.h>
#define maxn 1000000000000000000LL
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long t,n,a,b,c,d,x,ans;
map<long long,long long> mp;
map<long long,long long> :: iterator it;
void pus2(long long n,long long ans){
	if(mp.count(n)) 
		mp[n]=min(mp[n],ans);
	else 
		mp[n]=ans;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	t=read();
	while(t--){
		n=read();a=read();b=read();c=read();d=read();
		mp.clear();
		mp[n]=0;
		it=mp.end();
		while(1){
			it--;
			x=it->first;
			ans=it->second;
			if(x==0){
				pus(ans,2);
				break;
			}
			if(x%2==0)
				pus2(x/2,ans+a);
			else{
				pus2(x/2+1,ans+a+d);
				pus2(x/2,ans+a+d);
			}
			if(x%3<=1)
				pus2(x/3,ans+b+d*(x%3));
			else
				pus2(x/3+1,ans+b+d*(3-x%3));
			if(x%5<=2)
				pus2(x/5,ans+c+d*(x%5));
			else
				pus2(x/5+1,ans+c+d*(5-x%5));
			if(x<=(maxn-ans)/d)
				pus2(0,ans+d*x);
		}
	}
	return 0;
}

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

int main()
{
    long long int a,b,m,n,k;

    while(~scanf("%lld %lld",&a,&b))
    {
        long long int max=-1000000000;

        m=a+b;
        n=a*b;
        k=a-b;
         if(m>max)
            max=m;
        if(n>max)
            max=n;
        if(k>max)
            max=k;
            printf("%d\n",max);

    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h> 
#include<string>
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define IN insert
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define NL cout<<endl
#define ll long long int
#define ld long double
#define vl vector<ll>
#define sl set<ll>
#define ml map<ll,ll>
#define sc set<char>
#define li list<ll>
#define vp vector<pair<ll, ll> >
#define vs vector<string>
#define ss set<string>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define REPIT(it,a) for(auto it=a.begin();it!=a.end();it++)
#define N (ll)pow(2,32)-1
#define mod (ll)1000000007
using namespace std;
vl p;
vl sieve(ll m){
  vl f;
  REP(i,1,sqrt(m)+1){
    if(m%i==0){
      f.PB(i);
      if(m/i!=i)
       f.PB(m/i);
    }
  }
  return f;
}
void fill(ll n){
 p.PB(2); p.PB(3); p.PB(5); p.PB(7); 
 REP(i,11,n){
  vl v=sieve(i);
  if(v.size()==2) p.PB(i);
 }
}
int main()
{

ios::sync_with_stdio(0);
cin.tie(0);
ll t=1;
//cin>>t;
while(t--){
 p.clear();
 fill(150000ll);
 ll n; cin>>n; auto it=LB(p.begin(),p.end(),n); cout<<*it<<endl;
}
return 0; 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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; }

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for(int i = L; i <= R; i++)if(i%d == 0)ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3596
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = long.Parse(line[1]);
        var d = Convert.ToString(k, 2).Length;
        var a = new int[d,n];
        line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++) a[0,i] = int.Parse(line[i]) - 1;
        for (int i = 1; i < d; i++)
            for (int j = 0; j < n; j++)
                a[i, j] = a[i-1, a[i - 1, j]];
        getAns(n, k, d, a);
    }
    static void getAns (int n, long k, int d, int[,] a)
    {
        var p = 0;
        for (int i = 0; i <= d; i++)
        {
            var t = (k >> i) & 1;
            if (t == 1) p = a[i,p];
        }
        Console.WriteLine(p + 1);
    }
}



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

using namespace std;

typedef long long ll;

ll dp[110][110][310];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll W;
	cin >> n >> W;
	vector<ll> w(n), v(n);
	for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
	int wmax = 0;
	ll geta = w[0];
	for (int i = 0; i < n; i++) {
		w[i] -= geta;
		wmax += w[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= i + 1; j++) {
			for (int k = 0; k <= wmax; k++) {
				dp[i + 1][j][k] = dp[i][j][k];
				if (k >= w[i] && j > 0) dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j - 1][k - w[i]] + v[i]);
			}
		}
	}

	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= wmax; j++) {
			if (geta * i + j > W) continue;
			ans = max(ans, dp[n][i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 27008
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

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

    int happy = (x / 500) * 1000;
    x %= 500;
    happy += (x / 5) * 5;

    cout << happy << endl;
}


Measured memory_bytes: 256