akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt()-1;
        int y = sc.nextInt()-1;
        int[] ans = new int[n+1];
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                int tmp = Math.min(j-i, Math.abs(i-x)+Math.abs(j-y)+1);
                ans[tmp]++;
            }
        }
        for(int i = 1; i < n; i++){
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 22356
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long int ll;
typedef vector<long long int> vi;

int main(){
	double  a, b, c, d, e, f, x, y;
	while (cin>>a>>b>>c>>d>>e>>f){
		if (d < 0){
			d = -d;
			e = -e;
			f = -f;
		}
		if (a == 0){
			y = c / b;
			x = (f - e*y) / d;
		}
		else if (b == 0){
			x = c / a;
			y = (f - e*x) / d;
		}
		else if (a != 0 & b != 0){
			x = (b*f - c*e) / (b*d - a*e);
			y = (c*d - a*f) / (b*d - a*e);
		}
		printf("%.3lf %.3lf\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include<bits/stdc++.h>
#define rep(k,i,n) for(int i=k;i<n;++i)
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin>>S;
    rep(0,i,S.length()){
        if((S.substr(i,1)=="R"&&i%2==1)||(S.substr(i,1)=="L"&&i%2==0)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <math.h>
using namespace std;
typedef long long ll;


int main(){
int a,b;cin>>a>>b;
if(a>b)swap(a,b);
while(b--)cout<<a;

}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int d[] = new int[N];
        for(int i = 0; i < N; i++) {
            d[i] = scan.nextInt();
        }
        long answer = 0;
        for(int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                answer += d[i] * d[j];
            }
        }

        os.println(answer);

    }
}

Measured memory_bytes: 23764
const main = (input) => {
  input = input.trim().split('\n')
  const mod = BigInt(10**9 + 7)
  const arr = input[1].split(' ').map(BigInt)

  let sum = arr[0] + arr[1]
  let ans = arr[0] * arr[1] % mod

  for (let i=2; i<arr.length; i++) {
    ans += sum * arr[i] % mod
    sum += arr[i]
  }

  return console.log(Number(ans % mod))
}


process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int maks=0;
    int k=0;
    for(int i=1;i<n;i++)
    {
        if(a[i-1]>=a[i])
        {
            k++;
            if(k>maks)
            {
                maks=k;
            }
        }else
        {
            k=0;
        }
    }
    cout<<maks<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import heapq

def heap(h):
    hlst = list(map(int, input().split()))
    for i in hlst:
        heapq.heappush(h, i)
N = int(input())
d = []
heap(d)
M = int(input())
t = []
heap(t)

ans = 'YES'
for j in range(M):
    tmpT = heapq.heappop(t)
    for i in range(N):
        tmpD = heapq.heappop(d)
        if tmpT == tmpD:
            break
        if tmpT < tmpD:
            ans = 'NO'
            break
    if ans == 'NO':
        break

print(ans)

Measured memory_bytes: 33912
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define N 300005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, m;
int l[N], r[N], now;
Pair a[N];

inline bool cmp(Pair x, Pair y) {
	return (x.se - x.fi) > (y.se - y.fi);
}

struct BIT {
	int cnt[N];
	void Add(int x, int val) { for (; x < N; x += x & -x) cnt[x] += val; }
	int query(int x) { int res = 0; for (; x; x ^= x & -x) res += cnt[x]; return res; }
	void add(int l, int r) { Add(l, 1), Add(r + 1, -1); }
}bit;

int main() {
	read(n, m);
	for (int i = 1, l, r; i <= n; ++i)
		read(l, r), a[i] = make_pair(l, r);

	sort(a + 1, a + n + 1, cmp);
	for (int i = 1; i <= n; ++i)
		l[i] = a[i].fi, r[i] = a[i].se;
	now = n;

	for (int d = 1; d <= m; ++d) {
		while (now && r[now] - l[now] + 1 < d)
			bit.add(l[now], r[now]), --now;
		int ans = now;
		for (int i = 0; i <= m; i += d)
			ans += bit.query(i);
		printf("%d\n", ans);
	}
	return 0;
}


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

/*
*   author : dilip
*   time : 23-06-2019 22:11
*/

#include <iostream>
#include <fstream>

#include <iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n;
ll a[1000000];
ll dp[1000000];

class AFrog1 {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        in >> n;
        ll l = 9999999;
        memset(dp,l, sizeof(dp));
        dp[0] = 0;
        for(int i=0;i<n;i++)in >> a[i];

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

		out << dp[n-1] << endl;

	}
};


int main() {
	AFrog1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 10496
H, W = map(int, input().split())
C = [[] for i in range(10)]
A = [[] for i in range(H)]
for i in range(10):
    c = list(map(int, input().split()))
    C[i] = c

for i in range(H):
    a = list(map(int, input().split()))
    A[i] = a

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])

num = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            num += C[A[i][j]][1]

print(num)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
//const ll mod = 1000000007LL;
const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}
//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
 
