akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    vector<ll>A(n+1);
    A[0]=0;
    vector<vector<ll>>f(10000,vector<ll>(2));
    ll cnt=0,ans=0;
    rep(i,n){
        cin>>a[i];
        rep(j,a[i]){
            cin>>f[cnt][0]>>f[cnt][1];
            cnt++;
        }
    }
    a.resize(cnt);
    rep(i,n){
        A[i+1]=A[i]+a[i];
    }
    for(int tmp=0;tmp<(1<<n);tmp++){
        bitset<15>b=tmp;
        bool jud=false;
        rep(i,n){
            if(!b.test(i))continue;
            rep(j,a[i]){
                if(f[A[i]+j][1]==1&&!b.test(f[A[i]+j][0]-1))jud=true;
                else if(f[A[i]+j][1]==0&&b.test(f[A[i]+j][0]-1))jud=true;
            }
        }
        if(!jud){
            ll mx=b.count();
            ans=max(ans,mx);
        }
    }
    cout<<ans<<endl;
}









































Measured memory_bytes: 3924
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}
int n;
int m=1;
int a[800005];
int seg[2][800005];
int ans[200005];
struct node
{
	int a,b;
	int mint;
};
void update(int k)
{
	int odd;
	int pos=k;
	odd=k%2;
	k+=m-1;
	seg[odd][k]=pos;
	seg[(odd+1)%2][k]=INF;
	while(k>1)
	{
		k/=2;
		for(int i=0;i<2;i++)
		{
			if(seg[i][k*2]==INF and seg[i][k*2+1]!=INF)
			{
				seg[i][k]=seg[i][k*2+1];
			}
			else if(seg[i][k*2+1]==INF&&seg[i][k*2]!=INF)
			{
				seg[i][k]=seg[i][k*2];
			}
			else if(seg[i][k*2]!=INF&&seg[i][k*2+1]!=INF)
			{
				if(a[seg[i][k*2]]<a[seg[i][k*2+1]])
				{
					seg[i][k]=seg[i][k*2];
				}
				else
				{
					seg[i][k]=seg[i][k*2+1];
				}
			}
		}
	}
}
int query(int l,int r,int k,int l1,int r1)
{
	int odd=l%2;
	if(l<=l1 and r>=r1)
	{
		return seg[odd][k];
	}
	if(r<l1 or l>r1)
	{
		return INF;
	}
	else
	{
		int x=query(l,r,k*2,l1,(l1+r1)/2);
		int y=query(l,r,k*2+1,(l1+r1+1)/2,r1);
		if(x==INF and y!=INF)
		{
			return y;
		}
		else if(x!=INF and y==INF)
		{
			return x;
		}
		else if(x==INF and y==INF)
		{
			return INF;
		}
		else
		{
			if(a[x]<a[y])
			{
				return x;
			}
			else
			{
				return y;
			}
		}
	}
}
bool operator >(node x,node y)
{
	if(x.mint!=INF and y.mint!=INF)
	{
		return a[x.mint]>a[y.mint];
	}
	else if(x.mint==INF and y.mint!=INF)
	{
		return true;
	}
	else if(x.mint!=INF and y.mint==INF)
	{
		return false;
	}
	return true;
}
int main()
{
	cin>>n;
	for(int i=0;i<800000;i++)
	{
		a[i]=INF;
		seg[0][i]=INF;
		seg[1][i]=INF;
	}
	while(m<n)
	{
		m*=2;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=m;i++)
	{
		update(i);
	}
	priority_queue<node,vector<node>,greater<node> > pq;
	node init={1,n,query(1,n,1,1,m)};
	pq.push(init);
	int id=1;
	while(id<=n and !pq.empty())
	{
		node f=pq.top();
		pq.pop();
		ans[id++]=f.mint;
		int tmp=query(f.mint+1,f.b,1,1,m);
		node nx,dx={f.mint+1,f.b,tmp};
		if(f.a<f.mint-1)
		{
			tmp=query(f.a,f.mint-1,1,1,m);
			nx={f.a,f.mint-1,tmp};
			pq.push(nx);
		}
		ans[id++]=dx.mint;
		node sec,thir;
		if(dx.a<dx.mint-1)
		{
			tmp=query(dx.a,dx.mint-1,1,1,m);
			sec={dx.a,dx.mint-1,tmp};
			pq.push(sec);
		}
		if(dx.mint+1<dx.b)
		{
			tmp=query(dx.mint+1,dx.b,1,1,m);
			thir={dx.mint+1,dx.b,tmp};
			pq.push(thir);
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[ans[i]]<<" ";
	}
	return 0;
}

Measured memory_bytes: 12280
n = int(input())
s_1 = ''
s_2 = ''
s_3 = ''
s_4 = ''
s_5 = ''
s_6 = ''
for i in range(n):
    h = float(input())
    if h < 165.0:
        s_1 += '*'
    elif h < 170.0:
        s_2 += '*'
    elif h < 175.0:
        s_3 += '*'
    elif h < 180.0:
        s_4 += '*'
    elif h < 185.0:
        s_5 += '*'
    else:
        s_6 += '*'
print('1:'+s_1)
print('2:'+s_2)
print('3:'+s_3)
print('4:'+s_4)
print('5:'+s_5)
print('6:'+s_6)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>;
#define vi vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms


int a[1 << 8];
int N, M;

int dfs(int l, int r) {
    
    if (l + 2 == r) {
        if (a[l] + a[l + 1] == 0) return -1;
        return a[l] & a[l + 1];
    }
    int r1 = dfs(l, (l + r) / 2), r2 = dfs((l + r) / 2, r);
    
    if (r1 == -1 && r2 == -1) return -1;
    if (r1 == -1 || r2 == -1) return r1 + r2 + 1;
    return r1 + r2 + 1;
}
int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    
    
    
    cin >> N >> M;
    rep(i, N) a[i] = 1;
    
    rep(i, M) {int absent; cin >> absent; a[absent] = 0;}
    
    
    
    cout << dfs(0, N) << endl;
    
}
//cast caution







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

