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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define int ll

#define debug(x) cout << #x << " = " << x << endl;

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);

// const int MEM_SIZE = 5e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("cowboys");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}

void run() {
    int n, m;
    cin >> n >> m;
    vector<vector<char>> fld(n, vector<char>(m));
    for (auto &l : fld) {
        for (auto &x : l) {
            cin >> x;
        }
    }
    vector<vector<int>> dp(n, vector<int>(m, INF));
    dp[0][0] = 0;
    for (int i = 1; i < n; ++i) {
        dp[i][0] = dp[i - 1][0] + (fld[i][0] != fld[i - 1][0]);
    }
    for (int j = 1; j < m; ++j) {
        dp[0][j] = dp[0][j - 1] + (fld[0][j] != fld[0][j - 1]);
    }
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < m; ++j) {
            cmin(dp[i][j], dp[i - 1][j] + (fld[i][j] != fld[i - 1][j]));
            cmin(dp[i][j], dp[i][j - 1] + (fld[i][j] != fld[i][j - 1]));
        }
    }
    int cnt = dp.back().back();
    if (fld[0][0] == '#') {
        ++cnt;
    }
    if (fld.back().back() == '#') {
        ++cnt;
    }
    // cerr << cnt << endl;
    cout << (cnt >> 1) << endl;
}

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

using namespace std;

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

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define N 100010
#define M 200010
#define endl "\n"

ll gcd(ll a_,ll b_){if(b_>a_)swap(b_,a_);return (b_==0?a_:gcd(b_,a_%b_));}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	ll t, n, arr[M];
	
	cin >> n >> t;
	REP(i, n){
		cin >> arr[i];
	}
	
	ll ans = 0;
	REP(i, n - 1){
		if(arr[i + 1] - arr[i] > t){
			ans += t;
		}
		else{
			ans += arr[i + 1] - arr[i];
		}
	}
	
	cout << ans + t << endl;
	
	return 0;
}

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x.at(i);

    int ans = 400000000;
    int dist;
    for(int i = 0; i < n - k + 1; i++)
    {
        if (x.at(i) < 0 && x.at(i + k - 1) > 0) {
            dist = min(abs(x.at(i)), abs(x.at(i + k -1))) * 2 + max(abs(x.at(i)), abs(x.at(i + k -1)));
        }
        else {
            dist = max(abs(x.at(i)), abs(x.at(i + k - 1)));
        }
        ans = min(ans, dist);
    }
    cout << ans << endl;
}

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