//    cout << fixed << setprecision(15);


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> vec(N);
    ll wa = 0;
    rep(i,N){
        cin >> vec[i];
        wa += vec[i];
    }
    rep(i,N - 1){
        vec[i + 1] += vec[i];
    }
    ll sa = INF;
    rep(i,N){
        chmin(sa,abs(wa - vec[i] * 2));
    }
    cout << sa << endl;
}

Measured memory_bytes: 4784
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 62)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }


int main(int argc, char* argv[])
{
	for (;;) {
		ll N, M;
		cin >> N >> M;
		if (cin.fail()) break;

		ll result = 1;
		for (ll i = 1; i <= N; i++) {
			result = (result * i) % 1000000007;
		}
		for (ll i = 1; i <= M; i++) {
			result = (result * i) % 1000000007;
		}
		switch (abs(N - M)) {
		case 0:
			printf("%lld\n", (result * 2) % 1000000007);
			break;
		case 1:
			printf("%lld\n", result);
			break;
		default:
			printf("0\n");
			break;
		}
		
	}

	return 0;
}


Measured memory_bytes: 256
d, g = gets.split(" ").map(&:to_i)
info = Array.new(d){gets.split(" ").map(&:to_i)}
cnts = []
for i in 1..2 ** d
  bit = i
  cnt = score = 0
  rest = []
  info.each_with_index do |inf, j|
    # p "#{j} #{bit[j]} #{inf}"
    if bit[j] == 1
      cnt += inf[0]
      score += inf[1] + (j+1) * 100 * inf[0]
    else
      inf << j if inf.length == 2
      rest << inf
    end
  end
  rest.sort_by!{|item| item[-1]}
  rest_score = g - score
#   p rest
#   p rest_score
  k = l = 0
  while rest_score > 0
    rest_score -= (rest[-1-k][-1] + 1) * 100
    l += 1
    if l == rest[-1-k][0]
      rest_score -= rest[-1-k][1]
      k += 1 
      l = 0
    end
    cnt += 1
  end
  cnts << cnt
end

puts cnts.min


Measured memory_bytes: 1916
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,S=intput(),input()
rw=S.count('.')
lb=0
ans=rw
for i in range(N):
    if S[i]=='.':
        rw-=1
    else:
        lb+=1
    ans=min(ans,rw+lb)
print(ans)

Measured memory_bytes: 68240
s = input()
i = (len(s) - 1) // 2
j = len(s) // 2
k = s[i]
while i >= 0:
  if s[i] != k or s[j] != k:
    break
  i -= 1
  j += 1
if i <  0:
  print(len(s))
else:
  print(j)

Measured memory_bytes: 3316
import queue
n = int(input())

g = {}
for i in range(n):
    x = list(map(int, input().split()))
    g[x[0]] = [x[2:], 'w', x[0], None]

q = queue.Queue()
node = g[1]
node[-1] = 0
node[1] = 'g'
q.put(node)

while not q.empty():
    node  = q.get()
    d = node[-1] + 1
    for i in node[0]:
        ch = g[i]
        if ch[1] == 'w':
            ch[-1] = d
            ch[1] = 'g'
            q.put(ch)

