akhauriyash/Code-Regression huggingface dataset:
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

const ll mod = 1000000009;

inline ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

inline ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

inline ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

const int N = 1e5 + 5;

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

	ll n, k;
	cin >> n >> k;
	if(k >= (1<<n)) {
		cout << -1 << endl;
		return 0;
	}
	if(k == 0) {
		for(int i=0; i<(1<<n); i++) cout << i << " " << i << " ";
		cout << endl;
		return 0;
	}
	int x = 0;
	for(int i=0; i<(1<<n); i++) if(i != k) x ^= i;
	if(x == k) {
		deque <int> q;
		q.pb(k);
		for(int i=0; i<(1<<n); i++) {
			if(i == k) continue;
			q.push_back(i);
			q.push_front(i);
		}
		q.pb(k);
		for(auto e : q) cout << e << " ";
		cout << endl;
	}
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 2944
// abc169_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll llb = 100*b+0.01;
  cout<<a*llb/ 100<<endl;
  return 0;
}


Measured memory_bytes: 3732
#include<stdio.h>

#define N 100
 
int main(){
    int M[N][N];
    int n, u, k, v;
    int i, j;
   
    scanf("%d",&n);
 
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            M[i][j] = 0;
        }
    }
 
    for(i = 0; i < n; i++){
        scanf("%d %d",&u,&k);
        u--;
 
        for(j = 0; j < k; j++){
            scanf("%d",&v);
            v--;
            M[u][v] = 1;
        }
    }
 
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            if(j != 0) printf(" ");
            printf("%d",M[i][j]);
        }
        printf("\n");
    }
 
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {

int H,W;
vector<string> G(100);
cin>>H>>W;
fx(H){

		cin>>G.at(x);
	
}

	
	fx(H){
		int a=0;
	fy(W){
		if(G.at(x).at(y)=='.'){
			a++;
		}
	}
	if(a==W){
		fy(W){
		G.at(x).at(y)='0';
	    }
	}
	}
	
		fx(W){
		int a=0;
	fy(H){
		if(G.at(y).at(x)=='.'||G.at(y).at(x)=='0'){
			a++;
		}
	}
	if(a==H){
		fy(H){
		G.at(y).at(x)='0';
	    }
	}
	}
	

fx(H){
bool flag=false;
	fy(W){
		if(G.at(x).at(y)!='0'){
		cout<<G.at(x).at(y);
flag=true;
		}
	}
if(flag){
	cout<<endl;
}
}

}

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

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

