akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int[] v = new int[s.Length + 1];

            for (int i = 0; i < s.Length; i++)
            {
                if(s[i] == '<')
                {
                    v[i + 1] = v[i] + 1;
                }
            }
            for (int i = s.Length - 1; i >= 0; i--)
            {
                if(s[i] == '>')
                {
                    v[i] = Math.Max(v[i], v[i + 1] + 1);
                }
            }

            long ans = 0;
            for (int i = 0; i < s.Length + 1; i++)
            {
                ans += v[i];
            }

            Console.WriteLine(ans);
        }
    }
}



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

#pragma region union_find
class UnionFind {
private:
    vector<int> par;
    vector<int> rank;

public:
    UnionFind(int N) {
        par.resize(N);
        rank.resize(N, 0);
        for (int i = 0; i < N; ++i) {
            par.at(i) = i;
        }
    };
    int find(int x) {
        if (par.at(x) == x) {
            return x;
        } else {
            return par.at(x) = find(par.at(x));
        }
    };
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank.at(x) < rank.at(y)) {
            par.at(x) = y;
        } else {
            par.at(y) = x;
            if (rank.at(x) == rank.at(y)) ++rank.at(x);
        }
    };
    bool same(int x, int y) {
        return find(x) == find(y);
    };
};
#pragma endregion

#pragma region kruskal
struct edge {
    int from;
    int to;
    int cost;
};

bool comp(const edge &e1, const edge &e2) {
    return e1.cost < e2.cost;
}

int kruskal(vector<edge> &es, int V) {
    sort(es.begin(), es.end(), comp);
    UnionFind tree(V);
    int ret = 0;
    for (auto &e : es) {
        if (!tree.same(e.from, e.to)) {
            tree.unite(e.from, e.to);
            ret += e.cost;
        }
    }
    return ret;
}
#pragma endregion

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

    int V, E;
    cin >> V >> E;
    vector<edge> es;
    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        es.push_back(edge{s, t, w});
        es.push_back(edge{t, s, w});
    }

    cout << kruskal(es, V) << endl;

    return 0;
}


Measured memory_bytes: 6000
//23
#include<iostream>
#include<vector>
#include<complex>

using namespace std;

typedef complex<double> P;

vector<P> ip(){
  int m;
  cin>>m;
  vector<P> v(m);
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    v[i]=P(x,y);
  }
  return v;
}

bool cmp(vector<P> a,vector<P> b){
  if(a.size()!=b.size())return false;
  P d=a[0]-b[0];
  for(int i=0;i<4;i++){
    int j;
    for(j=0;j<a.size();j++){
      if(a[j]-a[0]!=(b[j]-b[0])*pow(P(0,1),i))break;
    }
    if(!(j<a.size()))return true;
  }
  return false;
}

