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

int main(int argc, char const *argv[]) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(c-a) <= d) {
    cout << "Yes" << endl;
    return 0;
  }
  if(abs(b-a) <= d && abs(c-b) <= d) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

fun abc000X() {
	val n = int()
	val a = list()
	var c = 0
	for(i in 0 until n) {
		for(j in i+1 until n) {
			for(k in j+1 until n) {
				if(a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]&&a[i]+a[j]>a[k]&&a[j]+a[k]>a[i]&&a[k]+a[i]>a[j]) {
					++c
				}
			}
		}
	}
	println(c)
}


Measured memory_bytes: 38724
import sys
readline = sys.stdin.readline

X,Y,Z,K = map(int,readline().split())

A = sorted(list(map(int,readline().split())),reverse = True)
B = sorted(list(map(int,readline().split())),reverse = True)
C = sorted(list(map(int,readline().split())),reverse = True)

ans = []
for a in range(len(A)):
  for b in range(len(B)):
    for c in range(len(C)):
      if (a + 1) * (b + 1) * (c + 1) > K:
        break
      ans += [A[a] + B[b] + C[c]]
      
ans = sorted(ans,reverse = True)[:K]
print(*ans,sep = "\n")

Measured memory_bytes: 9548
from collections import Counter
import sys

n = int(input())
Hs = list(map(int, input().split()))

res = 0

while True:
    if max(Hs) == 0:
        break

    i = 0
    while i < n:
        if Hs[i] == 0:
            i += 1
            continue
        else:
            res += 1
            while i < n and Hs[i] > 0:
                Hs[i] -= 1
                i += 1

print(res)

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

#define M 1007957/* your task*/
#define NIL '\0'
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}


int h1(int key){ return key%M; }
int h2(int key){ return key%(M-1); }


//search
int find(char str[]){


  int i;
  i=0;
  long long j;
  int key;

  key=getKey(str);


  //repeat j<-h(k,i)
  while(1){
    j=(h1(key)+i*h2(key))%M;
    if(strcmp(str,H[j])==0) return j;
    i++;
    if(H[j][0]==NIL || i==M) return NIL;
  }
 

}

//insert
int insert(char str[]){

  int i;
  long long j;
  i=0;
  int key;
  key=getKey(str);
  //repeatj <-h(k,i)
  while(1){
    j=(h1(key)+i*h2(key))%M;
    if(H[j][0]==NIL){
      strcpy(H[j],str);
      return j;
    }
    else i++;
    if(i==M) break;
  }

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    vector<int> mid, final, re;
    int m, f, r;

    while (true)
    {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)
        {
            break;
        }
        else
        {
            mid.emplace_back(m);
            final.emplace_back(f);
            re.emplace_back(r);
        }
    }

    for (int i = 0; i < mid.size(); i++)
    {
        if (mid[i] == -1 || final[i] == -1)
        {
            cout << "F" << endl;
        }
        else if (mid[i] + final[i] >= 80)
        {
            cout << "A" << endl;
        }
        else if (mid[i] + final[i] >= 65)
        {
            cout << "B" << endl;
        }
        else if (mid[i] + final[i] >= 50)
        {
            cout << "C" << endl;
        }
        else if (mid[i] + final[i] >= 30)
        {
            if (re[i] >= 50)
            {
                cout << "C" << endl;
            }
            else
            {
                cout << "D" << endl;
            }
        }
        else
        {
            cout << "F" << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3156
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> Dbg &dump(C b, C e) {
    *this << "\n[";
    int cur = 0;
    for (C i = b; i!=e and cur<26; i++, cur++) *this << ", "+2*(i==b) << *i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator <<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << '{' << x.first << ", " << x.second << '}';
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 100005;

int n, a[mxn*3];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11);
    cin >> n;
    for (int i = 0; i < 3*n; i++) {
        cin >> a[i];
    }
    sort(a, a+3*n);
    ll ans = 0;
    for (int i = n; i <= 3*n-1; i += 2) {
        ans += a[i];
    }
    cout << ans << '\n';
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);
    int x,y; cin >>x>>y;
    const int g[] = {-1,0,2,0,1,0,1,0,0,1,0,1,0 };
    Yes(g[x]==g[y]);
}


Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