for i in range(n):
    node = g[i+1]
    if node[-1] == None:
        d = -1
    else:
        d = node[-1]
    print("{} {}".format(i+1, d))

Measured memory_bytes: 8688
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll f(ll n) {
	if (n == 1) {
		return 1;
	}
	return 2 * f(n / 2) + 1;
}

int main() {
	ll n;
	cin >> n;
	cout << f(n);

	return 0;
}


Measured memory_bytes: 3156
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>

int main() {
  int h1, m1, h2, m2, k;
  scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

  m1 += 60 * h1;
  m2 += 60 * h2;
  printf("%d\n", m2-m1-k);
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

int main(){
    string s, t;
    cin >> s >> t;
    string ans="{";
    for(int i=0; i+t.size()-1<s.size(); i++){
        string ss=s;
        bool ok=true;
        for(int j=0; j<t.size(); j++){
            if(ss[i+j] != '?' && ss[i+j] != t[j]){
                ok=false;
                break;
            }
            ss[i+j]=t[j];
        }
        if(!ok) continue;
        for(int j=0; j<s.size(); j++){
            if(ss[j] == '?') ss[j]='a';
        }
        ans=min(ans, ss);
    }
    if(ans == "{") cout << "UNRESTORABLE" << endl;
    else cout << ans << endl;
    return 0;
}

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

template <typename T>
vector<T> dijkstra(Int s,vector<vector<pair<Int, T> > > & G,T INF){
  using P = pair<T, Int>;
  Int n=G.size();
  vector<T> d(n,INF);
  vector<Int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      Int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
	d[u]=d[v]+c;
	b[u]=v;
	q.emplace(d[u],u);
      }
    }
  }
  return d;
}
//INSERT ABOVE HERE
signed main(){
  Int n,m,s,t;
  cin>>n>>m>>s>>t;
  s--;t--;
  
  using P = pair<Int, Int>;
  vector<vector<P> > G(n),H(n);
  for(Int i=0;i<m;i++){
    Int x,y,a,b;
    cin>>x>>y>>a>>b;
    x--;y--;
    G[x].emplace_back(y,a);
    G[y].emplace_back(x,a);
    H[x].emplace_back(y,b);
    H[y].emplace_back(x,b);
  }
  
  const Int INF = 1e17;
  auto A=dijkstra(s,G,INF);
  auto B=dijkstra(t,H,INF);

  vector<Int> ans(n+1,INF);
  for(Int i=n-1;i>=0;i--)
    ans[i]=min(ans[i+1],A[i]+B[i]);

  Int tmp=1e15;
  for(Int i=0;i<n;i++) cout<<tmp-ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 19576
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n,kingaku;
  cin >> n >> kingaku;
  int x,y,z;

  for(y=0;y<=n;y++){
    for(z=n;z>=0;z--){
      x = n - (y+z);
      if(x < 0 ){
        continue;
      }
      //cout << x << "\t" << y << "\t" << z << "\n";

      if((x*10000) + (y*5000) + (z*1000) == kingaku){
          cout << x << " " << y << " " << z << "\n";
          return 0;
      }
    }
  }
  cout << "-1 -1 -1" << "\n";
  return 0;
}


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

using namespace std;

int a[300000], c[300000];
pair<int, int> b[300000][2];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < 1 << n; i++)
		scanf("%d", a + i);
	b[0][0] = make_pair(a[0], 0);
	for (int k = 1; k < 1 << n; k++) {
		vector<pair<int, int>> x;
		x.push_back(make_pair(a[k], k));
		for (int i = 0; i < n; i++)
			if (k & 1 << i)
				x.push_back(b[k ^ 1 << i][0]), x.push_back(b[k ^ 1 << i][1]);
		sort(x.begin(), x.end(), greater<pair<int, int>>());
		unique(x.begin(), x.end());
		b[k][0] = x[0];
		b[k][1] = x[1];
		c[k] = max(c[k - 1], x[0].first + x[1].first);
		cout << c[k] << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 10112
/*        omaera kann ning sunn na gomi www (^p^)9m       */











#include<stdio.h>
int main(){int b1,b2,b3;scanf("%d%d%d",&b1,&b2,&b3);if(b1==1&&b2==1||b3==1){printf("Open\n");}else{printf("Close\n");}return 0;}

Measured memory_bytes: 1016
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void MakeNextData(vector<int>&);

int main(){
  int i, n;
  vector<int> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    cout << n << endl;
    data.push_back(n);

    while(data[0] != 1){
      MakeNextData(data);

      for(i=0; i<data.size()-1; ++i)
	cout << data[i] << " ";
      cout << data[data.size()-1] << endl;
    }

    data.clear();
  }

  return 0;
}