int main(){
    int n;
    cin >> n;
    vector<double> x(n, 0); 

    double ans = 0;

    REP(i, n){
        string u;
        cin >> x[i] >> u;
        double t; 
        if (u=="JPY"){
            t = 1;
        }
        else{
            t = 380000;
        }
        ans += x[i]*t;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
abc_list = [list(map(int,input().split())) for _ in range(n)]

dp = [[0,0,0] for _ in range(n)]
dp[0] = abc_list[0]

for i in range(1,n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j], dp[i-1][k]+abc_list[i][j])

print(max(dp[-1]))

Measured memory_bytes: 47596
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
int Factorial(ll n)
{
	for (ll i = n - 1; i > 1; i--)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll Combination(const ll n, const ll r)
{
	return Factorial(n) / (Factorial(r) * Factorial(n - r));
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool IsPrime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll DigitSum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

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

void Main()
{
	inll a, b;
	
	return OUT((16 - min((ll)a, (ll)b) * 2) >= (max((ll)a, (ll)b) - min((ll)a, (ll)b)) * 2 ? "Yay!" : ":(");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;cin>>s>>t;
  int ans=t.size();
  for(int start=0;start+t.size()-1<s.size();start++){
    int tmp=0;
    for(int i=0;i<t.size();i++){
      if(s.at(start+i)!=t.at(i))tmp++;
    }
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3488
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<long long> x(n), y(n), u(n), v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i] >> y[i];
        u[i] = x[i] + y[i];
        v[i] = x[i] - y[i];
    }
    bool flag = true;
    for (int i = 0; i < n - 1; i++) {
        flag &= (u[i] & 1) == (u[i + 1] & 1);
    }
    if (!flag) {
        std::cout << -1 << std::endl;
        return 0;
    }

    std::vector<long long> d;
    for (int i = 38; i >= 0; i--) d.push_back(1LL << i);
    if (~u[0] & 1) d.push_back(1);

    std::cout << d.size() << std::endl;
    for (int i = 0; i < (int)d.size(); i++)
        std::cout << d[i] << " \n"[i == (int)d.size() - 1];

    std::vector<char> com = { 'L', 'U', 'D', 'R' };
    for (int t = 0; t < n; t++) {
        long long tu = x[t] + y[t];
        long long tv = x[t] - y[t];
        std::string ans = "";
        for (int i = 0; i < (int)d.size(); i++) {
            bool uflag = tu >= 0;
            bool vflag = tv >= 0;
            tu += (uflag ? -1 : 1)*d[i];
            tv += (vflag ? -1 : 1)*d[i];
            ans += com[uflag + 2 * vflag];
        }
        std::cout << ans << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;

ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }

class SegTree {
 private:
  const pll def_val_ = {INF,0};
  vector<pll> val_;
  ll n_;

  pll comp(pll l, pll r) { 
    if (l.first < r.first) {
      return l;
    } else if (l.first == r.first) {
      if (l.second < r.second) {
        return l;
      }
    }
    return r;
  }

  pll getr(ll x, ll y, ll k, ll l, ll r) {
    if (y <= l || r <= x) return def_val_;
    if (x <= l && r <= y) return val_[k];
    auto vl = getr(x, y, 2 * k + 1, l, (l + r) / 2);
    auto vr = getr(x, y, 2 * k + 2, (l + r) / 2, r);
    return comp(vl, vr);
  }

 public:
  SegTree(ll size) {
    n_ = 1;
    while (n_ < size) n_ *= 2;
    val_ = vector<pll>(2 * n_, def_val_);
  }

  void update(ll i, ll val) {
    // cout << "update" << endl;
    ll i0 = i;
    i += (n_ - 1);
    val_[i] = {val, i0};
    while (i > 0) {
      // cout << "up:" << val_[i].first << "," << val_[i].second << endl;
      i = (i - 1) / 2;
      val_[i] = comp(val_[2 * i + 1], val_[2 * i + 2]);
    }
  }

  // get XXX value between [x,y)
  pll getRange(ll x, ll y) { return getr(x, y, 0, 0, n_); }
};


int main() {
  ll n;
  cin >> n;
  vector<set<ll>> e(n);
  vl deg(n, 0);
  vl val(n);
  rep(i,n-1) {
    ll a,b;
    cin>>a>>b;
    a--,b--;
    e[a].insert(b);
    e[b].insert(a);
    deg[a]++;
    deg[b]++;
  }
  SegTree st(n);
  rep(i, n) {
    st.update(i, deg[i]);
  }
  // cout << st.getRange(0, n+1).first << "," << st.getRange(0, n+1).second << endl;

  vl c(n);
  rep(i,n) cin>>c[i];
  sort(ALL(c));

  ll ans = 0;
  for (auto& ci : c) {
    pll next = st.getRange(0, n+1);
    ll u = next.second;
    // cout << ci << ":" << u << "," << next.first << endl;
    val[u] = ci;
    for (auto& v : e[u]) {
      deg[v]--;
      st.update(v, deg[v]);
      set<ll>::iterator it = e[v].find(u);
      if (it != e[v].end()) e[v].erase(it);
      ans += ci;
    }
    st.update(u, INF);
  }
  cout << ans << endl;
  rep(i, n) {
    cout << val[i];
    if (i < n - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100007;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
vector<int> G[N];
int n,m,a[N],b[N],fa[N],rk[N],vis[N];
LL f[N],sum[N],ans;
bool cmp(int x,int y)
{
	return a[x]<a[y];
}
int getfa(int x)
{
	return fa[x]==x ? x : fa[x]=getfa(fa[x]);
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++){
		a[i]=read(),b[i]=read();
		a[i]=max(a[i]-b[i],0);
	}
	for(int i=1;i<=m;i++){
		int u=read(),v=read();
		G[u].push_back(v);G[v].push_back(u);
	}
	for(int i=1;i<=n;i++){
		rk[i]=fa[i]=i; f[i]=a[i]; sum[i]=b[i];
	}
	sort(rk+1,rk+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		int u=rk[i]; vis[u]=1;
		for(int j=0;j<G[u].size();j++)
		{
			int v=G[u][j];
			if(!vis[v]) continue;
			int x=getfa(u),y=getfa(v);
			if(x!=y){
				fa[y]=x; sum[x]+=sum[y];
//				f[x]=min(f[x],f[y]+max(f[y],a[x]-sum[y]));
				f[x]=min(f[x],max(f[y],a[x]-sum[y]));
			}
		}
	}
	int rt=getfa(1);
	printf("%lld\n",f[rt]+sum[rt]);
	return 0;
}


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

using namespace std;

int main(void) {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;

  if (s == u) {
    a--;
    cout << a << " " << b << endl;
  } else if (t == u) {
    b--;
    cout << a << " " << b << endl;
  }
}


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


lint MOD = 1000000007;
int N;
lint r;

lint b_pow(lint a, lint n, lint m){
    lint res = 1;
    
    while(n > 0){
        if(n & 1) res = (res * a) % m;
        a = (a * a) % m;
        n >>= 1;
    }
    return res;
}



int main(){
    cin >> N;

    r = b_pow(10, N, MOD)-b_pow(9, N, MOD)-b_pow(9, N, MOD)+b_pow(8, N, MOD);
    while(r < 0) r += MOD;
    r %= MOD;

    cout << r << endl;
    return 0;
}




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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 200005;

int n, a[N];
LL ans;

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n);
  for (int i = 1; i <= n; ++i) {
    Read(a[i]);
  }
  if (a[1]) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i < n; ++i) {
    if (a[i + 1] - a[i] > 1) {
      puts("-1");
      return 0;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (a[i]) {
      ++ans;
      if (a[i] != a[i - 1] + 1) {
        ans += a[i] - 1;
      }
    }
  }
  printf("%lld\n", ans);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 1024
while True:
    n = int(raw_input())
    if n == 0:
        break
    magic = [[0 for i in range(n)] for i in range(n)]
    x, y = n/2, n/2+1
    magic[y][x] = 1
    count = 2
    while count <= n**2:
        x, y = (x+1)%n, (y+1)%n
        if magic[y][x] == 0:
            magic[y][x] = count
            count += 1
        else:
            x, y = (x-1)%n, (y+1)%n
            magic[y][x] = count
            count += 1
    for i in xrange(n):
        print "".join(map(lambda s:str(s).rjust(4),magic[i]))

Measured memory_bytes: 4252
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <set>
#include <utility>

#define MAX_N (2000)
#define INF (1000000000)

using namespace std;

void move_small(set<pair<int, int>> &p1s, set<pair<int, int>> &p2s, int num) {
  for (int i = 0; i < num; i++) {
    pair<int, int> p = *p1s.begin();
    p2s.insert(p);
    p1s.erase(p);
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  int N, K, Q, as[MAX_N];
  scanf("%d %d %d", &N, &K, &Q);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }

  // solve
  int ans = INF;
  for (int i = 0; i < N; i++) {
    const int y = as[i];

    // check if it possible to take y
    int num_around_y = 1;
    for (int j = i + 1; j < N && as[j] >= y; j++) {
      num_around_y++;
    }
    for (int j = i - 1; j >= 0 && as[j] >= y; j--) {
      num_around_y++;
    }
    if (num_around_y < K) {
      continue;
    }

    // check that more than Q elements >= y can be removed
    set<pair<int, int>> ps, pblocks;
    for (int j = 0; j < N; j++) {
      const int a = as[j];
      if (a >= y) {
        pblocks.insert(make_pair(a, j));
      } else {
        move_small(pblocks, ps,
                   pblocks.size() >= K ? pblocks.size() - K + 1 : 0);
        pblocks.clear();
      }
    }
    move_small(pblocks, ps, pblocks.size() >= K ? pblocks.size() - K + 1 : 0);
    if (ps.size() < Q) {
      continue;
    }

    // update
    int x = 0;
    for (int k = 0; k < Q; k++) {
      pair<int, int> p = *ps.begin();
      x = p.first;
      ps.erase(p);
    }
    ans = min(ans, x - y);
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int hap = 0;
    REP(i, N) {
        if(S[i] == 'L') {
            if(i != 0 && S[i-1] == 'L') hap++;
        } else {
            if(i != N-1 && S[i+1] == 'R') hap++;
        }
    }
    hap += 2 * K;
    cout << min(hap, N-1) << endl;
}

Measured memory_bytes: 512
from math import floor, ceil

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
l = 0
r = max(a)
while r - l > 1:
    c = (l+r)//2
    cnt = 0
    for i in a:
        cnt += max(ceil(i/c) - 1, 0)
    if cnt <= k:
        r = c
    else:
        l = c
print(r)

Measured memory_bytes: 104192
import scala.io.StdIn._
import scala.math._

/**
 * ABC113B
 */
object Main extends App {

  readLine()
  val in = readLine().split(" ").toSeq
  val t = in(0).toInt
  val a = in(1).toInt
  val h: Seq[Int] = readLine().split(" ").toSeq.map(_.toInt).toSeq

  val hdiff = h.map(v => abs(t - v * 0.006 - a)).toIndexedSeq

  val ans = hdiff.indexWhere(_ == hdiff.min) + 1

  println(ans)
}


    

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

int n,k;ll ans;
int main(){
	scanf("%d%d",&n,&k);
	for(int b=k+1;b<=n;++b){
		int t=(n+1)/b;
		ans+=ll(b-k)*t;
		t=t*b+k;
		ans+=max(0,n-t+1);
	}
	if(!k)ans-=n-(k+1)+1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>> sum;
  int N,M,Q,L,R,p,q;
  scanf("%d %d %d",&N,&M,&Q);
  sum=vector<vector<int>>(N+1,vector<int>(N+1,0));
  for(int i=0;i<M;i++){cin>>L>>R; sum[L][R]++;}
  for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)
    sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
  for(int i=0;i<Q;i++){
    scanf("%d %d",&p,&q);
    printf("%d\n",sum[q][q]-sum[q][p-1]-sum[p-1][q]+sum[p-1][p-1]);
  }
}


Measured memory_bytes: 1920
#include <iostream>



using namespace std;

long long ans(int L,long long X){
    long long size = 1LL << (L+2);
    size-=3;
    if(X==0)return 0;
    if(L==0)return 1;
    if(X <= (1LL << (L+1)) -3 +1)return ans(L-1,X-1);
    return (1LL << L) + ans( L-1,X- ((1LL << (L+1)) -3 +2));
}


int main(void){
    int N;
    long long X;
    scanf("%d%lld",&N,&X);
    printf("%lld",ans(N,X));
    
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

const LLONG ComputeAttackNum(const LLONG H)
{
    if (H == 1) return 1;
    else return 1 + ComputeAttackNum(H / 2) * 2;
}

int main()
{
    LLONG H;
    cin >> H;
    cout << ComputeAttackNum(H) << endl;
}


Measured memory_bytes: 256
N = int(input())
S = str(input())
V = 'abcdefghijklmnopqrstuvwxyz'
Lavida = [1]*26
for i in range (0, N):
	Lavida[V.index(S[i])]+=1

count = 1
for i in range (0, 26):
	count*=Lavida[i]
	count=count%(10**9+7)

print((count-1)%(10**9+7))

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define  forloop for(int i=0;i<n;i++)
#define pb push_back 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define MOD 998244353;
#define unmap unordered_map
#define pi 3.1415926536
#define testcases ll t;cin>>t;while(t--)
#define  mp make_pair
#define  vcp vector<pair<ll,ll>>
#define preci(x,y)  fixed<<setprecision(y)<<x
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define fast ios::sync_with_stdio(false);   cin.tie(0); cout.tie(0);
#define preinc priority_queue <ll, vector<ll>, greater<ll>>
#define predec priority_queue<ll> 
#define vll vector<ll>
#define f(a,b) for(ll i=a;i<=b;i++)
int vac(int a[][3],int ind,int n,vector<vector<ll>>&v,int lastpic)
{
   if(ind>=n)
   {
    return 0;
   }
   if(v[ind][lastpic]!=-1)
    return v[ind][lastpic];
   int ans=INT_MIN;
    for(int j=0;j<3;j++)
    {
        if(j!=lastpic)
            ans=max(ans,vac(a,ind+1,n,v,j)+a[ind][j]);
    }
    
  // cout<<ans<<"\n";
   v[ind][lastpic]=ans;
   return ans;
}
int main() {
    #ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
   fast
   int n;
   cin>>n;
   int a[n][3];
   forloop
   {
   for(int j=0;j<3;j++)
    cin>>a[i][j];
   }
   vector<vector<ll>>v(n+1,vector<ll>(3,-1));
   int ans = -1;
    for (int i = 0; i < 3; i++)
        ans = max (ans, (vac(a,1,n,v,i)) + a[0][i]);
    cout<<ans;
    // your code goes here
    return 0;
}

Measured memory_bytes: 19256
def main():
    from collections import Counter as ct

    def soinsuu(a):
        yy, j = [], 2
        y = yy.append
        while(a > 1):
            for i in range(j, int(a**0.5)+1):
                if a % i == 0:
                    y(i)
                    a, j = a//i, i
                    break
            else:
                y(a)
                break
        return ct(yy)

    def yakusuu(a):
        s = {1}
        for i, j in a.items():
            s |= {l*i**k for l in s for k in range(1, j+1)}
        s.remove(1)
        return s

    n = int(input())

    ans = 1
    for i in soinsuu(n-1).values():
        ans *= i+1
    ans -= 1

    for i in yakusuu(soinsuu(n)):
        m = n
        while m % i == 0:
            m //= i
        m -= 1
        if m % i == 0:
            ans += 1
    print(ans)


main()

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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    
    ll n;
    cin>>n;
    ll a[n];
    ll mx = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mx = max(mx,a[i]);
    }
    ll ans1 = -1;
    long long low=-1,up=1e15+7,mid;
    while(up-low>1){
        mid=(up+low)/2;
        ll k = mid;
        for(int i=0;i<n;i++){
            k -= k%a[i];
        }
        if(k<=1){
            low=mid;
        }
        else{
            up=mid;
        }
    }
    ans1 = up;
    low=-1,up=1e15+7;
    while(up-low>1){
        mid=(up+low)/2;
        ll k = mid;
        for(int i=0;i<n;i++){
            k -= k%a[i];
        }
        if(k<=2){
            low=mid;
        }
        else{
            up=mid;
        }
    }
    ll ans2 = low;
    if(ans1>ans2){
        cout << -1 << endl;
        return 0;
    }
    cout << ans1 << " " << ans2<< endl;
    
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

bool isPrime(int N){
  bool ans = true;
  for (int i = 2; i * i <= N; i++){
    if (N % i == 0){
      ans = false;
      break;
    }
  }
  return ans;
}

int main(){
  vector <bool> Prime(100001);
  Prime[2] = true;
  for (int i = 3; i < 1e5 + 1; i+=2){
    Prime[i] = isPrime(i);
  }
  
  vector <int> cnt(100001);
  for (int i = 1; i < 1e5 + 1; i+=2){
    if (Prime[i] == true && Prime[(i + 1) / 2] == true){
      cnt[i]++;
    }
  }
  
  for (int i = 1; i < 1e5 + 1; i++){
    cnt[i] += cnt[i - 1];
  }
  
  int Q; cin >> Q;
  for (int i = 0; i < Q; i++){
    int L, R; cin >> L >> R;
    cout << cnt[R] - cnt[L - 1] << endl;
  }
  

  return 0;
}


Measured memory_bytes: 1152
// Example program
#include <iostream>
#include <string>
using namespace std;

void solve()
{
   int n;
   cin>>n;
   int ar[n]; int cnt=0;
   for(int i=0;i<n;i++){cin>>ar[i];
   if(i%2==0 && ar[i]%2)cnt++;
   }
   cout<<cnt<<endl;
}

int main()
{
 //int t; cin>>t;
// while(t--)
    solve();
}


Measured memory_bytes: 3632
#include<stdio.h>


int main(){
	double b;
int a[12],c,d,e,f,x,y,z;
while(1){
	scanf("%lf",&b);

	if(b<0)
	break;
	if(b>256)
	printf("NA\n");
	else{
		if(b-128.0>=0.0){
			b-=128.0;
			a[0]=1;
			
		
	}
	else
	a[0]=0;
	if(b-64.0>=0.0){
		b-=64.0;
		a[1]=1;
	}
	else
	a[1]=0;
	
	if(b-32.0>=0.0){
		b-=32.0;
		a[2]=1;
	}
	else
	a[2]=0;
	
	if(b-16.0>=0.0){
		b-=16.0;
		a[3]=1;
	}
	else
	a[3]=0;
	
	if(b-8.0>=0.0){
		b-=8.0;
		a[4]=1;
	}
	else
	a[4]=0;

	if(b-4.0>=0.0){
		b-=4.0;
		a[5]=1;
	}
	else
	a[5]=0;
	
	if(b-2.0>=0.0){
		b-=2.0;
		a[6]=1;
	}
	else
	a[6]=0;
	
	if(b-1.0>=0.0){
		b-=1.0;
		a[7]=1;
	}
	else
	a[7]=0;
	
	if(b-0.5>=0.0){
		b-=0.5;
		a[8]=1;
	}
	else
	a[8]=0;
	
	if(b-0.25>=0.0){
		b-=0.25;
		a[9]=1;
	}
	else
	a[9]=0;
}

	if(b-0.125>=0.0){
		b-=0.125;
		a[10]=1;
	}
	else
	a[10]=0;
	
	if(b-0.0625>=0.0){
		b-=0.0625;
		a[11]=1;
	}
	else
	a[11]=0;
	if(b>0.0){
	printf("NA");

	}else{
	for(x=0;x<12;x++){
		printf("%d",a[x]);
		if(x==7)
		printf(".");
	}
	}
	printf("\n");
}

	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = TEN(9) + 7;
const int maxn = TEN(6) + 10;

inline void add(ll &x, ll y) {
	x += y;
	if (x >= MOD) x -= MOD;
}

ll dp[maxn];
ll ps[maxn];

int main() {
	int N, H, D;
	cin >> N >> H >> D;
	ll k = 1;
	ll s = 0;
	for (int i = 1; i <= N; ++i) {
		k = k * i % MOD;
		add(s, k);
	}

	for (int i = 1; i <= H; ++i) {
		ps[i] = ps[i-1];
		dp[i] = ps[i] - ps[max(0, i-D-1)];
		
		if (dp[i] < 0) dp[i] += MOD;
		dp[i] = dp[i] * s % MOD;
		if (i <= D) add(dp[i], k);
		add(ps[i], dp[i]);
	}

	cout << dp[H] << endl;

	return 0;
}

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

total = sum(a)

for i in range(n):
    if a[i] < b[i]:
        b[i] = b[i] - a[i]
        a[i] = 0
        if a[i+1] < b[i]:
            b[i] = b[i] - a[i+1]
            a[i+1] = 0
        else:
            a[i+1] = a[i+1] - b[i]
    else:
        a[i] = a[i] - b[i]

kill = total - sum(a)

print(kill)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  map<string, int> m;
  REP(i, N){
    string s; cin >> s;
    m[s]++;
  }
  int MM = 0;
  for(auto &i : m){
    MM = max(MM, i.second);
  }
  vector<string> ans;
  for(auto &i : m){
    if(i.second == MM){
      ans.push_back(i.first);
    }
  }
  sort(ans.begin(), ans.end());
  for(auto &i : ans) cout << i << endl;
}

Measured memory_bytes: 25584
#include <bits/stdc++.h>
using namespace std;
const char *nl = "\n";

int main() {
    int n; cin >> n;
    n %= 10;
    switch (n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << nl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << nl;
        break;
    default:
        cout << "bon" << nl;
        break;
    }
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
void solve() {
 	int n, k;
  	cin >> n >> k;
  	if(k == 1)
      	cout << '0' << endl;
 	else
      	cout << n-k << endl;
 	return ;
}
int main() {
 	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);
  	solve();
  	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

train :: Int -> [Int] -> Int
train start [c, s, f]
    | s > start = s + c
    | (start - s) `mod` f == 0 = start + c
    | otherwise = start + f - start `mod` f + c
train _ _ = 0

time :: [[Int]] -> Int
time [] = 0
time xs = foldl train (head xs !! 1) xs

main :: IO ()
main = do
    n <- fst . fromJust . B.readInt <$> B.getLine
    ts <- replicateM (n - 1) $ map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    putStr $ unlines $ map (show . time) (tails ts)


Measured memory_bytes: 1148
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
judge = 0

for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      A[i][j] = 0
  
for i in range(3):
  if A[i][0] + A[i][1] + A[i][2] == 0 or A[0][i] + A[1][i] + A[2][i] == 0 or A[0][0]+A[1][1]+A[2][2] ==0 or A[2][0]+A[1][1]+A[0][2] ==0:
    judge += 1
  
  else:
    judge += 0
    
if judge >= 1:
  print('Yes')
  
else:
  print('No')

Measured memory_bytes: 3064
//============================================================================
// Name        : a.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
	string s;
	cin>>s;
	if(s[0]==s[1]){
		if(s[2]==s[3]){
			if(s[0]!=s[2]){
			cout<<"Yes"<<endl;
			return 0;
			}
		}
	}
	if(s[0]==s[2]){
		if(s[1]==s[3]){
			if(s[0]!=s[1]){
			cout<<"Yes"<<endl;
			return 0;
			}
		}
	}
	if(s[0]==s[3]){
		if(s[1]==s[2]){
			if(s[0]!=s[1]){
			cout<<"Yes"<<endl;
			return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc087/tasks/abc087_b

A = int(input())
B = int(input())
C = int(input())
X = int(input())

possible_values = [a * 500 + b * 100 + c * 50 for a in range(A+1) for b in range(B+1) for c in range(C+1)]
is_match = [1 for i in possible_values if i == X]
print(sum(is_match))

Measured memory_bytes: 13924
#include<stdio.h>
#include<math.h>
struct Point{
  double x,y;
};
void koch(int n,struct Point a,struct Point b){
  if(n==0)return;
  struct Point s,t,u;
  double th=M_PI*60.0/180.0;
  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1,t,b);
 
}

int main(){
  struct Point a,b;
  int n;
  scanf("%d",&n);
  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;
  printf("%.8f %.8f\n", a.x, a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n", b.x, b.y);
  return 0;
}
  

Measured memory_bytes: 640
#include <iostream> 
#include <string>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

typedef long long ll;

ll qexp(ll A, ll B, ll M) {
    if (B == 0) return 1;
    ll half = qexp(A, B/2, M) % M;
    half *= half;
    half %= M;
    if (B % 2 == 1) half *= A; 
    return half % M;
}

ll modInverseP(ll a, ll p) {
    return qexp(a, p-2, p);
}
static vector<int> fac;
ll nCrModP(int n, int r, ll p) {
    if (r == 0) return 1;
    return fac[n] * modInverseP(fac[r] * 1LL * fac[n-r] % p, p) % p;
}

int main()
{
    long long n, m, k;
    cin >> n >> m >> k;
    long long ans = 0;
    fac.push_back(1);
    for(long long i = 1; i <= n; ++i) {
        fac.push_back(fac[i - 1] * 1LL * i % 998244353);
    }
    for (long long i = 0; i <= k; i++)
    {
        ans += (((m * nCrModP(n-1, i, 998244353)) % 998244353) * qexp(m-1, n-1-i, 998244353)) % 998244353;
    }

    cout << ans % 998244353 << endl;
}




Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define mp make_pair
// GCD inbuilt func: __gcd(a,b)
// LCM formula: (a*b)/__gcd(a,b)

int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	// CODE goes here
    ll n;
    cin >> n;
    ll a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    if(n<3){
        cout << "0";
        return 0;
    }
    sort(a,a+n);
	ll count=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]) count++;
				else if(a[i]+a[j]<=a[k]) break;
			}
		}
	}
	cout << count;
	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  if(a>b && a-1>b){
    printf("%d\n",2*a-1);}
  if(a<b && b-1>a){
    printf("%d\n",2*b-1);}
  if(a>b && a-1==b){ 
    printf("%d\n",a+b);}
  if(a<b && b-1==a){
     printf("%d\n",a+b);}
  if(a==b){
     printf("%d\n",a+b);}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 

ll power(ll x, ll y) 
{ 
    ll res = 1; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x * x; 
    } 
    return res; 
}
int main()
{
    fastio
    ll t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,e,p,nl,np,q,r;
    string s;
    cin>>n>>s;
    ll f=0;
    if(s.size()>n)
        f=1;
    if(s.size()<=n)
    {
        cout<<s<<endl;
        return 0;
    }
    for(int i=0;i<n;i++)
        cout<<s[i];
    if(f==1)
        cout<<"..."<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
#define REP(i,n) for (int i = 1; i<= (n); i++)
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
const long double PI = acos(-1);
using ll = long long;
using ld = long double;
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << abs(n-3)*180 + 180 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]


using namespace std;

typedef double Real;

Real EPS = 1e-8;

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  bool operator < (Point p){return (p.x!=x)?p.x<x:p.y<y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
};

struct Circle{
  Point p;
  Real r;
  Circle(){}
  Circle(Point p, Real r) : p(p) , r(r){}
  
  vector<Point> intersectionPoints(Circle b){
    vector<Point> res;

    Point tmp=p-b.p;
    if(tmp.norm()>pow(r+b.r,2))return res;

    Real L = p.dist(b.p);
    Real C = atan2(b.p.y-p.y,b.p.x-p.x);
    Real a = acos((L*L+r*r-b.r*b.r)/(2*L*r));

    res.push_back(Point(p.x+cos(C+a), p.y+sin(C+a)));
    res.push_back(Point(p.x+cos(C-a), p.y+sin(C-a)));
    return res;
  }
};

int main(void){
  int n;
  Point a;
  vector<Point>P;
  vector<Circle>C;

  while(cin >> n,n){
    P.clear();
    C.clear();
    for(int i=0;i<n;i++){
      cin >> a.x >> a.y;
      P.push_back(a);
    }

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(sgn(P[i].dist(P[j]),2.0)>=0)continue;
	vector<Point>res=Circle(P[i],1.0).intersectionPoints(Circle(P[j],1.0));
	for(int k=0;k<res.size();k++)
	  C.push_back(Circle(res[k],1));
      }
    }

    int ans=1;
    for(int i=0;i<C.size();i++){
      int cnt=0;
      for(int j=0;j<P.size();j++)
	if(sgn(C[i].p.dist(P[j]),1.0)<=0)cnt++;

      ans=max(ans,cnt);
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2216
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int k;
    string s;
    cin >> k >> s;
    int slen = s.size();
    if(slen<=k){
        cout << s << endl;
    }else{
        rep(i, k){
            cout << s[i];
        }
        cout << "..." <<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  string s,t,w,e;
  cin >> s;
  t=s;
  reverse(all(t));
  int q,n=0;
  cin >> q;
  rep(i,q){
    int f;
    cin >> f;
    if (f==1) n=1-n;
    else{
      int g;
      char h;
      cin >> g >> h;
      if (g==2){
        if (n==0){
          w.push_back(h);
        }
        else{
          e.push_back(h);
        }
      }
      else{
        if (n==1){
          w.push_back(h);
        }
        else{
          e.push_back(h);
        }
      }
    }
  }
  reverse(all(e));
  s=e+s+w;
  if (n==0) cout << s << endl;
  else {
    reverse(all(s));
    cout << s << endl;
  }
}


Measured memory_bytes: 1476
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,m,a,b;
  vector<int> vec;
  
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    vec.push_back(a);
  }
 
  cin >> m;
  for(int i=0;i<m;i++){
    cin >> b;
    cout << lower_bound(vec.begin(),vec.end(),b)-vec.begin() << endl;
  }

  return(0);
}



Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;

int main()
{
  while(1){
    int N;
    cin >> N;
    if(N == 0){
      break;
    }else{
      int W, H, S, T;
      cin >> W >> H;
      int map[100][100] = {};
      REP(i, N){
        int x, y;
        cin >> x >> y;
        map[y - 1][x - 1] = 1;
      }
      cin >> S >> T;
      int ans = 0;
      for(int l = 0; l < H - T + 1; l++){
        for(int k = 0; k < W - S + 1; k++){
          int n = 0;
          for(int i = l; i < l + T; i++){
            for(int j = k; j < k + S; j++){
              if(map[i][j] == 1)
                n++;
            }
          }
          ans = max(ans, n);
        }
      }
      cout << ans << endl;     
    }
  }
} 

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

namespace ConsoleApplication36
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int a = int.Parse(Console.ReadLine());
                if (a == 0)
                    break;
                int d,e;
                d=e=0;
                for (int b = 0; b < a; b++)
                {
                    int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (c[0] > c[1])
                        d += c[0] + c[1];
                    if (c[0] < c[1])
                    e += c[0] + c[1];
                    if(c[0]==c[1]){
                        d+=c[0];
                        e+=c[1];
                    }
                }
                Console.WriteLine("{0} {1}", d, e);
            }
        }
    }
}

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