char getRestChar(char c1, char c2) {
	if (c1 == 'R') {
		if (c2 == 'B')
			return 'G';
		else
			return 'B';
	} else if (c1 == 'G') {
		if (c2 == 'B')
			return 'R';
		else
			return 'B';
	} else {
		if (c2 == 'R')
			return 'G';
		else
			return 'R';
	}
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	map<char, int> rgb;
	rgb['R'] = 0;
	rgb['G'] = 1;
	rgb['B'] = 2;
	int cnt[4000][3] = {};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			if (i > 0) cnt[i][j] = cnt[i - 1][j];
		}
		cnt[i][rgb[s[i]]]++;
	}
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int k = i + 2; k < n; k++) {
			if (s[i] == s[k]) continue;
			char rest = getRestChar(s[i], s[k]);
			ans += cnt[k - 1][rgb[rest]] - cnt[i][rgb[rest]];
			if ((k - i) % 2 == 0 && s[i + (k - i) / 2] == rest) ans--;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

using ll = long long;

map<ll, int> prime_factor(ll n) {
    map<ll, int> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    ll p;
    cin >> n >> p;
    map<ll, int> memo = prime_factor(p);
    ll ans = 1;
    for (auto& pp : memo) {
        ll hoge = pp.second;
        ll cnt = hoge / n;
        for (ll i = 0; i < cnt; i++) {
            ans *= pp.first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	unsigned long long num=0;
	char c=' ';
	bool flag=true;
	for(;c>'9'||c<'0';c=getchar())
	if(c=='-')
	flag=false;
	for(;c>='0'&&c<='9';num=num*10+c-48,c=getchar());
	return flag ? num : -num;
}
unsigned long long N,M;
int main()
{
	N=read();
	M=read();
	unsigned long long ans=0;

	if(N>=2&&M>=2)
	{
		ans=(N-2)*(M-2);
		printf("%lld\n",ans);
		return 0;
	}
	if(N==1&&M==1)
	{
		cout<<1;
		return 0;
	}
	if(N==1)
	{
		cout<<M-2;
		return 0;
	}
	if(M==1)
	{
		cout<<N-2;
		return 0;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,max_v=0,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    ans+=(a-1)/(max_v+1);
    if(a==max_v+1||max_v==0) max_v++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,K;
  cin >> N >> K;
  long x,x_alt;

  if(N > K){
      x = N % K;
  }else{
      x = N;
  }

  x_alt = K - x;

  if(x < x_alt){
    cout << x <<endl;
  }else{
    cout << x_alt <<endl; 
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
using System.Reflection;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] nw = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = nw[0];
            int W = nw[1];

            var ls = new List<MyClass>();
            for (int i = 0; i < n; i++)
            {
                var input = ReadLine().Split(' ').Select(int.Parse).ToArray();
                ls.Add(new MyClass(input[0], input[1]));
            }
            int[,] dp = new int[n+1, W+1];

            for (int i = 0; i < n; i++)
            {
                for (int w = 0; w <= W; w++)
                {
                    if (w >= ls[i].weight)
                    {
                        dp[i + 1, w] = Max(dp[i, w - ls[i].weight] + ls[i].value, dp[i, w]);
                    }
                    else dp[i + 1, w] = dp[i, w];
                }
            }
            WriteLine(dp[n, W]);
        }

        class MyClass
        {
            public MyClass(int value, int weight)
            {
                this.value = value;
                this.weight = weight;
            }

            public int value { get; set; }
            public int weight { get; set; }
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c) cout<<"Yes"<<endl;
	else if(a==c&&a!=b) cout<<"Yes"<<endl;
	else if(a!=b&&b==c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for(ll i=(ll)a;i<=(ll)b;i++)
#define per(i, a, b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define pb push_back
#define mkp make_pair
#define all(v) v.begin(), v.end()
#define N 100010
#define MAX 1234567890
#define gap ' '

int main()
{
    fastio;

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll mx = max(a*c, a*d);
    mx = max(mx, max(b*c, b*d));
    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 3648
n = gets.chomp.to_i
shops = []
n.times do |i|
  shop = gets.chomp.split
  shops.push([shop[0],shop[1].to_i,i+1])
end
shops.sort_by!{|a| [a[0],-a[1]]}
shops.each do |i|
  puts i[2]
end


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

void sol( ){
    int x ;
    cin >> x ;
    cout << !x << nl ;
}

signed main( ){
  timesaver ;
//  int t = 1 ; cin >> t ; while(t--)
  {
      sol( );
  }
}

Measured memory_bytes: 3648
/*input

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
    string s;cin >> s;
    if(s == "AAA" or s == "BBB")cout << "No";
    else cout << "Yes";
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n;cin>>n;
    ll val = n + (n%2?0:1);
    vector< pair<ll,ll> >ans;
    for(ll i=1;i<=n;i++)for(ll j=i+1;j<=n;j++)if(i+j!=val)ans.push_back({i,j});
    cout<<ans.size()<<"\n";
    for(auto &ele:ans)cout<<ele.first<<" "<<ele.second<<"\n";
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

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

    int L = A;
    int R = A + N - 1;

    int eat;
    if (R <= 0)eat = R;
    else if (L >= 0) eat = L;
    else eat = 0;

    int sum = (R + L) * (R - L + 1) / 2 - eat;
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int H = sc.nextInt();
			int W = sc.nextInt();
			sc.nextLine();

			String[][] board = new String[H][W];

			for (int i = 0; i < H; i++) {
				board[i] = sc.nextLine().split("");
			}

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if ("#".equals(board[i][j])) {
						continue;
					}

					int bombCount = 0;
					if (i > 0) {
						if (j > 0 && "#".equals(board[i - 1][j - 1])) {
							bombCount++;
						}
						if ("#".equals(board[i - 1][j])) {
							bombCount++;
						}
						if (j + 1 < W && "#".equals(board[i - 1][j + 1])) {
							bombCount++;
						}
					}
					if (i + 1 < H) {
						if (j > 0 && "#".equals(board[i + 1][j - 1])) {
							bombCount++;
						}
						if ("#".equals(board[i + 1][j])) {
							bombCount++;
						}
						if (j + 1 < W && "#".equals(board[i + 1][j + 1])) {
							bombCount++;
						}
					}
					if (j > 0 && "#".equals(board[i][j - 1])) {
						bombCount++;
					}
					if (j + 1 < W && "#".equals(board[i][j + 1])) {
						bombCount++;
					}

					board[i][j] = Integer.toString(bombCount);
				}
			}

			for (String[] sline : board) {
				System.out.println(String.join("", sline));
            }
			sc.close();
		}
}


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

#define int long long
typedef pair<int,int> P;
set<P> se,al;
bool f(int i,int n){
  if(n<i)return (n==1);
  if(se.count(P(i,n)))return 1;
  if(al.count(P(i,n)))return 0;
  al.insert(P(i,n));
  if(n%i){
    if(n%i==1){
      se.insert(P(i,n));
      return 1;
    }
    return 0;
  }
  if(f(i,n/i)){
    se.insert(P(i,n));
    return 1;
  }
  return 0;
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n;cin>>n;
  if(n==2)fin(1);
  int ans=2;
  for(int i=2;i*i<=n;i++)ans+=f(i,n);
  for(int i=2;i*i<=n;i++)ans+=(n%i==1&&n/i!=i);
  cout<<ans<<endl;
}


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

int main(){
	
	int a,b,n;
	while( cin >> a >> b >> n ){
		if( cin.eof() ) break ;
		
		int ans = 0 ,cnt = 0 ;
		while( cnt <= n ){
			if( a == 0 || b == 0 ) break;
			
			
			while( a < b ){
				a *= 10;
				cnt++ ;
			}
			if( cnt <= n ){
				if( cnt > 0 ) ans += a/b;
				a %= b ;
			}
		}
		
		cout << ans << endl ;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<int> water;
    for (int i = 1; i * a * 100 <= f; i++)
    {
        for (int j = 0; j * b * 100 + i * a * 100 <= f; j++)
        {
            water.push_back(j * b * 100 + i * a * 100);
        }
    }
    water.push_back(b * 100);
    vector<int> suger;
    for (int i = 0; i * c <= f; i++)
    {
        for (int j = 0; j * d + i * c <= f; j++)
        {
            suger.push_back(j * d + i * c);
        }
    }
    P ans = P(0, a * 100);
    for (auto i : water)
    {
        for(auto j:suger){
            if(i+j>f){
                continue;
            }
            if(i/100*e<j){
                continue;
            }
            if(ans.first*(i+j)<ans.second*j){
                ans = P(j,i+j);
            }
        }
    }
    cout << ans.second << ' ' << ans.first << endl;
    return 0;
}

Measured memory_bytes: 1400
/**
 *      ABC 104 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/19
**/

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

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

    int count = 0;
    int capital = 0;

    for (int i = 2; i < S.size() - 1; ++i){ //Cが出てきた回数
        if (S.at(i) == 'C'){
            ++count;
        }
    }

    for (int i = 0; i < S.size(); ++i){ //大文字が出てきた回数
        if (isupper(S.at(i)) != 0){
            ++capital;
        }
    }

    //cout << count << endl;
    //cout << capital << endl;

    if (S.at(0) != 'A'){
        cout << "WA";
    }
    else if (count != 1){
        cout << "WA";
    }
    else if (capital != 2){
        cout << "WA";
    }
    else {
        cout << "AC";
    }

    return 0;

}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		String result = "No";
		int i = n;
		int x = 0;
		while(i > 0){
		    x += i%10;
		    i /= 10;
		}
		if(n%x == 0) result = "Yes";
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  map<int,int> memo;
  rep(i,N){
    int a;
    cin >> a;
    memo[a]++;
  }

  priority_queue<int> que;
  FOR(it,memo){
    int x = it->second;
    if(x>=3){
      if(x%2==1) x = 1;
      else x = 2;
    }
    que.push(x);
  }

  while(que.size()>=2){
    int x = que.top();
    if(x == 1) break;
    que.pop();
    int y = que.top(); que.pop();
    if(y == 2){
      que.push(1);
      que.push(1);
    }else{
      x--;
      que.push(x);
    }
  }

  int ret = 0;
  while(!que.empty()){ ret++; que.pop(); }
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 5628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type edge struct {
	node   int
	weight int
}

type graph [][]edge

var (
	G     graph
	color []int
)

// v: node, p: parent, c: color
func dfs(v, p, c int) {
	color[v] = c
	for _, e := range G[v] {
		if e.node == p {
			continue
		}
		if e.weight == 1 {
			dfs(e.node, v, 1-c)
		} else {
			dfs(e.node, v, c)
		}
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	G = make([][]edge, n)
	for i := 0; i < n; i++ {
		G[i] = make([]edge, 0, 4)
	}
	color = make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var u, v, w int
	for i := 0; i < n-1; i++ {
		sc.Scan()
		u, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		v, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		w, _ = strconv.Atoi(sc.Text())
		u--
		v--
		w %= 2
		G[u] = append(G[u], edge{v, w})
		G[v] = append(G[v], edge{u, w})
	}
	dfs(0, -1, 1)
	wr := bufio.NewWriter(os.Stdout)
	for _, c := range color {
		fmt.Fprintln(wr, c)
	}
	wr.Flush()
}


Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
const long long INF = 1e18;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
ll dp[MAXN][MAXN];
int n, f, b, a[MAXN];
int main() {
	read(n), read(f), read(b);
	for (int i = 1; i <= n; i++)
		read(a[i]);
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= n; j++)
		dp[i][j] = INF;
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++)
	for (int j = 0; j <= n; j++) {
		ll tmp = dp[i - 1][j];
		if (tmp == INF) continue;
		if (a[i] > j) {
			chkmin(dp[i][j], tmp + f);
			chkmin(dp[i][a[i]], tmp);
		} else chkmin(dp[i][j], tmp + b);
	}
	ll ans = INF;
	for (int i = 0; i <= n; i++)
		chkmin(ans, dp[n][i]);
	writeln(ans);
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 100007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q, t, indx, l, r;
    char ch;
    string s;
    cin >> n >> s >> q;
    map<char, set<int> > cache;
    for (int i = 0; i < n; i++) {
        cache[s[i]].insert(i);
    }
    while (q--) {
        cin >> t;
        if (t == 1) {
            cin >> indx >> ch;
            indx--;
            if (s[indx] == ch) continue;
            cache[s[indx]].erase(indx);
            s[indx] = ch;
            cache[ch].insert(indx);
        } else {
            cin >> l >> r;
            l--, r--;
            int res = 0;
            for (char c = 'a'; c <= 'z'; c++) {
                auto iter = cache[c].upper_bound(l - 1);
                if (iter == cache[c].end()) continue;
                if (*iter <= r) res++;
            }
            cout << res << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 24220
N=io.read("n")
t={}
for i=1,N do
  t[i]=io.read("n")-i
end
table.sort(t)
s=0
if N%2==0 then
  for i=1,N do
    s=s+math.abs(t[i]-t[N//2])
  end
  else 
  for i=1,N do
    s=s+math.abs(t[i]-t[N//2+1])
  end
end
print(s)

Measured memory_bytes: 4472
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/arc067/tasks/arc067_a
# C - Factors of Factorial
"""
m > n impossible
m = n, possible only when n = 1


"""

N = gi()
ans = 0

for l in range(1, floor(sqrt(N)) + 1):
    if N % l:
        continue

    m = N // l

    if m < l - 1:
        ans += l - 1
    if l < m - 1:
        ans += m - 1

print(ans)


Measured memory_bytes: 18048
A, B, C = map(int, input().split())

sum_num = A + B + C

before_A = A
before_B = B
before_C = C
count = 1

if before_A % 2 == 1 or before_B % 2 == 1 or before_C % 2 == 1:
    print(0)
    exit()

while True:
    after_A = (sum_num - before_A) // 2
    after_B = (sum_num - before_B) // 2
    after_C = (sum_num - before_C) // 2
    if after_A == before_A and after_B == before_B and after_C == before_C:
        print(-1)
        exit()

    if after_A % 2 == 0 and after_B % 2 == 0 and after_C % 2 == 0:
        count += 1
        before_A = after_A
        before_B = after_B
        before_C = after_C

    else:
        print(count)
        exit()

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int x;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>x;
    int rating=400;
    int poz=8;
    while(poz>=1)
    {
        if(x>=rating&&x<rating+200)
        {
            cout<<poz;
            return 0;
        }
        poz--;
        rating+=200;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using pint = pair<int, int>;
using pll = pair<ll,ll>;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;
    cin >> n;
    vector<pair<ll,ll>> arms(n);
    ll x,l;
    REP(i,n){
        cin >> x >> l;
        arms[i]={x-l,x+l};
    }
    sort(arms.begin(),arms.end(),[](pll a,pll b){return a.second < b.second;});
    int count = 0;
    ll now = -LINF;
    for(int i=0;i<n;i++){
        if(now<=arms[i].first){
            now = arms[i].second;
            count++;
        }
    }
    COUT(count);
    return 0;
}  

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long   

const ll mod=1e9+7;

ll ar[100005]={0};
ll br[100005]={0};
bool isp(int n) {
    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}



int main()
{
    ll q;
    sfl(q);
    ll j,i;
    for( j=2;j<=100005;j++)
    {
        if(isp(j)==true)
        {
            ar[j]++;
        }
     //   cout<<j<<" "<<ar[j]<<endl;
    }
    ll p=0;
      for(i=2;i<=100005;i++)
        {
            if((i%2!=0)&&i!=1)
            {
                ll a=i;
                ll b=(i+1)/2;
               
                if(ar[a]==true && ar[b]==true)
                {
                   br[i]=p+1;
                   if(br[i]>0)
                   {
                       p=br[i];
                   }
                }
            }
          //  cout<<i<<" "<<br[i]<<endl;
        }
    for(j=0;j<q;j++)
    {
        ll l,r;
        sfl(l);
        sfl(r);
        ll cnt;
        if(br[r]>0&&br[l]>0)
        {
            cnt=br[r]-br[l]+1;
            
        }
        else if(br[r]==0&&br[l]==0)
        {
            while(br[r]==0&& r>=l)
            {
                r--;
            }
            while(br[l]==0&&l<=r)
            {
                l++;
            }
            if(br[r]>0&&br[l]>0)
            {
            cnt=br[r]-br[l]+1;
            }
            else
            {
                cnt=0;
            }
        }
        else if(br[r]==0 && br[l]!=0&&r>=l)
        {
            while(br[r]==0)
            {
                r--;
            }
             if(br[r]>0&&br[l]>0)
            {
            cnt=br[r]-br[l]+1;
            }
            else
            {
                cnt=0;
            }
        }
        else if(br[r]!=0 && br[l]==0)
        {
            while(br[l]==0&&l<=r)
            {
                l++;
            }
             if(br[r]>0&&br[l]>0)
            {
            cnt=br[r]-br[l]+1;
            }
            else
            {
                cnt=0;
            }
        }
        cout<<cnt<<endl;
    }
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 2176
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  h1 *= 60; h2 *= 60;
  int sa = max(h2 + m2 - h1 - m1 - k, 0);
  cout << sa << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<string.h>
int main(){
  int i;
  int a[3][3];
  char s[4];
  for(;;){
    scanf("%s",s);
    if(strcmp(s,"0")==0)
      break;
    for(i=0;i<3;i++){
      if(s[i]=='b')
	a[i][0]='b';
      else if(s[i]=='w')
	a[i][0]='w';
      else if(s[i]=='+')
	a[i][0]=0;
    }
    scanf("%s",s);
    for(i=0;i<3;i++){
      if(s[i]=='b')
	a[i][1]='b';
      else if(s[i]=='w')
	a[i][1]='w';
      else if(s[i]=='+')
	a[i][1]=0;
    }
    scanf("%s",s);
    for(i=0;i<3;i++){
      if(s[i]=='b')
	a[i][2]='b';
      else if(s[i]=='w')
	a[i][2]='w';
      else if(s[i]=='+')
	a[i][2]=0;
    }
    for(i=0;i<3;i++){
      if(a[i][0]&&a[i][0]==a[i][1]&&a[i][1]==a[i][2]){
	printf("%c\n",a[i][0]);
	break;
      }
      if(a[0][i]&&a[0][i]==a[1][i]&&a[1][i]==a[2][i]){
	printf("%c\n",a[0][i]);
	break;
      }
    }
    if(i==3){
      if(a[0][0]&&a[0][0]==a[1][1]&&a[1][1]==a[2][2]){
	printf("%c\n",a[0][0]);
	continue;
      }
      if(a[2][0]&&a[2][0]==a[1][1]&&a[1][1]==a[0][2]){
	printf("%c\n",a[2][0]);
	continue;
      }
    }else
      continue;
    puts("NA");
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <utility>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000007;
//ll mod = 998244353;

string ID(int n) {
	string ans = "";
	for (int i = 0; i < 6; i++) {
		char c = '0' + n % 10;
		ans = c + ans;
		n /= 10;
	}
	return ans;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<PP> p(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i].first.first >> p[i].first.second;
		p[i].second = i;
 	}
	sort(all(p));
	p[0].first.second = 1;
	for (int i = 1; i < m; i++) {
		if (p[i - 1].first.first != p[i].first.first) {
			p[i].first.second = 1;
		}
		else {
			p[i].first.second = p[i - 1].first.second + 1;
		}
	}
	vector<P> ans(m);
	for (int i = 0; i < m; i++) {
		ans[p[i].second].first = p[i].first.first;
		ans[p[i].second].second = p[i].first.second;
	}
	for (int i = 0; i < m; i++) {
		cout << ID(ans[i].first) << ID(ans[i].second) << endl;
	}
}

Measured memory_bytes: 5376
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int y, x;
	cin >> y >> x;
	vector<string> inp(y);
	vector<vector<int>> map(y+2,vector<int>(x+2));
	ff(i, 0, y) {
		cin >> inp.at(i);
	}
	ff(i, 0, y+2) {
		ff(j, 0, x + 2) {
			map.at(i).at(j) = 0;
		}
	}
	ff(i, 1, y + 1) {
		ff(j, 1, x + 1) {
			if (inp.at(i - 1).at(j - 1) == '#') {
				map.at(i).at(j) = 9;
				map.at(i-1).at(j-1)++;
				map.at(i-1).at(j)++;
				map.at(i-1).at(j+1)++;
				map.at(i).at(j-1)++;
				map.at(i).at(j+1)++;
				map.at(i+1).at(j-1)++;
				map.at(i+1).at(j)++;
				map.at(i+1).at(j+1)++;

		   }
		}
	}
	ff(i, 0, y) {
		ff(j, 0, x) {
			if (map.at(i+1).at(j+1) > 8) {
				cout << '#';
				continue;
			}
			cout << map.at(i+1).at(j+1);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[205];
  int ans=1<<27;
  
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }

  for(int i=0;i<n;i++){
    int cnt=0;
    while(a[i]%2==0){
      a[i]/=2;
      cnt++;
    }
    ans=min(ans,cnt);
  }

  cout << ans << endl;

  return (0);
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    cout<<(W*H/2.)<<" ";
    if(2*x==W && 2*y==H) cout<<1<<endl;
    else                 cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>

using namespace std;

int main(int argc, char const* argv[])
{
    int table_count=0;
    char key,value;

    while ( 1 ) 
    {
        /* ---  ティツェツュテ」ツ?ソティツセツシテ」ツ?ソ --- */
        cin >> table_count;
        if ( table_count == 0 ) { return 0; };
        //
        //cout << "table_count" << table_count << endl;

        map<char, char> map;
        for (int i = 0; i < table_count; i++) 
        {
            //cout << i << ": ";
            cin >> key; 
            cin >> value; 
            map[key] = value; 
            //
            //cout << key << " " << value << endl;
        }
        
        /* ---  テ・ツ?コテ・ツ環?--- */
        int char_count;
        cin >> char_count;
        //scanf("%d\n", &char_count);
        //
        //cout << "char_count :" << char_count << endl;
        for (int i = 0; i < char_count; i++) 
        {
            //
            //cout << i << " :";
            char tmp_char;
            cin >> tmp_char;
            
            if ( map.find(tmp_char) == map.end() ) 
            {
                cout << tmp_char;
            } 
            else 
            {
                cout << map[tmp_char];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
K, N = map(int, input().split())
A_list = list(map(int, input().split()))

result1 = A_list[-1]-A_list[0]
dist = []
for i in range(N-1):
    dist.append(A_list[i+1]-A_list[i])
dist = max(dist)
result2 = K-dist
if result1>=result2:
    print(result2)
else:
    print(result1)

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

int main(){

string t, ans;
int i;

ans = "Good";
cin >> t;

    for (i = 0; i < t.size() -1; i++)
    {
        if(t.at(i)==t.at(i + 1)){
            ans = "Bad";
        }
        else{
            continue;
        }
    }

cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int g1 = (s.length() + 1) / 2, p1 = s.length() / 2, g2 = 0, p2 = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'g') {
			g2++;
		}else{
			p2++;
		}
	}cout << p1 - p2 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;

int main()
{

	int N = 0;
	//int B = 0;

	std::cin >> N;

	if (N < 1000) {
		std::cout << "ABC"  << std::endl;
	}
	else {
		std::cout << "ABD" << std::endl;
	}

	return 0;

}

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

namespace ABC123_A_Five_Antennas
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] antena = new int[6];
			string output;

			for(int i = 0; i < 6; i++)
			{
				antena[i] = int.Parse(Console.ReadLine());
			}

			if(antena[4] - antena[0] > antena[5])
			{
				output = ":(";
			}
			else
			{
				output = "Yay!";
			}

			Console.WriteLine(output);
		}
	}
}


Measured memory_bytes: 11092
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.step = pow(2, n.bit_length() - 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get_sum(self, i):
        i += 1
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i & -i
        return x

    # Return sum for [l, r)
    def get_sum_range(self, l, r):
        return self.get_sum(r - 1) - self.get_sum(l - 1)

    # Return the minimum i that satisfies a_0 + a_1 + ... + a_i >= x
    def lower_bound(self, x):
        if x <= 0:
            return 0
        i = 0
        k = self.step
        while k:
            if i + k < self.n and self.data[i + k] < x:
                x -= self.data[i + k]
                i += k
            k >>= 1
        return i


def main():
    N, *P = map(int, read().split())

    index = [0] * (N + 1)
    for i, p in enumerate(P):
        index[p] = i

    bit = BIT(N)

    ans = 0
    for n in range(N, 0, -1):
        i = index[n]
        bit.add(i)
        x = bit.get_sum(i)

        left1 = left2 = -1
        right1 = right2 = N
        if x - 2 > 0:
            left2 = bit.lower_bound(x - 2)
        if x - 1 > 0:
            left1 = bit.lower_bound(x - 1)
        if x + 1 <= N - n + 1:
            right1 = bit.lower_bound(x + 1)
        if x + 2 <= N - n + 1:
            right2 = bit.lower_bound(x + 2)

        ans += ((left1 - left2) * (right1 - i) + (right2 - right1) * (i - left1)) * n

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 89628
n = int(input())
A = list(map(int, input().split()))
B = []
for i in range(n): B.append(A[i] - (i+1))
B.sort()
r = B[n//2] # median right
l = B[n//2] if n%2 else B[n//2-1] # median left
# print(n,A)
# print(B)
# print(l,r)
ans_l = 0
ans_r = 0
for bi in B:
    ans_l += abs(bi-l)
    ans_r += abs(bi-r)
print(min([ans_l, ans_r]))


Measured memory_bytes: 25196
#include <iostream>
#include <set>

using namespace std;

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

    set<int> d;
    for(int i = 0; i < N; ++i)
    {
        int di;
        cin >> di;
        d.insert(di);
    }

    cout << d.size() << endl;
    return 0;
}

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

int main(){
    ll a;
    cin >> a;
    cout << a + (a*a) + (a*a*a) << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){
  int w,h,x,y,r;

  scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);

  if(r <= x && x <= w-r && r <= y && y <= h-r ) printf("Yes\n");
  else printf("No\n");

  
  return 0;
}



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

int main(void) {
	// your code goes here
	int n,count=0;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++)
  scanf("%d",&a[i]);
   for(int i=0;i<n;i=i+2)
   {
     if(a[i]%2!=0)
     count++;
   }
   printf("%d\n",count);

	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  int n; cin >> n;
  vector<int> x;
  x = {105, 135, 165, 189, 195};
  int ans = 0;
  for (int i=0; i<x.size(); i++){
    if (n >= x[i]){
      ans += 1;
    }
    else break;
  }
  cout << ans << 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;
ll n, m, x,sum = 0, ans = 0;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMint() {
    fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k) {
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll PER(int n, int k) {
    return (fac[n] * finv[n - k]) % MOD;
}
int main(void) {
    COMint();cin >> n >> m;
    rep(i, n + 1) {
        x = (PER(m - i, n - i) * PER(m - i, n - i)) % MOD;
        sum = (COM(n, i) * PER(m, i)) % MOD;
        sum = (sum * x) % MOD;
        if (i % 2 == 0) ans += sum,ans %= MOD;
        else ans = (ans - sum + MOD) % MOD;
    }cout << ans << endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

/* プロトタイプ宣言 */
Node treeMinimum(Node x);
Node treeMaximum(Node x);
Node treeSearch(Node u, int k);
Node treeSuccessor(Node x);
void insert(int k);
void preorder(Node u);

#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main() {
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s", com);
    if ( com[0] == 'f' ) {
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ) {
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ) {
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}




Measured memory_bytes: 25124
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int n;

int main() {
	while(cin>>n){
		if(n==0)return 0;
		int ans=0;
		for(int i=1;i<12;i++)ans+=n/pow(5,i);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0