int main()
{
	vector<int> list;

	int N, K;
	cin >> N >> K;
	for (size_t i = 0; i < N; i++)
	{
		int in;
		cin >> in;
		list.push_back(in);
	}

	sort(list.begin(), list.end());

	int ans=0;
	vector<int>::reverse_iterator i = list.rbegin();
	for (int j= 0;	 j < K; j++,i++)
	{
		ans += *i;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
bool ac(vi &p){
  rep(i,1,p.size()){
    if(p[i-1]>p[i]) return false;
  }
  return true;
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n = in();
  vi p(n);
  rep(i,n) cin >> p[i];
  bool ok = false;
  if(ac(p))  ok = true;
  else {
    rep(i,n) rep(j,i+1,n){
      swap(p[i],p[j]);
      if(ac(p)){ ok = true; break; }
      else swap(p[i],p[j]);
    }
  }
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a_1 = [int(i) for i in input().split()]
a_2 = [int(i) for i in input().split()]

output = 0
for i in range(1,n+1):
    tmp = sum(a_1[:i]) + sum(a_2[i-1:])
    if tmp > output:
        output = tmp

print(output)

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=0;
b=a/15;
System.out.println(a*800-b*200);
}
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll N = (ll)5e5 + 2;
const ll MOD = (ll)1e9 + 7;
const ll MOD1 = (ll)998244353;
const ll inf = (ll)1e18 + 6;

template <class T>
bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T>
bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

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

ll sub(ll x, ll y)
{
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}

ll mult(ll x, ll y)
{
    return (x * y) % MOD;
}

ll bin_pow(ll x, ll p)
{
    if (p == 0)
        return 1;
    if (p & 1)
        return mult(x, bin_pow(x, p - 1));
    return bin_pow(mult(x, x), p / 2);
}

ll rev(ll x)
{
    return bin_pow(x, MOD - 2);
}

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(20);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif
    ld a, b, c, d;
    cin >> a >> b >> c >> d;
    if (ceil(c / b) <= ceil(a / d))
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3740
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, x; cin >> a >> b >> x;
	if (a == 0) {
		int ans = 0;
		ans++;
		ans += b / x;
		cout << ans << endl;
	}
	else {
		cout << b / x - (a - 1) / x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# B - Greedy Takahashi
A,B,K = map(int, input().split())

if (K-A)>=0:
    ans1 = 0
    ans2 = B-(K-A)
else:
    ans1 = A-K
    ans2 = B

if ans2 < 0:
    ans2 = 0
else:
    pass

print(ans1,ans2)

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        ll N; cin >> N;
        vector<ll> A(N); cin >> A;
        ll ans = 0;
        while(true) {
            auto a = max_element(all(A));
            if(*a < N) break;
            ll d = max<ll>(*a - (N - 1), 0LL);
            ll x = (d / N) + (d % N != 0);   
            ans += x;
            *a -= N * x + x;
            rep(i, N) A[i] += x;
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
  std::string s;
  std::cin>>s;
  int a;
  a=(s=="SUN"?7:s=="SAT"?1:s=="FRI"?2:s=="THU"?3:s=="WED"?4:s=="TUE"?5:6);
  std::cout<<a<<"\n";
}
  

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s,t;
  cin >> s;
  map<char,int> m;

  rep(i,sz(s))
  {
    m[s[i]]++;
  }

  bool b = true;

  for(auto itr = m.begin(); itr != m.end(); itr++)
  {
    if(itr->second % 2 != 0)
    {
      b = false;
      break;
    }
  }

  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 384
import java.util.Collections

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val Ls = readInputLine().split(" ").map { it.toInt() }.sorted()
    val LsArr = Ls.toIntArray()

    var ans = 0
    
    for (i in 0 until N) {
        for (j in i + 1 until N) {
            for (k in j + 1 until N) {
                if (LsArr[k] >= LsArr[i] + LsArr[j]) {
                    ans += k - j - 1
                    break
                }
                if (k == N - 1) {
                    ans += k - j
                }
            }
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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

using ll = long long;
using pii = pair<int, int>;

#define     endl               "\n"
#define     fast_io            ios::sync_with_stdio(false); cin.tie(0);
#define     file_io            freopen("input.txt", "r", stdin);   \
                               freopen("output.txt", "w", stdout);
#define     all(x)             begin(x), end(x)
#define     debug(x)           cerr <<"Line "<< __LINE__ <<" : "<< #x " = "<< x <<endl;
 
template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<"("<<t.first<<", "<<t.second<<")"; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }
 




int main(int argc, char** argv) {
    fast_io
   
	int a, b;
	while(cin >> a >> b && (a||b) ) {
	    cout << min(a, b) << " " << max(a, b) << endl;
	}
	
	
	

    return 0;
}























Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod=1e9+7,N=2010;
LL f[N];
int s;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main()
{
	s=read();
	f[0]=1;
	for(register int i=3;i<=s;i++)
		for(register int j=3;j<=i;j++)
			f[i]=(f[i]+f[i-j])%mod;
	printf("%lld\n",f[s]);
	return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

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

  bool hantei = 1;

  if(K < S.size()) hantei = 0;

  //cout << hantei << endl;
  if (hantei) cout << S << endl;
  else{
    string S2;
    rep(i, K) S2 += S[i];
    rep(i, 3)S2 += '.';
    cout << S2 << endl;
  }
}


Measured memory_bytes: 3632
import math
from itertools import product

N = int(input())
if N <= 356:
    print(0)
    exit()
c = 0
for keta in range(3, int(math.log(N, 10)) + 2):
    for t in product("753", repeat=keta):
        if int("".join(t)) <= N and len(set(t)) == 3:
            c += 1
print(c)

Measured memory_bytes: 44912
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(ll)>
using namespace std;
#define All(v) (v).begin(),(v).end()
int main(){
    string s;
    cin>>s;
    string now = {s[0]};
    string t = "";
    int res = 1;
    map<string,int> d;
    int i=1;
    while(i<s.size()){
        t+=s[i];
        if(t!=now){
            res++;
            now=t;
            t="";
        }
        i++;
    }
    cout<<res<<endl;
}


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

int main()
{
    ll s, c;
    cin >> s >> c;

    ll c2 = 2*s;
    if (c2 > c) {
        cout << c/2;
        return 0;
    }

    c -= c2;

    cout << s + (c / 4);
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		PriorityQueue<Double> q = new PriorityQueue<>();
		for(int i = 0; i < n; i++) {
			q.add((double)(-sc.nextInt()));
		}
		for(int i = 0; i < m; i++) {
			double a = q.poll();
			q.add(a/2);
		}
		long res = 0;
		while(!q.isEmpty()) {
			double a = -q.poll();
			res += (long)Math.floor(a);
		}
		System.out.println(res);
	}

}


Measured memory_bytes: 62380
# D - Sum of Divisors
from numba import njit


@njit
def solve(N):
    res = 0
    for a in range(1, N + 1):
        for b in range(1, N // a + 1):
            res += a * b
    return res


def main():
    N = int(input())
    print(solve(N))


if __name__ == "__main__":
    main()


Measured memory_bytes: 108948
#include<iostream>
using namespace std;
typedef long long ll;
int main(void)
{
    string s;
    ll cnt=0,ans=0;
    cin >> s;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]=='B') cnt++;
        else ans+=cnt;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(0);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[200];ll visit[300]={};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x,y,q;
string s;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	cout<<min(a,b)+min(c,d);
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


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

void call(int n){
	bool end_check_num=false;
	int i=1,x;
	while(1){//check_num
		while(1){//end_check_num
			x=i;
			if(x%3==0){
				cout<<" "<<i;
				break;//goto end_check_num
			}
			while(1){//include3
				if(x%10==3){
					cout<<" "<<i;
					end_check_num=true;
					break;//goto end_check_num
				}
				if(end_check_num) break;
				x/=10;
				if(x==0) break;//goto include3
			}
			break;
		}
		//end_check_num
		end_check_num=false;
		if(++i>n) break;
	}
	cout<<endl;
}

int main(){
	int n=0;
	cin>>n;
	call(n);
	return 0;
}

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

const int mask = (1 << 17) - 1;
const int mod = 1e9 + 7;

int f[47][mask + 7];

int append(int status, int x) {
    return ((status << x) | (1 << (x - 1))) & mask;
}

int main() {
    int n, x, y, z;
    scanf("%d%d%d%d", &n, &x, &y, &z);

    int S = 0;
    S = append(S, x);
    S = append(S, y);
    S = append(S, z);

    f[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= mask; j++)
        for (int k = 1; k <= 10; k++) {
            int new_status = append(j, k);
            if ((new_status & S) == S) continue;
            f[i][new_status] = (f[i][new_status] +f[i - 1][j]) % mod;
        }
    }
    int ans = 1;
    for (int i = 1; i <= n; i++) ans = 10LL * ans % mod;

    for (int i = 0; i <= mask; i++) ans = (ans - f[n][i]) % mod;
    printf("%d\n", (ans + mod) % mod);
    return 0;
}

Measured memory_bytes: 22272
n,a,b,c=map(int,input().split())
if a+b+c==0:
    print("No")
elif a+b+c==1:
    d=[]
    for i in range(n):
        s=input()
        if s=="AB":
            if a+b==0:
                print("No")
                exit()
            else:
                if a==0:
                    d.append("A")
                else:
                    d.append("B")
                a,b=b,a
        if s=="BC":
            if c+b==0:
                print("No")
                exit()
            else:
                if b==0:
                    d.append("B")
                else:
                    d.append("C")
                c,b=b,c
        if s=="AC":
            if a+c==0:
                print("No")
                exit()
            else:
                if a==0:
                    d.append("A")
                else:
                    d.append("C")
                a,c=c,a 
    print("Yes")
    for i in d:
        print(i)
else:
    d=[]
    s=[input()for i in range(n)]+["AB"]
    for i in range(n):
        if s[i]=="AB":
            if a+b==0:
                print("No")
                exit()
            if a+b+c==2 and a==1 and b==1 and s[i+1]!=s[i]:
                if s[i+1]=="AC":
                    d.append("A")
                    a+=1
                    b-=1
                else:
                    d.append("B")
                    b+=1
                    a-=1
            elif a<b:
                d.append("A")
                a+=1
                b-=1
            else:
                d.append("B")
                b+=1
                a-=1
        elif s[i]=="BC":
            if c+b==0:
                print("No")
                exit()
            if a+b+c==2 and c==1 and b==1 and s[i+1]!=s[i]:
                if s[i+1]=="AB":
                    d.append("B")
                    c-=1
                    b+=1
                else:
                    d.append("C")
                    c+=1
                    b-=1
            elif b<c:
                d.append("B")
                b+=1
                c-=1
            else:
                d.append("C")
                c+=1
                b-=1
        elif s[i]=="AC":
            if c+a==0:
                print("No")
                exit()
            if a+b+c==2 and c==1and a==1 and s[i+1]!=s[i]:
                if s[i+1]=="AB":
                    d.append("A")
                    a+=1
                    c-=1
                else:
                    d.append("C")
                    c+=1
                    a-=1
            elif a<c:
                d.append("A")
                a+=1
                c-=1
            else:
                d.append("C")
                c+=1
                a-=1
    print("Yes")
    for i in d:
        print(i)


Measured memory_bytes: 17048
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a, b;
	cin >> a >> b;
	dump(max(a + b, max(a - b, a * b)));
	
}


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

ull gcd(ull A, ull B) {
    if (B == 0) return A;
    else return gcd(B, A%B);
}

int main() {
    ull A, B, ans;
    cin >> A >> B;

    ans = A * B / (gcd(A, B));

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
struct unionf{
	vector <int> data;
	unionf(int size):data(size,-1){}
	bool unions(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;}
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int find(int x){
		return -data[x];
	}
};
int a[58],b[58];
int main()
{
	int n,m,out=0;
	cin>>n>>m;
	rep(i,m) cin>>a[i]>>b[i];
	rep(i,m){
		unionf uni(n+10);
		rep(j,m){
			if(i==j) continue;
			uni.unions(a[j],b[j]);
		}
		if(!uni.finds(a[i],b[i])) out++;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
A,B,K=map(int,input().split())
S=set()
for i in range(A,min([A+K,B+1])):
  S.add(i)
for i in range(max([B-K+1,A]),B+1):
  S.add(i)
T=list(S)
T.sort()
for i in T:
  print(i)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<int> vec(n, 0);
    rep(i,2*m) {
        int c;
        scanf("%d", &c);
        vec.at(c-1)++;
    }
    rep(i,n) {
        printf("%d\n", vec.at(i));
    }
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var h = o.a();
  var w = o.a();
  var a = o.r(h,1);
  var b = xArray(9e9,h,w);
  for(var i = 0; i < h; i++)for(var j = 0; j < w; j++){
    if(a[i][j] === "#"){
      b[i][j] = 0;
      continue;
    }
    if(i && b[i-1][j] < b[i][j])b[i][j] = b[i-1][j]+1;
    if(j && b[i][j-1] < b[i][j])b[i][j] = b[i][j-1]+1;
  }
  for(var i = h-1; i >= 0; i--)for(var j = w-1; j >= 0; j--){
    if(i < h-1 && b[i+1][j] < b[i][j])b[i][j] = b[i+1][j]+1;
    if(j < w-1 && b[i][j+1] < b[i][j])b[i][j] = b[i][j+1]+1;
  }
  var ans = 0;
  for(var i = 0; i < h; i++)for(var j = 0; j < w; j++){
    if(b[i][j] > ans)ans = b[i][j];
  }
  return ans;
}

Measured memory_bytes: 43252
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

list<int> Prime(int num) {
	list<int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (j*j > i) {
				break;
			}
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if (j*j > i + 2) {
				break;
			}
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

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

	list<int>P = Prime(102000);
	cin >> N >> M;
	while (N!=-1) {
		vector<int>box(M);
		int bag = 0;
		for (auto i : P) {
			if (i > N) {
				box[bag] = i;
				bag++;
			}
			if (bag == M) {
				break;
			}
		}
		vector<int>ans;
		for (int i = 0; i < M; i++) {
			for (int j = i; j < M; j++) {
				ans.push_back(box[i] + box[j]);
			}
		}
		sort(ans.begin(), ans.end());
		cout << ans[M - 1] << endl;
		cin >> N >> M;
	}
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

signed main() {
    int A,B; 
    char c;
    cin >> A >> c >> B;
    if(c=='+')  cout << A+B << endl;
    else cout << A-B << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  char c;
  int m[h+2][w+2];
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      m[i][j]=0;
    }
  }
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      cin>>c;
      if(c=='#'){
        m[i][j]=9;
        m[i-1][j-1]++;
        m[i][j-1]++;
        m[i+1][j-1]++;
        m[i-1][j]++;
        m[i+1][j]++;
        m[i-1][j+1]++;
        m[i][j+1]++;
        m[i+1][j+1]++;
      }
    }
  }
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(m[i][j]>8){
        cout<<"#";
      }else{
        cout<<m[i][j];
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		i = 0;
		while (n != 1){
			if (n%2 == 0){
				n /= 2;
			}
			else {
				n *= 3;
				n++;
			}
			i++;
		}
		printf("%d\n", i);
	}
	
	return (0);
}

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


