akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define allof(x) (x).begin(), (x).end()

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

const int MAXN = 606;

int N;
vector<pii> P1, P2;
int D1, D2;

int col1[MAXN][MAXN];
int col2[MAXN][MAXN];

void dfs1(int r, int c){
    for(pii p : P1){
        int nr = r + p.first;
        int nc = c + p.second;

        if(1 <= nr && nr <= 2 * N && 1 <= nc && nc <= 2 * N && col1[nr][nc] == -1){
            col1[nr][nc] = !col1[r][c];
            dfs1(nr, nc);
        }
    }
}

void dfs2(int r, int c){
    for(pii p : P2){
        int nr = r + p.first;
        int nc = c + p.second;

        if(1 <= nr && nr <= 2 * N && 1 <= nc && nc <= 2 * N && col2[nr][nc] == -1){
            col2[nr][nc] = !col2[r][c];
            dfs2(nr, nc);
        }
    }
}

vector<pii> ans[2][2];

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    memset(col1, -1, sizeof col1);
    memset(col2, -1, sizeof col2);

    cin >> N >> D1 >> D2;

    for(int a = -2 * N; a <= 2 * N; a++){
        for(int b = -2 * N; b <= 2 * N; b++){
            if(a * a + b * b == D1){
                P1.push_back({a, b});
            }
            if(a * a + b * b == D2){
                P2.push_back({a, b});
            }
        }
    }

    for(int a = 1; a <= 2 * N; a++){
        for(int b = 1; b <= 2 * N; b++){
            if(col1[a][b] == -1){
                col1[a][b] = 0;
                dfs1(a, b);
            }
            if(col2[a][b] == -1){
                col2[a][b] = 0;
                dfs2(a, b);
            }           
            ans[col1[a][b]][col2[a][b]].push_back({a, b});
        }
    }

    for(int a = 0; a < 2; a++){
        for(int b = 0; b < 2; b++){
            if((int)ans[a][b].size() >= N * N){
                for(int c = 0; c < N * N; c++){
                    cout << ans[a][b][c].first - 1 << " " << ans[a][b][c].second - 1 << "\n";
                }
                return 0;
            }
        }
    }
}


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

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

int main() {
	int a[5];
	for (int i = 0; i < 5; i++) {
		scanf("%d",&a[i]);
	}
	qsort(a,5,sizeof(int),compare_int);
	int k;
	scanf("%d",&k);
	int dif = a[4] - a[0];
	if (dif <= k) printf("Yay!\n");
	else printf(":(\n");
	return 0;
}

Measured memory_bytes: 128
import time
start = time.time()
import sys
# sys.stdin = open('input.txt')

n = int(input())
s = input()
# r = []
# g = []
# b = []
#
# for i in range(n):
#     if s[i] == 'R':
#         r.append(i)
#     elif s[i] == 'G':
#         g.append(i)
#     else:
#         b.append(i)


ans = s.count('R') * s.count('G') * s.count('B')
# print(ans)

for j in range(n):
    for i in range(j):
        k = 2 * j - i
        if k < n:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1

print(ans)
# end = time.time()
# print(end - start)

Measured memory_bytes: 9140
s = list(input())
t = list(input())

sorted_t = list(set(sorted(t)))

for i in sorted_t:
    check = 0
    temp = 'a'
    for j in range(len(t)):
        if t[j] == i:
            if check == 0:
                check = 1
                temp = s[j]
            elif s[j] != temp:
                print('No')
                exit()

sorted_s = list(set(sorted(s)))

for i in sorted_s:
    check = 0
    temp = 'a'
    for j in range(len(s)):
        if s[j] == i:
            if check == 0:
                check = 1
                temp = t[j]
            elif t[j] != temp:
                print('No')
                exit()

print('Yes')


