akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
struct Graph
{
    Graph(const std::size_t v) : V{v}, edge(v), rev_edge(v) {}
    void addEdge(const std::size_t from, const std::size_t to) { edge[from].push_back(to), rev_edge[to].push_back(from); }
    const std::size_t V;
    std::vector<std::vector<std::size_t>> edge, rev_edge;
};
class StronglyConnectedComponents
{
public:
    StronglyConnectedComponents(const Graph& g) : size(g.V), comp(size, size)
    {
        for (std::size_t i = 0; i < size; i++) {
            for (const std::size_t to : g.edge[i]) { edge.push_back({i, to}); }
        }
        std::vector<std::size_t> st;
        std::vector<bool> used(size, false);
        auto dfs1 = [&](auto&& self, const std::size_t s) -> void {
            used[s] = true;
            for (const std::size_t to : g.edge[s]) {
                if (not used[to]) { self(self, to); }
            }
            st.push_back(s);
        };
        auto dfs2 = [&](auto&& self, const std::size_t s) -> void {
            comp[s] = comp_num;
            for (const std::size_t to : g.rev_edge[s]) {
                if (comp[to] != size) { continue; }
                self(self, to);
            }
        };
        for (std::size_t i = 0; i < size; i++) {
            if (used[i]) { continue; }
            dfs1(dfs1, i);
        }
        for (std::size_t i = 0; i < st.size(); i++) {
            const std::size_t s = st[st.size() - i - 1];
            if (comp[s] != size) { continue; }
            dfs2(dfs2, s), comp_num++;
        }
    }
    const std::size_t getCompNum() const { return comp_num; }

private:
    std::size_t size, comp_num = 0;
    std::vector<std::size_t> comp;
    std::vector<std::pair<std::size_t, std::size_t>> edge;
};

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::string s;
    std::cin >> s;
    Graph g(4 * N);
    for (int i = 0; i < M; i++) {
        int a, b;
        std::cin >> a >> b, a--, b--;
        if (s[a] == 'A') { g.addEdge(4 * a + 0, 4 * b + 1), g.addEdge(4 * a + 1, 4 * b + 2); }
        if (s[a] == 'B') { g.addEdge(4 * a + 2, 4 * b + 3), g.addEdge(4 * a + 3, 4 * b + 0); }
        if (s[b] == 'A') { g.addEdge(4 * b + 0, 4 * a + 1), g.addEdge(4 * b + 1, 4 * a + 2); }
        if (s[b] == 'B') { g.addEdge(4 * b + 2, 4 * a + 3), g.addEdge(4 * b + 3, 4 * a + 0); }
    }
    StronglyConnectedComponents scc(g);
    std::cout << (scc.getCompNum() != 4 * N ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 99180
@n, @a = gets.chomp.split.map(&:to_i)
@arr = gets.chomp.split.map(&:to_i).sort
@count = 0

if @a<@arr[0]
  puts 0
  exit
end

# 方針を変えて最後まで探索することにする.
# 配列をもたせるとメモ化できないので、それまでの合計値ももたせる
# 更にそれだけじゃダメなので、今までに取った数ももたせる
@memo = Array.new(50+1).map{|x| Array.new(50+1).map{|x| Array.new(50*50+1, nil)}}
def func(i, j, s)
  if !(@memo[i][j][s].nil?)
    return @memo[i][j][s]
  end
  if i==@n
    # 平均をとる 整数で@aとなることに注意
    if (s.to_f/(j).to_f) == @a.to_f
      return 1
    else
      return 0
    end
  else
    ans = 0 # ?
    # 追加する場合としない場合
    ans += func(i+1, j+1, s+@arr[i]) + func(i+1, j, s)
    @memo[i][j][s] = ans
    return ans
  end
end

puts func(0, 0, 0)

Measured memory_bytes: 52732
s = input()

dream = "dream"
erase = "erase"

ans = True
ind = 0
while ind < len(s):
	if s[ind] == 'd':
		tmp = s[ind:ind+5]
		if tmp == dream:
			ind += 5
			if ind + 2 == len(s):
				if s[ind:ind+2] == 'er':
					break
			elif ind + 2 < len(s):
				if s[ind:ind+2] == 'er' and s[ind+2] != 'a':
					ind += 2
		else:
			ans = False
			break
	elif s[ind] == 'e':
		tmp = s[ind:ind+5]
		if tmp == erase:
			ind += 5
			if ind < len(s):
				if s[ind] == 'r':
					ind += 1
		else:
			ans = False
			break
	else:
		ans = False
		break

if ans:
	print("YES")
else:
	print("NO")


Measured memory_bytes: 3444
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class mint:
    def __init__(self, x):
        self.__x = x % md

    def __str__(self):
        return str(self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

def gcd(a, b):
    while b: a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

md = 10 ** 9 + 7
def main():
    n = II()
    aa = LI()
    l = 1
    for a in aa:
        l = lcm(l, a)
    l = mint(l)
    ans = sum(l / a for a in aa)
    print(ans)

main()


Measured memory_bytes: 4212
#include <stdio.h>

int N,pos[200200],T[200200],F[200200];

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<N;i++){
		int x; scanf ("%d",&x);
		pos[x] = i;
	}

	T[N] = F[N] = 0;
	for (int i=N-1;i>=1;i--){
		if (T[i+1] == 0){
			if (pos[i] < pos[i+1]) T[i] = F[i] = 0;
			else T[i] = 1, F[i] = i+1;
		}
		else{
			if (pos[i] < pos[i+1] && pos[i+1] < pos[F[i+1]]
				|| pos[i+1] < pos[F[i+1]] && pos[F[i+1]] < pos[i]
				|| pos[F[i+1]] < pos[i] && pos[i] < pos[i+1]) T[i] = T[i+1], F[i] = F[i+1];
			else T[i] = T[i+1] + 1, F[i] = i+1;
		}
	}

	printf ("%d\n",T[1]);

	return 0;
}


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