void MakeNextData(vector<int>& x){
  int i, n, count;

  for(i=x.size()-1, count=0; i>=0; --i, ++count){
    if(x[i] == 1) x.pop_back();
    else break;
  }
  x.erase(x.begin()+i+1, x.end());

  --x[x.size()-1];
  n = x[x.size()-1];
  ++count;

  while(count/n != 0){
    x.push_back(n);
    count -= n;
  }
  if(count != 0) x.push_back(count);
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    for (int i=a; i<=b; ++i) {
        if (i%k==0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long int find(long long int x)
{
	if(x==1)return 1;
	return find(x/2)*2+1;
}
int main()
{
	long long int ans;
	long long int n;
	cin>>n;
	ans=find(n);
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int d, g;
  cin >> d >> g;
  vi p(d), c(d);
  rep(i,d) cin >> p[i] >> c[i];

  int ans = INF;
  rep(b,1<<d) {
    int score = 0;
    int num = 0;
    //rep(i,d) {
    for (int i = d-1; i >= 0; --i) {
      if (b&(1<<i)) {
        score += 100*(i+1)*p[i]+c[i];
        //debug(b);
        //debug(score);
        num += p[i];
        if (score >= g) {
          ans = min(ans,num);
          break;
        }
      }
    }

    for (int i = d-1; i >= 0; --i) {
      rep(_,p[i]-1) {
        if (!(b&(1<<i))) {
          score += 100*(i+1);
          //debug(b);
          //debug(score);
          num++;
          if (score >= g) {
            ans = min(ans,num);
            break;
          }
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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>;
int main() {
  ll a;
  ll flag = 0;
  ll s = 0;
  ll add = 0;
  cin >> a;
  vector<int> vec(a);
  rep(i,a){
    cin >> vec[i];
  }
  flag = vec[0];
  rep(i,a){
    if(vec[i] < flag){
      s = flag - vec[i];
      add = add + s;
      
      
    }
    else{
      flag = vec[i];
    }
    
  }
  cout << add << endl;
  
    
 
 
 
  return 0;
}

Measured memory_bytes: 4036
#include<iostream>
using namespace std;
int main(){
int x,a,b,c,ans=0;
cin >> a >> b >> c >> x;
for(int i=0;i<=a;i++)
for(int j=0;j<=b;j++)
for(int q=0;q<=c;q++)
if(i*500+j*100+q*50==x)
ans++;
cout << ans;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n = 0, i, o, t, j, l, s, z, ans = 0;
	cin >> i >> o >> t >> j >> l >> s >> z;
	ans += o;
	if (i != 0 && j != 0 && l != 0) {
		if (i % 2 == 0) { ans += i - 2; i = 2; n++; }
		else { ans += i - 1; i = 1; }
		if (j % 2 == 0) { ans += j - 2; j = 2; n++; }
		else { ans += j - 1; j = 1; }
		if (l % 2 == 0) { ans += l - 2; l = 2; n++; }
		else { ans += l - 1; l = 1; }
		if (n == 3) { ans += 6; }
		else if (n == 2) { ans += 4; }
		else { ans += 3; }
	}
	else {
		ans += i / 2 * 2; ans += j / 2 * 2; ans += l / 2 * 2;
	}
	cout << ans << endl; return 0;
}

Measured memory_bytes: 256
function Main(input){
	input = input.split("\n");
	var sum = 0;
	for(var i=1;i<input.length;i++){
		var mem = input[i].split(" ");
		sum += mem[1]-mem[0]+1;
	}
	console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7484
#include<stdio.h>
#include<stdlib.h>

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

typedef struct node * Node;

#define NIL NULL

Node root = NIL;
Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node , int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

int count1 = 1,count2 = 1,ak;

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

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

  return 0;
}

Node treeMinimum(Node x){

  while(x->left != NIL) x = x->left;
  return x;
}

Node treeMaximum(Node x){

  while(x->left != NIL ) x = x->right;
  return x;
}

Node treeSearch(Node x , int k){

  while( x!= NIL && k != x->key){
    if(k < x->key) x = x->left;
    else x = x->right;
  }
  return x;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}


void treeDelete(Node z){
  Node y;
  Node x;

  if(y->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key =y->key;

}

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

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

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

    if(x == NIL) {
      y->right = z;
return;
}
  }
}
}

void inorder(Node u){

  if(u != NIL){

    inorder(u->left);

    printf(" %d",u->key);

    inorder(u->right);
  }

}

void preorder(Node u){

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



Measured memory_bytes: 20496
class Node
  attr_accessor :p, :num, :left, :right
  def initialize(p, num)
    @p = p
    @num = num
    @left = nil
    @right = nil
  end
end

def addnode(tree, p, num, depth)
  if tree == nil then
    tree = Node.new(p, num)
    return tree
  end
  k = p.size
  axis = depth % k

  if tree.p[axis] > p[axis]
    tree.left = addnode(tree.left, p, num, depth+1)
  else
    tree.right = addnode(tree.right, p, num, depth+1)
  end
  return tree
end

# def kdtree(arr, depth)
#   return nil if arr.size == 0
#   k = arr[0].size - 1
#   axis = depth % k

#   sorted = arr.sort_by{|x| x[axis]}
#   median = sorted.size / 2
#   min = sorted[0][axis]
#   max = sorted[-1][axis]
#   node = Node.new(sorted[median][0,k], sorted[median][k], max, min)
#   node.left = kdtree(sorted[0,median], depth+1)
#   node.right = kdtree(sorted[median+1..-1], depth+1)
#   return node
# end

def range_search(tree, r, depth)
  return [] unless tree
  it = depth % 2
  ans = []
  ans << tree.num if r[0] <= tree.p[0] && tree.p[0] <= r[1] && r[2] <= tree.p[1] && tree.p[1] <= r[3]
  ans += range_search(tree.left, r, depth+1) if tree.left && r[2*it] <= tree.p[it]
  ans += range_search(tree.right, r, depth+1) if tree.right && tree.p[it] <= r[2*it+1]
  return ans
end

arr = []
n = gets.to_i

tree = nil
n.times{|i|
  arr[i] = gets.split.map(&:to_i)
  arr[i] << i
}
arr.shuffle.each{|i|
  tree = addnode(tree, i[0,2], i[2], 0)
}
# tree = kdtree(arr, 0)

q = gets.to_i

q.times{
  range_search(tree, gets.split.map(&:to_i),  0).sort.each{|i|
    puts i
  }
  puts
}

Measured memory_bytes: 157296
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
using namespace std;
string s;
int main(){
		//freopen("main.in","r",stdin);
		cin >> s;
		int len;
		if(s[0] == s[s.length()-1]) {
				len = s.length() - 3;
		}
		else{
				len = s.length() - 2;
		}
		if(len % 2){
			   	cout << "First" << endl;

		}else {
				cout << "Second" << endl;
		}
		return 0;
}

Measured memory_bytes: 512
S=list(str(input()))
lst=['A','T','G','C']
N=len(S)
s=0
ans=0
def dp(s,ans):
  if s==N-1:
    return ans
  tmp=0
  if S[s] in lst:
    while s<=N-1 and S[s] in lst:
      s+=1
      tmp+=1
    ans=max(ans,tmp)
    if s==N:
      return ans
    else:
      return dp(s,ans)
  else:
    return dp(s+1,ans)
if N>=2: 
  print(dp(s,ans))
else:
  if S[0] in lst:
    print(1)
  else:
    print(0)

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  set<ll> si;
  rep(i, n) {
    int cnt = 0;
    ll tmp = a[i];
    while (tmp % 2 == 0) {
      tmp /= 2;
      cnt++;
    }
    si.insert(cnt);
  }

  if (si.size() != 1) {
    cout << 0 << endl;
    return 0;
  }

  ll lcm = 1;
  rep(i, n) {
    ll g = __gcd(lcm, a[i] / 2);
    lcm = lcm * a[i] / 2 / g;
    if (lcm > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << (m / lcm + 1) / 2 << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] num = new int[n];
			for (int i = 0; i < n; i++) {
				num[i] = scanner.nextInt();
			}
			int count = 0;
			boolean flag = true;
			while (flag) {
				flag = false;
				for (int i = 0; i < n - 1; i++) {
					if (num[i] > num[i + 1]) {
						count++;
						flag = true;
						int tmp = num[i];
						num[i] = num[i + 1];
						num[i + 1] = tmp;
					}
				}

			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 21056
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s; cin >> s;
	int q; cin >> q;
	int f = 0;
	deque<char> a;
	deque<char> b;
	while (q--) {
		int z; cin >> z;
		if (z == 1) {
			f = 1 - f;
		}
		else {
			int x; char y; cin >> x >> y;
			if (f == 0) {
				if (x == 1) {
					a.push_front(y);
				}
				else {
					b.push_back(y);
				}
			}
			else {
				if (x == 1) {
					b.push_back(y);
				}
				else {	
					a.push_front(y);
				}
			}
		}
	}

	if (f == 0) {
		while (!a.empty()) {
			cout << a.front(); a.pop_front();
		}
		cout << s;
		while (!b.empty()) {
			cout << b.front(); b.pop_front();
		}
	}
	else {
		while (!b.empty()) {
			cout << b.back(); b.pop_back();
		}
		for (int i = s.size() - 1; i >= 0; i--) {
			cout << s[i];
		}
		while (!a.empty()) {
			cout << a.back(); a.pop_back();
		}
	}


}




Measured memory_bytes: 848
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int,int> pii;

int main(){
  string a,b;
  cin >> a >> b;
  
  int l = min(a.size(), b.size());
  for(int len=l;len>=1;len--){
    set< vector<int> > ana;

    vector<int> cnt(26,0);
    rep(i,len) cnt[a[i]-'a']++;
    ana.insert(cnt);

    for(int i=len;i<(int)a.size();i++){
      cnt[a[i]-'a']++;
      cnt[a[i-len]-'a']--;
      ana.insert(cnt);  
    }

    cnt = vector<int>(26,0);
    rep(i,len) cnt[b[i]-'a']++;
    if(ana.count(cnt)){
      cout << len << endl;
      return 0;
    }

    for(int i=len;i<(int)b.size();i++){
      cnt[b[i]-'a']++;
      cnt[b[i-len]-'a']--;
      if(ana.count(cnt)){
	cout << len << endl;
	return 0;
      }
    }
  }
  
  cout << 0 << endl;
}

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

int main()
{
    int64_t X, Y;
    cin >> X >> Y;
    int64_t ans = 0;
    while (X <= Y)
    {
        X *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<cstring> 
//#define int long long
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double ans = 0;
 	int n;
    cin >> n;
	double a;
	rep(i,n){
		cin >> a;
		ans += double(1.00 / a);
	}
	cout << fixed << double(1.00 / ans) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

void solve(){
  while(true){
    int n;
    cin >> n;
    if(n == 0) return;
    int sum = 0;
    int Ma = -1, mi = INF;
    rep(i, n){
      int a;
      cin >> a;
      sum += a;
      Ma = max(Ma, a);
      mi = min(mi, a);
    }
    sum -= Ma + mi;
    cout << sum / (n-2) << endl;
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}



Measured memory_bytes: 3056
from operator import add
color = {"black":"000000","blue":"0000ff",
         "lime":"00ff00","aqua":"00ffff",
         "red":"ff0000","fuchsia":"ff00ff",
         "yellow":"ffff00","white":"ffffff"}

def parse(s):
    return map(lambda x:int(x,16), map(add,s[::2],s[1::2]))

def d(s1, s2,k):
    return sum(map(lambda a,b:(a-b)**2, *map(parse,(s1,s2))))

while True:
    s = raw_input()
    if s == "0":
        break
    print min(color.items(), key = lambda (k,v):d(s[1:],v,k))[0]

Measured memory_bytes: 4368
#include<stdio.h>


int main(void)
{
  int x;
  int h, m, s;
  scanf("%d", &x);
  h = x / 3600;
  m = x % 3600 / 60;
  s = x % 60;
  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 1836
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Integer D = sc.nextInt();
		Integer N = sc.nextInt();

		List<Integer> ansList = new ArrayList<>();
		if (D == 0) {
			for(int i=1; i<=99; i++) {
				ansList.add(i);
			}
			ansList.add(101);
		} else if (D == 1) {
			for(int i=1; i<=99; i++) {
				ansList.add(i * 100);
			}
			ansList.add(10100);
		} else {
			for(int i=1; i<=99; i++) {
				ansList.add(i * 10000);
			}
			ansList.add(1010000);
		}

		System.out.println(ansList.get(N-1));


	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    string s ;
    cin >> s ;
    ll n = s.len ;
    ll m = n-1 ;
    vector<string > ans ;
    forn(i , 0 , (1<<m) -1 ){
       char arr[m] ;
       for(ll j = 0 ; j <= m-1; ++j){
          if(i & (1 << j)){
            arr[j] = '+';
          }
          else {
            arr[j] = '.' ;
          }
       }
       string res = "" ;
       ll p1 = 0 , p2 = 0 ;
       ll cnt = 0 ;
       while(1) {
          if(cnt & 1){
             res = res + arr[p2];
             ++p2 ;
             ++cnt ;
          }
          else{
            res = res + s[p1] ;
            ++p1 ;
            ++cnt ;
          }
          if(p1 == n) br ;
       }
       string news = "" ;
       forn(i , 0 , res.len - 1 ){
          if(res[i] == '.') con ;
          else {
            news = news + res[i] ;
          }
       }
       ans.pb(news) ;
    }
    ll ziz = 0 ;
    for(auto &x : ans){
       /// cout << " x  is " <<x << el ;
        string res = "";
        forn(i , 0 , x.len - 1) {
            if(x[i] != '+') res = res + x[i] ;
            else if(x[i] == '+'){
                ///cout << "here res is " << res << el;
                stringstream geek(res);
                ll xx = 0 ;
                geek >> xx ;
                ziz = ziz + xx;
                res = "" ;
            }
        }
        if(res.sz != 0 ) {
            stringstream geek(res);
            ll xx = 0 ;
            geek>> xx;
            ziz = ziz +xx ;
           /// cout << "here xx is " << xx << el ;
        }
    }
    cout << ziz << el ;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll p[10000];
ll j;
ll ans;
bool is_prime(ll n){
      for(ll i=2;i*i<=n;i++){
    if(n%i==0) return false;
      }
      if(n==1) return false;
      return true;
  }
map<ll,ll> prime_factor(ll n){
      map<ll,ll> res;
      for(ll i=2;i*i<=n;i++){
          bool w=true;
    while(n%i==0){
        res[i]++;
        n=n/i;
        if(w){
            w=false;
            p[j]=i;
            j++;
        }
    }
      }
      if(n!=1){
          ans++;
      } 
      return res;
  }
int main(void){
    ll n;
    cin>>n;
    if(is_prime(n)){
        cout<<1<<endl;
        return 0;
    }
    map<ll,ll> m;
    m=prime_factor(n);
    for(int i=0;i<j;i++){
        if(m[p[i]]>0){
            ll k=1;
            while(m[p[i]]>0){
                m[p[i]]-=k;
                ans++;
                if(m[p[i]]<0){
                    ans--;
                }else{

                }
                k++;
            }
        }
    }
    cout<<ans<<endl;

}



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

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    ll a, b;
    cin >> a >> b;
    if(a == 1 || b == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll c = a * b + 1;
    cout << c / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
		int a = sc.nextInt();
		int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (a < c && b < c) {
            System.out.println("No");
        } else if  (a > c && b > c) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }



	}
}

Measured memory_bytes: 21716
n = int(input())
s = [input() for _ in range(n)]

l = []

for x in s:
  l.append(tuple(sorted(x)))

import collections
ans = 0
for _, c in collections.Counter(l).most_common():
  if c >= 1:
    ans += c * (c - 1) // 2

print(ans)


Measured memory_bytes: 38192
#include <stdio.h>
#include <stdlib.h>
#define MAXNUM 10000

int main(){
  int i,j,num;
  int array[MAXNUM+1];
  unsigned short *in,*out;
  scanf("%d",&num);
  in=malloc(sizeof(short)*num+1);
  out=malloc(sizeof(short)*num+1);

  for(i=0;i<=MAXNUM;i++) array[i]=0;
  
  for(i=0;i<num;i++) scanf("%hu",&in[i+1]);
  for(j=1;j<=num;j++) array[in[j]]++;
  for(i=1;i<=MAXNUM;i++) array[i]=array[i]+array[i-1];
  
  /*downto*/
  for(j=num;j>=1;j--){
    out[array[in[j]]]=in[j];
    array[in[j]]--;
  }
  for(i=0;i<num;i++){
    if(i>0)printf (" ");
    printf("%d",out[i+1]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9576
N=int(input())
lis=[tuple(map(int,input().split())) for _ in range(N)]
import itertools,math
p = itertools.permutations(list(range(N)))
sm=0

for v in p:
    #print(v)
    for k in range(N-1):
        xi,yi=lis[v[k]]
        xj,yj=lis[v[k+1]]
        #print(xi,yi,xj,yj)
        sm+=((xi-xj)**2+(yi-yj)**2)**(1/2)
print(sm/math.factorial(N))

Measured memory_bytes: 9388
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int N;
        int i = 0;
        Scanner s = new Scanner(System.in);
        N = s.nextInt();
        while (++i * i <= N)
            ;
        i--;
        System.out.println(i * i);
    }
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	
	if (n >= 400 && n < 600){
		cout << 8 << endl;
	}
	else if(n >= 600 && n < 800){
		cout << 7 << endl;
	}
	else if(n>= 800 && n < 1000){
		cout << 6 << endl;
	}
	else if(n >= 1000 && n < 1200){
		cout << 5 << endl;
	}
	else if(n >= 1200 && n < 1400){
		cout << 4 << endl;
	}
	else if(n >= 1400 && n < 1600){
		cout << 3 << endl;
	}
	else if(n >= 1600 && n < 1800){
		cout << 2 << endl;
	}
	else if(n >= 1800 && n < 2000){
		cout << 1 << endl;
	}
	
	return 0;	
}

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

using namespace std;

int main()
{
    int n;
    static bool p[20001];
    
    for (int i = 0; i <= 100; i++){
        for (int j = 1; i * i + j * j <= 20000; j++){
            if (i * i + j * j != 1 && !p[i * i + j * j]){
                for (int k = 2 * (i * i + j * j); k <= 20000; k += i * i + j * j){
                    p[k] = true;
                }
            }
        }
    }
    
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        
        printf("%c\n", "PC"[p[x * x + y * y]]);
    }
    
    return (0);
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int h,w;
  while(cin>>h>>w,h,w){
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(i==0 || i==h-1 || j==0 || j==w-1){
	  cout<<'#';
	}
	else{
	  cout<<'.';
	}
	if(j==w-1){
	  cout<<'\n';
	}
      }
    }
    cout<<'\n';
  }
  return(0);
}



Measured memory_bytes: 3104