akhauriyash/Code-Regression huggingface dataset:
using System;

namespace _056_Goldbach_sConjecture
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != "0")
			{
				int inputNum = int.Parse (inputStr);
				int count = 0;

				bool result = Conjecture.IsConjecture (2, inputNum - 2);
				if (result)
					count++;

				for (int lp = 3; lp <= inputNum / 2; lp += 2)
				{
					bool result2 = Conjecture.IsConjecture (lp, inputNum - lp);
					if (result2)
						count++;
				}

				Console.WriteLine (count);
			}
		}
	}

	class Conjecture
	{
		static Conjecture ()
		{
			IsPrimeNumberArray = new bool[50000 + 1];
			IsPrimeNumberArray[2] = true;
			for (int lp = 3; lp <= 50000; lp += 2)
			{
				IsPrimeNumberArray[lp] = IsPrimeNumber (lp);
			}
		}

		private static bool[] IsPrimeNumberArray;

		private static bool IsPrimeNumber ( int num )
		{
			int lp = 3;
			while (lp <= Math.Sqrt (num))
			{
				if (num % lp == 0)
				{
					return false;
				}

				lp += 2;
			}

			return true;
		}

		public static bool IsConjecture ( int num, int num2 )
		{
			return IsPrimeNumberArray[num2] && IsPrimeNumberArray[num];
		}
	}
}

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n; cin >> n;
  int mn = INT_MAX , mx = INT_MIN;
 while(n--){
   int x; cin >> x;
   mn = min(x,mn) , mx = max(mx , x);
 }
  cout << mx - mn;
  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <deque>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> svector;
typedef vector <int> ivector;
typedef deque <int> ideque;

int main(void){
	int n,q,tmp,ptr,t;
	ideque que;

	cin >> n >> q;
	svector name(n);
	ivector time(n);
	for (int i=0; i<n; i++){
		cin >> name[i] >> time[i];
		que.push_back(i);
	}

	t = 0;
	while (!que.empty()){
		ptr = que[0];
		tmp = time[ptr];
		que.pop_front();
		if (tmp >=q){
			t += q;
			tmp -= q;
		}else{
			t += tmp;
			tmp = 0;
		}
		time[ptr]=tmp;

		if (tmp>0){
			que.push_back(ptr);
		}else{
			cout << name[ptr] << " " << t << endl;
			name[ptr]="";
		}
	}
	return 0;
}

Measured memory_bytes: 4184
#include <cmath>
#include <iostream>
#include <vector>
#include <tuple>

using lli=long long;
int main(){
  lli N,C;
  std::cin >> N >> C;

  std::vector<std::tuple<lli, lli>> x_arr(N+2);
  for(int i = 0; i < N; i++) std::cin >> std::get<0>(x_arr[i+1]) >> std::get<1>(x_arr[i+1]);
  x_arr[N+1] = std::make_tuple(C, 0);

  lli tmp=0, max_single=0, max_double=0;
  std::vector<lli> xa_arr(N+3), max_single_arr(N+3), max_double_arr(N+3);
  for(int i = 0; i < N+2; i++){
    tmp += std::get<1>(x_arr[i]);
    max_single = std::max(max_single, tmp-std::get<0>(x_arr[i]));
    max_double = std::max(max_double, tmp-2*std::get<0>(x_arr[i]));
    xa_arr[i+1] = tmp;
    max_single_arr[i+1] = max_single;
    max_double_arr[i+1] = max_double;
  }

  lli max_c = 0;
  for(int j = 0; j < N+1; j++){
    lli jc = xa_arr[N+1]-xa_arr[N+1-j];
    lli jl = C-std::get<0>(x_arr[N+1-j]);
    max_c = std::max(max_c, jc-2*jl+max_single_arr[N+1-j]);
    max_c = std::max(max_c, jc-jl+max_double_arr[N+1-j]);
  }

  std::cout << max_c << std::endl;

  return 0;
}



Measured memory_bytes: 4224
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [1]*n
for _ in range(m):
    a, b = map(int, input().split())
    a = a - 1
    b = b-1
    if (h[a] < h[b]):
        p[a] = 0
    elif (h[a] > h[b]):
        p[b] = 0
    else:
        p[a] = 0
        p[b] = 0
print(sum(p))


Measured memory_bytes: 20108
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int SideA = keyboard.nextInt();
		int SideB = keyboard.nextInt();
		int SideC = keyboard.nextInt();
		
		int[] arr = new int[] {SideA, SideB, SideC};
		Arrays.sort(arr);
		
		if (arr[0] == 5  && arr[1] == 5 && arr[2] == 7) {
				System.out.println("YES");					
			}else {
			System.out.println("NO");
		}	
		keyboard.close();	
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#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;