using namespace std;

const int N=1e5+1;

int n,x[2*N],y[2*N],a[2*N],b[2*N];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d", x+i,y+i);
		a[i]=x[i]+y[i];
		b[i]=x[i]-y[i];
	} 
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	cout<<max(a[n]-a[1],b[n]-b[1])<<endl;
	return 0;
}

Measured memory_bytes: 6892
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
    int n, h;
    cin >> n;
    cin >> h;
    
    vector<int> a = vector<int>(n, 0);
    vector<int> b = vector<int>(n, 0);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        cin >> b[i];
    }
    
    auto elm = max_element(a.begin(), a.end());
    int comp = *elm;
    
    sort(b.begin(), b.end());
    
    int rem = h;
    int ret = 0;
    for (int i = n - 1; i >= 0; --i)
    {
        int d = b[i];
        if (d > comp && rem > 0)
        {
            ret++;
            rem -= d;
        }
    }
    
    if (rem > 0)
    {
        ret += (rem / comp);
        if ((rem % comp) != 0)
        {
            ret++;
        }
    }

    
    cout << ret << endl;
    
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,X,Y;
    cin >>N>>X>>Y;
    vector<vector<ll> > G(N);
    vector<ll>ans(N-1);
    rep(i,N-1){
        G[i].pb(i+1);
        G[i+1].pb(i);
    }

    G[X-1].pb(Y-1);
    G[Y-1].pb(X-1);


    rep(k,N){
        vector<ll> dist(N,-1);
        queue<ll> que;

        dist[k] = 0;
        que.push(k);

        while(!que.empty()){
            ll v = que.front();
            que.pop();

            for(ll i : G[v]){
                if(dist[i] !=-1) continue;

                dist[i] = dist[v] + 1;
                ans[dist[i]-1]++;
                que.push(i);
            }
        }
    }

    rep(i,N-1){
        cout << ans[i]/2 << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3752
N = int(input())
a = [int(x) for x in input().split()]

sl = [0] * (N+1)
for i in range(N):
    sl[i+1] = a[i] + sl[i]

half = sl[-1]/2
diff = []
for i in range(N):
    diff.append(abs(half - sl[i]))
l = sl[diff.index(min(diff))]
r = sl[-1] - l
print(abs(l-r))

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

int main() {
  int D; cin >> D;
  if (D == 25) {cout << "Christmas" << endl;}
  if (D == 24) {cout << "Christmas Eve" << endl;}
  if (D == 23) {cout << "Christmas Eve Eve" << endl;}
  if (D == 22) {cout << "Christmas Eve Eve Eve" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N;
ll a[300][300];
ll d[300][300];
int main(){
	cin>>N;
	rep(i,N) rep(j,N){
		cin>>a[i][j];
		d[i][j] = a[i][j];
	}
	rep(i,N) rep(j,N) rep(k,N) chmin(d[j][k],d[j][i]+d[i][k]);
	rep(i,N) rep(j,N){
		if(d[i][j] != a[i][j]){
			puts("-1");
			return 0;
		}
	}
	ll res = 0;
	rep(i,N) rep(j,i){
		bool need = 1;
		rep(k,N) if(k!=i && k!=j){
			if(a[i][k]+a[k][j] == a[i][j]) need = 0;
		}
		if(need) res += a[i][j];
	}
	cout<<res<<endl;
}


Measured memory_bytes: 1664
n,m = gets.split.map(&:to_i)
a = []
m.times { a << gets.to_i }
dp = [1,1]
broken = a.shift
if broken == 1
  broken = !a.empty? ? a.shift : nil
  dp[1] = 0
end
(2..n).each do |i|
  dp[i] = dp[i-1] + dp[i-2]
  if broken == i
    dp[i] = 0
    broken = !a.empty? ? a.shift : nil
  end
end
p dp[n] % 1000000007


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

int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> candles(n);
  for (int i = 0; i < n; i++) {
    std::cin >> candles[i];
  }
  int ans = 3 * 100000000;
  for (int i = 0; i + k - 1 < n; i++) {
    int l = candles[i];
    int r = candles[i + k - 1];
    if (r <= 0) {
      ans = std::min(ans, std::abs(l));
    } else if (l >= 0) {
      ans = std::min(ans, r);
    } else {
      ans = std::min(std::min(2 * std::abs(r) + std::abs(l),
                              2 * std::abs(l) + std::abs(r)),
                     ans);
    }
  }
  std::cout << ans << std::endl;
}

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

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N, M; cin >> N >> M;
    UnionFind U(N);
    rep(i, M){
        int x, y, z; cin >> x >> y >> z;
        x--; y--;
        U.merge(x, y);
    }

    int ans = 0;
    vector<int> check(N);
    rep(i, N){
        int r = U.root(i);
        if(check[r] == 0){
            ans++;
            check[r] = 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);
	
	string s;
	cin >> s;

	int a = count(all(s), 'A');
	int b = count(all(s), 'B');

	if(a == 2 || b == 2) cout << "Yes";
	else cout << "No";

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

string S;

int m[111111];

int dp[111111];

signed main(){
    cin>>S;
    
    
    bool flag=true;
    for(int i=0;i+1<S.size();i++)if(S[i]==S[i+1])flag=false;
    
    if(flag){
        cout<<1<<endl;
        return 0;
    }
    
    rep(i,S.size()){
        if(S[i]=='a')m[i+1]=(m[i]+1)%3;
        else m[i+1]=(m[i]+2)%3;
    }

    dp[0]=1;

    queue<int>que[3];
    rep(i,S.size())que[m[i+1]].push(i+1);

    rep(i,S.size()){
        for(int j=1;j<=2;j++){
            if(que[(m[i]+j)%3].size()==0)continue;
            int k=que[(m[i]+j)%3].front();
            add(dp[k],dp[i]);
        }
        que[m[i+1]].pop();
    }

    
    int ans=0;
    for(int i=1;i<=S.size();i++){
        if(m[i]==m[S.size()])add(ans,dp[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<numeric>

using namespace std;

#define MY_BIG_INT long long

class MYCP {
public:

	
	//数値を必要な個数だけ読み取る
	static vector<long long> ReadInts(long long number) {
		vector<long long> a(number);
		for (int i = 0; i < number; i++) {
			std::cin >> a[i];
		}

		return a;
	}


	//最初に呼び出す
	static void SetUp() {
		cin.tie(0);
		ios::sync_with_stdio(false);
	}
};




int main(void) {
	MYCP::SetUp();

	string s;
	MY_BIG_INT a, c, i, j, k, b;
	char x, y, z;

	cin >> s;

	if (s[0] == s[1]) {
		cout << "1 2" << endl;
		return 0;
	}

	for (i = 0; i < s.size() - 2; i++) {
		x = s[i];
		y = s[i + 1];
		z = s[i + 2];

		if (x == y || x == z || y == z) {
			a = i + 1;
			b = i + 3;

			cout << a << " " << b << endl;
			return 0;
		}
	}

	cout << "-1 -1" << endl;

}

Measured memory_bytes: 512
"""
def bs(num_array, max_element, min_element):
    from collections import deque
    if(num_array == max_element - min_element + 1):
        que = deque(deque([i for i in range(min_element, max_element+1, 1)]))
        return que
    else:        
        # If min_element is not used
        que = deque([deque([])])
        que.extend(bs(num_array, max_element, min_element + 1))
        # IF min_element is used
        subset_yes = bs(num_array-1, max_element, min_element + 1)
        for e in subset_yes:
            e.appendleft(min_element)
        
        que.extendleft(subset_yes)
        return que
"""
def solve(S):
    from itertools import combinations
    from collections import deque
    n = len(S)
    answer = 0
    for i in range(n):
        for item in combinations(list(range(1, n, 1)), i):
            char_list = [c for c in S]
            que = deque(item)
            while que:
                index = que.pop()
                char_list.insert(index, " ")
            split_s = ""
            for c in char_list:
                split_s += c
            #print(split_s)
            answer += sum(map(int, split_s.split()))
    return answer

def main():
    S = input()

    print(solve(S))
#print(solve("125"))
#print(solve("9999999999"))
main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
//typedef long long ll;
//#define ull       unsigned long long
#define int       long long
#define F           first
#define S           second
#define endl        "\n"//<<flush
#define eps         1e-6
#define lowbit(x)   (x&(-x))
#define PI          acos(-1.0)
#define inf         0x3f3f3f3f
#define MAXN        0x7fffffff
#define INF         0x3f3f3f3f3f3f3f3f
#define pa          pair<int,int>
#define ferma(a,b)  pow(a,b-2)
#define pb          push_back
#define all(x)      x.begin(),x.end()
#define memset(a,b) memset(a,b,sizeof(a));
#define IOS         ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
void file()
{
#ifdef ONLINE_JUDGE
#else
    freopen("cin.txt","r",stdin);
    //  freopen("cout.txt","w",stdout);
#endif
}
signed main()
{
    IOS;
    //file();
    string str;
    cin>>str;
    if(str[0]!=str[1]||str[1]!=str[2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
import heapq


def func(start, mp):
    d = [float("inf") for i in xrange(10)]
    d[start] = 0
    q = [(0, start)]
    while len(q):
        c, n = heapq.heappop(q)
        if d[n] < c:
            continue
        for i in xrange(10):
            if d[i] > d[n]+mp[n][i]:
                d[i] = d[n]+mp[n][i]
                heapq.heappush(q, (d[i], i))
    return d[1]

h, w = map(int, raw_input().split())
mp = list()
for i in xrange(10):
    mp.append(map(int, raw_input().split()))

m = [func(i, mp) for i in xrange(10)]
print sum([sum(map(lambda x:m[x] if not x == -1 else 0, map(int, raw_input().split()))) for i in xrange(h)])


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

int N;
vector<int> xsort;
int X[200001];

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
        xsort.push_back(X[i]);
    }

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

    int a = xsort[N / 2 - 1];
    int b = xsort[N / 2];
    for (int i = 0; i < N; i++)
    {
        if (X[i] <= a)
            cout << b << "\n";
        else
            cout << a << "\n";
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;

    cout << min(P+Q, min(Q+R, R+P)) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e6 + 42;
char u[N];
int a[N], erat[N];
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  for(int i = 2; i < N; i++)
    if(!erat[i]) {
      erat[i] = i;
      if(1ll * i * i < 1ll * N)
        for(int j = i * i; j < N; j += i)
          erat[j] = i;
    }

  int n = 0;

  cin >> n;

  int set = 0;

  bool bad = false;

  for(int i = 0; i < n; i++) {
    cin >> a[i];
    set = (set == 0 ? a[i] : __gcd(a[i], set));
    if(bad) continue;
    int x = a[i];
    while(erat[x]) {
      int c = erat[x];
      if(u[c]++) {
        bad = true;
      }
      while(x % c == 0) x /= c;
    }
  }

  if(!bad) cout << "pairwise coprime";
  else cout << (set == 1 ? "setwise coprime" : "not coprime");

  return 0;
}
/*

*/


Measured memory_bytes: 11376
line = int(input())
nums = [[[0 for x in range(0, 10)] for x in range(0, 3)] for x in range(0, 4)]
input1 = []
for i in range(line):
    input1.append(input())


for e in input1:
    efbv =  e.split(" ")
    e_b, e_f, e_r, e_v = map(int, efbv)
    nums[e_b - 1][e_f - 1][e_r -1] += e_v

for b in range(4):
    for f in range (3):
        print(" " + " ".join(map(str, nums[b][f])))
    if b != 3: print("#" * 20)

Measured memory_bytes: 7748
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); i++)
#define rep(i,b) loop(i,0,b)

template<class iter>
bool next_combination(iter f1, iter l1, iter f2, iter l2){
    if((f1==l1)||(f2==l2)){
        return false;
    }
    iter m1 =l1;
    iter m2 =l2; --m2;
    while(--m1!=f1 &&!(*m1<*m2)){
    }
    bool result =(m1==f1)&&!(*f1<*m2);
    if(!result){
        while(f2!=m2 &&!(*m1<*f2)){
            ++f2;
        }
        f1 =m1;
        iter_swap(f1, f2);
        ++f1;
        ++f2;
    }
    if((f1!=l1)&&(f2!=l2)){
        m1 =l1; m2 =f2;
        while((m1!=f1)&&(m2!=l2)){
            iter_swap(--m1, m2);
            ++m2;
        }
        reverse(f1, m1);
        reverse(f1, l1);
        reverse(m2, l2);
        reverse(f2, l2);
    }
    return !result;
}

template<class iter >
bool next_combination(iter first, iter middle, iter last){
    return next_combination(first, middle, middle, last);
}

int ns[11][1000];
int arr[10];
int n,s;
int main(){
    memset(ns,0,sizeof(ns));
    rep(i,10) arr[i]=i;
    loop(i,1,11){
        do{
            //rep(k,i) cout<<arr[k]<<" ";
            //cout<<endl;
            do{
                int ts=0;
                rep(j,i)ts+=(j+1)*arr[j];
                ns[i][ts]++;
            }while(next_permutation(arr,arr+i));
        }while(next_combination(arr,arr+i,arr+10));
    }
    while(cin>>n>>s){
        if(1<=n && n<=10 && 0 <= s && s<= 1000)
            cout<<ns[n][s]<<endl;
        else cout<<0<<endl;
    }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    if(n%2 ==0){
        cout << n/2 << endl;
    }else{
        cout << n/2+1 << endl;
    }
}

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

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

int w,h,x,y,r;

bool check(){
  return x >= r && y >= r && x <= w-r && y <= h-r;
}

int main(){
  cin >> w >> h >> x >> y >> r;
  cout << (check() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mx = 1e6 + 9;
vector<ll>adj[mx];
bitset<mx>mark;
ll dist[mx];

int main() {
    ll n, m; cin >> n >> m;
    for(ll i = 0; i < m; i++) {
        ll u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    bool nafisa = false;
    ll source = 1;
    mark[source] = 1;
    queue<ll>q;
    q.push(source);
    while(!q.empty()) {
        auto u = q.front();
        q.pop();
        if(u == n && dist[u] == 2) {
            nafisa = true;
            break;
        }
        for(auto v : adj[u]) {
            if(!mark[v]) {
            mark[v] = 1;
            dist[v] = dist[u] + 1;
            q.push(v);
            }
        }
    }
    if(nafisa) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;

}


Measured memory_bytes: 36892
#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>;
using vv = 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;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int h,w,k;cin >> h >> w >> k;
    vector<string> s(h);
    for(int i=0;i<h;i++){
	cin >> s[i];	
    }
    ll ans = 0;
    for(int bit=0;bit<(1<<h);bit++){
	for(int bit2=0;bit2<(1<<w);bit2++){
	    int count=0;
	    for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
		    if(!(bit & (1<<i)) && !(bit2 & (1<<j)) ){ 
			if(s[i][j]=='#') count++;				
		    }
		}
	    }
	    if(count==k) ans++;
	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define vv(dt) vector<vector<dt>>
#define vec vector<int>
#define un unsigned
#define mp(x,y) make_pair(x,y)
#define dbl double
#define wking(t) cout<<"Working "<<t<<endl;
#define loop(i,s,n) for(auto i=s;i!=n;i++)
#define min2(a,b) (a)<(b)?(a):(b)
#define mod %1000000007
#define eps 0.000000001
#define inf 100000000000000001
using namespace std;

ll f(int h,int w,vv(char) &ch,vv(ll) &dp)
{
    // wking(ch[h][w]);
    if(h<0 || w<0) return 0;
    // wking(w);
    if(dp[h][w]!=-1) return dp[h][w]mod;
    // wking(h);
    dp[h][w] = 0;
    if(w-1>=0 && ch[h][w-1]=='.') dp[h][w] = (dp[h][w]mod + f(h,w-1,ch,dp)mod)mod;
    if(h-1>=0 && ch[h-1][w]=='.') dp[h][w] = (dp[h][w]mod + f(h-1,w,ch,dp)mod)mod;
    return dp[h][w]mod;
}

ll calc(int h,int w,vv(char) &ch)
{
    vv(ll) dp(h+1,vector<ll> (w+1,-1));
    dp[0][0] = 1;
    dp[h][w] = f(h,w,ch,dp)mod;
    return dp[h][w]mod;
}

int main()
{
    int H,W;
    cin>>H>>W;
    vv(char) ch(H,vector<char> (W));
    loop(i,0,H) loop(j,0,W) cin>>ch[i][j];
    cout<<calc(H-1,W-1,ch)<<endl;
    return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n, m;
	cin >> n >> m;

	vector<string> a, b;
	for(int i=0; i<n; i++){
		string t;
		cin >> t;
		a.push_back(t);
	}

	for(int i=0; i<m; i++){
		string t;
		cin >> t;
		b.push_back(t);
	}

	for(int j=0; j <= n - m; j++){
		for(int i=0; i <= a[0].size() -b[0].size(); i++){
			bool f = true;
			for(int k=0; k < m; k++){
				for(int l=0; l < b[0].size(); l++){
					if(a[j+k][i+l] != b[k][l]){
						f = false;
						break;
					}
				}
			}
			if(f){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	
	return 0;
}


Measured memory_bytes: 256
(let* ((a (read))
    (b (read))
    (c (read))
    (ab (* a b))
    (bc (* b c))
    (ca (* c a))
    (ans 0))
    (if (not (or (zerop (rem a 2)) (zerop (rem b 2)) (zerop (rem c 2))))
        (progn
            (if (<= ab bc)
                (setq ans ab)
                (setq ans bc)
            )
            (if (< ca ans)
                (setq ans ca)
            )
        )
    )
    (format t "~D~%" ans)
)

Measured memory_bytes: 24328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

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

    long long a,b,x,i=0;
    cin>>a>>b>>x;

    if(a%x==0){
	i=1;
    }
    
    cout<<b/x-a/x+i<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int left = 0, right = 0, need_left = 0, need_right = 0;
    REP(i,n){
        if(s[i] == '('){
            left++;
        }else{
            if(left == 0){
                need_left++;
            }else{
                left--;
            }
        }
    }
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == ')'){
            right++;
        }else{
            if(right == 0){
                need_right++;
            }else{
                right--;
            }
        }
    }
    REP(i,need_left){
        cout << "(";
    }
    cout << s;
    REP(i,need_right){
        cout << ")";
    }
    cout << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

def lowlink(g, root=0):
    n = len(g)
    order = [n]*n
    low = [n]*n

    s = [root]
    cnt = 1
    par = [-1]*n
    seq = []
    while s:
        v = s.pop()
        if order[v] != n:
            continue
        order[v] = cnt
        seq.append(v)
        low[v] = cnt
        cnt += 1
        for u in g[v]:
            if order[u] < cnt:
                if par[v] != u:
                    low[v] = min(low[v], order[u])
                    continue
            else:
                par[u] = v
                s.append(u)
    child = [[] for _ in range(n)]
    for v in range(n):
        if par[v] != -1:
            child[par[v]].append(v)
    seq.reverse()
    for v in seq:
        for u in child[v]:
            low[v] = min(low[v], low[u])
    # bridge
    bridge = []
    for p in range(n):
        for c in child[p]:
            if order[p] < low[c]:
                bridge.append((p, c))

    # articulation points
    AP = []
    for v in range(n):
        if v == root:
            if len(child[v]) >= 2:
                AP.append(v)
        else:
            for c in child[v]:
                if order[v] <= low[c]:
                    AP.append(v)
                    break
    return AP, bridge

_, bridge = lowlink(g, 0)
print(len(bridge))

Measured memory_bytes: 9324
t_hp, t_atk, a_hp, a_atk = map(int, input().split())
frag = 0
winner = 0 # 1:takahashi, 2:Aoki
while(frag == 0):
    a_hp = a_hp - t_atk
    if(a_hp <= 0):
        frag = 1
        winner = 1
        break
    t_hp = t_hp - a_atk
    if(t_hp <= 0):
        frag = 1
        winner = 2
        break

if(winner == 1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9200
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	A := make([]int, N)
	B := make([]int, N)
	C := make([]int, N - 1)

	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}

	for i := 0; i < N; i++ {
		fmt.Scan(&B[i])
	}

	for i := 0; i < N - 1; i++ {
		fmt.Scan(&C[i])
	}


	res := 0
	for i := 0; i < N; i++ {
		res += B[i]
		if i > 0 && A[i] == A[i - 1] + 1 {
			res += C[A[i - 1] - 1]
		}
	}
	fmt.Println(res)

}

Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#include<algorithm>
#define Max (int)1e5+5
#define MAX2 (int)1e5+5
#define MOD ((int)1e9+7)
using namespace std;

int search(int a[],int n,int key){
	int start = 0;
	int end = n-1,mid,pos = -1;
	while(start<=end){
		mid = (start+end)/2;
		if(a[mid]<=key){
			pos = mid;
			start=mid+1;
		}else{
			end = mid-1;
		}
	}
	return pos;
}

int main(){
	int n,c=0,tmp,a[Max],i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}

	sort(a,a+n);
	for(i=1;i<Max;i++){
		tmp = search(a,n,i);
		if(tmp == -1)
			continue;

		if(tmp+1 == n-(tmp+1)){
			c++;
		}

	}
//	printf("%d %d\n",search(a,n,4),search(a,n,5));

	printf("%d\n",c);
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
inline int tax_included(int v, int t)
{
	return v * (100 + t) / 100;
}
int main()
{
	while (true)
	{
		int x = in(), y = in(), s = in();
		if (x == 0 && y == 0 && s == 0)
		{
			break;
		}
		int max = -1;
		REP1(a, s - 1)
		{
			REP1(b, s - 1)
			{
				if (tax_included(a, x) + tax_included(b, x) == s)
				{
					int foo = tax_included(a, y) + tax_included(b, y);
					if (max < foo)
					{
						max = foo;
					}
				}
			}
		}
		cout << max << endl;
	}
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

bool table[12][5000];
int n;
string text;
string str[12];
bool visited[1<<12];

bool dfs(int S, int now) {
  if (visited[S]) return 0;
  visited[S] = 1;
  if (S == (1<<n)-1) return 1;
  if (now >= text.size()) return 0;
  REP(i, n) {
    if (S>>i&1) continue;
    if (table[i][now] && dfs(S|1<<i, now+str[i].size()))
      return 1;
  }
  return 0;
}

int main() {
  int m;
  while(cin>>n>>m,n||m) {
    int len = 0;
    REP(i, n) {
      cin >> str[i];
      len += str[i].size();
    }
    text.clear();
    REP(i,m) {
      string tmp;
      cin >> tmp;
      text += tmp;
    }
    memset(table,0,sizeof(table));
    REP(i, n) {
      REP(j, text.size() - str[i].size() + 1) {
        if (str[i] == text.substr(j, str[i].size()))
          table[i][j] = 1;
      }
    }
    int ans = 0;
    REP(i, text.size() - len+1) {
      memset(visited, 0, sizeof(visited));
      ans += dfs(0, i);
    }
    cout << ans << endl;
  }
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);
    int res = 0;
    for(int i = 0; i < k; i++) {
        res += a[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 3628
unittest
{
	assert( [ "2", "4 8" ].parse.expand.solve == 8 );
	assert( [ "3", "1 1 3" ].parse.expand.solve == 3 );
	assert( [ "3", "4 2 5" ].parse.expand.solve == 5 );
	assert( [ "4", "-100 -100 -100 -100" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 0L;
	auto ave = roundTo!long( cast( real ) as.sum / as.length );
	foreach( a; as )
	{
		ans += ( ave - a ) ^^ 2;
	}
	return ans;
}


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

using namespace std;

struct SegmentTree
{
  vector< pair< int, int > > seg;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, make_pair(0, 0));
  }

  void push(int k)
  {
    if(k >= sz - 1 || seg[k] == make_pair(0, 0)) return;
    if(seg[2 * k + 1] == make_pair(0, 0)) {
      seg[2 * k + 1] = seg[k];
    } else if(seg[k].first == seg[2 * k + 1].second) {
      seg[2 * k + 1].second = seg[k].second;
    } else {
      seg[2 * k + 1] = {-1, -1};
    }
    if(seg[2 * k + 2] == make_pair(0, 0)) {
      seg[2 * k + 2] = seg[k];
    } else if(seg[k].first == seg[2 * k + 2].second) {
      seg[2 * k + 2].second = seg[k].second;
    } else {
      seg[2 * k + 2] = {-1, -1};
    }
    seg[k] = {0, 0};
  }

  void update(int a, int b, int x, int k, int l, int r)
  {
    push(k);
    if(a >= r || b <= l) {

    } else if(a <= l && r <= b) {
      if(seg[k] == make_pair(-1, -1)) return;
      if(k >= sz - 1) {
        if(seg[k].second == x) seg[k].second++;
        else seg[k] = {-1, -1};
      } else {
        seg[k] = {x, x + 1};
      }
      push(k);
    } else {
      update(a, b, x, 2 * k + 1, l, (l + r) >> 1);
      update(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    }
  }

  void update(int a, int b, int x)
  {
    update(a, b, x, 0, 0, sz);
  }

  int query(int a, int b, int x, int k, int l, int r)
  {
    push(k);
    if(a >= r || b <= l) return (0);
    if(a <= l && r <= b) {
      return (seg[k] == make_pair(0, x));
    }
    return (query(a, b, x, 2 * k + 1, l, (l + r) >> 1) +
            query(a, b, x, 2 * k + 2, (l + r) >> 1, r));
  }

  int query(int a, int b, int x)
  {
    return (query(a, b, x, 0, 0, sz));
  }

};

int main()
{

  int N, K, T;
  scanf("%d %d", &N, &K);
  scanf("%d", &T);
  SegmentTree tree(N);
  while(T--) {
    int l, r, x;
    scanf("%d %d %d", &l, &r, &x);
    tree.update(--l, r, --x);
  }
  int ret = 0;
  for(int i = 0; i < N; i++) ret += tree.query(i, i + 1, K);
  printf("%d\n", ret);
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[10010],y[200200];
string s,str;
char ch;
int main(){
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout<<"Yes";
  }else{
    
  cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int>v(n), dp(k + 5, 0);
    for(int i = 0; i < n; i++){
        cin >> v[i];
        dp[v[i]] = 1;
    }
    for(int i = v[0] + 1; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(i - v[j] >= 0 && dp[i - v[j]] == 0){
                dp[i] = 1;
            }
        }
    }
    
    if(dp[k] == 1){
        cout << "First";
    }
    else{
        cout << "Second";
    }
    return 0;
}

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



int main()
{
	while (1){
		char str[1000];
		cin >> str;
		if (str[0] == '0') break;
		else{
			int sum = 0;
			for (int i = 0; i < 1000; i++){
				if (str[i] == '\0') break;
				else sum += str[i] - '0';
			}
			cout << sum << endl;

		}
	}
	return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<int> v(N);
    for (auto &&i : v) {
        cin >> i;
    }

    int two = 0, four = 0;
    for (auto &&i : v) {
        if (i % 4 == 0)
            four++;
        else if (i % 2 == 0)
            two++;
    }

    int cnt = N - (2 * four + 1) - 2 * (two / 2);
    if (cnt <= 0) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}

Measured memory_bytes: 640
def main():
    N = int(input())

    A = list(map(int, input().split()))

    n = max(A)
    A.remove(n)

    tmp = []
    for a in A:
        # print(
        #     n,
        #     a,
        #     n - a, )
        tmp.append((max(a, n - a), a))
    print(n, min(tmp)[1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 15712
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	w := make([]int, n)
	t := make([]int, n-1)

	for i := 0; i < n; i++ {
		fmt.Scan(&w[i])
	}

	for i := 1; i < n; i++ {
		t[i-1] = absolute(sumValue(w[:i]) - sumValue(w[i:]))
	}

	min := minValue(t)
	fmt.Println(min)

}

func absolute(num int) int {
	if num < 0 {
		return -num
	} else {
		return num
	}
}

func sumValue(n []int) int {
	sum := 0
	for i := 0; i < len(n); i++ {
		sum += n[i]
	}

	return sum
}

func minValue(n []int) int {
	min := n[0]
	for i := 1; i < len(n); i++ {
		if min > n[i] {
			min = n[i]
		}
	}
	return min
}


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

using namespace std;

ostream& operator<<(ostream &os, const vector<uint64_t> &v)
{
  for (uint64_t i = 0; i < v.size(); ++i) {
    os << v[i];
    if (i + 1 < v.size()) { os << ' '; }
  }
  return os;
}

int main()
{
  string S;
  cin >> S;
  
  uint64_t N = S.size();
  
  vector<uint64_t> L(N + 1, -1), R(N + 1, -1);
  R[0] = 0;
  for (uint64_t n = 0; n < N; ++n) {
    R[n + 1] = (S[n] == 'R') ? n : R[n];
  }
  
  L[N] = N - 1;
  for (uint64_t n = 0; n < N; ++n) {
    L[(N - 1) - n] = (S[(N - 1) - n] == 'L') ? (N - 1) - n : L[N - n];
  }
  
  vector<uint64_t> count(N, 0);
  for (uint64_t n = 0; n < N; ++n) {
    if (S[n] == 'L') {
      if (((n - R[n]) % 2) == 0) {
        ++count[ R[n] ];
      } else {
        ++count[ R[n] + 1 ];
      }
    } else { // S[n] == 'R'
      if (((L[n] - n) % 2) == 0) {
        ++count[ L[n] ];
      } else {
        ++count[ L[n] - 1 ];
      }
    }
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
#define per(i, r, l) for(int i = (r); i >= (l); i--)
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> os;

int k, x;
int main(){
  cin >> k >> x;
  for(int i = max(x - k + 1, -1000000); i <= min(x + k - 1, 1000000); i++) cout << i << " ";
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		ans = Math.max(ans, 2 * A - 1);
		ans = Math.max(ans, A + B);
		ans = Math.max(ans, 2 * B - 1);
		System.out.println(ans);

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin>>N;
	vector<int> a(N);
	for(int i=0;i<N;i++) cin>>a[i];
	sort(a.begin(),a.end());
	cout<<a[N/2]-a[(N/2)-1]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
	int _s=0,_f=1,_q=getchar();
	while(_q<48||_q>57){if(_q=='-')_f=-1;_q=getchar();}
	while(_q>47&&_q<58)_s=(_s<<3)+(_s<<1)+_q^48,_q=getchar();
	return _s*_f;
}
int a[2020]={1};
const int m=1000000007;
int main(){
	for(int i=3;i<=2000;i++)
		for(int j=3;j<=i;j++)
			a[i]+=a[i-j],a[i]%=m;
	int s;
	cin>>s;
	cout<<a[s];
	return 0;
}


Measured memory_bytes: 3636