akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
lld rec(lld h){
  if(h==1){
    return 1;
  }
  else{
    return 2*rec(floor(h/2))+1;
  }
}
int main(){
    fastio;
    file();
    lld h;
    cin>>h;
    cout<<rec(h);
}
// 2
// 4
// 1000000000000

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

set<string> data;
char *ans[1000000];
int cor = 0;

int main(){
	int n;
	string A,B;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> A >> B;
		if(A == "insert"){
			data.insert(B);
		}
		else if(A == "find"){
			if(data.find(B) == data.end())
				ans[cor] = "no";
			else
				ans[cor] = "yes";
			cor++;
		}
	}
	for(int i = 0;i < cor;i++)
		cout << ans[i] << endl;
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  vector<PLL> xs(N);
  cin >> xs;

  LL pr = (abs(xs[0].FF) + abs(xs[0].SS)) % 2;
  for(auto& x: xs){
	if(pr != (abs(x.FF) + abs(x.SS)) % 2){
	  cout << -1 << endl;
	  return 0;
	}
  }

  bool ev = (pr == 0);
  if(ev){
	for(auto& x: xs)
	  ++x.FF;
  }

  LL mx = 0;
  for(auto& p: xs) maxi(mx, abs(p.FF) + abs(p.SS));
  VL ans;
  LL i=1, p=0;
  for(;p<mx;){
	p += i;
	ans.PB(i);

	i *= 2;
  }

  if(SZ(ans) > 40){
	cout << -1 << endl;
	return 0;
  }

  int M = SZ(ans);
  cout << (M + (ev?1:0)) << endl
	   << ans << (ev ? " 1":"") << endl;
  for(auto p: xs){
	string str(M, '?');
	for(int i=M-1;i>=0;--i){
	  vector<tuple<LL,PLL,char>> ps;
	  for(LL dx=-1;dx<=1;dx+=2){
		LL tx = p.FF + dx * ans[i];
		ps.EB(abs(tx)+abs(p.SS), MP(tx,p.SS), "RL"[(dx+1)/2]);
	  }
	  for(LL dy=-1;dy<=1;dy+=2){
		LL ty = p.SS + dy * ans[i];
		ps.EB(abs(p.FF)+abs(ty), MP(p.FF,ty), "UD"[(dy+1)/2]);
	  }
	  SORT(ps);

	  str[i] = get<2>(ps[0]);
	  p = get<1>(ps[0]);
	}
	
	cout << str << (ev? "L" : "") << endl;
  }

  return 0;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9;
const llong LINF = 2e18;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// ATCODER RATING!!!

// Code below

int n;

llong k;

vector<pair<llong, llong> > orig;

void inp() {
    cin >> n >> k;
    orig.resize(n);
    for (auto & x : orig) {
        cin >> x.fi >> x.se;
    }
}

llong get(vector<pair<llong, llong> > cur, llong bit) {
    llong mask = ((k >> bit) << bit), ans = 0;
    for (auto & x : cur) {
        x.fi = ((x.fi >> (bit - 1)) << (bit - 1)); 
        if ((x.fi | mask) == mask) {
            ans += x.se;
        }
    }
    return ans;
}

void solve() {
    llong ans = 0;
    for (auto x : orig) {
        if ((x.fi | k) == k) {
            ans += x.se;
        }
    }
    for (llong i = 63; i >= 0; i--) {
        if (((k >> i) & 1)) {
            umax(ans, get(orig, i + 1));
        }
    }
    cout << ans;
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/

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

int main() {
  string S;
  cin >> S;
  int answer = 700;
  rep(i,3) {
    char c = S.at(i);
    if ( c == 'o' ) {
      answer += 100;
    }
  }
  cout << answer << endl;
}

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

vector<long long>v;
long long dp[1000007];
const long long inf = 100000000007;

int main ()
{
    long long x,n,k;
    cin>>n>>k;

    while(n--) cin>>x,v.push_back(x);

    dp[1]=abs(v[1]-v[0]);

    for(long long i=2;i<=k;i++)
    {
        dp[i] = abs(v[i]-v[0]);
        for(long long j=1;j<i;j++)
        {
            dp[i]=min(dp[i],dp[j]+abs(v[i]-v[j]));
        }

    }

    for(long long i=k+1;i<=v.size();i++)
    {
        dp[i] = inf;
        for(long long j=k;j>0;j--)
        {
            dp[i] = min(dp[i],dp[i-j]+abs(v[i-j]-v[i]));
        }

    }
    cout<<dp[v.size()-1]<<endl;

}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  bool awins = true;
  while(a > 0 && c > 0) {
  	c -= b;
    if(c <= 0)
      break;
    a -= d;
    if(a <=0) {
      awins=false;
      break;
    }
  }
    if(awins) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	PRINTD(Min(c, b / a));
}