int main(){
	long  m,n,a = 0;
	cin >> m >> n;

	if(m * 2 <= n){
		a += m;
		n -= m * 2;

		a += n / 4;
	}
	else{
		a += n / 2;
	}

	cout << a <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int LLI;
int main()
{
  	LLI n, t, tmp, next, ans;
  	cin >> n >> t >> tmp;
  	ans = t;
  	for(int i = 1; i < n; i++)
    {
      cin >> next;
      if( next - tmp >= t )
        ans += t;
      else
        ans += next - tmp;
      tmp = next;
    }
  	cout << ans;
	return 0;
}

Measured memory_bytes: 3192
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
int dp[41][505][505];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin >> a[i] >> b[i] >> c[i];
    rep(i,n+1)rep(j,501)rep(k,501) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    int ans = INF;
    rep(i,n)rep(j,401)rep(k,401){
        chmin(dp[i+1][j][k], dp[i][j][k]);
        chmin(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
    }
    for(int j = 1; j <= 400; ++j){
        for(int k = 1; k <= 400; ++k){
            if(j*mb == k*ma && dp[n][j][k] != 0){
                chmin(ans, dp[n][j][k]);
            }
        }
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 44296
unittest
{
	assert( [ "4 3", "0 1 W", "1 2 W", "5 3 B", "5 4 B" ].parse.expand.solve == 4 );
	assert( [ "2 1000", "0 0 B", "0 1 W" ].parse.expand.solve == 2 );
	assert( [ "6 2", "1 2 B", "2 1 W", "2 2 B", "1 0 B", "0 6 W", "4 5 W" ].parse.expand.solve == 4 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( int[] );
	auto xycs = new Tuple!( int, int, char )[ nk[ 0 ] ];
	foreach( ref xyc; xycs )
	{
		input.popFront;
		auto ts = input.front.split.to!( char[][] );
		xyc = tuple( ts[ 0 ].to!( int ), ts[ 1 ].to!( int ), ts[ 2 ][ 0 ] );
	}
	return tuple( nk[ 1 ], xycs );
}

auto solve( int k, Tuple!( int, int, char )[] xycs )
{
	auto kk = 2 * k;
	
	// 各希望を市松模様4セットの中にプロット
	auto bss = new int[][]( 1 + kk * 2, 1 + kk * 2 );
	auto wss = new int[][]( 1 + kk * 2, 1 + kk * 2 );
	foreach( xyc; xycs )
	{
		auto x = xyc[ 0 ] % kk;
		auto y = xyc[ 1 ] % kk;
		if( xyc[ 2 ] == 'B' )
		{
			bss[ 1 + x      ][ 1 + y      ]++;
			bss[ 1 + x + kk ][ 1 + y      ]++;
			bss[ 1 + x      ][ 1 + y + kk ]++;
			bss[ 1 + x + kk ][ 1 + y + kk ]++;
		}
		else
		{
			wss[ 1 + x      ][ 1 + y      ]++;
			wss[ 1 + x + kk ][ 1 + y      ]++;
			wss[ 1 + x      ][ 1 + y + kk ]++;
			wss[ 1 + x + kk ][ 1 + y + kk ]++;
		}
	}
	
	// 二次元累積和表に変換
	for( auto x = 1; x < bss.length; x++ )
	{
		for( auto y = 1; y < bss[ x ].length; y++ )
		{
			bss[ x ][ y ] += bss[ x - 1 ][ y ] + bss[ x ][ y - 1 ] - bss[ x - 1 ][ y - 1 ];
			wss[ x ][ y ] += wss[ x - 1 ][ y ] + wss[ x ][ y - 1 ] - wss[ x - 1 ][ y - 1 ];
		}
	}
	
	// 市松模様をずらして希望を叶えられる最大数を検索
	auto ans = 0;
	for( auto x = kk; x < bss.length; x++ )
	{
		for( auto y = kk; y < bss[ x ].length; y++ )
		{
			auto bc = bss[ x      ][ y      ] - bss[ x - k  ][ y      ] - bss[ x      ][ y - k  ] + bss[ x - k  ][ y - k  ]
			        + bss[ x - k  ][ y - k  ] - bss[ x - kk ][ y - k  ] - bss[ x - k  ][ y - kk ] + bss[ x - kk ][ y - kk ];
			auto wc = wss[ x - k  ][ y      ] - wss[ x - kk ][ y      ] - wss[ x - k  ][ y - k  ] + wss[ x - kk ][ y - k  ]
			        + wss[ x      ][ y - k  ] - wss[ x      ][ y - kk ] - wss[ x - k  ][ y - k  ] + wss[ x - k  ][ y - kk ];
			ans = max( ans, bc + wc );
		}
	}
	return ans;
}


Measured memory_bytes: 131964
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a >= 1 && a <= 9 && b >= 1 && b <= 9)
            System.out.println(a*b);
        else
            System.out.println(-1);

    }
}

Measured memory_bytes: 26708
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	vi a{ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << a[k - 1];
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	int n;
	string op, v;
	map<string, int> M;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> op >> v;

		if (op == "insert") {
			M[v] = 1;
		}
		else {
			if (M[v] > 0) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
}


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; // 合計金額
        if (total == X) ++ res; //合計金額がXに一致したら答をインクリメント
      }
    }
  }
  cout << res << endl;

  return 0;
}

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

typedef long long ll;