Measured memory_bytes: 10728
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=4e5+10;
int n,x[N],sa[N],pos[N],Max,Min;
bool cmp(int a,int b){return x[a]<x[b];}
ll ans=1e18;
void add(int *cnt,int*num,int v,int d){
	num[cnt[v]]--;
	num[cnt[v]+=d]++;
}
void solve1(){//Min,Max属于一个集合的情况
	static int cnt[N],num[N];
	//cnt[i]表示(x[i],y[i])在当前区间中出现了几次
	//num[i]表示出现了i次的区间有几个
	num[0]=n;
	for (int l=1,r=0;l<=n+n;l++){
		while (num[0]&&r<n+n) add(cnt,num,pos[++r],1);
		if (!num[0]) ans=min(ans,1ll*(Max-Min)*(x[sa[r]]-x[sa[l]]));
		add(cnt,num,pos[l],-1);
	}
}
void solve2(){//Min,Max不在同一个集合的情况
	static int cnt1[N],num1[N],cnt2[N],num2[N];
	num1[0]=n;num2[0]=n;
	int l=0,r=n+n+1;
	while (num1[0]) add(cnt1,num1,pos[++l],1);
	while (num2[0]) add(cnt2,num2,pos[--r],1);
	ans=min(ans,1ll*(x[sa[l]]-Min)*(Max-x[sa[r]]));
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&x[i],&x[i+n]);
	for (int i=1;i<=n+n;i++) sa[i]=i;
	sort(sa+1,sa+n+n+1,cmp);
	for (int i=1;i<=n+n;i++) pos[i]=(sa[i]>n?sa[i]-n:sa[i]);
	Min=x[sa[1]];Max=x[sa[n+n]];
	solve1();solve2();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12416
#include <cstdio>
#include <iostream>
#include <string>

std::string a, b;
bool f = false;

int main(){
	std::cin >> a >> b;
	if(a.size() < b.size()) std::cout << "LESS" << std::endl;
	else if(a.size() > b.size()) std::cout << "GREATER" << std::endl;
	else{
		for(int i=0; i<a.size(); ++i){
			if(a[i] < b[i]){
				f = true;
				std::cout << "LESS" << std::endl;
				break;
			}else if(a[i] > b[i]){
				f = true;
				std::cout << "GREATER" << std::endl;
				break;
			}
		}
		if(!f) std::cout << "EQUAL" << std::endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long op = 0;
        op += 2*(x/11);
        x = x%11;
        if(x>6) op +=2;
        else if(x>0) op+=1;
        System.out.println(op);
    }
}

Measured memory_bytes: 9808
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),(OUT(YES),1),(OUT(NO),0))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p998 = 998244353;
const LL p107 = 1000000007;
const LL p = p107;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q,  H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL A[SIZE],B[SIZE],C[SIZE];
LL D[SIZE];
LL P[SIZE];
LL solve(){
	cin >> N;
	P[0]=1;
	REP(i,N+1){
		cin >>D[i];
		if(i) P[i]=min(INF,P[i-1]*2-D[i]);
	}
	if(N==0) return (D[0]==1)?1:-1;
	if(D[0]!=0) return -1;
	A[N]=D[N];
	LL ans=A[N];
	REP(i,N+1){
		if(P[i]<0) return -1;
	}
	RREP(i,N){
		if(A[i+1]>P[i]*2) return -1;
		MN(P[i],A[i+1]);
		A[i]=P[i]+D[i];
		ans+=A[i];
	}
	return ans;
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	LL T=1;

	REP(i,T){
		DEFAULT;

	}
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 17740
import bisect
from collections import defaultdict
d = defaultdict(int)
n=int(input())
a=list(map(int,input().split()))
q=int(input())
a.sort()
for key in a:
  d[key] += 1
#print(d)
wa=sum(a)
for i in range(q):
  b,c=map(int,input().split())
  if d[b]>0:
    d[c]+=d[b]
    wa+=d[b]*(c-b)
    d[b]=0
  print(wa)


Measured memory_bytes: 22644
n = int(input())
lst1 = list(map(int,input().split()))

i = 0
ans = 0
flag = 0
while True:
    if i+1 == lst1[i]:
        if i+1 == 1:
            ans += 1
            i += 2
        elif i+1 == n:
            ans += 1
            flag = 1
        else:
            ans += 1
            i += 2
    else:
        i+=1
    if flag or i >= n:
        break

print(ans)
        
        

Measured memory_bytes: 53036
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  string s;cin>>s;
  //for(int i=0;i<N;i++)cin>>v[i];
  int ans=0;int ans2=0;
  int N=s.size();
  for(int i=0;i<N;i++){
    if(s[i]-'0'!=i%2)ans++;
  }
  for(int i=0;i<N;i++){
    if(s[i]-'0'!=(i+1)%2)ans2++;
  }
  cout<<min(ans,ans2)<<endl;
}


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

int main(void) {
    int n, p;
    while (cin >> n >> p, n+p) {
        vector<int> m(n, 0);
        int pos = 0;
        int wan = p;

        while (1) {
            // for (int i = 0; i < n; i++) {
            //     cout << "m[" << i << "]: " << m[i] << ", ";
            // }
            // cout << endl;
            if (m[pos] == p) break;

            if (wan == 0) {
                wan += m[pos];
                m[pos] = 0;
            } else {
                m[pos]++;
                wan--;
            }

            pos = (pos+1) % n;
        }

        cout << pos << endl;
    }

    return 0;
}