Measured memory_bytes: 128
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = -1;
		for(int i = 0; i <= 50000; i++) {
			if(Math.floor(i*(1.08))==n) {
				ans = i;
				break;
			}
		}
		if(ans == -1) System.out.println(":(");
		else System.out.println(ans);
	 }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli solve(){
    lli n;
    cin>>n;
    vector<double> p(n);
    loop(i, 0, n)
        cin>>p[i];
    vector<vector<double> > dp(n+1, vector<double>(n+1, 0.0));
    dp[0][0] = 1.0;
    loop(index, 1, n+1){
        loop(head, 0, n+1){
            if(head == 0)
                dp[index][head] = dp[index-1][0]*(1.0-p[index-1]);
            else{
                dp[index][head] = dp[index-1][head-1]*p[index-1] + dp[index-1][head]*(1.0-p[index-1]);
            }
        }
    }
    double ans = 0.0;
    loop(i, n/2+1, n+1)
        ans += dp[n][i];
    cout<<setprecision(15)<<ans<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 73744
#include<stdio.h>

int palindorme(char s[ ], int start, int end){
/*最初のindexがstart、最後のindexがendのsの部分文字列が回文か判定する関数。sizeは文字列sの長さ。*/
	int flag = 1, i = 0;
	for(i = start; i <  (end - start + 1)/ 2 + start; i++){
		if(s[i] != s[end + start - i]){
			flag = 0;
			break;
		}
	}
	return flag;
}

int main(){
	char s[100];
	scanf("%s", s);
	int i, size, flag;
	i = size = 0;
	flag = 0;
	for(i = 0; s[i] != 0; i++){
		size++;
	}
	if(palindorme(s, 0, size - 1) && palindorme(s, 0, (size - 1) / 2 - 1) && palindorme(s, (size + 3)/2 - 1, size - 1)){
		flag = 1;
	}
	
	if(flag){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

#pragma region typedef 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
#pragma endregion

#pragma region define
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#pragma endregion

#pragma region const
const ld PI = 3.141592653589793;
#pragma endregion

#pragma region function
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, T &b, T &c){
  if (b<a) { a=b; c++; return 1; } return 0; }
int sort_3int(int a, int b, int c){
  if (a>b) { swap(a,b); }
  if (a>c) { swap(a,c); }
  if (b>c) { swap(b,c); } return true;}
#pragma endregion

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;

  for(int i = 1; i < n; i++){
    if (a[i-1] > a[i]){
      ans += a[i-1] - a[i];
      a[i] = a[i-1];
    }
  }
  cout << ans << endl;

return 0;
}


Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
//#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    double x,h;
    while(cin>>x>>h && x){
    printf("%.10f\n",x*x+2.0*(x*sqrt((x/2)*(x/2)+h*h)));
    }
    
    return 0;
}



Measured memory_bytes: 3156
def main():
    N, L = map(int, input().split())

    e = sorted((x + L for x in range(N)), key=lambda x: abs(x))
    ans = N * L + (N - 1) * N // 2 - e[0]
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
#include<stdio.h>

#define N 2000001

int n;