const int MAX_N = 100'000;

int dp[MAX_N];

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }

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

    for (int i=2; i<N; i++) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[N-1] << endl;
    
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a[n];
    r(i,n)cin>>a[i];
    for(int i=0;i<n;i++){
      if(a[i]==a[i+1]-1){
        cout<<a[i];
        while(a[i]==a[i+1]-1){
          i++;
          if(i==n-1)break;
        }
        cout<<'-'<<a[i];
      }
      else{
        cout<<a[i];
      }
      if(i!=n-1)cout<<' ';
    }
    cout<<endl;
  }
}

Measured memory_bytes: 2960
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] a = new String[4];
        String s = sc.nextLine();
        int sum = 0;
        a = s.split("");
        for(int i = 0; i < a.length; i++) {
            // a[i] = sc.nextLine().split("");
            if(a[i].equals("+")){
                sum++;
            }else{
                sum--;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <limits>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define ll long long int
#define rep(i,k,n) for(int i = k; n > i; i++)
#define REP(i,n) rep(i,0,n)

int main(){
    int n;
    long double Pi4 = atan((long double)1);
    cin >> n;
    vector<pair<long double,long double>> b(n); 

    map<long double, vector<int>> c;
    rep(i,1,n + 1) {
        cin >> b[i-1].first >> b[i-1].second;

        long double theta = atan2(b[i-1].second, b[i-1].first);
        long double t[2] = {theta + Pi4 * 2, theta - Pi4 * 2};
        
        c[t[1]].push_back(-i);
        c[t[0]].push_back(i);
        c[t[1] + Pi4 * 8].push_back(-i);
        c[t[0] + Pi4 * 8].push_back(i);
        c[t[1] - Pi4 * 8].push_back(-i);
        c[t[0] - Pi4 * 8].push_back(i);

        c[t[1] + Pi4 * 16].push_back(-i);
        c[t[0] + Pi4 * 16].push_back(i);
        c[t[1] - Pi4 * 16].push_back(-i);
        c[t[0] - Pi4 * 16].push_back(i);
    }

    long double ans = 0;
    set<int> cand;
    for(auto itr : c){
        for(auto v : itr.second){
            if(v > 0)
                cand.insert(v-1);
            if(v < 0 && cand.count(-v-1)){
                cand.erase(-v-1);
            }
        }


        long double x = 0,y = 0;
        for(auto p : cand){
            x += b[p].first;
            y += b[p].second;
        }
        ans = max(ans, sqrt(x * x + y * y));
    }

printf("%.11llf\n", ans);

    return 0;
} 

Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXIST2(s,e) (find(ALL(s),(e))!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI = acos(-1.0);


typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<double, double> pdd;

#define EQ(a,b) (abs((a)-(b))<EPS)

struct node{
	int left,right;
	double cost;
	node(int left,int right,double cost):left(left),right(right),cost(cost){}
	bool operator<(const node& other)const{
		return cost>other.cost;
	}
};
const int MAX=INT_MAX/10;

double dist(pdd &a,pdd &b){
	double dx=a.first-b.first;
	double dy=a.second-b.second;
	return sqrt(dx*dx+dy*dy);
}

int main(){
	cout.precision(20);
	int n;
	while(cin>>n,n){
		vector<pdd> pp(n);
		REP(i,n){
			cin>>pp[i].first>>pp[i].second;
		}
		vector<pdd> p(pp);
		REP(i,n){
			REP(j,n-1){
				if((pp[j].second<pp[i].second&&pp[i].second<pp[j+1].second)||
					(pp[j].second>pp[i].second&&pp[i].second>pp[j+1].second)){
						double ratio=abs(pp[j].second-pp[i].second)/abs(pp[j].second-pp[j+1].second);
						double x=pp[j].first+(pp[j+1].first-pp[j].first)*ratio;
						p.push_back(make_pair(x,pp[i].second));
				}
			}
		}
		sort(ALL(p));
		p.erase( unique( ALL(p) ), p.end() );

		int sz=p.size();
		priority_queue<node> q;
		q.push(node(0,sz-1,0));
		map<pii,double> cost;
		cost[make_pair(0,sz-1)]=0;
		while(!q.empty()){
			node cnode=q.top();q.pop();
			if(cost[make_pair(cnode.left,cnode.right)]<cnode.cost){
				continue;
			}
			for(int i=-1;i<=1;i++){
				for(int j=-1;j<=1;j++){
					int nleft=cnode.left+i;
					int nright=cnode.right+j;
					if(nleft>=0&&nright<sz&&nleft<=nright&&EQ(p[nleft].second,p[nright].second)){
						double d1=dist(p[nleft],p[cnode.left]);
						double d2=dist(p[nright],p[cnode.right]);
						double newcost=cnode.cost+d1+d2;
						pii p=make_pair(nleft,nright);
						if(!EXIST(cost,p)){
							cost[p]=INT_MAX;
						}
						if(cost[p]>newcost){
							cost[p]=newcost;
							q.push(node(nleft,nright,newcost));
						}
					}
				}
			}
		}
		double ans=INT_MAX;
		REP(i,sz){
			ans=min(ans,cost[make_pair(i,i)]);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 4172
N = int(input())
X = input()
val = int(X,2)

cnt1 = X.count("1")
p_cnt = cnt1+1
m_cnt = cnt1-1
p_amari = val%(cnt1+1)
if cnt1-1 != 0:
  m_amari = val%(cnt1-1)
else:
  m_amari = 0

def f(x):
  if x==0: return 0
  return 1 + f(x%bin(x).count("1"))

for i in range(N):
  ans = 0
  if X[i] == "0":
    amari = p_amari + pow(2,N-i-1,p_cnt)
    amari %= p_cnt
    ans += 1
  else:
    if cnt1-1==0:
      print(0)
      continue
    amari = m_amari - pow(2,N-i-1,m_cnt)
    amari %= m_cnt
    ans += 1

  ans += f(amari)
  print(ans)

Measured memory_bytes: 79708
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


vector<vector<ll>> adj(101);
vector<ll> corr;
ll cnt=0;

void dfs(ll w,ll n){
    corr.push_back(w);
    while(adj[w].size()<n){
        ll num;
        cin>>num;
        if(num<0){
            ll p=corr[corr.size()-1+num];
            adj[p].push_back(w);
            adj[w].push_back(p);
        }
        else if(num==0){corr.pop_back(); return;}
        else{
            cnt++;
            adj[cnt].push_back(w);
            adj[w].push_back(cnt);
            dfs(cnt,num);
        }
    }
    //cout<<w<<" "<<n<<endl;
    corr.pop_back();
}


int main(){
    ll N;
    cin>>N;
    while(N--){
    corr.clear();
    cnt=0;
    for(int i=0;i<101;i++){
        adj[i].clear();
    }
    ll num;
    cin>>num;
    dfs(0,num+1);
    for(int i=0;i<=cnt;i++){
        cout<<i+1;
        sort(adj[i].begin(),adj[i].end());
        for(int t=0;t<adj[i].size();t++){
            cout<<" "<<adj[i][t]+1;
        }
        cout<<endl;
    }
    }
    
    
    return 0;
}



Measured memory_bytes: 3148
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//ABC 146B
char convert(int i)
{
    return (i%26) + 'A';
}

int main() {
	int n;
	string s;
	string res = "";

	cin >> n >> s;
	int l = s.length();

	for (int i=0; i<l; i++) {
		int c = s[i] - '0' + n - 17;
		char ans = convert(c);
		res += ans;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    rep(i,m){
        cin >> p[i] >> s[i];
    }
    vector<int> pen(n,0);
    vector<bool> ac(n,false);
    int ans = 0;
    int totalpen = 0;
    rep(i,m){
        if(ac[p[i]-1])continue;
        if(s[i] == "WA"){
            pen[p[i]-1]++;
        } else{
            ac[p[i]-1] = true;
            ans++;
            totalpen += pen[p[i]-1];
        }
    }
    cout << ans << " " << totalpen << endl;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int t;
    cin>>s;
    int n=s.size()-2;
    for(int i=(n/2);i>=1;i--){
        t=0;
        for(int j=0;j<i;j++){
            if(s[j]==s[i+j])t+=1;
        }
        //cout<<t<<endl;
        if(t==i){
            cout<<t*2<<endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c) 
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<string> svec;

int main(){
    ll n;
    cin>>n;
    if(n%2==0) cout<<n/2-1;
    else cout<<n/2;
}

Measured memory_bytes: 256