Measured memory_bytes: 1196
r1, c1, r2, c2 = map(int, input().split())

M = r2+c2+10#1000010
mod = 10**9+7

f    = [1]*M
p = 1
for i in range(1, M):
    p = p*i%mod
    f[i] = p
    #finv[i] = pow(p, mod-2, mod)

finv = [1]*M
p = finv[-1] = pow(f[-1], mod-2, mod)
for i in range(M-2, 0, -1):
    p = p*(i+1)%mod
    finv[i] = p

g = [0]*M
p = 0
for i in range(1, M):
  g[i] = p = ((p+1)*2-1)%mod

def comb(n, k):
    return f[n] * finv[n-k] * finv[k] % mod

def count(R,C):
    ret = g[R+C+1] % mod

    for c in range(C):
        x1 = comb(R+c, c)
        x2 = g[C-c]
        ret = (ret-x1*x2) % mod

    for r in range(R):
        x1 = comb(C+r, r)
        x2 = g[R-r]
        ret = (ret-x1*x2) % mod

    return ret

ans = count(r2, c2) + count(r1-1, c1-1) - count(r2, c1-1) - count(r1-1, c2)
ans %= mod
print(ans)

Measured memory_bytes: 88540
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h,w,k,x,y,num,l,yy
    integer(int32), allocatable:: ans(:,:)
    character(1),allocatable:: s(:,:)
    logical:: exist, exist2,first

    read*, h,w,k
    allocate(s(w,h), ans(w,0:h))
    ans(:,0) = 1
    block
        character(w):: inpt_s
        do y=1,h
            read*, inpt_s
            do x=1,w
                s(x,y) = inpt_s(x:x)
            end do
        end do
    end block
    
    num=1
    first=.true.
    do y=1,h
        exist = .false.
        exist2 = .false.
        do x=1,w
            if (s(x,y) == '#' .and. exist) exist2 = .true.
            if (s(x,y) == '#') exist = .true.
        end do

        if (.not. exist) then
            ans(:,y) = ans(:,y-1)
            cycle
        end if

        if (.not. exist2) then
            ans(:,y) = num
            if (first) then
                do yy=1,y-1
                    ans(:,yy) = ans(:,y)
                end do
                first=.false. 
            end if
            num=num+1
            cycle
        end if
        l=1
        do x=1,w
            if (s(x,y) == '#') then
                ans(l:x,y) = num
                l = x+1
                num=num+1
            end if
        end do
        if (l <= w) then
            ans(l:w,y) = num-1
        end if
        
        if (first) then
            do yy=1,y-1
                ans(:,yy) = ans(:,y)
            end do
            first=.false. 
        end if
    end do

    do y=1,h
        print'(*(i0,1x))', ans(:,y)
    end do
end program main

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

#include <string>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

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