//function Counting sort
void Counting_Sort(int a[],int b[],int k){

  int i, j, c[N];

  for(i=0; i<=k; i++) c[i]=0;

  for(j=1; j<=n; j++) c[a[j]]++;

  for(i=1; i<=k ;i++) c[i]+=c[i-1];

  for(j=n; j>0; j--) {
    b[c[a[j]]]=a[j];
    c[a[j]]--;
  }

  //print
  for(i=1;i<=n;i++){
    printf("%d",b[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");
 

}


int main(){
  int i,  max=0;

  //N is too big number, so this array is static
 static  int a[N],b[N];
 //load number
  scanf("%d",&n);
  //load data and decide max
  for(i=1; i<=n; i++){
    scanf("%d",&a[i]);
    if(a[i]>max)  max=a[i];
  }
  
  //execute counting sort
  Counting_Sort(a,b,max);
   

  return 0;
}

Measured memory_bytes: 15000
n = int(input())
menu = [int(x) for x in input().split()]
score = [int(x) for x in input().split()]
additional = [int(x) for x in input().split()]

total = 0
for i in range(n):
  total +=score[menu[i]-1]
  if i + 1 < n:
    if menu[i] + 1 ==menu[i+1]:
      total += additional[menu[i] -1 ]
print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
 
 
int main(){
  long long h,w,n;
 
  cin >> h>>w>>n;

  vector<pair<long long, long long> > pairs;
  for(int i=0;i<n;i++){
      long long a,b;
      cin >> a>>b;
      for(long long l=-1;l<=1;l++)
	for(long long k=-1;k<=1;k++){
	  if((a+l)>=2 && (a+l) <= h-1 && (b+k) >= 2 && (b+k)<=w-1){
	    pairs.push_back( make_pair(a+l, b+k));
	  }
	}
  }
  long long ret[10]={};
  if(n>0){
    sort(pairs.begin(),pairs.end());
    
    auto it = pairs.begin();
    
    long long at = (*it).first, bt=(*it).second;
    long long cnt=1;
    it++;
    for (; it!= pairs.end(); it++){
      if((*it).first == at && (*it).second == bt){
	cnt++;
      }
      else{
	ret[cnt]++;
	cnt=1;
	at = (*it).first;
	bt = (*it).second;
      }
      //cout << (*it).first <<","<<(*it).second<<","<<cnt<<endl;
      
    }
    ret[cnt]++;
  }
  long long sum=0;
  for(int i =0;i<10;i++)
    sum+=ret[i];
  ret[0] = (h-2)*(w-2)-sum;
  for(int i=0;i<10;i++)
    cout << ret[i]<<endl;

  
}


Measured memory_bytes: 16744
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t {}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 0xde0b6b43b9aca00;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;

  vector <ll> a (n);
  rep (i, n) cin >> a [i];

  ll psum1 = 0, psum2 = 0;
  ll ans1 = 0, ans2 = 0;
  bool sign = true;
  for (auto && elem : a)
  {
    psum1 += elem;
    psum2 += elem;

    if (sign && psum1 <= 0) ans1 += 1 - exchange (psum1, 1);
    if (! sign && psum1 >= 0) ans1 += 1 + exchange (psum1, - 1);

    if (! sign && psum2 <= 0) ans2 += 1 - exchange (psum2, 1);
    if (sign && psum2 >= 0) ans2 += 1 + exchange (psum2, - 1);

    sign = ! sign;
  }
  cout << min (ans1, ans2) << endl;
}


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

int main()
{
 int a, b, x;
 cin >> x >> a >> b ;
 int  out = b- a;
 if(out <= 0){
     cout << "delicious" << endl;
 }else if(out <= x  ){
     cout <<"safe" << endl;
 }else if(out >= x + 1){
     cout << "dangerous" << endl;
 }
}


Measured memory_bytes: 256
input = raw_input

k = int(input())

suf_dict = {}
for d in range(10):
    if d == 0:
        suf_dict[str(d)] = ["0", "1"]
    elif d == 1:
        suf_dict[str(d)] = ["0", "1", "2"]
    elif d == 9:
        suf_dict[str(d)] = ["8", "9"]
    else:
        suf_dict[str(d)] = [str(d-1), str(d), str(d+1)]


def find(x):
    sufs = suf_dict[x[-1]]
    ret = [x+suf for suf in sufs]
    return ret

def main():
    xs = list("123456789")
    last_count = 9
    if k <= 9:
        out = k
        return out
    else:
        while True:
            next_xs = []
            for x in xs:
                first_count = last_count + 1
                elms = find(x)
                cur_num = len(elms)
                last_count = first_count + cur_num - 1
                #print(first_count, last_count, elms)
                if first_count <= k <= last_count:
                    out = elms[k-first_count]
                    return out
                next_xs += elms
            xs = next_xs

out = main()
print(out)

Measured memory_bytes: 37916
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstdlib>
#include<deque>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int len=2e5+5;
const ll mod=998244353;
const ull seed=131;
int main()
{	
	ll n,w,h;
	cin>>n>>w>>h;
	cout<<(n-w+1)*(n-h+1)<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int n, ans = 0;
void solve(ll now, bool t, bool f, bool s){
    if(now > n)return;
    if(t && f && s)ans++;
    solve(now*10+3, true, f, s);    
    solve(now*10+5, t, true, s);
    solve(now*10+7, t, f, true);
}

int main() {
    cin >> n;
    solve(0, false, false, false);
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (y, m, d) = readLine()!!.split("/").map { it.toInt() }

    val dates = 365 * y + 30 * m + d
    val target = 365 * 2019 + 30 * 4  + 30

    if (dates > target) print("TBD") else print("Heisei")
}

Measured memory_bytes: 35956
#include <bits/stdc++.h>
using namespace std;
#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 SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  REP(i,a.size()){
      cout << a[i];
      if (i!=a.size()-1 || a.size()==b.size())cout << b[i];
  }
  cout << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,x,y,kai=1;
    double ans=0.0;
	ll z[]={0,1,2,3,4,5,6,7};
    cin >> n;
    vector<pair<ll,ll>> xy(n);
    rep(i,n){
        cin >> x >> y;
        xy[i]=m_p(x,y);
    }
    for(int i=1;i<=n;i++) kai*=i;
    do{
        rep(i,n-1){
            ans+=sqrt(pow(xy[z[i]].first-xy[z[i+1]].first,2)+pow(xy[z[i]].second-xy[z[i+1]].second,2));
        }
    }while(next_permutation(z,z+n));
    cout << DOUBLE << ans/kai << endl;
	return 0;
}

Measured memory_bytes: 256
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 724249387, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int a[N];

int32_t main() {
 	use_fast;
	int n, m, cnt = 0;
	cin >> m >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] % 2 == 1)
			cnt++;
	}
	if(cnt > 2)
		return cout << "Impossible" << endl, 0;
	if(m == 1) {
		cout << "1\n1\n1" << endl;
		return 0;
	}
	if(m == 2) {
		for(int i = 0; i < n; i++)
			cout << a[i] << " ";
		cout << endl;
		cout << 1 << endl << 2 << endl;
		return 0;
	}
	if(n == 1) {
		cout << a[0] << endl << 2 << endl << a[0] - 1 << " " << 1 << endl;
		return 0;
	}
	for(int i = 0; i < n; i++) {
		if(a[i] % 2 == 1) {
			swap(a[i], a[0]);
			break;
		}
	}
	for(int i = 1; i < n; i++) {
		if(a[i] % 2 == 1) {
			swap(a[i], a[n - 1]);
			break;
		}
	}
	for(int i = 0; i < n; i++)
		cout << a[i] << " ";
	cout << endl;
	if(a[0] == 1)
		cout << n - 1 << endl;
	else
		cout << n << endl << a[0] - 1 << " ";
	for(int i = 1; i < n - 1; i++) 
		cout << a[i] << " ";
	cout << a[n - 1] + 1 << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/