int main(){
  ll l, r;  cin >> l >> r;
  ll ans = 1e18;
  ll limit = (r>l+2019 ? l+2019 : r);
  for(ll i=l; i<limit; i++){
    for(ll j=l+1; j<=limit; j++){
      ans = min(ans, ((i%2019) * (j%2019)) % 2019);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

char s[200'009];

int main() {
  scanf("%s", s);
  int n = (int)strlen(s);
  int cnt = 0;
  long long ans = 0;
  for (int i = 0; i < n;) {
    if (s[i] == 'A') {
      ++cnt;
      ++i;
    } else
    if (i + 1 < n && s[i] == 'B' && s[i + 1] == 'C') {
      ans += cnt;
      i += 2;
    } else {
      cnt = 0;
      ++i;
    }
  }
  printf("%lld\n", ans);
}


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

struct card {
    char suit;
    int val;
};

void merge(struct card a[],int left,int mid,int right){
    int l_side = mid - left;
    int r_side = right - mid;
    int i = 0,j = 0;
    struct card l[l_side + 1],r[r_side + 1];
    
    for(i = 0;i<l_side;i++){
        l[i] = a[left + i];
    }
    
    for(i = 0;i<r_side;i++){
        r[i] = a[mid + i];
    }
    l[l_side].val = 2000000000;
    r[r_side].val = 2000000000;
    
    i = 0;
    j = 0;
    
    for(int k = left;k<right;k++){
        if(l[i].val <=r[j].val){
            a[k] = l[i];
            i++;
        }else{
            a[k] = r[j];
            j++;
        }
    }
}

void mergesort(struct card a[],int l,int r){
    if(l + 1 < r){
        int mid = (l + r) / 2;
        mergesort(a,l,mid);
        mergesort(a,mid,r);
        merge(a,l,mid,r);
    }
}

int partition(struct card a[],int p,int r){
    struct card t,x;
    x = a[r];
    int i = p - 1;
    for(int j = p;j < r;j++){
        if(a[j].val <= x.val){
            i++;
            t = a[i],a[i] = a[j],a[j] = t;
        }
    }
    t = a[i + 1],a[i + 1] = a[r],a[r] = t;
    return i + 1;
}

void quicksort(struct card a[],int left,int right){
    if(left < right){
        int q = partition(a,left,right);
        quicksort(a,left,q - 1);
        quicksort(a,q + 1,right);
    }
}

int main(){
    int n,v,i;
    struct card a[100000],b[100000];
    char S[10];
    bool stable = true;
  
    scanf("%d", &n);
    
  for( i = 0;i < n;i++){
    scanf("%s %d",S,&v);
    a[i].suit = b[i].suit = S[0];
    a[i].val = b[i].val = v;
  }
  
  mergesort(a,0,n);
  quicksort(b,0,n - 1);
  for(i = 0;i < n;i++){
    if(a[i].suit != b[i].suit)stable = false;
  }
  if(stable)printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0;i < n;i++){
    printf("%c %d\n",b[i].suit ,b[i].val);
  }
}


Measured memory_bytes: 5444
import java.util.Scanner;

class Main {

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

  private static Scanner sc = new Scanner(System.in);

  int getCoin(int great, int less) {
    if (great - less >= 2) {
      return great + great - 1;
    } else {
      return great + less;
    }
  }

  private void run() {
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());


    if (A > B) {
      System.out.println(getCoin(A, B));
    } else if (A < B) {
      System.out.println(getCoin(B, A));
    } else {
      System.out.println(A * 2);
    }
  }
}


Measured memory_bytes: 26980
#include<cstdio>
#include<algorithm>
using namespace std;

const int N=2e5+6;
int A[N],n,k;

signed main()
{
	scanf("%d%d",&k,&n);
	for(register int i=1;i<=n;i++)
		scanf("%d",A+i);
	sort(A+1,A+1+n);
	int ans=0;
	for(register int i=1;i<n;i++)
		ans=max(ans,A[i+1]-A[i]);
	ans=max(ans,k-A[n]+A[1]);
	printf("%d\n",k-ans);
	return 0;
}

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


ll n,a,sei,fu,sum1,sum2,tyu1,tyu2;
vector<ll> v;
int main(){
  cin>>n;
  REP(i,n){
    cin>>a;
    a-=(i+1);
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  tyu1=v[n/2];
  tyu2=v[n/2-1];
  REP(i,n){
    sum1+=abs(v[i]-tyu1);
    sum2+=abs(v[i]-tyu2);
  }
  cout<<min(sum1,sum2)<<endl;
  return 0;
}




Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	//long long n, mi = 1000000000, ma = -1000000000,r;
	long long n, mi = 10000000000, ma = -10000000000, r;
	cin >> n;
	for (int i = 0; i < n; i++)

	{
		cin >> r;
		ma = max(ma, r - mi);
		mi = min(mi, r);
	}
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, ar[N];
lli ans;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> ar[i];
	if(ar[1] != 0) {
		cout << -1;
		return 0;
	}
	for(int i = n; i > 1; i--)
		if(ar[i - 1] + 1 < ar[i]) {
			cout << -1;
			return 0;
		}

	for(int i = n; i >= 1; i--) {
		ans += ar[i];
		for(int j = i; j >= 2; j--) {
			if(ar[j] - 1 != ar[j - 1]) {
				i = j;
				break;
			}
			i = j - 1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
char s[100010];
int a[111];
ll ans[10+(1<<26)];
int main(){
    int n;
    cin>>n;
    scanf("%s",&s);
    for(int i=0; i<n; ++i){
        ++a[s[i]-'a'];
    }
    int tmp=1, cnt=0;
    ll res=0;
    const ll mod=1e9+7;
    ans[0]=1;
    for(int i=1; i<(1<<26); ++i){
        while(i>=tmp){
            tmp*=2;
            ++cnt;
        }
        ans[i]=(ans[i-tmp/2]*a[cnt-1])%mod;
        res+=ans[i];
        while(res>=mod)
            res-=mod;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 524672
#include<iostream>
#include<cstring>

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

int main(){
	int m, c[4], p[4], r[4];
	int d[4] = {10, 50, 100, 500};

	bool firstline = true;

	while(std::cin >> m, (m)){
		if(!firstline){
			std::cout << std::endl;
		}
		firstline = false;

		rep(i,4){
			std::cin >> c[i];
		}

		int min=20*20*20*20, minc[4];
		memset(minc,0,sizeof(minc));
		for(p[0]=0; p[0]<=c[0]; p[0]++){
			for(p[1]=0; p[1]<=c[1]; p[1]++){
				for(p[2]=0; p[2]<=c[2]; p[2]++){
					for(p[3]=0; p[3]<=c[3]; p[3]++){
						memset(r,0,sizeof(r));

						int sum=0;
						rep(i,4){
							sum += d[i] * p[i];
						}
						if(sum<m){
							continue;
						}
						sum -= m;
						rep(i,4){
							while(sum >= d[3-i]){
								sum -= d[3-i];
								r[3-i]++;
							}
						}

						int remain = 0;
						rep(i,4){
							remain += c[i] - p[i] + r[i];
						}
						if(remain < min){
							min = remain;
							rep(i,4){
								minc[i] = p[i];
							}
						}
					}
				}
			}
		}
		rep(i,4){
			if(minc[i] > 0){
				std::cout << d[i] << ' ' << minc[i] << std::endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 864
#include "bits/stdc++.h"

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) (a).begin(), (a).end()
#define inf 1999999999
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin>>n>>m;
    vector<long long> a(n),b(n),c(m),d(m),dist(m);
    vector<int>ans(n), tem(m);
    REP(i,n) cin>>a[i]>>b[i];
    REP(j,m) cin>>c[j]>>d[j];
    REP(i,n){
        int temp = inf;
        REP(j,m){
            dist[j] = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(dist[j] < temp){
                temp = dist[j];
                ans[i] = j;
            }
        }
    }
    
    
    REP(i,n) cout<<ans[i]+1<<endl; 
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    i64 n, k;
    cin >> n >> k;
    double ans = 0;
    for (i64 i = 1; i <= n; ++i) {
        double a = 1;
        for (i64 x = i; x < k; x *= 2) {
            a /= 2;
        }
        ans += a;
    }
    printf("%.10f\n", ans / n);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w,i,j,k,n=0;
  int c[10][10];
  int a[200][200];
  scanf("%d %d",&h,&w);
  if(h<=200&&h>=1&&w<=200&&w>=1){
    for(i=0;i<10;i++){
      for(j=0;j<10;j++)
        scanf("%d",&c[i][j]);
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++)
        scanf("%d",&a[i][j]);
    }
    for(k=0;k<10;k++){
      for(i=0;i<10;i++){
        for(j=0;j<10;j++){
          if(c[i][j]>c[k][j]+c[i][k])
            c[i][j]=c[k][j]+c[i][k];
        }
      }
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(a[i][j]==1||a[i][j]==-1){
          n+=0;
        }
        else{
          n+=c[a[i][j]][1];
        }
      }
    }
    printf("%d\n",n);
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  for(int c=1,w; cin>>w,w; c++){
    int n,t[1001][2],dp[1001][1001]={0},m=0,ans;
    cin >>n;
    for(int i=1; i<=n; i++) scanf("%d,%d",&t[i][0],&t[i][1]);
    for(int i=1; i<=n; i++){
      for(int j=0; j<=w; j++){
	if(j>=t[i][1]) dp[i][j] = max(dp[i-1][j],dp[i-1][j-t[i][1]]+t[i][0]);
	else dp[i][j] = dp[i-1][j];
      }
    }
    for(int i=0; i<=w; i++){
      if(m<dp[n][i]){m = dp[n][i];ans = i;}
    }
    cout <<"Case "<<c<<":"<<endl<<m<<endl<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 5172
N = gets.chomp.to_i
s = []
N.times do
  s << gets.chomp.to_i
end
s_ten_sum = 0
s_n_ten_sum = 0
s_n_ten_min = 100
s.each do |x|
  if x % 10 == 0 then
    s_ten_sum = s_ten_sum + x
  else
    s_n_ten_sum = s_n_ten_sum + x
    if x < s_n_ten_min then
      s_n_ten_min = x
    end
  end
end
if s_n_ten_sum == 0 then
  puts 0
elsif s_n_ten_sum % 10 == 0 then
  puts s_ten_sum + s_n_ten_sum - s_n_ten_min
else
  puts s_ten_sum + s_n_ten_sum
end

Measured memory_bytes: 3836
n = gets.to_i
a = gets.split.map(&:to_i)

num = 1
cnt = 0
flag = 0
for i in 0..(n-1)
  if a[i] == num
    num += 1
    flag = 1
  else
    cnt += 1
  end
end

if flag == 1
  if cnt > 0
    puts cnt
  else
  	puts 0
  end
else
  puts -1
end

Measured memory_bytes: 15364
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n; ll allpoint = n*(n+1)/2;
  
  ll mispoint = n*(n+1)/2 - n;
  
  for(ll i=n; i > 0; i--){
    if(mispoint >= i){
      mispoint -= i;
    }
    else cout << i << endl;
  }
  
  
}
    
  
  

Measured memory_bytes: 256
#!/usr/bin/env python3

#import
import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= [int(input()) for _ in range(N)]
#= {i:[] for i in range(N)}

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

res = factorization(N)

li = [0] * 101
for i in range(1, 101):
    li[i] = li[i - 1] + i

ans = 0
for r in res:
    if r[0] == 1:
        continue
    i = 0
    while li[i] <= r[1]:
        i += 1
    ans += i - 1

print(ans)



Measured memory_bytes: 9212
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

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

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

	int n, x;
	scanf("%d%d", &n, &x);
	vector < int > a(n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(all(a));
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		x -= a[i];
		if (x >= 0)
			ans = i + 1;
		else
			break;
	}
	if (ans == n && x != 0)
		ans--;      
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        String[] marks = {"S", "H", "C", "D"};

        // all card -> cards
        ArrayList<String> cards = new ArrayList<String>();
        for (int i=0; i<marks.length; i++) {
            for (int j=1; j<=13; j++){
                cards.add(marks[i] + " " + j);
            }
        }
        
        int cardLen = scanner.nextInt();
        
        // remove card from cards
        for (int i=0; i<cardLen; i++) {
            
            String mark = scanner.next();
            int rank = scanner.nextInt();
            String card = mark + " " + rank;
            
            for (int j=0; j<cards.size(); j++) {
                
                if (cards.get(j).equals(card)) {
                    cards.remove(j);
                    break;
                }
                
            }
        }
        
        // display
        for (String card : cards) {
            System.out.println(card);
        }
    }
}


Measured memory_bytes: 26296
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	return count;
}
int main(){
	map<string, vector<int> > dic;
	string sent;
	string mlength="a";
	string moc;
	int max = 0;

	while (cin >> sent) {
		dic[sent].push_back(0);
		if (max < dic[sent].size()) {
			max = dic[sent].size();
			moc = sent;
		}
		if (mlength.length() < sent.length()) {
			mlength = sent;
		}
	}
	cout << moc << " " << mlength << endl;

}

Measured memory_bytes: 1220
#include<algorithm>//sort(all(変数),greater<型名>())で降順に、*max_element(all(変数))で最大値を獲得
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric>
// xとyのgcdは__gcd(x,y),xとyのlcmは(x*y)/__gcd、accumulate(all(変数),0)で要素の全加算
#include<queue>//priority_queue<型名> 変数
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,いくつ)
#include<vector>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int n,m;  cin >> n >> m;
  vector<set<int>> x(n);
  rep(i,m){
    int s,c; cin >> s >> c;
    s--;
    x[s].insert(c);
  }
  rep(i,n){
    if(x[i].empty()){
      if(i == 0)  x[i].insert(1);
      else x[i].insert(0);
    }else if(2 <= x[i].size()){
      cout << -1;
      return 0;
    }
  }

  int ans = 0;
  if(n == 1){
    if(m != 0)  ans += *x[0].begin();
  }else{
    rep(i,n){
      if(i == 0 and *x[i].begin() == 0){
        cout << -1;
        return 0;
      }
      ans *= 10;
      ans += *x[i].begin();
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import heapq
N, M = map(int, input().split())
dct = defaultdict(list)

for i in range(N):
  A, B = map(int, input().split())
  dct[A].append(-B)

h = []
ans = 0
for i in range(1,M+1):
  if dct[i]:
    for item in dct[i]:
      heapq.heappush(h,item)
  if h:
    ans += heapq.heappop(h)

print(-ans)

Measured memory_bytes: 27676
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r){
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main() {
	int n, cnt=0;
	cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	while(1){
		bool on = false;
		int flag = 0;
		rep(i,n){
			if(h[i] > 0){
				flag++;
				if(!on) cnt++;
				h[i]--;
				on = true;
			}else on=false;
		}
		if(flag == 0) break;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[200005],ans;
int main()
{
	int n,m,i,j;
	scanf("%lld",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	if (a[1]!=0)
	{
		cout<<-1;
		return 0;
	}
	for (i=2;i<=n;i++)
	{
		if (a[i]>a[i-1]+1)
		{
			cout<<-1;
			return 0;
		}
	}
	for (i=2;i<=n;i++) if (a[i]==a[i-1]+1) ans++; else ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;

void dfs(int v,vector<bool> &seen,int &sum){
  bool end=true;
  rep(i,seen.size()){
    if(!seen[i] && i!=v){
      end=false;
    }
  }
  if(end){
      sum++;
      return ;
  }
  seen[v]=true;
  for(auto nv :G[v]){
    if(seen[nv])continue;
    dfs(nv,seen,sum);
  }
  seen[v]=false;
}

int main(){
  int n,m;
  cin >> n >> m;  
  
  G.assign(n,vector<int>());
  rep(i,m){
    int a,b;
    cin >> a>> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<bool>seen(n,false);
  int sum=0;
  dfs(0,seen,sum);
  cout<<sum<<endl;
}


Measured memory_bytes: 256
/**
 *    author:  math2do
 *    created: 18.01.2020 17:35:21
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  int sum = 0;
  int ans = 0;
  while (true) {
    if (n > m) {
      sum += n;
      m--;
    } else {
      sum += m;
      n--;
    } 
    ans++;
    if (sum >= k) break;
  }
  cout << ans << '\n'; 
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
b = [list(map(int, input().split())) for _ in range(h)]

dif = []
for aj, bj in zip(a, b):
    dif.append([abs(aij - bij) for aij, bij in zip(aj, bj)])

dp = [0] * w

dp[0] = 1 << 6400

for i in range(h):
    dp[0] = (dp[0] << dif[i][0])|(dp[0] >> dif[i][0])
    for j in range(1, w):
        dp[j] = (dp[j-1] << dif[i][j])|(dp[j-1] >> dif[i][j])|(dp[j] << dif[i][j])|(dp[j] >> dif[i][j])

result = list(format(dp[-1] >> 6400, "b"))[::-1]
ans = 0
for i in range(len(result)):
    if result[i] == "1":
        print(ans)
        break
    else:
        ans += 1

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int result = n * (n - 1) / 2 + m * (m - 1) / 2;
		System.out.println(result);

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define vll vector< ll >
//#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<int,int>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//#define int unsigned long long
//#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
#define int long long
using namespace std;
//using ll = unsigned long long;
ll md=MD;
//ll M=1073741824;
ll M=998244353;
//ll exp(ll a,ll b){ll r=1;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(int a,int b){if(a<b)return a; return b;}
ll Max(int a,int b){if(a>b)return a; return b;}
ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1)ans=(ans*a)%M;a=(a*a)%M;b=b>>1;}return ans;}
const int INF=1000000000000000000;
//000111000111  1c7
//4x-2a=y 2i+4x-4i
int32_t main()
{
	IOS;
	int x,n;
	cin>>x>>n;
	int chk[101];
	memset(chk,0,sizeof(chk));
	for(int i=0;i<n;++i)
	{
		int x;
		cin>>x;
		chk[x]=1;
	}
	int temp=0;
	int ans;
	while(true)
	{
		if(x-temp<0 || !chk[x-temp])
		{
			ans=x-temp;
			break;
		}
		else
		{
			if(x+temp>100 || !chk[x+temp])
			{
				ans=x+temp;
				break;
			}
		}
		++temp;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3616
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,x,y,ans,curr,rose,n,m;
    int r,c;
    cin >> r >> c;
    cin >> x >> y;
    cout << (r-x)*(c-y) << endl;
    return 0;
}


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

int main(){
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    int t = max(A + B, A - B);
    t = max(t, A * B);

    cout << t << endl;

    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    set<int> st;
    rep(i,n){
        int j;
        cin>>j;
        st.insert(j);
    }
    cout<<st.size()<<endl;
    return 0;
}



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

int main(){
	int N,count;
	list<int> counter;
	
	while(!(cin>>N).eof()){
		count=0;
		for(int i=0; i<10;i++){
			if((N-i)/3 >9) continue;
			for(int j=0; j<10;j++){
				if((N-i-j)/2 > 9) continue;
				for(int k=0; k<10;k++){
					if((N-i-j-k) > 9 || (N-i-j-k)<0) continue;
					//cout << i<< " " << j << " " << k << " "<< N-i-j-k <<endl;
					count++;
				}
			}
		}
		counter.push_back(count);
	}
	list<int>::iterator it = counter.begin();
	while(it != counter.end()){
		cout << *it << endl;
		it++;
	}
	return 0;
}

Measured memory_bytes: 1192
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005

void solve()
{
	ll x;
	cin>>x;
	ll ans=0;
	ans+=(x/500)*1000;
	x=x%500;
	ans+=(x/5)*5;
	cout<<ans<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 256
def main():
    n, l = map(int, input().split())
    a_score = list()
    
    for i in range(n):
        # りんごiはl+i-1。indexがずれるので-1しない
        a_score.append(l+i)
    a_sum = sum(a_score)
    if 0 in a_score:
        print(a_sum - 0)
    elif min(a_score) < 0:
        print(a_sum - max(a_score))
    else:
        print(a_sum - min(a_score))
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
string S; int ans[100001];
int main() {
  cin >> S;
  S.append("R");
  for(int i = 0, r = 0, l = 0, lp = 0; i < S.size(); ++i) {
    if(S.at(i) == 'R') {
      if(l > 0) {
        ans[lp] += l/2+l%2;
        ans[lp-1] += l/2;
        l = 0;        
      }
      ++r;
    }
    else {
      if(r > 0) {
        ans[i-1] += r/2+r%2;
        ans[i] += r/2;
        r = 0;
        lp = i;
      }
      ++l;
    }
  }
  for(int i = 0; i < S.size()-1; ++i) {
    printf("%d ", ans[i]);
  }
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    int N = nextInt();
	    int K = nextInt();
	    String S = nextString();
	    char[] C = S.toCharArray();
	    
	    if(C[K-1]=='A'){
	        C[K-1]='a';
	    }else if(C[K-1]=='B'){
	        C[K-1]='b';
	    }else{
	        C[K-1]='c';
	    }
		out.print(C);
	}
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

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

#define int long long
#define MOD 1000000007

int n;
char c[300];

int memo[300][300];

int dp(int i, int j){
    if(i == n){
        return j == 0 ? 1 : 0;
    }

    if(memo[i][j] != -1) return memo[i][j];

    int ans = 0;
    if(c[i] == '-'){
        ans = dp(i+1, j);
    }else if(c[i] == 'U'){
        if(j > 0) ans = (dp(i+1, j) * j) % MOD;
        ans = (ans + (dp(i+1, j+1) % MOD))%MOD;
    }else{
        if(j > 0) ans = dp(i+1, j-1) * j % MOD * j % MOD;
        ans = (ans + (dp(i+1, j) * j) % MOD)%MOD;
    }

    return memo[i][j] = ans;
}

signed main(){
    cin >> n;

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

    memset(memo, -1, sizeof(memo));

    cout << dp(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,h[20],ans=0;
  cin>>n;
  rep(i,n) cin>>h[i];
  rep(i,n){
    int b=0;
    for(int j=0;j<i;j++) if(h[i]>=h[j]) b++;
    if(b==i) ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	cout<<a*a-b;
	








	cout<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s,ans;
    cin >> s;
    for (int i=0;i<s.size();i++){
    	if (s[i] == 'B'){
        	if (ans==""){
            	continue;
            }
          	else{
            	ans.erase(ans.size()-1);
            }
        }
        else{
        	ans += s[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c,m;
  cin>>a>>b>>c;
  m=(a*100)+(b*10)+c;
  if(m%4==0)std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';

 return 0;

}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr

template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print(const ContainerType<ValueType, Args...> &c)
{
    for (const auto &v : c)
        cout << v << ' ';
    cout << '\n';
}

void print() { cout << '\n'; }
template <typename T, typename... Args>
void print(T a, Args... args)
{
    cout << a << " ";
    print(args...);
}

lli llipower(lli x, lli y, lli p = LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}

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

int main()
{
    // int t,tt;
    // cin >> t;
    // tt=t;
    // while (t--)
    // {
    //     int n;
    //     cin>>n;
    //     vector<int> a(n);
    //     fori(n) cin>>a[i];
    //     vector<int> pref(n+1,0);
    //     int sumv=0;
    //     fori(n){
    //         sumv+=a[i];
    //         pref[i+1]=sumv;
    //     }
    //     vector<int> sqs;
    //     fori(10000){
    //         if(i*i<=10000099) sqs.pb(i*i);
    //     }
    //     int curr;
    //     int ans=0;
    //     for(int i=1;i<=n;i++){
    //         curr=pref[i];
    //         for(auto j:sqs){
    //             if(binarySearch(pref,0,n,pref[i]-j)!=-1 &&){
    //                 ans++;
    //                 cout<<i<<" "<<j<<endl;
    //             }
    //         }
    //     }

        
    //     cout<<"Case #"<<tt-t<<": "<<ans<<endl;
    // }
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    lld th=abs((h+(lld)m/60.0)*30-m*6);
    th = th * 3.141592653589793238/180.0;
    cout << fixed << setprecision(12) << sqrt(b * b + a * a - 2 * a * b * cos(th)) << endl;
}

Measured memory_bytes: 4136