akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int calc_digit(int n) {
  int res = 0;
  while (n) {
    n /= 10;
    res++;
  }
  return res;
}

int main() {
  ll N;
  cin >> N;
  int ans = 1e9;
  for (long long a = 1; a * a <= N; a++) {
    if (N % a == 0) {
      ll b = N / a;
      int f = max(calc_digit(a), calc_digit(b));
      ans = min(ans, f);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
H, W, K = map(int, input().split())
a = [input() for i in range(H)]
ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        black = 0
        for k in range(H):
            for l in range(W):
                if (i >> k) & 1 == 0 and (j >> l) & 1 == 0 and a[k][l] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)


Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,L;cin>>N>>L;
  vector<string>S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  for(int i=0;i<N;i++){
    cout<<S.at(i);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, m, v, p, ans, a[100005], s[100005];
ll k, mx, num1, num2;

int main() {
	ll i;
	cin>> n>> m>> v>> p;
	for(i=1; i<=n; i++) scanf("%lld", &a[i]);
	sort(a+1, a+n+1);
	k = n - p + 1;
	for(i=k; i; i--) s[i] = s[i+1] + a[i];
	for(i=1; i<=n; i++) {
		if(i >= k) ans++;
		else {
			mx = a[i] + m;
			if(mx >= a[k]) {
				num1 = mx * (k-i) - (s[i+1]);
				num2 = m * (v - (p - 1 + i));
				if(num1 >= num2) ans++;
			}
		}
	}
	cout<< ans;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
 
		int n, x, t;
 
		n = sc.nextInt();
		x = sc.nextInt();
		t = sc.nextInt();
 
		int cook = (int) Math.ceil((double) n / (double) x);
 
		System.out.println(cook * t);
 
		sc.close();
	}
 
}

Measured memory_bytes: 35872
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int tmp;
int main(){
    cin >> N;
    ll A[N];
    ll b[100002] = {0};
    rep(i, N) cin >> A[i];
    sort(A, A + N, greater<int>());
    for(int i = 0; i < N - 1; i++){
        if(A[i] == A[i + 1]){
            b[cnt] = A[i];
            cnt++;
            i++;
        }
    }
    if(cnt >= 2)
        cout << b[0] * b[1] << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1792
while True:
    s=input()
    sep_li=s.split()
    a=int(sep_li[0])
    b=int(sep_li[2])
    op=sep_li[1]
    if b== "?":
        n+= 1
    elif op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op== "/":
        print(a//b)
    elif op== "?":
        break
 


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
const int inf=0x3f3f3f3f;

int main()
{
    ios::sync_with_stdio(false);
    ll a;cin>>a;
    ll t=a/500*1000;
    a%=500;
    cout<<t+a/5*5<<endl;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "5", "oof" ].solve == 575111451 );
	assert( [ "37564", "whydidyoudesertme" ].solve == 318008117 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto k = input.front.to!( long );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	
	const M = 10L ^^ 9 + 7;
	auto ans = ModWorld!M( 0L );
	
	foreach( i; 0L .. k + 1 )
	{
		auto c = ( i + s.length.signed - 1 ).combination!M( s.length.signed - 1 );
		auto d = ( ModWorld!M( 25 ) ^^ i ) * ( ModWorld!M( 26 ) ^^ ( k - i ) );
		ans += c * d;
	}
	return ans;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}

// 階乗
auto factorial( long M )( long x )
{
	static memo = [ ModWorld!M( 1L ) ];
	if( memo.length <= x )
	{
		auto i = memo.length.signed;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * i;
	}
	return memo[ x ];
}

// 組み合わせ数
auto combination( long M )( long n, long k )
{
	if( n < k ) return ModWorld!M( 0L );
	else        return n.factorial!M / ( k.factorial!M * ( n - k ).factorial!M );
}


Measured memory_bytes: 38364
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
void solve(ll a,ll b){
    ll ans = 2*(a-1);
    ll k = floor(sqrt(a*b));
    if (a != b && k*k == a*b){
        ans += 2*min(k-a,b-k)-1;
    }
    else if (k*(k+1) < a*b){
        ans += 2*min(k-a,b-k-1)+1;
    }
    else{
        ans += 2*min(k-a,b-k);
    }
    PRINT(ans);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    ll a,b;
    cin >> q;
    rep(i,q){
        cin >> a >> b;
        solve(a,b);
    }
}


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

using namespace std;

int main()
{
    ll n,W; cin>>n>>W;
    ll w[n],v[n];
    for(ll i=0;i<n;i++) cin>>w[i]>>v[i];
    ll dp[n+1][W+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=W;j++)
        {
            dp[i][j]=0;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=W;j++)
        {
            if(w[i-1]<=j)
            {
                dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
}

Measured memory_bytes: 79104
import java.util.Scanner;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);

        while (true) {
            final double r = scanner.nextDouble();
            if (r == 0.0) {
                break;
            }
            for (int den = 1; ; den++) {
                final double num = Math.round(Math.PI * den);
                if (Math.abs(Math.PI - num / den) < r) {
                    System.out.println((int) num + "/" + den);
                    break;
                }
            }
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

typedef pair<double, int> P;

//ダイクストラ法を用いて単一始点最短路問題を解く
const int MAX_V = 110000;
const double INF = -log(0);

struct edge {
    int to;
    double cost;
};

int V;
vector<edge> G[MAX_V];
double d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int xs, ys, xt, yt;
int N;
int x[1100], y[1100], r[1100];

double dist(int x1, int y1, int x2, int y2) {
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

signed main() {
    cin >> xs >> ys >> xt >> yt;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> x[i] >> y[i] >> r[i];
    }
    x[0] = xs;
    x[N + 1] = xt;
    y[0] = ys;
    y[N + 1] = yt;
    for (int i = 0; i <= N + 1; i++) {
        for (int j = 0; j <= N + 1; j++) {
            G[i].push_back({j, max(dist(x[i], y[i], x[j], y[j]) - r[i] - r[j], 0.0)});
        }
    }
    V = N + 2;
    dijkstra(0);
    cout << setprecision(15) << d[N + 1] << endl;
}


Measured memory_bytes: 25072
lst = gets.split(" ")
start = lst[2].to_i
omomi_lst = gets.split(" ")
#p lst
#p omomi_lst
right_w = 0
left_w = 0
for l in omomi_lst
  if l.to_i <= start
    left_w = left_w + 1
  else
    right_w = right_w + 1
  end
end
#p "l = " + left_w.to_s
#p "r = " + right_w.to_s
if left_w > right_w
  print(right_w)
  print("\n")
else 
  print(left_w)
  print("\n")
end


Measured memory_bytes: 1788
#include<cstdio>
int main() {
	int a, b, t;
	scanf("%d%d", &a, &b);
	t = b;
	while (t > 0) {
		a *= 10;
		t /= 10;
	}
	a += b;
	for (t = 1; t*t <= a; t++) {
		if (t*t == a) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
typedef vector<int> vi;
using Graph = vector<vector<int>>;

int main() {
  int a, b, k;
  cin >> a >> b >> k;

  for (int i = min(a, b); i >= i; i--) {
    if (a % i == 0 && b % i == 0) {
      k--;
      if (k == 0) {
        cout << i << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iterator>
using namespace std;

const int MAXN = 256;
const int MAXR = 1e3 + 16;

int N, M, R;
int dl[MAXN][MAXN], ds[MAXN][MAXN];
int path[MAXR];
int dp[2][MAXN];

int x, y, t;
char sl;

void floyd() {
    for (int k = 1; k <= N; k++) {
        for (int u = 1; u <= N; u++) {
            for (int v = 1; v <= N; v++) {
                if (dl[u][v] > dl[u][k] + dl[k][v]) dl[u][v] = dl[u][k] + dl[k][v];
                if (ds[u][v] > ds[u][k] + ds[k][v]) ds[u][v] = ds[u][k] + ds[k][v];
            }
        }
    }
}

int main() {
    //freopen("2200-input.txt", "r", stdin);
    //freopen("mine.txt", "w", stdout);
    while (cin >> N >> M, N || M) {
        memset(dl, 0x1f, sizeof(dl));
        memset(ds, 0x1f, sizeof(ds));
        for (int i = 1; i <= N; i++) {
            dl[i][i] = ds[i][i] = 0;
        }
        for (int i = 0; i < M; i++) {
            cin >> x >> y >> t >> sl;
            if (sl == 'L') {
                dl[x][y] = dl[y][x] = min(dl[x][y], t);
            } else {
                ds[x][y] = ds[y][x] = min(ds[x][y], t);
            }
        }
        floyd(); 
        cin >> R;
        for (int i = 1; i <= R; ++i) {
            cin >> path[i];
        }
        path[0] = path[1];
        memset(dp[0], 0x1f, sizeof(dp[0]));
        dp[0][path[0]] = 0;
        for (int i = 1; i <= R; ++i) {
            memset(dp[i & 1], 0x1f, sizeof(dp[i & 1]));
            for (int j = 1; j <= N; ++j) {
                for (int k = 1; k <= N; k++) {
                    dp[i & 1][k] = min(dp[!(i & 1)][j] + dl[path[i-1]][j] + ds[j][k] + dl[k][path[i]], 
                        dp[i & 1][k]);
                    if (j == k) dp[i & 1][k] = min(dp[i & 1][k], dp[!(i & 1)][j] + dl[path[i-1]][path[i]]);
                }
            }
            //copy(dp[i & 1] + 1, dp[i & 1] + N + 1, ostream_iterator<int>(cout, " "));
            //cout << "\n";
        }
        cout << *min_element(dp[R & 1] + 1, dp[R & 1] + N + 1) << "\n";
    }
}

Measured memory_bytes: 3592
N = int(input())
A = list(map(int, input().split()))
mod = int(1e+9 + 7)
p = mod - 2
S = []
while p != 0:
  S = [p%2] + S[:]
  p //= 2
frac = 1
for i in range(N - 1):
  frac *= i+1
  frac %= mod
T = 0
for i in range(N - 1):
  k = 1
  for j in range(len(S)):
    if S[j] == 1:
      k *= i+1
      k %= mod
    if j != len(S) - 1:
      k *= k
      k %= mod
  T += (frac * k * (A[N - 1] - A[i])) % mod
  T %= mod
print(T%mod)

Measured memory_bytes: 14480
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long n, m;
  cin >> n >> m;
  cout << (n-1) * (m-1) << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<string> W(N);
    rep(i, N) cin >> W.at(i);

    bool flg = true;
    repi(i, 1, N) {
        rep(j, i) {
            if(W.at(j) == W.at(i)) {
                flg = false;
                break;
            }
        }
        if(W.at(i).at(0) != W.at(i - 1).at(W.at(i - 1).size() - 1)) {
            flg = false;
            break;
        }
    }

    cout << (flg ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if (a < b)
System.out.println("a < b");
else if(a > b)
System.out.println("a > b");
else
System.out.println("a == b");
}
}



Measured memory_bytes: 26368
import  Data.List

main = do
    [w,h,n] <- map read . words <$> getLine
    xyas <- tuplify . map read . words <$> getContents
    print . count $ foldl' solve (0,0,w,h) xyas

sat = max 0
count (l,t,r,b) = sat (r-l) * sat (b-t)

solve (l,t,r,b) (x,_,1) = (max l x, t, r, b)
solve (l,t,r,b) (x,_,2) = (l, t, min r x, b)
solve (l,t,r,b) (_,y,3) = (l, max t y, r, b)
solve (l,t,r,b) (_,y,4) = (l, t, r, min b y)

tuplify [] = []
tuplify (x:y:a:xs) = (x,y,a):tuplify xs


Measured memory_bytes: 1020
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			String str = sc.next();
			if (str.indexOf("apple") != -1)
			{
				System.out.print(str.replaceAll("apple", "peach"));
			}
			else if (str.indexOf("peach") != -1)
			{
				System.out.print(str.replaceAll("peach", "apple"));
			}
			else
			{
				System.out.print(str);
			}
			if (sc.hasNext())
			{
				System.out.print(" ");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include<iostream>

int add(int,int);
int digit (int);

int main()
{
    int a,b;
    while(std::cin >> a >> b)
    {
        std::cout << digit(add(a,b)) << std::endl;
    }
    return 0;
}

int add(int x, int y)
{
    return (x + y);
}

int digit(int num)
{
    int count = 0;
    while(num >= 10){
        num /= 10;
        count++;
    }
    return (count + 1);
}

Measured memory_bytes: 1160
import numpy as np
import copy
from collections import defaultdict
from heapq import heappush, heappop


def djkstra(adj_mat, src):
    dist = defaultdict(lambda: np.inf)
    dist[src] = 0

    prev = defaultdict(lambda: None)

    queue = []
    heappush(queue, (dist[src], src))

    while len(queue) > 0:
        dist_u, u = heappop(queue)
        vs = np.argwhere(adj_mat[u] > 0).flatten()
        for v in vs:
            weight = adj_mat[u, v]
            alt = dist_u + weight
            if alt < dist[v]:
                dist[v] = alt
                prev[v] = u
                heappush(queue, (alt, v))
    visited_edges = np.zeros_like(adj_mat, dtype=np.int32)

    for v in range(adj_mat.shape[0]):
        u = prev[v]
        if u is not None:
            visited_edges[u, v] = 1
            visited_edges[v, u] = 1

    return visited_edges


def main():
    N, M = map(int, input().split())
    adj_mat = np.zeros((N, N), dtype=np.int32)
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        adj_mat[a, b] = c
        adj_mat[b, a] = c

    visited_edge_count = np.sum(
        np.concatenate([djkstra(adj_mat, src)[np.newaxis, :, :] for src in range(N)], axis=0), axis=0)
    out = np.sum(np.logical_and(adj_mat > 0, visited_edge_count == 0)) // 2
    print(out)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20280
N = int(input())
A = [int(n) for n in input().split()]
flg = 1
cnt = 0
while flg:
    flg = 0
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            t = A[i]
            A[i] = A[i-1]
            A[i-1] = t
            flg = 1
            cnt += 1
for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print(A[i], end=" ")
print(cnt)

Measured memory_bytes: 7732
#include<iostream>

using namespace std;

int main(){
  int A, B;
  
  cin >> A >> B;
  
  int result;
  
  result = A + B;
  result = (A-B > result ? A-B : result);
  result = (A*B > result ? A*B : result);
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int N, H, W;
	cin >> N >> H >> W;

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		if ((A >= H) && (B >= W)) cnt++;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 3484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
    string s; cin >> s;
    int n = s.length();
    vector<ll> a;
//cout << n << endl;
    int i = 0, cnt = 1;
    while(i < n - 1){
        if(s[i] == s[i+1]){
            cnt++;
        }else{
            a.pb(cnt);
            cnt = 1;
        }
        i++;
    }
    if(cnt != 1) a.pb(cnt);
    if(s[n-1] != s[n-2]) a.pb(1);

    ll ans = 0;
    int N = a.size();
    if(s[0] == '<'){
        for(int i = 0; i < N-1; i+=2){
            ll MA = max(a[i],a[i+1]);
            ll MI = min(a[i],a[i+1]);
            ans += (1+MA) * MA / 2;
            ans += MI * (MI-1) / 2;
        }
        if(N%2==1) ans += (a[N-1]+1) * a[N-1] / 2;
    }else{
        ans += a[0] * (a[0] + 1) / 2;
        for(int i = 1; i < N -1; i+=2){
            ll MA = max(a[i],a[i+1]);
            ll MI = min(a[i],a[i+1]);
            ans += (1+MA) * MA / 2;
            ans += MI * (MI-1) / 2;
        }
        if(N%2==0) ans += (a[N-1]+1) * a[N-1] / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3068
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    # S = input().rstrip()
    mS = [[] for _ in [0,]*(N+1)]
    for i in range(N):
        Ai = int(input())
        for j in range(Ai):
            x, y = map(int, input().split())
            mS[i+1].append((x,y))

    # T1, T2 = map(int,input().split())
    # A1, A2 = map(int,input().split())
    # B1, B2 = map(int,input().split())
    # vA = list(map(int, input().split()))

    res = 0
    # print(mS)
    M = 1<<N
    for m in range(M):
        vS = []
        vH = [-1]*(N+1)
        cnt = 0
        d = 0
        while m:
            if m&1:
                vS.extend(mS[d+1])
                vH[d+1] = 1
                cnt += 1
            d += 1
            m >>= 1
        
        ok_in_xy = True
        while vS:
            x,y = vS.pop()
            if vH[x] == -1:
                vH[x] = y
                if y:
                    vS.extend(mS[x])
            elif vH[x] != y:
                ok_in_xy = False
                break

        if ok_in_xy:
            res = max(res, cnt)

    print(res)


main()


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

int main() {
    int n, dp[1005][1005], ans = 0;
    string s[1005];
    while(cin >> n, n){
        REP(i,n){
            cin >> s[i];
        }
        REP(i,n+1) fill(dp[i], dp[i]+n+1, 0);
        ans = 0;
        REP(i,n){
            REP(j,n){
                if(s[i][j] == '*') continue;
                dp[i+1][j+1] = min({dp[i][j] ,dp[i][j+1], dp[i+1][j]}) + 1;
                ans = max(ans, dp[i+1][j+1]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 8008
N = int(input())
shougen = [[] for _ in range(N)]
for k in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        x -= 1
        shougen[k].append((x, y))
ans = 0
bit = 2**N-1
while bit:
    person = [-1 for _ in range(N)]
    b = bit
    count = 0
    while count < N:
        person[count] = b & 1
        b >>= 1
        count += 1
    flag = True
    for k in range(N):
        if person[k] == 1:
            for x, y in shougen[k]:
                if person[x] != y:
                    flag = False
                    break
            else:
                continue
            break
    if flag:
        ans = max(ans, sum(person))
    bit -= 1
print(ans)



Measured memory_bytes: 9116
#include <iostream>
using namespace std;
int main(){
	int n,m,l;
	int a[100][100],b[100][100];
	long long int c[100][100];
	cin >>n >> m>> l;

	for(int i=0; i<n ;i++){
        for(int j=0 ;j<m;j++){
            cin >>a[i][j];
        }
	}
	for(int i=0; i<m ;i++){
        for(int j=0 ;j<l;j++){
            cin >>b[i][j];
        }
    }
	//input end
	for(int i = 0; i<n ;i++){
		for(int j = 0; j<l;j++){
			c[i][j] = 0;
				for(int k = 0; k<m;k++){
					c[i][j] += a[i][k]*b[k][j];
				}
		}
	}




	 for(int i = 0; i<n ;i++){
        for(int j = 0; j<l ;j++){
            cout<<c[i][j];
            if(j!=l-1){cout <<" ";}
            else{cout <<endl;}
        }
    }
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int visit[100005];
int diff[100005];
int n,m;
int32_t main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>visit[i];
	}
	sort(visit+1,visit+m+1);
	for(int i=1;i<m;i++){
		diff[i]=visit[i+1]-visit[i];
	}
	sort(diff+1,diff+m);
	int ans = 0;
	for(int i=1;i<=m-n;i++){
		ans += diff[i];
	}
	cout<<ans;
}


Measured memory_bytes: 1792
from decimal import Decimal
from decimal import *
a, b, c = map(str, input().split())

getcontext().prec = 500

a = Decimal(a)
b = Decimal(b)
c = Decimal(c)

if a**Decimal("0.5")  + b**Decimal("0.5") < c**Decimal("0.5"):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 60140
S = input()
ans = 'WA'
if S[0] == 'A':
    if S[2 : -1].count('C') == 1:
        if S[0].replace('A', 'a') + S[1] + S[2 : -1].replace('C', 'c') + S[-1] == S.lower():
            ans = 'AC'
print(ans)

Measured memory_bytes: 3060
def main():
    moji=input()
    cycle=int(input())
    flont_or_back=0
    flont=""
    back=""
    for i in range(cycle):
        line=input()
        if line[0]=="1":
            flont_or_back+=1
        else:
            fi=line[2]
            ci=line[4]
            if flont_or_back%2==0:
                if fi=="1":
                    flont=ci+flont
                else:
                    back+=ci
            else:
                if fi=="1":
                    back+=ci
                else:
                    flont=ci+flont
    moji=flont+moji+back
    if flont_or_back%2==0:
        print(moji)
    else:
        print(moji[::-1])
    

if __name__ == '__main__':
    main() 
  

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

int main(){
    int n;
    long int x;
    cin>>n>>x;
    long int a[n];
    long int n_t = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        if(a[i]>x){
            n_t += a[i]-x;
            a[i] = x;
        }
        if(a[i]+a[i+1]>x){
            n_t += a[i]+a[i+1]-x;
            a[i+1] -= a[i]+a[i+1]-x;
        }
        //これだけだと、箱の中身が負になりうる
    }
    cout<<n_t<<endl;
    return 0;
}

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

int main() {
    std::string s, p;
    std::cin >> s >> p;

    std::string t = s + s;
    for (int i = 0; i < s.size(); ++i) {
        if (t.substr(i, p.size()) == p) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;
}


Measured memory_bytes: 3212
/*
  ∧,,∧
( 'ω' )つ ＜またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

int main()
{
    int N, temp;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> temp;
        A[i] = temp;
    }

    int g = A[0];
    for (int i = 0; i < N; i++) {
        temp = g;
        g = __gcd(temp, A[i]);
    }

    sort(all(A));
    int alt = A[N-1] % g;
    cout << g + alt << endl;

    return 0;
}


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

signed main(){
	int N, ans = 0;
	scanf("%lld", &N);
	for(int i = 1; i <= N; i++){
		if(i % 3 != 0 && i % 5 != 0){
			ans += i;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3828
# -*- coding: utf-8 -*-
N, M = map(int, input().split(' '))
counts = [0 for _ in range(N+2)]

for _ in range(M):
    l, r = map(int, input().split(' '))
    counts[l] += 1
    counts[r+1] -= 1

ret = 0
for i in range(1, N+2):
    counts[i] += counts[i-1]
    if counts[i] == M:
        ret += 1

print(ret)







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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> D(N);
	for (int i = 0; i < N; i++)cin >> D[i];
	
	int ans = 0;
	for (int i = 0; i <= K; i++) {
		if (i > N)continue;
		for (int j = 0; j <= i; j++) {

			vector<int> n;
			for (int k = 0; k < j; k++) n.push_back(D[k]);
			for (int k = 0; k < i - j; k++)n.push_back(D[N - k - 1]);

			//cout << endl;
			//for (int k = 0; k < n.size(); k++)cout << n[k] << endl;
			//cout << " " << K - i << endl;

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

			for (int k = 0; k <= K - i && k < n.size(); k++) {
				int tmp = 0;
				for (int s = k; s < n.size(); s++)tmp += n[s];
				ans = max(tmp, ans);
			}
		}
	}
	cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 1; i <= n; ++i) cin >> a[i];
  
  int ans = 0;
  for(int i = 1; i <= n; ++i){
    if(i%2 == 1)
      if(a[i]%2 == 1) ++ans;
  }
  cout << ans << endl;
  return  0;
}
  
  


Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	char buf[256];
	int n;
	scanf("%d\n", &n);
	while (n--)
	{
		cin.getline(buf, sizeof(buf));
		string s(buf);
		bool ok = false;
		for (int i = 1; i < 100; ++i)
		{
			string a = ">'";
			for (int j = 0; j < i; ++j)
				a += "=";
			a += "#";
			for (int j = 0; j < i; ++j)
				a += "=";
			a += "~";
			if (s == a)
			{
				puts("A");
				ok = true;
				break;
			}

			string b = ">^";
			for (int j = 0; j < i; ++j)
				b += "Q=";
			b += "~~";
			if (s == b)
			{
				puts("B");
				ok = true;
				break;
			}
		}
		if (!ok)
			puts("NA");
	}

	return 0;
}

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


int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a ,b, c, d, e, X, Y ,r;
  long long  a, b, c, d, e, X, Y;
  //  double  c;
 long long  A[200003]={};
//  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][100001]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld%", &a);
  sum=factorial(a,1);
//   printf("%lld\n", sum); 
  for(i=0;i<sum;i++){
    p=p+pow(2,i);
 //     printf("%llf %lld\n", pow(2,i), p);
  }
  
  printf("%lld\n", p);
  
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int x;
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>x;
    ans+=2*min(x,k-x);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int n;
    vector<double> x, y;
    vector<int> perm;
    int i;
    double z;
    double ans = 0;
    int sum = 0;

    cin >> n;

    x.resize(n + 1);
    y.resize(n + 1);

    rep(i, 1, n + 1)
    {
        cin >> x[i] >> y[i];
        perm.push_back(i);
    }

    do
    {
        rep(i, 0, n - 1)
        {
            z = (x[perm[i]] - x[perm[i + 1]]) * (x[perm[i]] - x[perm[i + 1]]) + (y[perm[i]] - y[perm[i + 1]]) * (y[perm[i]] - y[perm[i + 1]]);
            ans += sqrt(z);
        }

        sum++;
    } while (next_permutation(perm.begin(), perm.end()));

    printf("%.10lf\n", ans / sum);
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  long n, m;
  cin >> n ;

  vector<long> l(n);

  long medge = 0;
  long sum = 0;

  bool ans = false;

  for (int i = 0; i < n; ++i){
    cin >> l[i];
    medge = max(medge,l[i]);
    sum += l[i];
  }


  sum-=medge;

  ans = (sum>medge);




  cout << ((ans)? "Yes": "No");




}




















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


int main() {
 string S, T;
  cin >> S >> T;
  int x = 0;
  for(int i=0;i<3 ;i++){
	if(S.at(i) == T.at(i)){
x++;
    }
  }
   cout << x << endl;
}
  


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int a[51],b[51],c[51],d[51],ans[51],min[51];
int abs(int x) {return x>0?x:-x;}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=m;i++) scanf("%d%d",&c[i],&d[i]);
	memset(min,0x3f,sizeof(min));
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		int s=abs(a[i]-c[j])+abs(b[i]-d[j]);
		if(s<min[i]) {min[i]=s;ans[i]=j;}
	}
	for(int i=1;i<=n;i++)
	printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n + 1)
	b := iSScan(n)
	ans := 0
	for i := 0; i < n; i++ {
		if a[i] < b[i] {
			ans += a[i]
			b[i] -= a[i]
			ans += smaller(a[i+1], b[i])
			a[i+1] -= smaller(a[i+1], b[i])
		} else {
			ans += b[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5852
import copy
import itertools
import sys
sys.setrecursionlimit(10**5)
def addp(a, i, j):
    tmp1 = searchp(a, i)
    tmp2 = searchp(a, j)
    if(tmp1 != tmp2):
        a[tmp2][0] = tmp1
        a[tmp1][1] += a[tmp2][1]

def searchp(a, i):
    if(a[i][0]==i):
        return i
    else:
        tmp = searchp(a, a[i][0])
        a[i][0] = tmp
        return tmp
n, m, k = map(int, input().split())

clist = [[1] * 2 for i in range(n)]

for i in range(n):
    clist[i][0] = i
flist = [[0] * 2 for i in range(m)]
blist = [[0] * 2 for i in range(k)]
for i in range(m):
    flist[i] = list(map(int, input().split()))
for i in range(k):
    blist[i] = list(map(int, input().split()))
for i in range(m):
    addp(clist, flist[i][0]-1, flist[i][1]-1)
for i in range(n):
    if(clist[i][0] != i):
        tmp = searchp(clist, i)
        clist[i][0] = tmp
        clist[i][1] = clist[tmp][1]
for i in range(m):
    if(searchp(clist, flist[i][0]-1) == searchp(clist, flist[i][1]-1)):
        clist[flist[i][0]-1][1] -= 1
        clist[flist[i][1]-1][1] -= 1
for i in range(k):
    if(searchp(clist, blist[i][0]-1) == searchp(clist, blist[i][1]-1)):
        clist[blist[i][0]-1][1] -= 1
        clist[blist[i][1]-1][1] -= 1
for i in range(n):
    print(clist[i][1]-1)






Measured memory_bytes: 98164
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int main() {
    int n,m; cin >> n >> m;
    vector<string> v(n);
    rep(i,n) cin >> v[i];
    vector<bool> row(n, false), col(m, false);
    rep(i, n)rep(k,m){
        if (v[i][k] == '#'){
            row[i] = true;
            col[k] = true;
        }
    }
    rep(i,n){
        if (!row[i]) continue;
        rep(k,m){
            if (!col[k]) continue;
            cout << v[i][k];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import sys
import time
st = time.perf_counter()
# ------------------------------


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

from itertools import groupby
N = int(input())
P = prime_decomposition(N)
ans = 0
for k, g in groupby(P):
    n = len(list(g))
    for i in range(1, 10000000):
        n -= i
        if n >=0:
            ans += 1
        else:
            break
print(ans)

        
        



# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9116
#include<iostream>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int N;
int cnt[1<<20];
int all=0;
bool isp[1<<20];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		cnt[A]++;
		all=gcd(all,A);
	}
	bool ok=true;
	for(int i=2;i<1<<20;i++)
	{
		int sum=0;
		for(int j=i;j<1<<20;j+=i)sum+=cnt[j];
		if(sum>1)ok=false;
	}
	cout<<(ok?"pairwise coprime":all==1?"setwise coprime":"not coprime")<<endl;
}


Measured memory_bytes: 7552
#include <stdio.h>
main()
{
     int a,b,c,x,y,z;
     scanf("%d%d%d",&a,&b,&c);  
    if(a > b){     x = a;     a = b;     b = x;  
}   
  if(b > c){  
   y = b;     b = c;     c = y;
  }   
  if(a > b){  
   z = a;     a = b;     b = z;
  }   
  printf("%d %d %d\n",a,b,c);
     return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

string s;
long long int solve(int i, long long int sum, long long int carry)
{
	if (i == s.size()) {
		return sum + carry;
	}
	int v			 = s[i] - '0';
	long long int v1 = solve(i + 1, sum, carry * 10 + v);  //	cond.
	long long int v2 = solve(i + 1, sum + carry, v);	   //	insert +
	return v1 + v2;
}
int main(int argc, const char* argv[])
{
	cin >> s;
	int v = s[0] - '0';
	cout << solve(1, 0, v);
	return 0;
}


Measured memory_bytes: 256
# abc159_a.py
# https://atcoder.jp/contests/abc159/tasks/abc159_a

# A - The Number of Even Pairs /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# N+M個のボールがあります。各ボールには整数が 1つ書かれています。
# これらのボールに書かれている数について、
#     N個のボールに書かれている数は偶数
#     M個のボールに書かれている数は奇数
# であることがわかっています。

# これらの N+M個のボールの中から 2つ選んで、書かれた数の和が偶数になる方法の数を求めてください。
# 選ぶ順序は考慮しません。
# なお、この方法の数はボールに書かれている整数の実際の値によらないことが示せます。

# 制約
#     0≤N,M≤100
#     2≤N+M
#     入力はすべて整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N M

# 出力
# 答えを出力せよ。

# 入力例 1
# 2 1

# 出力例 1
# 1

# 例えば 3つのボールに書かれている数がそれぞれ 1,2,4であるとすると、
#     1が書かれたボールと 2が書かれたボールを選ぶと、和は奇数
#     1が書かれたボールと 4が書かれたボールを選ぶと、和は奇数
#     2が書かれたボールと 4が書かれたボールを選ぶと、和は偶数
# であるので、答えは 1です。

# 入力例 2
# 4 3

# 出力例 2
# 9

# 入力例 3
# 1 1

# 出力例 3
# 0

# 入力例 4
# 13 3

# 出力例 4
# 81

# 入力例 5
# 0 3

# 出力例 5
# 3


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 0

    # 偶数二つ
    if N > 1:
        result += N*(N-1)/2
    # 奇数二つ
    if M > 1:
        result += M*(M-1)/2
    result = int(result)
    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2 1']
        lines_export = [1]
    if pattern == 2:
        lines_input = ['4 3']
        lines_export = [9]
    if pattern == 3:
        lines_input = ['1 1']
        lines_export = [0]
    if pattern == 4:
        lines_input = ['13 3']
        lines_export = [81]
    if pattern == 5:
        lines_input = ['0 3']
        lines_export = [3]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9300
s, t = list(input()), list(input())
ans = 10**10
if len(s) == len(t):
    tmp = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            tmp += 1
    ans = min(ans, tmp)
else:
    for i in range(len(s) - len(t)):
        tmp = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                tmp += 1
        ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 9136
#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(){
    int L;
    cin >> L;
    long double ans = L*L*L/27.000000;

    cout << fixed;
    cout << setprecision(10) << ans << endl;
    return 0;
}

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

int main ()
{
    int k,s,cnt=0;
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=(s-x-y);
            if(z<=k && z>=0 )
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include<set>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//ABC97-C
int main() {
	string s;
	cin >> s;
	ll K;
	cin >> K;

	ll len = s.length();
	set<string> st;

	for (ll i = 0; i < len; i++) {
		for (ll j = 1; j <= min(K, len - i); j++) {
			st.insert(s.substr(i, j));
		}
	}

	vector<string> A;
	for (auto item : st) {
		A.push_back(item);
	}

	std::sort(A.begin(), A.end());

	cout << A[K - 1];

}


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

using namespace std;

const int MOD = 998244353;

bitset <101> takeOnly[101];
bitset <101> substr(const bitset <101> &b, const int l, const int r) {
    return ((b & takeOnly[r + 1]) >> l);
}

unordered_map <bitset <101>, int> memo;
static int solve(const int N, bitset <101> str) {
    str[N] = 1;
    const auto it = memo.find(str);
    if (it != memo.end())
        return it -> second;

    // Do nothing
    int ans = 1;
    for (int i = 0; i < N; ++ i)
        if (str[i] == 1)
            ans = (2LL * ans) % MOD;

    // Split in 2 halves
    for (int r = 1; r < N; ++ r) {
        int pow2 = 1;
        const int aux = solve(N - r - 1, substr(str, r + 1, N - 1));
        for (int l = 0; l < r; ++ l) {
            for (int per = 1; per < r - l + 1; ++ per) if ((r - l + 1) % per == 0) {
                // Try splitting in groups of length per
                bitset <101> acc = substr(str, l, l + per - 1);
                for (int x = l + per; x <= r; x += per)
                    acc &= substr(str, x, x + per - 1);
                ans = (ans + (1LL * pow2 * solve(per, acc)) % MOD * aux) % MOD;
            }
            if (str[l] == 1)
                pow2 = (2LL * pow2) % MOD;
        }
    }

    memo[str] = ans;
    return ans;
}

int main()
{
    memo.max_load_factor(0.5);

    for (int i = 0; i < 101; ++ i)
        for (int j = 0; j < i; ++ j)
            takeOnly[i][j] = 1;

    string s;
    cin >> s;

    bitset <101> str;
    for (int i = 0; i < s.size(); ++ i)
        if (s[i] == '1')
            str[i] = 1;
    cout << solve(s.size(), str) << '\n';
    return 0;
}


Measured memory_bytes: 2960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B < C)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s1, s2; cin >> s1 >> s2;
	if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])cout << "YES\n"; else cout << "NO\n";
}

Measured memory_bytes: 256