int main(){
  for(int n;cin>>n,n;){
    vector<P> o=ip();
    for(int i=1;i<=n;i++){
      vector<P> l=ip();
      if(cmp(o,l)||cmp(o,vector<P>(l.rbegin(),l.rend()))){
	cout<<i<<endl;
      }
    }
    cout<<"+++++"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B;
  cin >> A >> B;
  if(A==B)
    cout << "Draw" << endl;
  else if(A==1 && B!=1)
    cout << "Alice" << endl;
  else if(A!=1 && B==1)
    cout << "Bob" << endl;
  else if(A!=1 && B!=1 && A>B)
    cout << "Alice" << endl;
  else if(A!=1 && B!=1 && A<B)
    cout << "Bob" << endl;
}


Measured memory_bytes: 256
INF = float('inf')
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
c = [0,2,5,5,4,5,6,3,7,6]

dp = [-INF]*(N+1)
dp[0] = 0
for a in A:
    if c[a] <= N:
        dp[c[a]] = 1

for i in range(N+1):
    for a in A:
        if i-c[a]>=0:
            dp[i] = max(dp[i],dp[i-c[a]]+1)

ans = ''
n = N
for a in A:
    if n-c[a]>=0:
        while dp[n] == dp[n-c[a]]+1:
            n -= c[a]
            ans = ans + str(a)
print(ans)

Measured memory_bytes: 42092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var a = GetLongs(N);

		long D = a.Max();
		var cnt = new long[D + 1];
		for(long i = 0; i < N; i++)
			cnt[a[i]]++;

		for(long i = 0; i <= D; i++)
		{
			long d = Max(i, D - i);
			if(cnt[d] == 0)
			{
				WriteLine("Impossible");
				return;
			}
			cnt[d]--;
		}
		for(long i = 0; i < (D + 1)/ 2 + 1; i++)
		{
			if(cnt[i] > 0)
			{
				WriteLine("Impossible");
				return;
			}
		}
		WriteLine("Possible");
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 28392
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    ll n,k;cin>>n>>k;
    vec<ll>v(n);
    rep(i,n){cin>>v[i];}
    sort(all(v));
    ll ans=10000000000+22;
    rep(i,n-(k-1)){
	   ans=min(ans,abs( v[i]-v[i+k-1]));
    }
    cout<<ans<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


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

void init() {
//#if __GLIBCXX__ == 20160609
#ifdef FIRE_MIND
    freopen("a.in", "r", stdin);
    ///freopen("a.out", "w", stdout);
#else
    ///freopen(TASKNAME".in", "r", stdin);
    ///freopen(TASKNAME".out", "w", stdout);
#endif
}

typedef long long ll;
typedef long double ld;

const double EPS = 1e-9;
const int INF = (int)1e9 + 41;
const int N = (int)1e6 + 34;

int main() {
    init();
    int n, a, b;
    cin >> n >> a >> b;
    int d = abs(a - b);
    if (d % 2) {
        cout << "Borys";
    } else {
        cout << "Alice";
    }

    return 0;
}


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

const int V_MAX=100000;

struct edge{
	int from;
	int to;
	bool operator<( const edge& right ) const {
        return from == right.from ? to < right.to : from < right.from;
    }
};

vector<int> G[V_MAX];
vector<bool> check(V_MAX,false);
vector<int> pre(V_MAX);
vector<int> low(V_MAX,INT_MAX);
vector<edge> result;
int order;

void dfs(int s,int p){
	if(check[s]==true){return;}
	check[s]=true;
	pre[s]=order;
	low[s]=order;
	order++;
	for (int i=0;i<G[s].size();i++){
		if(G[s][i]!=p && low[G[s][i]]<low[s]){
			low[s]=low[G[s][i]];
		}
		if(check[G[s][i]]==false){
			dfs(G[s][i],s);
		}
	}
	
	if(!(s==0&&p==0) && pre[s]==low[s]){
		edge e;
		e.from=min(s,p);
		e.to=max(s,p);
		result.push_back(e);
		//cout << p << " " << s << endl;
	}
	
	
	
	if(low[p]>low[s]){
		low[p]=low[s];
	}
}

int main(){
	int V,E,s,t;
	cin>> V >> E;
	for (int i=0;i<E;i++){
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	
	order=0;
	dfs(0,0);
	
	sort(result.begin(),result.end());
	for(int i=0;i<result.size();i++){
		cout << result[i].from << " " << result[i].to << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5760
n,m = map(int,input().split())
box = []
for i in range(m):
  box.append(list(map(int,input().split())))
for j in range(1,n+1):
  count = 0
  for k in range(m):
    if box[k][0] == j or box[k][1] ==j:
      count += 1
  print(count)

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; ++i){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  long ans = 0;
  for(int i = 0; i < K; ++i){
    ans += p.at(i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3624
while s = gets do
  hu = s.split(',').map(&:to_i)
  cc = Array.new(13){0}
  hu.each { |c| cc[c-1] += 1 }
  st = cc.join
  cc.delete(0)

  scr='null'
  case cc.sort
    when [1,4]
      scr='four card'
    when [2,3]
      scr='full house'
    when [1,1,1,1,1]
      scr='straight' if st =~ /1{5}/ or st =~ /10{8}1{4}/
    when [1,1,3]
      scr='three card'
    when [1,2,2]
      scr='two pair'
    when [1,1,1,2]
      scr='one pair'
  end
  puts scr
end

Measured memory_bytes: 6104
var
	S:String;
	ans,T,pr:Array[0..10]of int64;
	i,j:Longint;
	tmp:int64;
begin
	readln(S);
	T[0]:=1;
	pr[0]:=1;
	for i:=1 to 10 do pr[i]:=pr[i-1]*10;
	for i:=1 to length(S) do begin
		tmp:=ord(S[i])-48;
		for j:=i-1 downto 0 do begin
			inc(ans[i],T[j]*tmp+ans[j]);
			inc(tmp,(ord(S[j])-48)*pr[i-j]);
			inc(T[i],T[j]);
		end;
	end;
	writeln(ans[length(S)]);
end.


Measured memory_bytes: 128
N = int(input())
a = list(map(int, input().split()))
M = max(a)
m = min(a)
if M > m + 1:
    print("No")
else:
    if M == m:
        if M == N-1:
            print("Yes")
        elif M*2 <= N:
            print("Yes")
        else:
            print("No")

    else:
        # ai == m　ならば、ai以外にその色はない
        c = a.count(m)
        if (M - c) * 2 <= N-c and c < M:  # (M-c) -> 一人だけではない色の種類一人だけではないはずなので*2 したものよりも残りの人数が多いはず
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 20768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

struct Point {
	int x, y;
	Point(int x, int y) : x(x), y(y) {}
};

signed main() {
	int N, K;
	cin >> N >> K;

	vector<Point> pts;

	rep(i, N) {
		int x, y;
		cin >> x >> y;
		pts.push_back(Point(x, y));
	}

	int ret = LLONG_MAX;

	rep(i, N) rep(j, N) rep(k, N) rep(m, N) {
		int minX = pts[i].x;
		int maxX = pts[j].x;
		int minY = pts[k].y;
		int maxY = pts[m].y;
		if (minX > maxX) continue;
		if (minY > maxY) continue;

		int cnt = 0;
		rep(i, N) {
			cnt += minX <= pts[i].x && pts[i].x <= maxX
				&& minY <= pts[i].y && pts[i].y <= maxY;
		}
		if (cnt >= K) {
			ret = min(ret, (maxX - minX) * (maxY - minY));
		}
	}

	cout << ret << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll x,y;
int main()
{
	scanf("%lld%lld",&x,&y);
	if(abs(x-y)>=2)
		printf("Alice\n");
	else
		printf("Brown\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct A {
  i64 s, t, x;
};

struct B {
  i64 si, ti, x;
};

i64 n, q;
vector<A> a;
vector<i64> d;

int main() {
  cin >> n >> q;
  init_n(a, n);

  for (i64 i = 0; i < n; ++i) {
    cin >> a[i].s >> a[i].t >> a[i].x;
  }
  sort(begin(a), end(a), [](A p, A q) {
    return p.x < q.x; 
  });
  read_n(d, q);
  
  vector<i64> y(q, -1);
  set<i64> st;
  for (i64 i = 0; i < q; ++i) st.insert(i);

  for (i64 i = 0; i < n; ++i) {
    i64 s = a[i].s, t = a[i].t, x = a[i].x;
    i64 si = lower_bound(begin(d), end(d), s - x) - begin(d);
    i64 ti = lower_bound(begin(d), end(d), t - x) - begin(d);

    auto sit = st.lower_bound(si), tit = st.lower_bound(ti);
    for (auto it = sit; it != tit; ++it) {
      y[*it] = x;
    }

    st.erase(sit, tit);
  }

  for (i64 i = 0; i < q; ++i) cout << y[i] << '\n';

  return 0;
}


Measured memory_bytes: 19072
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int m = sc.nextInt();
			int n = sc.nextInt();
			if(m == 0 && n == 0) break;

			ArrayList<Integer> al = new ArrayList<Integer>();
			for(int i=1;i<=m;i++){
				al.add(i);
			}

			for(int i=1,now=0;i<=n;i++,now=(now+1)%al.size()){
				String s = sc.next();
				if(al.size() > 1){
					if(!check(i,s)){
						al.remove(now);
						now--;
					}
				}
			}

			System.out.println(al.toString().replaceAll("\\[|\\]|,",""));
		}
	}

	private static boolean check(int x,String s){
		String t = (x % 3 == 0 ? "Fizz" : "") + (x % 5 == 0 ? "Buzz" : "");
		if(t.isEmpty()) t += x;

		return s.equals(t);
	}
}

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

int ret[200000] = {0};

int main(void) {
  
  int n;
  //int *ret;
  scanf("%d", &n);
  //ret = calloc(n, sizeof(int));
  for (int i = 1; i < n; i++)
  {
    int a;
    scanf("%d", &a);
    ret[a-1]++;
  }
  for (int i = 0; i < n; i++)
  {
    printf("%d\n", ret[i]);
  }
  
  
 
  return 0;
}

Measured memory_bytes: 2904
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#include<string>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern

//const int nax = 1e5 + 2;
 

signed main() {    
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    if(n >= 30){
		cout<<"Yes\n";
	}
	else
		cout<<"No\n";
    
    
    return 0;
}


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

int main() {
   int x, y;
   cin >> x >> y;

   cout << x + y/2 << endl;
}

Measured memory_bytes: 256
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a=set(primes(100100))
b=[0]
for i in range(100100):
    f=0
    if i%2==1 and i in a and (i+1)//2 in a:
        f=1
    b.append(b[-1]+f)
q=int(input())
for i in range(q):
    a=list(map(int,input().split()))
    print(b[a[1]+1]-b[a[0]])

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

long long tmp = 1e9+7;

int main()
{
    int N;
    cin >> N;
    long long amari_10 = 1;
    long long amari_9 = 1;
    long long amari_8 = 1;
    for (int i=0; i<N; i++)
    {
        amari_10 = (amari_10 * 10) % tmp;
        amari_9 = (amari_9 * 9) % tmp;
        amari_8 = (amari_8 * 8) % tmp;
    }
    long long ans = (amari_10 - 2 * amari_9 + amari_8 + 2*tmp) % tmp;
    cout << ans << endl;
    //cout << tmp << endl;
}

Measured memory_bytes: 3612
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        int a = sc.nextInt();
      	String op = sc.next();
      	int b = sc.nextInt();
      	int ans;
      
      	if(op.equals("+")) ans = a+b;
      	else ans = a-b;
          
      	System.out.print(ans);
      
	}
}

Measured memory_bytes: 35816
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<int>> v(h, vector<int>(w));
  rep(i,h) rep(j,w) cin>>v[i][j];

  vector<pair<pair<int,int>, pair<int,int>>> ans;
  rep(i,h){
    int ij,dj;
    if(i%2==0) ij=0, dj=1;
    else ij=w-1, dj=-1;
    for(int j=ij; j>=0 && j<w; j+=dj){
      int ni = i, nj = j + dj;
      if(nj < 0 || nj >= w) ni = i+1, nj = j;
      if(ni >= h) break;

      if(v[i][j]%2 != 0){
        ans.pb({{i+1,j+1}, {ni+1,nj+1}});
        v[i][j]--;
        v[ni][nj]++;
      }
    }
  }

  cout << ans.size() << endl;
  for(auto &pp : ans) cout << pp.first.first << " " << pp.first.second << " " << pp.second.first << " " << pp.second.second << endl;

  return 0;
}


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

int n;
string s, t, now, next;
bool ans = 0;
//第二引数"から"分ける
vector<string> split(string splitstring, int stringnum) {
  int i;
  vector<string> stringanswer;
  string answerstring1 = "";
  string answerstring2 = "";
  for(i = stringnum - 1; i < splitstring.size(); ++i)
    answerstring2 += splitstring[i];
  splitstring.erase(splitstring.begin() + stringnum - 1, splitstring.end());
  answerstring1 = splitstring;
  stringanswer.push_back(answerstring1);
  stringanswer.push_back(answerstring2);
  return stringanswer;
}

int main() {
  int i;
  cin >> s >> t;
  now = s;
  while(1) {
    now += now[0];
    now.erase(now.begin());
    if(now == t) ans = 1;
    if(now == s) break;
  }
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair

#define N 100'005
int n, m; 
typedef pair<ll, pii> edg ;
vector<edg> edgs;
ll x[N]; // vertex cost

vi ufc[N];
int ufp[N], ufd[N];
int ufg(int a){
	while(ufp[a]!=a) a=ufp[a];
	return a;
}
bool ufm(int a, int b){
	a = ufg(a), b = ufg(b);
	if(a == b) return false;
	if(ufd[a] > ufd[b]) swap(a, b);
	// a is always smaller
	ufp[a] = b;
	ufc[b].EB(a);
	LAR(ufd[b], ufd[a]+1);
	return true;
}
ll z[N]; // vertex cost subtree
void dfs(int i){
	z[i]=x[i];
	for(int j : ufc[i]){
		dfs(j);
		z[i]+=z[j];
	}
}

int main(){
	scanf("%d%d", &n, &m);
	REP(i, n) scanf("%lld", x+i);
	REP(i, m){
		int a, b; ll y; scanf("%d%d%lld", &a, &b, &y); a--; b--;
		edgs.EB(y, MP(a, b));
	}
	sort(ALL(edgs));

	REP(i, n) ufp[i]=i, ufd[i]=0;
	REP(i, m){
		edg &e = edgs[i];
		int a=e.second.first, b=e.second.second;
		a = ufg(a), b = ufg(b);
		if(a != b){
			ufm(a, b);
		}
		e.second.first = a, e.second.second = b;
	}
	dfs(ufg(0));
	// REP(i, n) printf("%2d ", i+1); printf("\n");
	// REP(i, n) printf("%2d ", ufp[i]+1); printf("\n");

	int ans = 0;
	for(int i=m-1; i>=0; i--){
		edg &e = edgs[i];
		int a=e.second.first, b=e.second.second;
		// printf("edge %d->%d\n", a, b);
		if(a==b){
			if(e.first > z[ufg(a)]){
				ans++;
			}
			continue;
		}else if(ufp[a] == b){
		}else if(ufp[b] == a){
			swap(a, b);
		}else{
			// printf("okapeople\n");
			return 1;
		}
		// a --parent--> b
		if(e.first > z[ufg(b)]){
			if(ufp[b] != b){
				// printf("That's strange...\n");
				return 1;
			}
			ans++;
			ufp[a]=a;
			z[b]-=z[a];
		}
	}
	printf("%d\n", ans);
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
    int n;
    string s;

    ci >> n >> s;

    int r = 0, b = 0;
    for(int i = 0; i < n; i++) {
	if(s[i] == 'R') r++;
	else b++;
    }

    if(r > b) co << "Yes" << en;
    else co << "No" << en;
    
    return 0;
}



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

int main()
{
    string s;
    cin >> s;
    int i;
    stack<char> st;
    int len = 0;
    for (i = 0; i < s.length(); i++)
    {
        if (s[i] == 'B')
        {
            if (len != 0)
            {
                st.pop();
                len--;
            }
        }
        else
        {
            st.push(s[i]);
            len++;
        }
    }
    //cout<<st.size()<<endl;
    string ans = "";
    for (i = 0; i < st.size(); i++)
    {
        ans = st.top() + ans;
        //cout<<ans<<"P"<<endl;
        st.pop();
        i = -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1
#define INF 1000000000 //1e9
#define PI 3.14159265359
#define mod 1000000007

int main(){
    int H,N;
    cin >> H >> N;
    int a = 0;
    for(int i = 0; i < N;i++){
        int b;
        cin >> b;
        a += b; 
    }
    if( a >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T = sorted([int(input()) for i in range(N)])

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

if N == 1:
    print(T[0])
else:
    ans = T[0]
    for i in range(1, N):
        ans = (ans*T[i])//(gcd(ans, T[i]))
    
    print(ans)

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

using namespace std;

int calc(int x)
{
	int ret=0;
	while(x%100==0){
		x/=100;
		ret++;
	}
	return(ret);
}

int main(void)
{
	int d,n;
	int val=0,cnt=0;

	cin>>d>>n;

	while(cnt<n){
		val++;
		if(calc(val)==d) cnt++;
	}

	cout<<val<<endl;

	return 0;
}


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

struct Node
{
    int key;
    Node* parent = nullptr;
    Node* l_child = nullptr;
    Node* r_child = nullptr;
};
Node* root;

void InsertNode(int value) 
{
    Node* currentNode = root;
    Node* parent = nullptr;
    Node* newNode = new Node;
    newNode->key = value;

    while(currentNode != nullptr)
    {
        parent = currentNode;
        if (newNode->key <= currentNode->key) currentNode = currentNode->l_child;
        else currentNode = currentNode->r_child;
    }
    newNode->parent = parent;
    if (root == nullptr) root = newNode;
    else if (value <= parent->key) parent->l_child = newNode;
    else parent->r_child = newNode;
}

bool FindNode(int targetV)
{
    Node* currentNode = root;
    while (currentNode != nullptr)
    {
        if (currentNode->key == targetV) return true;
        else if (currentNode->key < targetV) currentNode = currentNode->r_child;
        else currentNode = currentNode->l_child;
    }
    return false;
}

void Preorder_Print(const Node* currentNode) 
{
    printf(" %d", currentNode->key);
    if (currentNode->l_child != nullptr) Preorder_Print(currentNode->l_child);
    if (currentNode->r_child != nullptr) Preorder_Print(currentNode->r_child);
}

void Inorder_Print(const Node* currentNode) 
{
    if (currentNode->l_child != nullptr) Inorder_Print(currentNode->l_child);
    printf(" %d", currentNode->key);
    if (currentNode->r_child != nullptr) Inorder_Print(currentNode->r_child);
}

int main() 
{
    root = nullptr;
    int node_num, value;
    char order[10];
    scanf("%d", &node_num);
    for (int i = 0; i < node_num; ++i) 
    {
        scanf("%s %d", order, &value);
        if (order[0] == 'i')
        {
            InsertNode(value);
        }
        else if (order[0] == 'f')
        {
            if (FindNode(value)) printf("yes\n");
            else printf("no\n");
        }
        else if (order[0] == 'p')
        {
            Inorder_Print(root);
            printf("\n");
            Preorder_Print(root);
            printf("\n");
        }
    }
}


Measured memory_bytes: 21820
#include <stdio.h>
int main () {
int W,H,x,y,r;
scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
if (x>=0 && y>=0 && x+r<=W && y+r<=H)printf("Yes\n");
else  printf("No\n");
return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define N 1000010
using namespace std;
typedef long long ll;
typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> ii;
ll a[N];
int p=2;
ll pow(ll y,int z,int p){
    y%=p;ll ans=1;
    for(int i=z;i;i>>=1,y=y*y%p)if(i&1)ans=ans*y%p;
    return ans;
}
ll C(ll n,ll m){
    if(m>n)return 0;
    return ((a[n]*pow(a[m],p-2,p))%p*pow(a[n-m],p-2,p)%p);
}
ll Lucas(ll n,ll m){
    if(!m)return 1;
    return C(n%p,m%p)*Lucas(n/p,m/p)%p;
}
inline int read(){
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
class TaskB {
 public:
  int innerSolve(int n, const vector<int>& a) {
    int res = 0;
    for (int i = 0; i < n; ++i) {
//      if (((n - 1) & i) == i) {
//        res ^= a[i];
//      }
		if(Lucas(n-1,i))res ^= a[i];
    }
    return res;
  }

  void solveOne(istream &in, ostream &out) {
    int n;
    string s;
    in >> n;
    in >> s;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      a[i] = s[i] - '1';
    }
    bool anyOnes = false;
    for (int x : a) if (x == 1) anyOnes = true;
    if (anyOnes) {
      for (int i = 0; i < n; ++i) if (a[i] == 2) a[i] = 0;
      out << innerSolve(n, a) << "\n";
    } else {
      for (int i = 0; i < n; ++i) if (a[i] == 2) a[i] = 1;
      out << 2 * innerSolve(n, a) << "\n";
    }
  }

  void solve(std::istream &in, std::ostream &out) {
    int nt;
    nt = 1;
    for (int it = 0; it < nt; ++it) {
      solveOne(in, out);
    }
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  TaskB solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  a[0]=1;
  for(int i=1;i<=p;i++)a[i]=(a[i-1]*i)%p;
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 5276
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int i,N;
	cin>>N;
	vector<int> A(N);
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	if (N==1){
		cout<<0<<endl;
		return 0;
	}
	if (N==2){
		if (A[0]!=A[1]){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
		return 0;
	}
	int ans=0;
	for (i=0;i<N-2;i++){
		if (A[i]==A[i+1]){
			for (int j=1;j<=100000;j++){
				if (j!=A[i]&&j!=A[i+2]){
					A[i+1]=j;
					break;
				}
			}
			ans++;					
		}
	}
	if (A[N-2]==A[N-1]){
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

typedef long long ll;
using namespace std;


int k, t, ans;
int Max;

int main() {

    ios::sync_with_stdio(false);

    cin >> k >> t;
    int value;
    for (int i = 0; i < t; i++) {
        cin >> value;
        Max = max(Max, value);
    }
    
    cout << max(Max - 1 - (k - Max), 0) << endl;
    
    
    return 0;
}

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

int main() {
  int a, b, c ,d;
  cin >> a >> b >> c >> d;

  if ( a+b > c+d ) {
    cout << "Left" << endl;
  }
  else if ( a+b == c+d ) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int n,m,a[100005],b[100005][2],fa[100005];
int find(int t)
{
    if(fa[t]!=t)
        fa[t]=find(fa[t]);
    return fa[t];
}
void unionn(int r1,int r2)
{
    fa[r2]=r1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&b[i][0],&b[i][1]);
        int r1=find(b[i][0]),r2=find(b[i][1]);
        if(r1!=r2)
            unionn(r1,r2);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(find(i)==find(a[i]))
			ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

int main(){
  int n,m,nsum,msum,s;
  scanf("%d""%d",&n,&m);
  if(n < 2)
  nsum = 0;
  else if(n > 1)
  nsum = n*(n-1)/2;

  if(m < 2)
  msum = 0;
  else if(m > 1)
  msum = m*(m-1)/2;

  s = nsum + msum;

  printf("%d\n",s);

  return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    string s;
    cin >> s;
    vector<vector<int>> edge(N+1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> na(N+1, 0), nb(N+1, 0);
    for (int i = 1; i <= N; i++) {
        if (s[i-1] == 'A') {
            for (int n : edge[i]) na[n]++;
        }else {
            for (int n : edge[i]) nb[n]++;
        }
    }
    queue<int> q;
    int cnt = N;
    vector<bool> use(N+1, true);
    for (int i = 1; i <= N; i++) {
        if (na[i] == 0 || nb[i] == 0) {
            q.push(i);
            use[i] = false;
        }
    }
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        cnt--;
        if (s[now-1] == 'A') {
            for (int nxt : edge[now]) {
                na[nxt]--;
                if (use[nxt] && na[nxt] == 0) {
                    q.push(nxt);
                    use[nxt] = false;
                }
            }
        }else {
            for (int nxt : edge[now]) {
                nb[nxt]--;
                if (use[nxt] && nb[nxt] == 0) {
                    q.push(nxt);
                    use[nxt] = false;
                }
            }
        }
    }
    if (cnt > 0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 12164
#include <cstdio>
using namespace std;
typedef long long ll;
ll n,a,b,t1,t2,ans;
int main() {
	scanf("%lld %lld %lld",&n,&a,&b);
	t1=a*(n-1)+b; t2=a+(n-1)*b;
	ans=t2-t1+1;
	if (ans<0) ans=0;
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int n;
  string a, b, c;

  cin >> n;
  cin >> a;
  cin >> b;
  cin >> c;

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i] && b[i] == c[i]) {
      continue;
    }
    if (a[i] != b[i] && a[i] != c[i] && b[i] != c[i]) {
      ans += 2;
    }
    else {
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    ll n, m;
    map<ll, ll> m1, m2;
    cin >> n;
    ll d;
    REP(i, n){
        cin >> d;
        m1[d]++;
    }
    cin >> m;
    ll t;
    REP(i, m){
        cin >> t;
        m2[t]++;
    }

    for(auto itr = m2.begin(); itr != m2.end(); itr++){
        ll res = itr->first;
        if(m1[res] < m2[res]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 25216
class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]

def main():
    n,m = map(int,input().split())
    ls = [[int(x) for x in input().split()] for _ in range(m)]
    uni = Uf(n+1)

    for i in range(m):
        a,b,c = ls[i]
        uni.unite(a,b)
    ans = 0
    for i in range(1,n+1):
        if i == uni.root(i):
            ans +=1
        else:
            pass
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;
#define ll long long
const int N = 1e6 + 5;
int sv[N];

void factorize(int n, map<int, bool> &v) {
    if (n == 1)
        return;
    if (sv[n] == 0)
        sv[n] = n;
    v[sv[n]] = 1;
    factorize(n / sv[n], v);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    for (int i = 2; i * i < N; i++)
        if (sv[i] == 0)
            for (int j = i * i; j < N; j += i)
                if (sv[j] == 0)
                    sv[j] = i;
    int n;
    cin >> n;
    int gc = 0;
    map<int, int> mp;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        map<int, bool> temp;
        factorize(a, temp);
        gc = __gcd(gc, a);
        for (auto &it:temp) {
            mp[it.first]++;
            mx = max(mx, mp[it.first]);
        }
    }
    if (mx <= 1) {
        cout << "pairwise coprime";
    } else if (gc == 1) cout << "setwise coprime";
    else cout << "not coprime";
    return 0;
}

Measured memory_bytes: 11200
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {

  int n, a = 0, b = 0, c;
  cin >> a >> b >> c;
  cin >> n;
  cout << (a + b + c) - max(max(a, b), c) + (max(max(a, b), c) << n);
}


Measured memory_bytes: 3580
#include <stdio.h>

int main()
{
  int n,x,i,j,k;
  int count;

  scanf("%d",&n);
  scanf("%d",&x);
  while (!((n==0) && (x==0))){
    count=0;
    for (i=1;i<=n;i++){
      for (j=1;j<=n;j++){
        for (k=1;k<=n;k++){
          if (!((i==j) || (i==k) || (j==k))){
            if (i+j+k==x){
              count++;

            }
          }
        }
      }
    }
    printf("%d\n",count/6);
    scanf("%d",&n);
    scanf("%d",&x);
  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n; 
    vector<ll> a(n);
    int z=0;
    for(int i=0;i<n;i++)
     {
         cin>>a[i];
         if(!a[i])
          z++;
     }
  if(z>0)
   cout<<"0\n";
   else 
     {
         ll ans=1;
         for(int i=0;i<n;i++)
          {
              if(a[i]<=1000000000000000000/ans)
                ans*=a[i];
              else 
                {
                    cout<<"-1\n";
                    return 0;
                } 
          }
       cout<<ans<<"\n";
     } 
}

Measured memory_bytes: 3984
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n;
vector<pint> pl;
int fi[10][10];
bool seen[10][10];

bool rec(int x, int y, int ind, int sum) {
	//cout << x << ", " << y << " (" << ind << ") : " << sum << endl;
	if (sum == -fi[pl[ind].first][pl[ind].second]) {
		if (ind == pl.size()-1) return true;
		else if ( rec(pl[ind+1].first, pl[ind+1].second, ind+1, 0) ) return true;
		else return false;
	}

	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx < 0 || nx >= n || ny < 0 || ny >= n) continue;
		if (seen[nx][ny]) continue;
		if (sum + fi[nx][ny] >  -fi[pl[ind].first][pl[ind].second]) continue;
		
		seen[nx][ny] = true;
		if ( rec(nx, ny, ind, sum + fi[nx][ny]) ) return true;
		seen[nx][ny] = false;
	}

	return false;
}

bool solve() {
	int sum_kiten = 0, sum_rem = 0;
	memset(seen, 0, sizeof(seen));

	pl.clear();
	for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
		cin >> fi[i][j];
		if (fi[i][j] < 0) sum_kiten -= fi[i][j], pl.PB(pint(i,j)), seen[i][j] = true;
		else sum_rem += fi[i][j];
	}
	if (sum_rem != sum_kiten) {
		return false;
	}

	//COUT(pl);

	if ( rec(pl[0].first, pl[0].second, 0, 0) ) return true;
	return false;
}

int main() {
	while (cin >> n) {  
		if (n == 0) break;
		if (solve()) puts("YES");
		else puts("NO");
	}
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const bool DEBUG = true;
#define ff first
#define ss second
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using ll = long long;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vii = vector<ii>;

int main(){
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	ll n;
	cin >> n;
	ll k = 0;
	for(ll i=1; i<=n; i+=2) ++k;
	cout << double(k/double(n)) << endl;
}


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

int main(){
  	int A,B,i;
  	bool flag=true;
	cin >> A >> B;
  	for(i=0;i<=1000;i++){
    	if((int)(i * 0.08) == A &&(int)(i * 0.1) == B){
          cout << i << endl;
          flag = false;
          break;
        }
    }
  	if(flag) cout << -1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(std::string X){
    int cnt=0;
    int res=0;
    REP(i,X.size()){
        if(X[i]=='S')cnt++;
        if(cnt>0 && X[i]=='T'){
            res++;
            cnt--;
        }
    }
    cout<<X.size()-res*2<<endl;
}

int main(){
    std::string X;
    std::cin >> X;
    solve(X);
    return 0;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	vector<P> ps(n);
	rep(i,n) ps[i] = P(a[i],i);
	sort(ps.rbegin(), ps.rend());

	ll INF = 1e18;
	vector<vector<ll>> dp(n+1,vector<ll>(n+1, -INF));
	rep(i,n+1) dp[0][i] = 0;

	rep(i,n){
		rep(j,n+1){
          	if(i < j) continue;
			dp[i+1][j] = max(dp[i+1][j], dp[i][j] + ps[i].first * (n-(i-j)-1 - ps[i].second));
			if(j+1 <= n) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + ps[i].first * (ps[i].second - j));
		}
	}

	ll res = 0;
	rep(i,n+1) res = max(res, dp[n][i]);
	cout << res << endl;
	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 34676