Measured memory_bytes: 3668
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); <-- PUT IN main()/solve()!

using namespace std;

int n,k,a[105],ma=0,ans[100025]={0};
string win[2]= {"Second","First"};
class KStones {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n >> k;
		f(i,0,n)
			in >> a[i];
		f(i,1,k+1)
			f(j,0,n)
				if(i-a[j]>=0&&!ans[i-a[j]])
					ans[i]=1;
		out << win[ans[k]] << "\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	KStones solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
input = gets.chomp.split
stack = []
input.each do |item|
  if /[0-9]/ =~ item
    stack.push(item.to_i)
  else
    b = stack.pop
    a = stack.pop
    case item
    when "+"
      stack.push(a + b)
    when "-"
      stack.push(a - b)
    when "*"
      stack.push(a * b)
    end
  end
end

puts stack

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

int main(){
    int a, b, c, d, buf;
    cin >> a >> b >> c >> d;
    if(a > c){
        buf = a;
        a = c;
        c = buf;
        buf = b;
        b = d;
        d = buf;
    }
    if(b > c){
        if(b < d){
            cout << b - c << endl;
        }else{
            cout << d - c << endl;
        }
    }else{
        cout << 0 << endl;
    }
}

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

class Program
{
    struct cell
    {
        public long val;
        public long weight;
        public cell(long w, long v)
        {
            val = v;
            weight = w;
        }
        public static cell operator +(cell lhs, cell rhs)
        {
            return new cell(lhs.weight + rhs.weight, lhs.val + rhs.val);
        }
    }
    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');