struct P {
  int y, x, dis;
};
int main() {
  int w, h;
  while(cin>>w>>h, w||h) {
    int gx,gy;
    vector<P> pv[2502];
    REP(i, h) {
      REP(j ,w) {
        string s;
        cin >> s;
        if (s[0] == 'S') {
          pv[0].push_back((P){i,j,0});
        } else if (s[0] == 'G') {
          gy = i;
          gx = j;
        } else if (s[0] != '.') {
          stringstream ss(s);
          int a;
          ss >> a;
          pv[a].push_back((P){i,j,INF});
        }
      }
    }
    int ans = INF;
    REP(i, 2500) {
      if (pv[i+1].size() == 0) {
        FOR(it, pv[i]) {
          int d = abs(it->x-gx) + abs(it->y-gy);
          ans = min(ans, it->dis+d);
        }
      }
      FOR(it, pv[i]) {
        FOR(jt, pv[i+1]) {
          int d = abs(it->x-jt->x) + abs(it->y-jt->y);
          jt->dis = min(jt->dis, it->dis + d);
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 1e5;
int n, m, color[MAX_N];
vector<int> g[MAX_N];

bool dfs(int u, int c)
{
	color[u] = c;
	for (int i = 0; i < g[u].size(); ++i)
	{
		int v = g[u][i];
		if (color[v] == c)
		{
			return false;
		}
		else if (color[v] == 0 && !dfs(v, -c))
		{
			return false;
		}
	}
	return true;
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	if (dfs(0, 1))
	{
		int64_t b = 0, w = 0;
		for (int i = 0; i < n; ++i)
		{
			if (color[i] == 1)
			{
				++b;
			}
			else if (color[i] == -1)
			{
				++w;
			}
		}
		cout << b * w - m << endl;
	}
	else
	{
		cout << 1LL * n * (n - 1) / 2 - m << endl;
	}
}

Measured memory_bytes: 6528
//                                                       ,.へ 
//___ 　　　　　　　 　 　 　 　 　　　　　　　　　　　    　ﾑ　　i 
//「 ﾋ_i〉　　　 　 　　　　　　 　 　　　　　　　　　　　　 ゝ　〈 
//ﾄ　ノ 　　　　　　　　　　　　　　　　　　　　　　　　  　　iニ(() 
//i 　{ 　 　　　　　　　 　　　＿＿＿_ 　 　　　　　　　  　| 　ヽ 
//i　　i　　　 　　　　　　　／__,　 , ‐-＼ 　 　 　 　 　　i 　　} 
//|　　 i　　　　　　 　　／（●) 　 ( ● )  ＼　　　　　　 {､　 λ 
//ト－┤.　　　　　   　／ 　 （__人__） 　　　＼　　　 ,ノ　￣ ,! 
//i　　　ゝ､_ 　　　　|　　　　　´￣` 　 　　　　|　,. '´ﾊ　　　,! 
//.　ヽ、 　　　｀`　､,__＼ 　　 　 　　　　　 　 ／"　＼ 　ヽ／ 
//＼ノ　ﾉ　　　ﾊ￣r/:::r―--―/::７　　 ﾉ　　　　／ 
//ヽ.　　　　　　ヽ::〈； . '::. :' |::/　　 /　　　,. " 
//`ｰ ､　　　　＼ヽ::. ;::：|/　　　　　ｒ'" 
//／￣二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二
/*| 答*/ import java.util.Arrays;import java.util.Scanner;public class Main{public static void main(String[]args){Scanner scan=new Scanner(System.in);int a=scan.nextInt();long w=0,h=0;int d[]=new int[a];int e[]=new int[a];int count=0;for(int i=0;i<a;i++) {d[i]=scan.nextInt();}Arrays.sort(d);for(int i=0;i<a;i++) {e[i]=d[a-i-1];}for(int i=1;i<a;i++) {if(e[i]==e[i-1]) {i++;if(count==0) {w=e[i-1];count++;}else {h=e[i-1];break;}}}System.out.println(w*h);}}//|| 
//＼＿二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二二


Measured memory_bytes: 50696
import itertools
n = int(input())
p = tuple(map(str, input().split()))
q = tuple(map(str, input().split()))
pc = 0
qc = 0
ans_l = list(itertools.permutations(p, n))
ans_l = sorted(ans_l)
for i in ans_l:
    pc += 1
    if i == p:
        break
for i in ans_l:
    qc += 1
    if i == q:
        break
print(abs(pc - qc))


Measured memory_bytes: 8308
#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() {
  vector<int> x(5,0);
  int ans;
  rep(i,5){
    cin >> x.at(i);
    if(x.at(i)==0) ans = i;
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 3624
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N, K;
    cin >> N >> K;
    V<ll> A(N);
    for (ll &e : A) cin >> e;
    sort(ALL(A));
    ll ok = 1e18, ng = -1e18;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        ll cnt = 0;
        for (ll e : A) {
            if (e == 0) {
                cnt += (0 <= mid ? N - 1 : 0);
                continue;
            }
            if (e < 0 && e * A.back() <= mid) {
                ll ok2 = N - 1, ng2 = -1;
                while (abs(ok2 - ng2) > 1) {
                    ll mid2 = (ok2 + ng2) / 2;
                    (e * A[mid2] <= mid ? ok2 : ng2) = mid2;
                }
                DEBUG(make_tuple(e, N - ok2, mid));
                cnt += N - ok2;
                cnt -= (e * e <= mid);
            } else if(0 < e && e * A[0] <= mid) {
                ll ok2 = 0, ng2 = N;
                while (abs(ok2 - ng2) > 1) {
                    ll mid2 = (ok2 + ng2) / 2;
                    (e * A[mid2] <= mid ? ok2 : ng2) = mid2;
                }
                DEBUG(make_tuple(e, ok2, mid));
                cnt += ok2 + 1;
                cnt -= (e * e <= mid);
            }
        }
        DEBUG(PLL(mid, cnt));
        (K <= cnt / 2 ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,m, ans = 0,lmax,rmin;
	string s;
	bool flag = true;

	cin >> n >> m;

	lmax = 0;
	rmin = n;

	vector<pair<ll, ll>> a(m);

	forll(i, 0, m)
		cin >> a[i].first >> a[i].second;

	forll(i, 0, m)
	{
		if (lmax < a[i].first-1)
			lmax = a[i].first-1;
		if (rmin > a[i].second - 1)
			rmin = a[i].second - 1;
	}

	forll(i, 0, n)
	{
		if (i >= lmax && i <= rmin)
			ans++;
	}

	cout << ans;

}

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

bool f[100001];
int c[100002];
int N ,L, R;

int main (){
    for(int i = 2; i <=100000; i++)
    {
        if(!f[i])
        {
            for(int j = i+i; j <= 100000; j += i) f[j] = true;
        }
    }

    for(int i = 3; i <= 100000; i +=2)
    {
        if(!f[i] && !f[(i+1)/2]) c[i]++;
    }

    for(int i = 3; i <= 100000; i++) c[i] += c[i-1];

    scanf("%d", &N);

    while(N--)
    {
        scanf("%d %d", &L, &R);
        printf("%d\n", c[R] - c[L-1]);
    }
}


Measured memory_bytes: 1152
#include<stdio.h>
int main(){
int N,s=0,x,max=0,i,j,a[100][1000];
char S[101];
scanf("%d %s",&N,S);
for(x=1;x<N;x++){
for(i=0;i<x;i++){
for(j=x;j<N;j++){
if(S[i]==S[j]&&a[x][S[j]]==0){
s++;
a[x][S[j]]++;
break;}
}
}
if(s>max){max=s;}
s=0;
}
printf("%d",max);
return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N; 
    cin >> N;

    ll a = 1;
    ll b = 1;

    rep(i, N){
      ll T, U;
      cin >> T >> U; // T:U

      ll c = (a+T-1)/T;
      ll d = (b+U-1)/U;
      ll n = max(c, d);

      a = T*n;
      b = U*n;
    }
    p(a+b);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string s;
	cin>>s;
	fore(i,0,s.size()){
		if(s[i]==',')s[i]=' ';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

template<int jt> struct ModInt {
	int x;
	ModInt(int v = 0) {x = v; if(x >= jt || x < 0) {x %= jt; if(x < 0) x += jt;}}
	ModInt(ll v) {x = v % jt; if(x < 0) x += jt;}
	operator int() const {return x;}
	friend inline ModInt &operator+=(ModInt &a, const ModInt &b) {a.x += b.x; if(a.x >= jt) a.x -= jt; return a;}
	friend inline ModInt operator+(ModInt a, const ModInt &b) {return a += b;}
	friend inline ModInt operator+(ModInt a, int b) {return a += ModInt(b);}
	friend inline ModInt operator+(int a, ModInt b) {return b += ModInt(a);}
	friend inline ModInt &operator++(ModInt &a) {return a += 1;}
	friend inline ModInt &operator-=(ModInt &a, const ModInt &b) {a.x -= b.x; if(a.x < 0) a.x += jt; return a;}
	friend inline ModInt operator-(ModInt a, const ModInt &b) {return a -= b;}
	friend inline ModInt operator-(ModInt a, int b) {return a -= ModInt(b);}
	friend inline ModInt operator-(int a, ModInt b) {return ModInt(a) - b;}
	friend inline ModInt &operator--(ModInt &a) {return a -= 1;}
	friend inline ModInt &operator*=(ModInt &a, const ModInt &b) {a.x = (ll)a.x * b.x % jt; return a;}
	friend inline ModInt operator*(ModInt a, const ModInt &b) {return a *= b;}
	friend inline ModInt operator*(ModInt a, int b) {return a *= ModInt(b);}
	friend inline ModInt operator*(int a, ModInt b) {return b *= ModInt(a);}
	static inline void exgcd(ll a, ll b, ll &x, ll &y) {b ? (exgcd(b, a % b, y, x), y -= a / b * x) : (x = 1, y = 0);}
	friend inline ModInt inv(const ModInt &a) {ll x, y; exgcd(a, jt, x, y); return x;}
	friend inline ModInt operator/(const ModInt &a, const ModInt &b) {return a * inv(b);}
	friend inline ModInt operator/(ModInt a, int b) {return a * inv(ModInt(b));}
	friend inline ModInt operator/(int a, ModInt b) {return ModInt(a) * inv(b);}
	friend inline ModInt operator/=(ModInt &a, const ModInt &b) {return a = a / b;}
};
const int jt = 1000000007;
typedef ModInt<jt> mint;

int n;

mint ksmii(mint a, int b) {
	if(!b) return 1;
	mint x = ksmii(a, b >> 1);
	x *= x; if(b & 1) x *= a;
	return x;
}

int main() {
	cin >> n;
	cout << ksmii(10, n) - 2 * ksmii(9, n) + ksmii(8, n) << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  cout << min((a+b),min((b+c),(c+a))) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n;
  ll sum = 0;
  cin >> n;
  vector<ll> a(n);
  vector<ll> ans(n);
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  rep(i,n) {
    a.push_back(a[i]);
  }
  ans[0] = sum;
  rep(j,n/2) {
    ans[0] -= 2*a[1+2*j];
  }
  rep(i,n-1) {
    ans[i+1] = 2*a[i] - ans[i];
  }
  rep(i,n) {
    cout << ans[i] << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3696
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<string> v;

char s[18], tt[18];
char temp[18];

pli trans(char ss[18]) {
	ll ret, t;
	int sum = 0;
	sscanf(ss, "%lld", &ret);
	t = ret;

	while (t) {
		sum += t % 10;
		t /= 10;
	}

	return pli(ret, sum);
}

int n;
void go(int o, int sst) {
	if (o == n) return;

	go(o + 1, 0);
	for (int i = '8'; i >= '0'; i--) {
		if (sst && i == '0') break;
 		memcpy(temp, s, sizeof(temp));
		temp[o] = i;

		// printf("%s////\n", temp);

		pli k = trans(s), kk = trans(temp);
		// 이게 앞에서부터 채우면 이렇게 되나??
		// 

		if (k.first * kk.second >= kk.first * k.second) {
			string st = temp;
			v.push_back(st);
			s[o] = i;
			go(o + 1, sst & (i == '0'));
			s[o] = '9';
		}
		else break;
	}
}

int main() {
	int k;
	scanf("%d", &k);


	// 14자리 쓰는 것.
	for (int i = 14; i >= 0; i--) {
		memset(s, 0, sizeof(s));

		for (int j = 0; j <= i; j++)
			s[j] = '9';

		string st = s;
		v.push_back(st);
		
		n = i + 1;
		go(0, 1);
	}

	int cnt = 0;
	for (auto i = v.rbegin(); cnt < k; i++) {
		printf("%s\n", i->c_str());
		cnt++;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int N,i,j,count1=0,count2=0;
	
	scanf("%d",&N);
	
	for(i=1;i<=N;i+=2){
		for(j=1;j<=i;j++){
			if(i%j==0){
				count1++;
			}
		}
		if(count1==8){
			count2++;
		}
		count1=0;
	}
	
	printf("%d\n",count2);
	
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void print_vector(vector<int> v){
  for(int i = 0; i < (int)v.size(); i++){
	  if (i == (int)v.size() - 1) cout << v[i];
	  else cout << v[i] << " ";  
	}
  cout << endl;	
}

void solve(){
  	int n, q;
  	vector<int> v;
  	cin >> n;
  	for(int i = 0; i < n; i++){
	  int x;
	  cin >> x;
	  v.push_back(x);	
	}
	cin >> q;
	for(int i = 0; i < q; i++){
	  int query;
	  cin >> query;
	  if (binary_search(all(v), query)) cout << 1 << endl;
	  else cout << 0 << endl;	
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3944
//#pragma comment (linker,"/STACK:256000000")
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000

#define INF 1000000000
#define LLINF 10000000000000000

typedef long long ll;

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int cnt = 0;


void insertion_sort(int *a, int n,int g)
{
	int i, j;
	int k;

	for (i = g; i < n; i++)
	{
		k = i;

		while (a[k] < a[k - g] && k>=g)
		{
			swap(&a[k], &a[k - g]);
			k-=g;
			cnt++;
		}
	}
}

/*
void insertion_sort(int *A, int n, int g) {
	int i, j, v;
	for (i = g; i < n; i++) {
		v = A[i];
		j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
}*/


void shell_sort(int *a, int n)
{
	long long int h=1;
	int m = 1;
	int G[100];
	int i, j;

	while ((h*3+1) < n)
	{
		h = h * 3 + 1;
		m++;
	}

	for (i = 0; i < m; i++)
	{
		G[i] = h;
		h /= 3;
	}

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

	for (i = 0; i < m; i++)
	{
		if (i == m - 1)
			printf("%d\n", G[i]);
		else
			printf("%d ", G[i]);
	}

	for (i = 0; i < m; i++)
		insertion_sort(a, n, G[i]);

	printf("%d\n", cnt);
}
/*

int GCD(int x, int y)
{
	if (x < y)
		swap(&x, &y);

	int z;

	while (y > 0)
	{
		z = x;
		x = y;
		y = z % y;
	}
	return x;
}

int prime(int x)
{
	int i, j;

	for (i = 2; i <= sqrt(x); i++)
	{
		if (x % i == 0)
			return -1;
	}

	return 1;
}

void bubble_sort(int* p, int n)
{
	int i, j;

	for (i = 0; i < n; i++)
	{
		for (j=n-1; j > i ; j--)
		{
			if (p[j] < p[j - 1])
			{
				swap(&p[j], &p[j - 1]);
				cnt++;
			}
		}
	}
}
*/

/*
void selection_sort(int* p, int n)
{
	int i, j, min;

	for (i = 0; i < n; i++)
	{
		min = i;
		for (j = i+1; j < n; j++)
		{
			if (p[j] < p[min])
				min = j;
		}
		if (min != i)
		{
			swap(&p[min], &p[i]);
			cnt++;
		}
	}
}*/


int binary_search(int* a, int n,int key)
{
	int low, middle, high;

	low = 0, high = n - 1;

	while (low <= high)
	{
		middle = (low + high) / 2;

		if (key < a[middle])
			high = middle - 1;
		else if (key > a[middle])
			low = middle + 1;
		else
			return 1;
	}
	return 0;
}

void reverse(int a[], int b, int e)
{
	int i;

	for (i = 0; i <= (e-b-1) / 2; i++)
	{
		swap(&a[b+i], &a[e - 1 - i]);
	}
}

int main()
{
	int n;
	int a[100000];
	int q;
	int k;

	scanf("%d", &n);

	int i, j;

	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);

	scanf("%d", &q);

	for (i = 0; i < q; i++)
	{
		scanf("%d", &k);
		if (binary_search(a, n, k))
			printf("1\n");
		else
			printf("0\n");
	}

	return 0;
}


Measured memory_bytes: 2100
N = int(input())
s = [0] * N
for i in range(N):
	s[i] = input()
ans = 0
for j in range(N):
	ans += s[j].count("AB")
acnt, bcnt, bacnt = 0, 0, 0
for k in range(N):
	if s[k][0] == "B" and s[k][-1] == "A":
		bacnt += 1
	elif s[k][0] == "B":
		bcnt += 1
	elif s[k][-1] == "A":
		acnt += 1
if acnt >= 1 and bcnt >= 1:
	ans += (bacnt + 1) + max(0, min(acnt - 1, bcnt - 1))
elif acnt >= 1 or bcnt >= 1:
	ans += bacnt
else:
	ans += max(0, bacnt - 1)
print(ans)


Measured memory_bytes: 3700
let n = read_int ()
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let k = Array.fold_left (fun c a -> if a = c then c + 1 else c) 1 a_s - 1
let _ = Printf.printf "%d\n" @@ if k = 0 then -1 else n - k

Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long int n,k;
  cin>>n>>k;
  long int arr[n],vec[n];
  for(long int j=0;j<n;j++)
  {
     cin>>vec[j];
  }
  arr[0] = 0;
  arr[1]=abs(vec[1]-vec[0]);
  for(long int p=2;p<n;p++)
  {
      arr[p]=INT_MAX;
      for(int r=1;r<=k;r++)
      {
        if(p-r>=0){
       arr[p] = min(arr[p],arr[p-r]+abs(vec[p]-vec[p-r]));
        }
    }
  }
  cout<<arr[n-1];

}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>

using namespace std;

int a[30][30];
int w, h, cnt;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

void search(int x, int y);

bool issearched[30][30];

int main()
{
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		char c;
		int is, js;
		cnt = 1;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> c;
				if(c == '.') a[i][j] = 1;
				else if(c == '#') a[i][j] = -1;
				else if(c == '@'){
					is = i;
					js = j;
				}
			}
		}
		search(is, js);
		cout << cnt << endl;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				a[i][j] = 0;
				issearched[i][j] = false;
			}
		}
	}
	return 0;
}

void search(int x, int y)
{
	int nx, ny;
	for(int i = 0; i < 4; i++){
		nx = x + dx[i];
		ny = y + dy[i];
		issearched[x][y] = true;
		if(nx >= h || ny >=w || nx < 0 || ny < 0) continue;
		if(a[nx][ny] == 1 && !issearched[nx][ny]){
			cnt++;
			search(nx, ny);
		}
	}
}

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

using namespace std;

int main()
{
  string s[3];
  for(int i = 0; i < 3; i++) cin >> s[i];
  int idx[3] = {0};
  int t = 0;
  while(idx[t] < s[t].size()) {
    switch(s[t][idx[t]]) {
    case 'a': idx[t]++, t = 0; break;
    case 'b': idx[t]++, t = 1; break;
    case 'c': idx[t]++, t = 2; break;
    }
  }
  cout << (char)('A'+t) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <math.h>

using namespace std;

void solve()
{
	int n, k;
	cin >> n >> k;
	long long cnt = 0;
	long long cnt_loop = n / k;
	if (k % 2 == 0)
	{
		
		long long cnt_half = cnt_loop;
		if (k * cnt_loop + k / 2 <= n) cnt_half++;

		cnt = cnt_half * cnt_half*cnt_half + cnt_loop * cnt_loop*cnt_loop;
	}
	else
	{
		cnt = cnt_loop * cnt_loop*cnt_loop;
	}
	
	cout << cnt << endl;
}

int main()
{

	solve();
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int>> mi;
typedef vector<vector<pair<int, int>>> w_graph;
typedef vector<vector<int>> uw_graph;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	#ifdef DEBUG
		freopen("out.txt", "w", stdout);
	#endif

	string s, s1; cin >> s >> s1;
	int n = s.size(), m = s1.size();
	int dp[n + 1][m + 1];
	ii p[n + 1][m + 1];
	
	for (int i = 0; i < n + 1; i++){
		for (int j = 0; j < m + 1; j++){
			dp[i][j] = 0;
			p[i][j] = {-1, -1};
		}
	}
	
	for(int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (s[i - 1] != s1[j - 1]){
				dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1]));
				if (dp[i - 1][j] > dp[i][j - 1]){
					dp[i][j] = dp[i - 1][j];
					p[i][j].first = i - 1;
					p[i][j].second = j;
 				}
 				else{
 					dp[i][j] = dp[i][j - 1];
					p[i][j].first = i;
					p[i][j].second = j - 1;
 				}
			}
			else{
				dp[i][j] = dp[i - 1][j - 1] + 1;
				p[i][j].first = i - 1;
				p[i][j].second = j - 1;
			}
		}
	} 
	string ans;
	int cn = n, cm = m;
	while(p[cn][cm].first != -1){
		if ((p[cn][cm].first != cn) && (p[cn][cm].second != cm)){
			ans = s[cn - 1] + ans;
		}
		int tn = p[cn][cm].first, tm = p[cn][cm].second;
		cn = tn; cm = tm;
	}
	
	cout << ans << endl;
	return 0;
}


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

using ull = unsigned __int128;

vector<int> res;

void Rolling_Hash(const string& a, const string& b) {
	const ull B = 100000007;
	int al = a.length(), bl = b.length();
	if (al > bl) return;

	ull t = 1, ah = 0, bh = 0;
	for (int i = 0; i < al; i++) t *= B;
	for (int i = 0; i < al; i++) ah = ah * B + a[i];
	for (int i = 0; i < al; i++) bh = bh * B + b[i];
	for (int i = 0; i + al <= bl; i++) {
		if (ah == bh) {
			res.push_back(i);
		}
		if (i + al < bl) bh = bh * B + b[i + al] - b[i] * t;
	}
}

int main()
{
	string T, P;
	cin.sync_with_stdio(false);
	cin >> T >> P;
	Rolling_Hash(P, T);
	for (auto &i : res) {
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 8928
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

template <class T>
T gcd(T a, T b)
{
    if (a < b) {
        return gcd(b, a);
    }
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


bool solve()
{
    std::int64_t a, b, c, d;
    std::cin >> a >> b >> c >> d;
    if (a < b) {
        return false;
    }
    if (d < b) {
        return false;
    }
    if (a % b > c) {
        return false;
    }
    auto g = gcd(b, d);
    if (b - c > g) {
        return false;
    }
    if (b - c == g) {
        if (a % b % g != 0) {
            return false;
        }
    }
    return true;
}

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

    int T;
    std::cin >> T;
    for (int i = 0; i < T; ++i) {
        if (solve()) {
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    int x, n;
    cin>>x>>n;
    VI p(n);
    REP(i,n) cin>>p[i];
    SORT(p);

    if (p.empty()) {
        cout<<x<<endl;
        return 0;
    }

    FOR(i,0, n + 10) {
        if (!COUNT(p,x-i)) {
            cout<<x-i<<endl;
            break;
        }
        if (!COUNT(p,x+i)) {
            cout<<x+i<<endl;
            break;
        }
    }


    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int ans = 0;
    int CMax = 0;
    for(int i = N; 0 < i; i--){
        int S = i;
        int Count = 0;
        while(S % 2 == 0){
            Count++;
            S /= 2;
        }
        CMax = max(CMax,Count);
        if(CMax == Count) ans = i;
    }
    cout << ans << endl;
}


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

int main()
{
 int n;
  cin >> n;
	int mn = 9999999;
  int cnt = 0;
  for (int i = 0;i < n;i++)
  {
	int tmp;
    cin >> tmp;
    if (mn >= tmp)
    {
     cnt++;
      mn = tmp;
    }
  }
  cout << cnt << endl;
}

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

int main(){
	string s;
	cin >> s;

	int fi = 200010;
	int la = 0;
	rep(i, s.size()){
		if(s.at(i) == 'A'){
			fi = min(fi, i);
		}else if(s.at(i) == 'Z'){
			la = max(la, i);
		}
	}

	cout << la-fi+1 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>          // printf(), scanf()

#define MAX_N 100
#define MAX_M 100

int
main(int argc, char** argv)
{
	int data[MAX_N + 1][MAX_M + 1];
	int n, m;
	int i, j;

	scanf("%d %d\n", &n, &m);
	for (i = 0; i < n; ++i)
	{
		data[i][m] = 0;
		for (j = 0; j < m; ++j)
		{
			scanf("%d", &data[i][j]);
			data[i][m] += data[i][j];
		}
	}

	for (j = 0; j <= m; ++j)
	{
		data[n][j] = 0;
		for (i = 0; i < n; ++i)
			data[n][j] += data[i][j];
	}

	for (i = 0; i <= n; ++i)
	{
		for (j = 0; j <= m; ++j)
			printf("%d%c", data[i][j], j != m ? ' ' : '\n');
	}

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define test(a) cout << "*" << a << endl
int main(){
  int i,j;
  int n;
  int a[100];
  int aMin,aMax;
  
  
  cin >> n;
  rep0(i,n){
    cin >> a[i];
    if(i==0){
      aMin = a[i];
      aMax = a[i];
    }
    if(a[i]<aMin)
      aMin = a[i];
    if(aMax<a[i]){
      aMax = a[i];
      //test(aMax);
    }
  }
  //test(aMin);
  //test(aMax);
  //
  cout << aMax - aMin << endl;
  
  
  
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] wjy) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		Graph g = new Graph(num);
		for (int i=0;i<num;i++) {
			for (int m =0;m<num;m++) {
				int we = sc.nextInt();
				g.setEdge(i,m,we);
			}
		}
		//for (int i =0;i<g.getV();i++) {
		//	System.out.println(g.getAdj(i));
		//}
		System.out.println(g.getMst());
	}
	static class Graph{
		public Vertice[] ver;
		public int[][] matrix;
		public Graph(int n) {
			this.ver= new Vertice[n];
			for (int i=0;i<n;i++) {
				this.ver[i] = new Vertice(i);
			}
			this.matrix=new int[n][n];
		}
		
		public int getV() {
			return this.ver.length;
		}
		
		public void setEdge(int n,int m,int we) {
			this.matrix[n][m] = we;
		}
		
		public ArrayList<ArrayList<Integer>> getAdj(int n){
			ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>();
			int m = this.getV();
			for (int i=0;i<m;i++) {
				if (this.matrix[n][i] !=-1) {
					ArrayList<Integer> arr = new ArrayList<Integer>();
					arr.add(i);
					arr.add(this.matrix[n][i]);
					a.add(arr);
				}
			}
			return a;
		}
		
		public int getMinVe(ArrayList<Integer> arr) {
			int index = -1;
			int m=Integer.MAX_VALUE;
			for (int i=0;i<arr.size();i++) {
				if (this.ver[arr.get(i)].value<=m) {
					index = i;
					m = this.ver[arr.get(i)].value;
				}
			}
			return index;
		}
		
		public int getMst(){
			//ArrayList<int[]> al= new ArrayList<int[]>();
			int mindis =0;
			ArrayList<Integer> q = new ArrayList<Integer>();
			for (int i=0;i<this.getV();i++) {
				q.add(i);
			}
			this.ver[0].setValue(0);
			while (!q.isEmpty()) {
				//for (int i=0;i<this.getV();i++) {
				//	System.out.println(this.ver[i]);
				//}
				//System.out.println();
				int index = this.getMinVe(q);
				//System.out.println(index);
				int m = q.remove(index);
				this.ver[m].setVisit();
				if (this.ver[m].parent != -20) {
					int k =this.ver[m].parent;
					int l =this.ver[m].key;
					mindis = mindis + this.matrix[k][l];
				} 
				ArrayList<ArrayList<Integer>> arr = this.getAdj(m);
				for (int i=0;i<arr.size();i++) {
					int ve = arr.get(i).get(0);
					if (this.ver[ve].visit == 0) {
						int we = arr.get(i).get(1);
						if (we<this.ver[ve].value) {
							this.ver[ve].setValue(we);
							this.ver[ve].setParent(m);
						}
					}
				}
				
			}
			return mindis;
			
		}
	}
	
	static class Vertice{
		public int key;
		public int value;
		public int parent;
		public int visit;
		//@SuppressWarnings("null")
		public String toString() {
			return this.value +" "+ this.parent+" "+this.visit; 
		}
		public Vertice(int num) {
			this.key = num;
			this.value = Integer.MAX_VALUE;
			this.parent = -20;
			this.visit=0;
		}
		
		public void setValue(int k) {
			this.value =k;
		}
		
		public void setParent(int n) {
			this.parent =n;
		}
		
		public int getParent() {
			return this.parent;
		}
		public void setVisit() {
			this.visit = 1;
		}
	}
}



Measured memory_bytes: 41848
#include <stdio.h>
#include <math.h>
  
#define ELEMENT_CNT_MIN 1
#define ELEMENT_CNT_MAX 1000000
#define ELEMENT_MIN 0
#define ELEMENT_MAX 1000000000
#define SHELL_SROT_CNT_MIN 1
#define SHELL_SROT_CNT_MAX 100
 
void shell_sort(int *p_arr, int size);
int insertion_srot(int *p_arr, int size, int interval);
void put_arr(int *p_arr, int size);
int get_int_sequence(int *p_num, int min, int max, int size);
int get_int(int *p_num, int min, int max);
int judge_constraint(int test_num, int min, int max);
 
  
int main(void){
      
    int element_num;
    int element[ELEMENT_CNT_MAX];
      
    if(get_int(&element_num, ELEMENT_CNT_MIN, ELEMENT_CNT_MAX) == -1)
    {
        return -1;
    }
      
    if(get_int_sequence(&element[0], ELEMENT_MIN, ELEMENT_MAX, element_num) == -1)
    {
        return -1;
    }
     
    shell_sort(&element[0], element_num);
     
    put_arr(&element[0], element_num);
     
    return 0;
}
  
int insertion_srot(int *p_arr, int size, int interval)
{
    int cnt = 0;    /* calculation amount */
    int i;
    int j;
    int locator;
     
    for(i = interval; i < size; i++)
    {
        locator = p_arr[i];
        j = i - interval;
        while(j >= 0 && p_arr[j] > locator)
        {
            p_arr[j + interval] = p_arr[j];
            j = j - interval;
            cnt++;
        }
        p_arr[j + interval] = locator;
    }
     
    return cnt;
}
 
void shell_sort(int *p_arr, int size)
{
   int cnt = 0;
   int interval = 1;    /* (pow(3, 0) - 1) / 2 == 0 */
   int i;
   int shell_sort_cnt = SHELL_SROT_CNT_MIN;
    
  for(i = shell_sort_cnt ;i <= SHELL_SROT_CNT_MAX; i++)
  {
      interval =  (int)((pow(3, i) - 1) / 2);
      if(interval > size)
      {
          shell_sort_cnt = i - 1;
          printf("%d\n",shell_sort_cnt);
          break;
      }
  }
    
    
   for(i = shell_sort_cnt;;i--)
   {
       interval =  (int)((pow(3, i) - 1) / 2);
       cnt += insertion_srot(p_arr, size, interval);
       printf("%d ", interval);
       if(interval <= 1)
       {
           printf("\n");
           break;
       }
   }
    
   printf("%d\n", cnt);
    
   return;
}
  
void put_arr(int *p_arr, int size)
{
    int i;
      
    for(i = 0; i < size; i++)
    {
        printf("%d\n", p_arr[i]);
    }
     
    return;
}
  
int get_int_sequence(int *p_num, int min, int max, int size)
{
    int i;
      
    for(i = 0; i < size; i++)
    {
        if(get_int(&p_num[i], min, max) == -1)
        {
            return -1;
        }
    }
      
    return 0;
}
  
int get_int(int *p_num, int min, int max)
{
    scanf("%d%*c", p_num);
      
    if(judge_constraint(*p_num, min, max) == -1)
    {
        return -1;
    }
      
    return 0;
}
int judge_constraint(int test_num, int min, int max)
{
    if(test_num < min || test_num > max)
    {
        return -1;
    }
      
    return 0;
}

Measured memory_bytes: 5796
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
summ = 0
count = 0
for i in range(N):
    summ += A[i]

for i in range(N):
    if A[i] >= summ / (4 * M):
        count += 1

if count >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

bool is_even(vector<int> &a)
{
	for (int i = 0; i < (int)a.size(); i++) {
		if (a[i] % 2 != 0) {
			return false;
		}
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n);
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	int cnt = 0;

	while (is_even(a)) {
		cnt++;
		for (i = 0; i < n; i++) {
			a[i] /= 2;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int A,B,C,K; cin >> A >> B >> C >> K;
    int cnt = 0;
    while (A >= B) {
        cnt++;
        B <<= 1;
    }
    while (B >= C) {
        cnt++;
        C <<= 1;
    }
    cout << (cnt <= K ? "Yes" : "No") << ln;
}

Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<vector<bool>> board(N, vector<bool>(N));
		rep(i, N) rep(j, N)
			board[i][j] = (i + j) % 2 == 0;
		rep(i, N) board[i][0] = board[i][N - 1] = true;
		rep(j, N) board[0][j] = board[N - 1][j] = true;
		rer(k, 1, 20) {
			rep(i, N >> (k - 1)) rep(j, N >> (k - 1)) if((i + j) % 2 == 1) {
				int y = ((i + 1) << k);
				int x = ((j + 1) << k) - 1;
				if(y < N && x < N)
					board[y][x] = true;
			}
		}
		vpii ans;
		rep(i, N) rep(j, N) if(board[i][j] != ((i + j) % 2 == 0)) {
			assert(board[i][j]);
			ans.emplace_back(i, j);
		}
		printf("%d\n", (int)ans.size());
		for(int i = 0; i < (int)ans.size(); ++ i)
			printf("%d %d\n", ans[i].first, ans[i].second);
	}
	return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
using namespace std;
int h[100005];
int dp[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>h[i];
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 4328