typedef long long ll;

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

    int P = 2019;
    int N = S.size();
    vector<int> d(N + 1);
    int count = 1;
    for (int i = N - 1; 0 <= i; i--) {
        int a = (S[i] - '0') * count % P;
        d[i] = (d[i + 1] + a) % P;
        count *= 10;
        count %= P;
    }

    vector<int> sum(P);
    ll ans = 0;
    for (int i = N; 0 <= i; i--) {
        ans += sum[d[i]];
        sum[d[i]]++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4320
#include <stdio.h>
char map[9][9];

void kibaku (int x, int y);

main(){
  int i,j,k,n,x,y;

  scanf("%d", &n);
  getchar();

  for(i=0;i<n;i++){
    getchar();
    for(j=0;j<8;j++){
      for(k=0;k<8;k++){
	scanf("%c", &map[k][j]);
      }
      getchar();
    }

    scanf("%d%d", &x, &y);
    x--;
    y--;
    getchar();

    kibaku(x,y);

    printf("Data %d:\n", i+1);

    for(j=0;j<8;j++){
      for(k=0;k<8;k++){
	printf("%c", map[k][j]);
      }
      printf("\n");
    }
  }

  return 0;
}



void kibaku (int x, int y){
  int i, j, tx, ty;
  int dx[12]={0,0,0,1,2,3,0,0,0,-1,-2,-3};
  int dy[12]={-1,-2,-3,0,0,0,1,2,3,0,0,0};

  map[x][y]='0';

  for(i=0;i<12;i++){
    tx = x + dx[i];
    ty = y + dy[i];
    if(tx<0 || tx>7 || ty<0 || ty>7) continue;

    if(map[tx][ty]=='1'){
      kibaku(tx,ty);
    }
  }

  return;
}

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

#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define sieve(j,mp) for(ll j=2*i ; j<=mp ; j+=i)
#define pb(x) push_back(x)
#define mp(x,y) push_back(make_pair(x,y))
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t=1; while(t--)
#define F first
#define S second
main()
{
    flash
    clock_t launch=clock();
    test
    {
        ll n,dp[3],a,b,c,ca,cb,cc; cin>>n;
        mem(dp,0);
        rep(i,1,n+1)
        {
            cin>>a>>b>>c;
            ca=max(dp[1],dp[2])+a;
            cb=max(dp[0],dp[2])+b;
            cc=max(dp[0],dp[1])+c;
            dp[0]=ca; dp[1]=cb; dp[2]=cc;
        }
        cout<<max(dp[0],max(dp[1],dp[2]))<<endl;
    }
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 100000000;
    for (int i = -100; i <= 100; i++) {
        int res = 0;
        for (int j = 0; j < n; j++) {
            res += (i - a[j]) * (i - a[j]);
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
X = int(input())

'''
500: 1000
5: 5
'''

ans = 0
if X >= 500:
    x500 = X // 500
    ans += x500 * 1000
    X -= 500 * x500
    #print('x500: {}'.format(x500))

if X >= 5:
    x5 = X // 5
    ans += x5 * 5
    X -= 5 * x5
    #print('x5: {}'.format(x5))

print(ans)

Measured memory_bytes: 38256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	static long MOD = 1000000007;
	static BigInteger BMOD = new BigInteger(Long.toString(MOD));

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long NINV = (new BigInteger(Integer.toString(n))).modInverse(BMOD).longValue();

		long combi = 1;
		long ans = 1;
		for ( int i = 0 ; i < Math.min(n - 1, k) ; i++ ) {
			combi = (combi * (n - i)) % MOD;
			combi = (combi * (new BigInteger(Integer.toString(i + 1))).modInverse(BMOD).longValue()) % MOD;

			long h = (combi * (n - i - 1)) % MOD;
			h = (h * NINV) % MOD;

			long p = (combi * h) % MOD;
			ans = (ans + p) % MOD;
		}

		System.out.println(ans);
	}
}


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

int main()
{
	vector<int> Number(5);
	for(int i = 0; i < 5; i++){
		scanf("%d", &Number[i]);
	}
	sort(Number.begin(), Number.end(), greater<int>());
	for(int i = 0; i < 5; i++){
		printf("%d", Number[i]);
		if(i != 4){
			printf(" ");
		}else{
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3180
N,M,X,Y=map(int,input().split())
XX=max(list(map(int,input().split())))
YY=min(list(map(int,input().split())))
c=0

for i in range(X+1,Y+1):
    if i>XX and i<=YY:
        c=1
print(['War','No War'][c])

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n , K;
    cin >> n >> K;
    VLL que(n);
    rep(i,n){
      cin >> que[i];
    }
    priority_queue< ll, vector<ll>, greater<ll>> p;
    priority_queue< ll, vector<ll>, greater<ll>> q;
    ll psum = 0;
    ll ans = 0;

    rep(i,K+1){//右からi個とる
      if(i > 0){
        p.push(que[i-1]);
        psum += que[i-1];
      }



      ll qsum = 0;
      rep(j,K+1-i){
        if(i+j > n) continue;
        if(j > 0 && (n-j) > (i-1)){
          q.push(que[n-j]);
          qsum += que[n-j];
        }
        priority_queue< ll, vector<ll>, greater<ll>> tmp(p);
        priority_queue< ll, vector<ll>, greater<ll>> tmp2(q);
        while (!tmp2.empty()){
          tmp.push(tmp2.top());
          tmp2.pop();
        }

        ll minus = 0;
        int k = K - i - j;
        while(k > 0){
          if(!tmp.empty()){
            if(tmp.top() < 0){
              minus += tmp.top();
              tmp.pop();
            }
          }
          k--;
        }
        ans = max(ans, psum + qsum - minus);
      }
      q = priority_queue< ll, vector<ll>, greater<ll>>();
    }
    cout << ans << endl;
    return 0;
}


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

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

// bool checkA = false;
// bool checkB = false;
// bool checkC = false;

// bool check(){
//     rep(i,l.size()){
//         if(l[i]==A) checkA = true;
//         if(l[i]==B) checkB = true;
//         if(l[i]==C) checkC = true;
//     }
//     if(checkA && checkB && checkC) return true;
//     return false;
// }

vector<int> l(8,0);
int N, A, B, C;
int INF = 1000000007;

// a || b || c の箱を用意して，そこに竹を入れていく（合成していく）
// 入れきったら，A || B || Cに対して何回延長（または縮小）すれば良いかを考える
int search(int i, int a, int b, int c){
    if(i>N){
        // 最初a,b,cに入れる時は合成(+10)しないのでその余計な+10*3の分を引き算する
        if(a>0 && b>0 && c>0) return abs(A-a) + abs(B-b) + abs(C-c) - 30;
        else return INF;
    }

    int mp0 = search(i+1, a, b, c); // l[i]をどこにも入れない
    int mp1 = search(i+1, a+l[i], b, c) + 10; // l[i]をaに入れる
    int mp2 = search(i+1, a, b+l[i], c) + 10; // l[i]をbに入れる
    int mp3 = search(i+1, a, b, c+l[i]) + 10; // l[i]をcに入れる

    return min(min(min(mp0, mp1), mp2),mp3);
}

int main(){
    cin >> N >> A >> B >> C;
    rep(i,N) cin >> l[i];
    cout << search(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x;
	scanf("%d",&x);
	if(x==4||x==11||x==18||x==25){
		printf("mon\n");
	}
	else if(x==5||x==12||x==19||x==26){
		printf("tue\n");
	}
	else if(x==6||x==13||x==20||x==27){
		printf("wed\n");
	}
	else if(x==7||x==14||x==21||x==28){
		printf("thu\n");
	}
	else if(x==1||x==8||x==15||x==22||x==29){
		printf("fri\n");
	}
	else if(x==2||x==9||x==16||x==23||x==30){
		printf("sat\n");
	}
	else printf("sun\n");
	return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const int N = 1e5 + 10;

int main() {
    ll n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += n / i;
        if (n % i == 0)
            ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//











int main() {

    int a, b, c, d;
    cin >> a >> b >> c >>d;

    bool flag = false;
    if (abs(a - c) <= d) flag = true;
    if (abs(a - b) <= d && abs(b - c) <= d) flag = true;

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    int good = min(a, k);
    ans += good;
    k -= good;
    good = min(b, k);
    k -= good;
    good = min(c, k);
    ans -= good;
    cout << ans << '\n';
    return 0;
}



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

int S;
set<int> M;

int main(void) {
	cin >> S;

	M.insert(S);
	int ans = 0;
	int p = 2;
	while (true) {
		if (S % 2 == 0)
			S /= 2;
		else
			S = 3 * S + 1;
		if (M.count(S) != 0) {
			ans = p;
			break;
		}
		M.insert(S);
		++p;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N], B[N];
    REP(i, 0, N) {
        cin >> A[i] >> B[i];
    }
    sort(A, A + N);
    sort(B, B + N);
    if (N % 2 == 1) {
        ll lo = A[N / 2];
        ll hi = B[N / 2];
        cout << hi - lo + 1 << endl;
    } else {
        ll lo = A[N / 2 - 1];
        ll lob = A[N / 2];
        ll hi = B[N / 2 - 1];
        ll hib = B[N / 2];
        cout << hi + hib - lo - lob + 1 << endl;
    }
}


Measured memory_bytes: 6788
/************************Code by Hardik Aggarwal!!!!***********************************/

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;

int main()
{
     

    IOS
    ll a,b,x;
    cin>>a>>b>>x;
    if(x-a>=0&&x-a<=b) cout<<"YES";
    else
        cout<<"NO";

    
}
    
 
    
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    vector<int> ans(n);
    rep(i,n){
        cin>>a[i];
    }
    vector<int> s(n,0),e(n,0);
    rep(j,k){
        rep(i,n){
            s[i]=0;
            e[i]=0;
        }
        rep(i,n){
            s[max(i-a[i],0)]++;
            e[min(i+a[i],n-1)]++;
        }
        /*
        rep(i,n){
            cout<<s[i]<<" ";
        }
        cout<<endl;
        rep(i,n)cout<<e[i]<<" ";
        cout<<endl;*/
        //ans[0] = s[0];
        a[0] = s[0];
        rep(i,n-1){
            //ans[i+1] = ans[i]+s[i+1]-e[i];
            a[i+1]=a[i]+s[i+1]-e[i];
        }
        bool all=true;
        rep(i,n){
            if(a[i]!=n){
                all=false;
            }
            //cout<<ans[i]<<" ";
            //cout<<a[i]<<" ";
        }
        if(all)break;
        //cout<<endl;
    }
    rep(i,n){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 6352
#include<iostream>
#include<cstdio>
const int N=1005;
int main() {
    int n,m,a,b;
    scanf("%d%d%d%d",&n,&m,&a,&b);
    for(int i=1;i<=b;i++) {
        for(int j=1;j<=a;j++) printf("0");
        for(int j=a+1;j<=m;j++) printf("1");
        printf("\n");
    }
    for(int i=b+1;i<=n;i++) {
        for(int j=1;j<=a;j++) printf("1");
        for(int j=a+1;j<=m;j++) printf("0");
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

LL COM(LL a){
    return a*(a-1)/2;
}

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

    map<LL,LL> m;
    rep(i,N)m[A[i]]++;

    vector<LL> moto(N+2);
    vector<LL> cut(N+2);
    vector<LL> ans(N,0);

    for(auto t : m){
        LL tmp = t.F;
        LL num = t.S;

        moto[tmp] = COM(t.S);
        cut[tmp] = COM(t.S -1);
    }

    LL ma = 0;
    rep(i,N+1)ma += moto[i];

    rep(i,N){
        ans[i] = ma - moto[A[i]] + cut[A[i]];   
    }

    rep(i,N)cout << ans[i] << endl;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 1e6 +9;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9+7;
#define w first
#define v second
#define pb push_back
#define mp make_pair

const int MAX_N = 105, MAX_K = 1e5 + 5, MOD = 1e9 + 7;

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

     ll q = 1;
     // cin>>q;
     while(q--){
          ll h,a;cin>>h>>a;
          ll ans = h/a;
          if(h -(ans*a)>0){
               ans++;
          }
          cout<<ans<<'\n';
     }
}         

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    
    ll money=1000;
    for (int i=1; i<n; i++) {
        if (a[i]>a[i-1]) {
            ll times=money/a[i-1];
            money%=a[i-1];
            money+=times*a[i];
        }
    }
    
    cout << money << endl;
}

int main() {
    FAST_INPUT;

    solve();

    return 0;
}


Measured memory_bytes: 3668
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] array = line.split(" ");
		int height = Integer.parseInt(array[0]);
		int base = Integer.parseInt(array[1]);
		
		int rectangleArea = height * base;
		int rectanglePeriphery = (height + base) * 2;
		System.out.println(rectangleArea + " " + rectanglePeriphery);
	}
}

Measured memory_bytes: 26120
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
    int x=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if((i+1)%2==1 && A.at(i)%2==1){
      x++;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
int main(){
  std::cout << std::fixed << std::setprecision(20);
  int N;
  cin >> N;
  if(N%2==0) cout << 0.5;
  else cout << (N/2+1)*1.0/N;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long a, b, c;
set<long long> st;
long long gcd(long long x, long long y)
{
	if (y == 0) return x;
	return gcd(y, x%y);
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	c = gcd(a, b);
	st.insert(1);
	for (int i = 2; i * 1LL * i <= c; i++) {
		while (c%i == 0) {
			c /= i;
			st.insert(i);
		}
	}
	st.insert(c);
	cout << st.size() << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;


int main() {
    int h, w;
    cin >> h >> w;
    vector<string>s(h);
    rep(i, h)cin >> s[i];
    vector<vector<int>>row(h,vector<int>(w));
    vector<vector<int>>line(w,vector<int>(h));
    int sum = 0;
    int rres = 0, rans = 0;

    rep(i, h) {
        int index = 0;
        sum = 0;
        rep(j, w) {
            if (s[i][j] == '#') {
                while (index <= j) {
                    row[i][index]=sum;
                    index++;
                }
                sum = 0;
            }
            else {
                sum++;
            }
        }
        while (index < w) {
            row[i][index] = sum;
            index++;
        }
    }
    sum = 0;

    rep(i, w) {
        int index = 0;
        sum = 0;
        rep(j, h) {
            if (s[j][i] == '#') {
                while (index <= j) {
                    line[i][index]=sum;
                    index++;
                }
                sum = 0;
            }
            else {
                sum++;
            }
        }
        while (index < h) {
            line[i][index] = sum;
            index++;
        }
    }
    int ans = 0;

    rep(i, h)rep(j, w) {
        if (s[i][j] == '#')continue;
        ans = max(ans, row[i][j] + line[j][i] - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35840
#include <stdio.h>
int main(void){
    // Your code here!
    int N,i,max=0,min=1001;
    scanf("%d",&N);
    int a[N];
    for(i=0;i<N;i++) scanf("%d",&a[i]);
    for(i=0;i<N;i++){
        if(min>a[i]) min=a[i];
        if(max<a[i]) max=a[i];
    }
    printf("%d\n",max-min);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main(){
	int h, w; cin>>h>>w;
	vector<string> m(110);
	bool erasex[110]={}, erasey[110]={};
	for (int i=0; i<h; ++i){
		cin>>m[i];
		if (m[i].find('#')==string::npos)erasey[i]=1;
	}
	bool tmp;
	for (int j=0; j<w; ++j){
		tmp=1;
		for (int i = 0; i<h; ++i)if (m[i][j]=='#')goto L_erase;
		erasex[j]=1;
L_erase:;
	}

	for (int i=0; i<h; ++i)if (!erasey[i]){
		for (int j=0; j<w; ++j){
			if (!erasex[j])cout<<m[i][j];
		}cout<<endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll dp[500][500], n;
vi a, sum;
ll f(int i, int j) {
	if (i == j)
		return 0;
	if(dp[i][j] != -1)
		return dp[i][j];
	ll& ans = dp[i][j];
	ans = LLONG_MAX;
	for (int k = i; k < j; k++) {
		ans = min(ans, (f(i, k) + f(k + 1, j)));
	}
	ans += sum[j] - (i ? sum[i - 1] : 0);
	return ans;
}
int main() {
	doin();
	for (int i = 0; i < 500; i++)
		for (int j = 0; j < 500; j++)
			dp[i][j] = -1;
	cin >> n;
	getv(a, n);
	sum.resize(n);
	partial_sum(all(a), sum.begin());
	cout << fixed << f(0, n - 1);
}


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

int main(int argc, char *argv[])
{
  double r, pi = 3.141592653589;
  cin >> r;
  cout << fixed << setprecision(8);
  cout << (double)r*r*pi << " " << (double)r*2*pi << endl;
  return 0;
}



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

int main()
{
  int n,t,a;
  cin>>n>>t>>a;
  int temp[n+1];
  float min=99999;
  int index=-1;
  for(int i=0;i<n;i++)
  {
    cin>>temp[i];
    float temprature=t-temp[i]*0.006;
    float diff=abs(temprature-a);
    if(diff<min)
    {
      min=diff;
      index=i;
    }
  }
  cout<<index+1;
}

Measured memory_bytes: 256
char op[9];w,h,x,y,d;move(r){x+=d-1?d-3?0:-r:r;y+=d?d-2?0:-r:r;x=x<1?1:x>w?w:x;y=y<1?1:y>h?h:y;}main(r){for(;scanf("%d%d",&w,&h)*w;printf("%d %d\n",x,y))for(x=y=1,d=0;scanf("%s",op),*op!='S';){if(*op=='F'||*op=='B')scanf("%d",&r),move(*op=='F'?r:-r);if(*op=='R')d=(d+1)%4;if(*op=='L')d=(d+3)%4;}}

Measured memory_bytes: 0
n = int(input())
a=list(map(int, input().split()))

tasug=[]
hikug=[]
for i in range(n):
  if a[i]<0:
    hikug.append(a[i])
  else:
    tasug.append(a[i])

if len(hikug)==0:
  tasug.sort()
  ans=sum(tasug)-2*tasug[0]
  print(ans)
  for i in range(len(tasug)-1):
    if i ==0:
      print(tasug[0],tasug[1])
      a=tasug[0]-tasug[i]
    elif i==1:
      continue
    else:
      print(a,tasug[i])
      a=a-tasug[i]
  if not n==2:
    print(tasug[len(tasug)-1],a)
  
  
elif len(tasug)==0:
  hikug.sort()
  ans=-sum(hikug)+2*hikug[n-1]
  print(ans)
  for i in range(n-1):
    if i ==0:
      a=hikug[n-1]

    print(a,hikug[i])
    a=a-hikug[i]

else:
  ans=sum(tasug)-sum(hikug)
  print(ans)
  if len(tasug)==1:
    for i in range(len(hikug)):
      if i ==0:
        print(tasug[0],hikug[i])
        a=tasug[0]-hikug[i]
      else:
        print(a,hikug[i])
        a=a-hikug[i]
  else:
    for i in range(len(tasug)-1):
      if i ==0:
        print(hikug[0],tasug[i])
        a=hikug[0]-tasug[i]
      else:
        print(a,tasug[i])
        a=a-tasug[i]

    print(tasug[len(tasug)-1],a)
    a=tasug[len(tasug)-1]-a
  
    for i in range(1,len(hikug)):
      print(a,hikug[i])
      a=a-hikug[i]


  
  
  

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

using namespace std;

int main(void)
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    vector<int> sum_matrix;
    int sum_e = count(s.begin(), s.end(), 'E');
    int sum_w = 0;
    int res = n;
    for (auto it = s.begin(); it != s.end(); it++)
    {
        if(*it == 'E') sum_e--;
        res = min(res, sum_e + sum_w);
        if(*it == 'W') sum_w++;
        // sum_matrix.push_back(sum_e);
    }
    cout << res << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int num[11]={};

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> d(N);

  //好きな数字は0嫌いな数字は1
  for(int i=0;i<K;i++) {
    int d;
    cin >> d;
    num[d]=1;
  }
  vector<int> A;
  for(int i=0;i<10;i++) {
    if(num[i]==0) {
      A.push_back(i);
    }
  }
  queue<int> S;
  S.push(0);
  while(1) {
    int num=S.front();
    S.pop();
    if(num>=N) {
      cout << num << endl;
      return 0;
    }
    for(int i=0;i<A.size();i++) {
      S.push(num*10+A[i]);
    }
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
int main(){
    char s[110];
    ll k;
    while(~scanf("%s%lld",s,&k)){
        int cnt = 0;
        int i;
        for(i = 0; s[i]; i++){
            if(s[i] == '1'){
                cnt++;
            }
            else{
                break;
            }
        }
        if(k <= cnt) printf("1\n");
        else printf("%c\n",s[i]);
    }
    return 0;
}


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

int main(void)
{
	int N;
	long long W;
	cin >> N >> W;

	vector<long long> w(N), v(N);
	for (int i = 0; i < N; i++)
		cin >> w[i] >> v[i];

	const long long inf = LLONG_MAX / 2;
	long long vmax = 0;
	for (int i = 0; i < N; i++)
		vmax += v[i];
	vector<vector<long long>> dp(N + 1, vector<long long>(vmax + 1, inf));
	dp[0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= vmax; j++) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);

			int index = j - v[i];
			if (index < 0)
				continue;

			dp[i + 1][j] = min(dp[i + 1][j], dp[i][index] + w[i]);
		}
	}

	int ans = -1;
	for (int i = 0; i <= vmax; i++) {
		if (dp[N][i] <= W)
			ans = max(ans, i);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 80256
// Longest Common Subsequence

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
#define MAX 1001

int make_lcs(string x, string y) {
	int lcs[MAX][MAX] = {};
	x = ' ' + x;
	y = ' ' + y;
	for (unsigned int i=0;i<x.length();i++) {
	for (unsigned int j=0;j<y.length();j++) {
	if (i!=0 && j!=0) {
	if (x[i] == y[j]) {
	lcs[i][j] = lcs[i-1][j-1] + 1;
	}
	else {
	lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1]);
	}
	}
	}
	}
	return lcs[x.length()-1][y.length()-1];
}
int main() {
	int n;
	string x,y;
	cin >> n;
	for (int k=0;k<n;k++) {
	cin >> x >> y;
	cout << make_lcs(x,y) << endl;
	}
	return 0;
}	

Measured memory_bytes: 7048
#include<bits/stdc++.h>
using namespace std;
#define int long long
const long long INF = 10000000000;

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

signed main(){
  int N;
  cin >> N;
  int h[100000+10];
  for(int i=0;i<N;i++) cin >> h[i];
  int dp[100000+10];
  for(int i=0;i<100000+10;i++) dp[i]=INF;//初期化の際のiの範囲は配列の要素数！
  dp[0]=0;//初期タッ君
  for(int i=1;i<N;i++){
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
a,b = map(int,input().split())

if a % 2 != 0:
    st = a
    if b % 2 != 0:
        ed = 0
        bl = (b-(a+0))//2
    else:
        ed = b
        bl = (b-(a+1))//2
else:
    st = 0
    if b % 2 != 0:
        ed = 0
        bl = (b-(a-1))//2
    else:
        ed = b
        bl = (b-(a-0))//2

print(st^ed^(1 if bl%2!=0 else 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;++i){
        int x=i;
        int tmp=0;
        while(x){
            x/=10;
            tmp++;
        }
        if(tmp&1)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

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

    int a, b, c;
    a = n / 100;
    b = (n % 100) / 10;
    c = n % 10;

    if(a == 7){
        printf("Yes");
        return 0;
    } else if(b == 7){
        printf("Yes");
        return 0;
    }else if(c == 7){
        printf("Yes");
        return 0;
    }

    printf("No");
    return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int a = sc.nextInt();
            String b = sc.next();
            int c = sc.nextInt();
            int d = 0;
            if("?".equals(b)) {
                return;
            }
            switch(b) {
            case "+":
                d = a + c;
                break;
            case "-":
                d = a - c;
                break;
            case "*":
                d = a * c;
                break;
            case "/":
                d = a / c;
                break;
            default:
                break;
            }
            System.out.println(d);
        }
    }
}



Measured memory_bytes: 26348