        int N = int.Parse(s[0]);
        int W = int.Parse(s[1]);

        cell[] List = new cell[N];

        cell[][] MaxV = new cell[N][];

        for (int i = 0; i < N; i++)
        {
            s = Console.ReadLine().Split(' ');
            List[i] = new cell(int.Parse(s[0]), int.Parse(s[1]));
            MaxV[i] = new cell[W + 1];
        }
        for (int j = 0; j <= W; j++)
        {
            if (List[0].weight > j)
                MaxV[0][j] = new cell(0, 0);
            else
                MaxV[0][j] = List[0];
        }

        for (int i = 1; i < N; i++)
        {
            for (int j = 1; j <= W; j++)
            {
                if (j >= List[i].weight)
                {
                    if (MaxV[i - 1][j - 1].val > (MaxV[i - 1][j - List[i].weight] + List[i]).val)
                        MaxV[i][j] = MaxV[i - 1][j - 1];
                    else
                        MaxV[i][j] = MaxV[i - 1][j - List[i].weight] + List[i];
                }
                else
                    MaxV[i][j] = MaxV[i - 1][j];
            }
        }
        Console.WriteLine(MaxV[N - 1][W].val);
    }
}


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

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

    int n;
    cin >> n;
    string s = "";
    while(n != 0){
        if(n % (-2) != 0){
            n--;
            s += "1";
        }else{
            s += "0";
        }
        n /= -2;
    }
    if(s == "") s = "0";

    reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}

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

thu = N // 1000
cto = (N - 1000*thu) // 100
ten = (N - 1000*thu - 100*cto) // 10
one = N % 10
if (one == ten == cto) or (ten == cto == thu) or (one ==ten == cto == thu):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int[] ans = {1,2,3};
		for(int i = 0;i<3;i++){
			if(ans[i]!=a&&ans[i]!=b)System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 21844
N = int(input())
import math

K = 10**9+7

def binary(N):
    s = N
    k = int(math.log2(N))
    result = []
    for i in range(k+1,0,-1):
        q = 2**(i-1)
        r = s // q
        result.append(r)
        s -= r*q
        i += 1
    return result

def compute(L, N):
    binary_seq = binary(N)[::-1]
    res = 1
    p = L
    for b in binary_seq:
        if b == 1:
            res = (res * p) % K
        p = p**2 % K
    return res

A= compute(8, N)
B= compute(9, N)
C= compute(10, N)

R = (A+C-2*B) % K
print(R)



Measured memory_bytes: 62328
import java.util.*;
import java.lang.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.charAt(0)=='R' && s.charAt(1)=='R' && s.charAt(2)=='R')
      System.out.println(3);
    else if(s.charAt(1)=='R' && (s.charAt(0)=='R' || s.charAt(2)=='R'))
      System.out.println(2);
    else if(s.charAt(0)=='R' || s.charAt(1)=='R' || s.charAt(2)=='R')
      System.out.println(1);
    else
        System.out.println(0);
	}
}