#define BUF 5

int main(void) {
  char str[BUF];
  scanf("%s", str);
  if (!strncmp(str, "ABC", BUF)) {
    printf("ARC\n");
  } else if (!strncmp(str, "ARC", BUF)) {
    printf("ABC\n");
  }

  return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;
#define START 0
#define FORWARD 1
#define BACK 2
using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;
bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll gcd(ll a, ll b)
{
	ll tmp, r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
	//// 引数に０がある場合は０を返す
	//if ((0 == m) || (0 == n))
	//	return 0;

	//// ユークリッドの方法
	//while (m != n)
	//{
	//	if (m > n) m = m - n;
	//	else         n = n - m;
	//}
	//return m;
}//gcd
int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll x[100004] = {};
	ll y[100004] = {};
	ll z[100004] = {};
	ll x2[200][200] = { {} };
	string s[1000];
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	//cout << LLONG_MAX<< endl;

	cin >> a;
	
	cout << (a-2)*180 << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//sort(x, x + a, std::greater<ll>());

//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得
//
//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}
//
//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え


/*vector<pair<ll, ll> > hoges(a);
for (int i = 0; i < a; i++)
{
cin >> x[i];
cin >> y[i];
hoges[i] = make_pair(x[i], y[i]);
}
sort(hoges.begin(),hoges.end(),comp);
for (int i = 0; i < a; i++)
{
if (hoges[i].second>=b)
{
ans += hoges[i].first*b;
break;
}
else
{
ans += hoges[i].first*hoges[i].second;
b -= hoges[i].second;

}
}*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int main() {
    string s,t;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='B') {if(t.size())t.pop_back();}
        else t.push_back(s[i]);
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define p pair<int,int>
using namespace std;
#define Mod 1000000007

int main(){
  int N,M;
  cin>>N>>M;
  vector<p> v;
  int i;
  int x,y;
  for(i=0;i<M;i++){
	cin>>x>>y;
	v.push_back(make_pair(y,x));
  }
  sort(v.begin(),v.end());
  int ans=0;
  int rightest=0;
  for(i=0;i<M;i++){
	if(v[i].second>=rightest){
		ans+=1;
		rightest=v[i].first;
	}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1400