Measured memory_bytes: 35732
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int MAXN = 1000001;
vector<int> adj[MAXN];
int power(int x, int y, int p = mod){ 
    int res = 1; 
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0) {  
        if (y & 1) res = (res*x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
} 
int modFact(int n, int p = mod) 
{ 
    if (n >= p) 
        return 0; 
  
    int result = 1; 
    for (int i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result; 
} 
int32_t main(){
    SPEED;
    SPEED;
    string s;
    cin >> s;
    map<char, int> fre;
    for(char c : s){
        fre[c]++;
    }
    int cnt = 0;
    if(s[0] == 'A'){
        int yes = 0;
        for(int i = 2; i < len(s) - 1; ++i){
            if(s[i] == 'C') yes++;
        }
        if(yes == 1){
            for(char c: s){
                if(c >= 97 && c <= 122) cnt++;
            }
            if(cnt + 2 == len(s)) cout << "AC";
            else cout << "WA";
        }
        else cout << "WA" ;
    }
    else cout << "WA" ;
}
// check indices of loop
// check for overflow


Measured memory_bytes: 27004
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;

int cnt[2][N];

int main(){
	int n; scanf("%d", &n);
	for(int i=0;i<n;i++){
		int x; scanf("%d",&x);
		cnt[i&1][x]++;
	}
	pair<int,int> mi1={1<<30,0}, mi2={1<<30,0};
	for(int i=1;i<N;i++){
		mi1=min(mi1,{n/2-cnt[0][i], i});
		mi2=min(mi2,{n/2-cnt[1][i], i});
	}
	pair<int,int> mii1={1<<30,0}, mii2={1<<30,0};
	for(int i=1;i<N;i++){
		if(i!=mi1.second)
			mii1=min(mii1,{n/2-cnt[0][i], i});
		if(i!=mi2.second)
			mii2=min(mii2,{n/2-cnt[1][i], i});
	}
	if(mi1.second != mi2.second) printf("%d\n",mi1.first+mi2.first);
	else
		printf("%d\n",min(mii1.first+mi2.first,mi1.first+mii2.first));
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func main() {
	var n, x int
	fmt.Scan(&n, &x)

	var xx = make([]int, n)
	for i := range xx {
		fmt.Scan(&xx[i])
	}
	xx = append(xx, x)
	sort.Ints(xx)
	if x == 1 {
		fmt.Println(xx[1] - x)
		return
	}

	var deff []int
	for i := 0; i < n; i++ {
		temp := xx[i] - xx[i+1]
		if temp < 0 {
			deff = append(deff, -temp)
		} else {
			deff = append(deff, temp)
		}
	}
	sort.Ints(deff)

	ans := deff[len(deff)-1]
	for i := len(deff); i > 0; i-- {
		ans = gcd(ans, deff[i-1])
	}
	fmt.Println(ans)
}

Measured memory_bytes: 6784
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <iomanip>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
#define fsp(c) fixed << setprecision(c)

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

double cutl(int i,double n,double r) {
  if (i<=0||n<=i) return 0;
  return r*sqrt(1-((double)i-n/2)*((double)i-n/2)*4/n/n);
}

int main(){
  string s;
  int t=0;
  cin >> s;
  REP(i,6){
    if(s[i]=='1')t++;
  }
  cout << t;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<cstdio>
    #include<math.h>
    #include<string>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<set>
    #include<map>
    #define INF 999999
    #define EPS 1.0e-6
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef pair<int, P> PP;
     
    int n, k;
     
    int main()
    {
    	cin >> n >> k;
    	int a = 1;
    	for (int i = 0; i < n; i++) {
    		if (a + k > 2 * a)a = 2 * a;
    		else a += k;
    	}
    	cout << a << endl;
    	return 0;
    }

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
minus = 0
for i in range(n):
    if A[i] < 0:
        minus += 1
A = sorted(A,key = lambda x:abs(x))
#print(A)
#print(A)
sumA = sum(list(abs(v) for v in A))
#print(sumA)
if minus % 2:
    print(sumA - abs(A[0])*2)
else:
    print(sumA)


Measured memory_bytes: 16392
x = list(map(int,input().split(" ")))
a = x[0]
b = x[1]

ab_list = []

if a >= b:
    half_num = a // 2
else:
    half_num = b // 2

for i in range(half_num):
    if a % (i+1) == 0 and b % (i+1) == 0:
        ab_list.append(i+1)

for i in ab_list:
    min_mul = (a * b) / i
print(int(min_mul))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int a[5], b[5], c[5]={};
    bool flag=true;
    for(int i=1; i<=3; i++){
        cin >> a[i] >> b[i];
        c[a[i]]++;
        c[b[i]]++;
    }
    for(int i=1; i<=4; i++){
        if(c[i]>2){
            flag = false;
        }
    }
    if(flag){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[]) {
  std::string s;
  size_t k;
  std::cin >> k >> s;
  if (s.size() <= k) {
    std::cout << s << std::endl;
  } else {
    std::cout << s.substr(0, k) + "..." << std::endl;
  }
}


Measured memory_bytes: 3068
#include <iostream>

using namespace std;

int main()
{
	int operations = 0;
	string s, t;
	cin >> s >> t;
	int size = s.length();
	for (int i = 0;i < size;i++) {
		if (s[i] != t[i])
			operations++;
	}
	cout << operations;
}


Measured memory_bytes: 3836
import sys
n = int(input())
h = list(map(int,input().split()))

if n == 1:
    print("Yes")
    sys.exit()

for i in range(n-1,0,-1):
    if h[i] != h[i-1]:
        if h[i] - h[i-1] < -1:
            print("No")
            sys.exit()
        elif h[i] - h[i-1] < 0:
            h[i-1] -= 1

print("Yes")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int x;
    cin>>x;
    int a=(x/500)*1000;
    x-=(x/500)*500;
    int b=(x/5)*5;
    cout<<a+b<<endl;
    
    return 0;
}

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

int main(void) {
	int i, p;
	char s[16] = {'\0'};
	char result[16] = {'\0'};

	fgets(s, sizeof(s), stdin);
	i = 0;
	p = 0;
	while(s[i] != '\0') {
		if(s[i] != 'B') {
			result[p] = s[i];
			p += 1;
		} else {
			if(p > 0) {
				p -= 1;
			}
		}
		i += 1;
	}
	result[p] = '\0';
	printf("%s", result);

	return 0;
}


Measured memory_bytes: 2032
import java.io.*;
import java.util.*;
class Main
{
  public static void main(String ar[])
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    if(s.indexOf('A')==-1 || s.indexOf('B')==-1)
      System.out.println("No");
    else
      System.out.println("Yes");
  }
}

Measured memory_bytes: 35680
#include<iostream>
#include<sstream>
#include<string>

int main(){
  while(1){
    std::string str1,str2;
    std::cin>>str1;
    if(str1==".") break;
    std::cin>>str2;
    std::string s1[201],s2[201];
    for(int i=0;i<201;i++){
      s1[i]=".";s2[i]=".";
    }
    s1[0]="";s2[0]="";
    int now1=0,now2=0;
    int l1,l2;
    l1=str1.size();
    l2=str2.size();
    for(int i=0;i<l1;i++){
      if(str1[i]=='"'){
	now1++;
	s1[now1]="";
      }else s1[now1]+=str1[i];
    }
    for(int i=0;i<l2;i++){
      if(str2[i]=='"'){
	now2++;
	s2[now2]="";
      }else s2[now2]+=str2[i];
    }
    int mistake=0;
    for(int i=0;i<201;i++){
      if(s1[i]!=s2[i]){
	if(i&1){
	  mistake++;
	}else mistake+=2;
      }
    }
    if(mistake==0){
      std::cout<<"IDENTICAL";
    }else if(mistake==1){
      std::cout<<"CLOSE";
    }else{
      std::cout<<"DIFFERENT";
    }
    std::cout<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n;
    cin>>x>>n;
    // vector<int> a;
    bool flag[102];
    for(int i=0; i<102; i++)
    {
        flag[i] = false;
    }
    if(n==0)
    {
        cout<<x<<'\n';
        return 0;
    }
    for(int i=0; i<n; i++)
    {
        int y;
        cin>>y;
        // a.push_back(y);
        flag[y] = true;
    }
    int ans = 1000;
    for(int i=0; i<102; i++)
    {
        if(flag[i] == false)
        {
            if(abs(x - i) < abs(ans - x))
            {
                ans = i;
            }
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 3616
from itertools import accumulate
#from operator import add

N,K = map(int,input().split())
A = map(int,input().split()) 
for k in range(K):
    B = [0] * N
    for i,x in enumerate(A):
        L = max(0, i-x)
        R = min(N-1, i+x)
        B[L] += 1
        if R+1 != N:
            B[R+1] -= 1
    #L = accumulate(B,add) 
    L = list(accumulate(B))[:]
    if L == A:
        break
    A = L
print(*A)    

Measured memory_bytes: 179776
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N, K;
string S;
int main(void){
    cin >> N >> K;
    cin >> S;
    S[K-1] = tolower(S[K-1]);
    cout << S << endl;
    return 0;
}



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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    for(int i=1;;i++){
        if(a<b*i+c*(i+1)){
            cout << i-1;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    int i;
    char haiku[39] = {0};


    scanf("%s",haiku);
    for(i=0;i<5;i++){
        printf("%c",haiku[i]);
    }
    printf(" ");
    for(i=6;i<13;i++){
        printf("%c",haiku[i]);
    }
    printf(" ");
    for(i=14;i<19;i++){
        printf("%c",haiku[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt(),w=sc.nextInt();
		for(int i=0;i<h;i++) {
			String a=sc.next();
			System.out.println(a+"\n"+a);
		}
		sc.close();
	}
}

Measured memory_bytes: 22868
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pii pair<int,int>
#define pb push_back
#define N 300003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;

signed main()
{
    warmup
    
    string s,t,u;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    cin>>u;
    if(s==u)
        --a;
    else if(u==t)
        --b;
    cout<<a<<' '<<b;
    
    return 0;
}


Measured memory_bytes: 256
/*|In The Name of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
int k;
int h[N];
int dp[N];

int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &h[i]);
        dp[i] = 1e9;
    }
    dp[1] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= k && i+j <= n; j++){
            dp[i + j] = min(dp[i + j] , dp[i] + abs(h[i + j] - h[i]));
        }
    }
    printf("%d\n" , dp[n]);
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll A, B, T;
    cin >> A >> B >> T;
    cout << (T/A)*B << endl;
    return 0;
}

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

int DoubleCompare(const void* pElem1, const void* pElem2)
{
    return *(const double*)pElem1 - *(const double*)pElem2;
}
 
int main(){

    int n;

    cin >> n;

    double *v;

    v = new double[n];

    int i;

    for(i=0; i<n; i++)
        cin >> v[i];

    qsort(v, n, sizeof(double), DoubleCompare);


    for(i=0; i<n-1; i++){
        v[i+1] = (v[i] + v[i+1]) / 2;
    }

    cout << v[n-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 109;

int h, w, n, m;
int c[N][N];

int main() {
    cin >> h >> w >> n;
    int x = 1, y = 1;
    for (int i = 1; i <= n; i++) {
        cin >> m;
        while (m--) {
            c[x][y] = i;
            if (y == w && x % 2 == 1) x++, y = w;
            else 
                if (y == 1 && x % 2 == 0) x++, y = 1;
                else y += ((x % 2 == 1) ? 1 : -1);
        }
    }

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cout << c[i][j] << ((j < w) ? " " : "\n");
        }
    }
    return 0;
}

Measured memory_bytes: 384