akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var d = G;
		Array.Sort(d);
		WriteLine(d[N / 2] - d[N / 2 - 1]);
	}
}
static class Func
{
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	public static long GCD(long a, long b)
	{
		var n = (ulong)Math.Abs(a); var m = (ulong)Math.Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Math.Min(zm, zn);
	}
	public static long Inverse(long a, long mod)
	{
		if (a < 0) { a %= mod; if (a < 0) a += mod; }
		var t = SolveLinear(a, mod);
		return t.Item1 > 0 ? t.Item1 : t.Item1 + mod;
	}
	public static long Pow(long a, long b, long mod)
	{
		var p = 1L;
		var x = a;
		while (b > 0)
		{
			if ((b & 1) == 1) p = (p * x) % mod;
			b >>= 1;
			x = (x * x) % mod;
		}
		return p;
	}
	public static Tuple<long, long> SolveLinear(long n, long m)
	{
		if (n < 0) { var p = SolveLinear(-n, m); return p == null ? p : new Tuple<long, long>(-p.Item1, p.Item2); }
		if (m < 0) { var p = SolveLinear(n, -m); return p == null ? p : new Tuple<long, long>(p.Item1, -p.Item2); }
		if (n < m) { var p = SolveLinear(m, n); return p == null ? p : new Tuple<long, long>(p.Item2, p.Item1); }
		long a = 1, b = 0, c = 0, d = 1;
		while (m > 0)
		{
			var r = n % m;
			var q = n / m;
			n = m;
			m = r;
			var tmp = a;
			a = -a * q + b;
			b = tmp;
			tmp = c;
			c = -c * q + d;
			d = tmp;
		}
		return n != 1 ? null : new Tuple<long, long>(d, b);
	}
}


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

int main()
{
	int n;
	int max_ = 0;
	cin >> n;

	for (int i = 0; i * i <= n; i++)
	{
		max_ = max(max_, i * i);
	}
	cout << max_ << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (char& c : s) {
        int next = (c - 'A') + n;
        if (next >= 26) next -= 26;
        c = 'A' + next;
    }
    OUT(s);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int d;
	cin >> d;
	cout << "Christmas ";
	for(int i = d; i < 25; i++){
		cout << "Eve ";
	}
	cout << endl;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)



int main() {
    int N;
    cin >>N;

    vector<string> s(N);
    rep(i,N) cin >> s[i];
    rep(i,N) sort(s[i].begin(),s[i].end());
    sort(s.begin(),s.end());
    s.push_back("");
    ll K=0;
    ll ans=0;
    rep(i,N){
        if(s[i]==s[i+1])K++;
        else if(K!=0){
            K++;
            ans+= K*(K-1)/2;
            K=0;
        }
    }
    cout<< ans<<endl;


    return (0);
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int MX=100010;


char S[MX];
int n, m, k;
struct ord {
	int l, r;
	void scan(){
		cin>>l>>r;
	}
	void norm(){
		if(r<=k) return;
		if(k<l){ tie(l,r)=pii(n-r+1, n-l+1); return; }
		if(l<=n-r+1) r=n-r;
		else if(n-l+1<=r) tie(l,r)=pii(n-r+1,l-1);
		else assert(false);
	}
} V[MX];
int A[MX], B[MX];

int U[MX];
int find(int x){ return x==U[x] ? x : U[x]=find(U[x]); }
void unite(int x, int y){ U[find(y)]=find(x); }

bool solve(){
	int sum[MX]={};

	for(int i=1; i<=k+1; i++){
		sum[find(i)]+=B[i];
	}
	for(int i=1; i<=k+1; i++) if(sum[i]%26!=0) return false;
	return true;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>(S+1)>>m;
	for(n=1; S[n+1]!='\0'; n++);
	k=n/2;
	for(int i=1; i<=k+1; i++) U[i]=i;

	for(int i=1; i<=m; i++) V[i].scan(), V[i].norm();
	for(int i=1; i<=k; i++) A[i]=(S[i]-S[n-i+1]+26)%26;
	for(int i=1; i<=k+1; i++) B[i]=(A[i]-A[i-1]+26)%26;

	for(int i=1; i<=m; i++) unite(V[i].l, V[i].r+1);

	cout<<(solve() ? "YES" : "NO")<<'\n';


	return 0;
}

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


using namespace std;

int main (){
  int i,N,odd,even;
  cin >> N;
  odd=0;
  even=0;
  vector<int> input(N);
  for(i=0;i<N;i++){
    cin >> input.at(i);
  }
  for(i=0;i<N;i++){
    if((input.at(i) % 2) == 0){
//      cout << input.at(i)<<"even" << endl;
      even++;
    } else{
  //    cout << input.at(i)<<"odd" << endl;
      odd++;
    }
  }
  if((odd%2) == 0){
    cout << "YES" << endl;
  } else{
    cout << "NO" << endl;
  }
  return 0;
}





Measured memory_bytes: 640
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  int q, h, s, d;
  cin >> q >> h >> s >> d;
  int n;
  cin >> n;
  int nn = n;

  int flag;
  if(q*4 <= s && q*4 <= h*2) flag = 0;
  else if(h*2 <= s && h*2 <= q*4) flag = 1;
  else if(s <= h*2 && s <= q*4) flag = 2;
  else assert(false);

  // cout << flag << endl;

  ll ret = 0;
  ret += n/2*d;
  // cout << ret << endl;
  n %= 2;
  if(n) {
    if(flag == 0) ret += q*4;
    else if(flag == 1) ret += h*2;
    else if(flag == 2) ret += s;
  }
  n = nn;
  ll ans = ret;
  ret = 0;
  if(flag == 0) ret += q*4*n;
  else if(flag == 1) ret += h*2*n;
  else if(flag == 2) ret += s*n;

  // cout << ret << " " << ans << endl;
  cout << min(ret, ans) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll H, W,an=0;
	cin >> H >> W;
	string S,k="Impossible";
	rep(i, H) {
		cin >> S;
		rep(j, W) {
			if (S.at(j) == '#') {
				an++;
			}
		}
	}
	if (an == H + W - 1) {
		k = "Possible";
	}
	cout << k << endl;


}



Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long H;
  scanln(H);

  long rec(long n) {
    if (n == 1) return 1;
    return 1 + 2*rec(n/2);
  }
  rec(H).writeln;
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int N;
	long long int b,ans=0;
	cin>>N;
	vector<long long int> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
		A[i]-=i+1;
	}
	sort(A.begin(),A.end());
	b=A[N/2];
	for(int i=0;i<N;i++){
		ans+=abs(A[i]-b);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int N,i;
char s[99][99];

int ch(int b)
{
	int j=0,a=0,t[]={5,7,5,7,7};
	for(;b<N;b++)
	{
		a+=strlen(s[b]);
		if(a>=t[j])
		{
			if(a==t[j])
			{
				j++;a=0;
				if(j==5)return 1;
			}
			else return 0;
		}
	}
}

int main()
{
	for(;scanf("%d",&N),N;)
	{
		for(i=0;i<N;i++)scanf("%s",s[i]);
		for(i=0;i<N;i++)
		{
			if(ch(i))
			{
				printf("%d\n",i+1);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 616
#include<iostream>
#include<map>
#include<string>
#include<queue>

int dir[4] = { -1, -4, 1, 4 };
std::map<std::string, int> res;

void bfs()
{
	std::queue<std::string> que;
	que.push( "01234567" );

	while( !que.empty() )
	{
		std::string p = que.front(); que.pop();

		int s;
		for( int i = 0; i != 8; ++i )
			if( p[i] == '0' )
				s = i;

		for( int i = 0; i != 4; ++i )
		{
			int ns = s + dir[i];

			if( ns < 0 || ns > 7 || ( s == 3 && i == 2 ) || ( s == 4 && !i ) )
				continue;

			std::string q = p;
			std::swap( q[s], q[ns] );

			if( !res[q] )
			{
				que.push( q );
				res[q] = res[p] + 1;
			}
		}
	}

	return;
}

int main()
{
	res["01234567"] = 1;

	bfs();

	while( true )
	{
		std::string s;

		for( int i = 0; i != 8; ++i )
		{
			int a;
			if( !( std::cin >> a ) )
				return 0;
			
			s += a + '0';
		}

		std::cout << res[s] - 1 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (int)(n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
const int N = 555;
int n;
char str[N][N], T[N][N];
int main(void) {
	read(n);
	rep (i, n) scanf("%s", str[i] + 1);
	int ans = 0;
	rep (A, n) {
		rep (i, n) rep (j, n) 
			T[i][j] = str[(i + A - 1) % n + 1][j];
		int ok = 1;
		rep (i, n) rep (j, n) ok &= T[i][j] == T[j][i];
		ans += ok * n;
	}
	cout << ans << "\n";	
}


Measured memory_bytes: 640
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<x;l=m;else;r=m;end;end;l;end

function main()
	n,k = readline() |> split |> parseMap
	h = readline() |> split |> parseMap |> sort
	println(n-bsearch(h,k))
end

main()

Measured memory_bytes: 168228
#include <iostream>
#include <cstdio>
using namespace std;
int main() { 
  int count=0;  
  char str[21]={}; 
  while(scanf("%c",&str[count])) {  
    if(str[count] == '\n') break;
    count++;
  } 
  for(int i=count-1; i>=0; i--) {  
    cout << str[i];  
  } 
  cout << endl; 
  return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main() {
	int a, b, c,d;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	d = (a - b) / c;
	printf("%d\n", a - b - c * d);
	return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
MOD=10**9+7
total=(pow(2,n,MOD)-1)%MOD
na=1
nb=1
atotal=1
btotal=1
for i in range(a):
    na=(na*(n-i))%MOD
for i in range(b):
    nb=(nb*(n-i))%MOD
for i in range(1,a+1):
    atotal=(atotal*i)%MOD
for i in range(1, b + 1):
    btotal = (btotal * i) % MOD
atotal=pow(atotal,MOD-2,MOD)%MOD
btotal=pow(btotal,MOD-2,MOD)%MOD
ans=total%MOD-(na*atotal)%MOD-(nb*btotal)%MOD
print(ans%MOD)

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

int main()
{
    int n, Max = 0;

    cin >> n;
    int I_a[n], I_b[n];

    for(int i = 0;i < n;i++)  // Input mode
        cin >> I_a[i];

    for(int i = 0;i < n;i++)
    {
        if(i != 0)
            I_a[i] = I_a[i-1] + I_a[i];
    }

    for(int i = 0;i < n;i++)  // Input mode
        cin >> I_b[i];

    for(int i = n-1;i >= 0;i--)
    {
        if(i != n-1)
            I_b[i] = I_b[i+1] + I_b[i];
    }
    for(int i = 0;i < n;i++)
    {
        if(I_a[i] + I_b[i] >= Max)
            Max = I_a[i] + I_b[i];
    }

    cout << Max << endl;
    return 0;
}


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

int main ()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int xy = max(x, y);
  int res = 1e9;
  for (int i = 0; i <= xy; i++)
  {
    int temp;
    temp = c * i * 2;
    temp += a * max(x - i, 0);
    temp += b * max(y - i, 0);
    res = min(res, temp);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
/*
注意范围！
short范围：-32768~32767
unsigned short范围：0~65535
int范围：-2147483648~2147483647
uint范围：0~4294967295
INT范围：-9223372036854775808~9223372036854775807
UINT范围：0~18446744073709551615
float范围：-3.4e38～3.4e38，精度：6~7位
double范围：-1.7e308~1.7e308，精度：15~16位
ldouble范围：-1.2e4932~1.2e4932，精度：18~19位
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;

int main()
{
	int n;
	cin>>n;
	if(n==1)OVER("1");
	if(n>=2&&n<4)OVER("2");
	if(n>=4&&n<8)OVER("4");
	if(n>=8&&n<16)OVER("8");
	if(n>=16&&n<32)OVER("16");
	if(n>=32&&n<64)OVER("32");
	if(n>=64)OVER("64");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int n;
    scanf("%d",&n);
    int count=0;
    for(int i=1;i<=n;i++){
        int p=log10(i)/1;
        p++;
        if(p%2!=0)
            count++;
    }
    printf("%d\n",count);
    return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  int A,B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(U == S){
  	A -= 1;
  }else if(U == T){
  	B -= 1;
  }
  cout << A << " " << B << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

ll dp[110][101010];
ll w[110], v[110];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, W; cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, N) {
        reps(j, W) {
            if (j + w[i] <= W) {
                chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
            }
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,X;cin >> A >> B >> X;
  YESNO( A<=X && A+B>=X );
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long ll;
 string s,s1;
int len,len1;
int dd(int i)
{
    int j=0;
    int sum=0;
    while(i<len&&j<len1)
     {
      if(s[i]!=s1[j])sum++;
      i++;j++;
      }
      return sum;
}

int main()
{

    cin>>s>>s1;
    int Max=0;
     len=s.size();
     len1=s1.size();
     int Min=len1;
    for(int i=0;i<=len-len1;i++)
    Min=min(Min,dd(i));

    cout<<Min;

}


Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

ll dp[51][51][2501];

int main(int argc, char const* argv[])
{
  int n, a;
  cin >> n >> a;
  vector<int> x;
  for(int i = 0; i < n; i++){
    int y;
    cin >> y;
    x.pb(y);
  }
  dp[0][0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= i + 1; j++){
      if(j == 0)dp[i + 1][j][0] = 1;
      else dp[i + 1][j][0] = 0;
      for(int k = 1; k <= a * n; k++){
        dp[i + 1][j][k] = dp[i][j][k];
        if(j > 0 && k >= x[i])dp[i + 1][j][k] += dp[i][j - 1][k - x[i]];
      }
    }
  }
  ll res = 0;
  for(int i = 1; i <= n; i++){
    res += dp[n][i][i * a];
  }
  cout << res << endl;
	return 0;
}


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

int main()
{
    string ss;
    cin >> ss;
    int ca=0;
    for(int i=0;i<3;i++)
    {
        if(ss[i]=='A')  ca++;
    }
    if(ca==0)   cout << "No\n";
    else if(ca==3)  cout << "No\n";
    else    cout << "Yes\n";
    return 0;
}

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

int main () {
	string str;
	int q;
	cin >> str >> q;
	for (int i=0;q>i;i++){
		string order;
		int a,b;
		cin >> order >> a >> b;
		if (order=="print") cout << str.substr(a,b-a+1) << endl;
		if (order=="reverse") reverse(str.begin()+a,str.begin()+b+1);
		if (order=="replace"){
			string rep;
			cin >> rep;
			str.replace(a,b-a+1,rep);
		}
	}
}


Measured memory_bytes: 3180
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 y00

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll bt = 30;
const ld eps = 1e-9;
const ll INF = (ll)(1e18 + 239);
const int BIG = (int)(2e9 + 239);
const int MOD = 998244353; //1e9 + 7;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

//constants
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 20;
const int T = (1 << 20);
const int B = (int)sqrt(M);
const int X = 1e4 + 239;

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--, b--, c--, d--;
    string s;
    cin >> s;
    if (c > d)
    {
        bool ch = false;
        for (int i = b; i <= d; i++)
            if (s[i - 1] == '.' && s[i + 1] == '.' && s[i] == '.')
                ch = true;
        if (!ch)
        {
            cout << "No";
            return 0;
        }
    }
    for (int i = a; i < c; i++)
        if (s[i] == '#' && s[i + 1] == '#')
        {
            cout << "No";
            return 0;
        }
    for (int i = b; i < d; i++)
        if (s[i] == '#' && s[i + 1] == '#')
        {
            cout << "No";
            return 0;
        }
    cout << "Yes";
    return 0;
}

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

int main()
{
  int n,m;
  cin>>n>>m;
  int matrix[n][m];
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < m; ++j)
    {
      cin>>matrix[i][j];
    }
  }
  int vec[m];
  for (int i = 0; i < m; ++i)
  {
    cin>>vec[i];
  }
  for (int i = 0; i < n; ++i)
  {
    int c=0;
    for (int j = 0; j < m; ++j)
    {
      c+=matrix[i][j]*vec[j];
    }
    cout<<c<<endl;
  }
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる
//std::binary_search(v.bgn,v.en,a);
//abs(a,b)   pow(a,n)  to_string  stoll
//auto Iter=lower_bound(v.bgn,v.en,a);
//lower//upper  co(*Iter)co(Iter-v.bgn);

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n,k;
  cin>>n>>k;
  vll v(n);
  FOR(i,0,n){
    cin>>v[i];
  }
  vll c(n);
  vll d(n);
  ll ans=0;
  FOR(i,0,n){
    for(ll j=i;j>=0;j--){
      if(v[i]<v[j]){
        c[j]++;
      }
    }
    FOR(j,i,n){
      //co(v[i]<<" "<<v[j]);
      if(v[i]<v[j]){
        d[j]++;
      }
    }
  }
  FOR(i,0,n){
    //co(c[i]);
    ans+=c[i]*(k*(k+1)/2%MOD)%MOD;
    ans%=MOD;
  }
  FOR(i,0,n){
    //co(d[i]);
    ans+=d[i]*(k*(k-1)/2%MOD)%MOD;
    ans%=MOD;
  }
  co(ans);
}
  

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

bool linearSearch(int A[], int k, int n){
    A[n] = k;
    int i = 0;
    while(A[i] != k){
        i++;
    }
    // printf("i: %d\n", i);
    return i!=n;
}

bool linearSearch2(int A[], int k, int n){
    rep(i,n){
        if(A[i] == k) return true;
    }
    return false;
}

int main()
{
    int n; cin >> n;
    int A[n+1];
    rep(i,n) cin >> A[i];
    int q; cin >> q;
    int sum = 0;
    rep(_,q){
        int x; cin >> x;
        if(linearSearch2(A, x, n)) sum++;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3140
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
lli power(int x)
{
    lli ans=1ll,p=2ll;
    while(x)
    {
        if(x&1)
            ans=ans*p%MOD;
        p=p*p%MOD;
        x>>=1;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,x=0;bool flag=false;lli res=0ll;
    cin>>n;
    map<int, int> m;
    for(int i=0;i<n;++i)
    {
        cin>>x;
        ++m[x];
    }
    if(n&1)
    {
        if(m[0]>1)
            flag=true;
        else
        {
            for(int i=1;i<n;++i)
            {
                if(m[i]>2||m[i]==1)
                    flag=true;
                if(flag)
                    break;
            }
        }
        if(!flag)
            res=power(n/2);
    }
    else
    {
        if(m[0]>0)
            flag=true;
        else
        {
            for(int i=1;i<n;++i)
            {
                if(m[i]>2||m[i]==1)
                    flag=true;
                if(flag)
                    break;
            }
        }
        if(!flag)
            res=power(n/2);
    }
    if(flag)
        cout<<"0";
    else
        cout<<res;
    cout<<endl;
}

Measured memory_bytes: 4992
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D - All Your Paths are Different Lengths
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 20;
const int MAX_M = 60;

/* typedef */

struct Edge {
  int i, j, d;
  Edge() {}
  Edge(int _i, int _j, int _d): i(_i), j(_j), d(_d) {}
};

/* global variables */

Edge es[MAX_M];

/* subroutines */

/* main */

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

  int n = 0, m = 0;
  for (int bi = 1; (bi << 1) <= l; n++, bi <<= 1) {
    es[m++] = Edge(n, n + 1, 0);
    es[m++] = Edge(n, n + 1, bi);
  }

  int x = 1 << n;
  for (int i = n - 1, bi = 1 << i; i >= 0; i--, bi >>= 1)
    if (l & bi) {
      es[m++] = Edge(i, n, x);
      x += bi;
    }

  printf("%d %d\n", n + 1, m);
  for (int i = 0; i < m; i++) {
    Edge &e = es[i];
    printf("%d %d %d\n", e.i + 1, e.j + 1, e.d);
  }
  return 0;
}


Measured memory_bytes: 256
#include<stack>
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;(int) (n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
using namespace std;
int main(){
ll n,a,b;
cin >> n >> a >> b;
ll ans=0;
ans+=n/(a+b);
n-=ans*(a+b);
ans*=a;
ans+=min(a,n);
cout << ans << endl;
return 0;

}


Measured memory_bytes: 256
n,k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf') for i in range(n)]
dp[0] = 0

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
    
for i in range(n-1):
    if i == 0:
        dp[i+1] = abs(h[i+1] - h[i])
    else:
        for j in range(k):
            dp[i+1] = chmin(dp[i+1], dp[i-j] + abs(h[i+1] - h[i-j]))
print(dp[n-1])

Measured memory_bytes: 57440
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define vit vector<int> :: iterator 
#define all(ans) ans.begin(),ans.end()
//#define sz(a) int(a.size())
#define ub upper_bound
#define lb lower_bound
#define create(Name,N,M,val) vector<vector<int> > Name(N,vector<int>(M,val))
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
//#define all(c) c.begin(),c.end()
#define tr(c,it) for(typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define mpr make_pair
#define pb push_back
void solve()
{
int n, m, x;
  cin>>n>>m>>x;
  vi c(n), t(m, 0);
  vector<vi> a(n, vi(m));
  rep(i, 0, n) {
    cin>>c[i];
    rep(j, 0, m) {
    cin>>a[i][j];
      t[j] += a[i][j];
    }
  }
  int mn = 1e7;
  rep(i, 0, m)
    mn = min(mn, t[i]);
  if (mn < x) {
    cout<<"-1";
    return;
  }
 
  int ans = 1e8;
  rep(i, 0, (1 << n)) {
    int cost = 0;
    t.assign(m, 0);
    rep(j, 0, n) if (i & (1 << j)) {
      rep(k, 0, m) t[k] += a[j][k];
      cost += c[j];
    }
    mn = 1e7;
    rep(j, 0, m)
      mn = min(mn, t[j]);
    if (mn >= x)
      ans = min(ans, cost);
  }
 
  cout<<ans;

return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}


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

int main(void){
  int n,x;
  int d=0;
  int c=0;
  vector<int> l;
  cin >> n >> x;
  l.resize(n);
  for(auto& i:l){
    cin >> i;
  }
  for(int i=1;i<=n+1&&d<=x;i++){
    d+=l[i-1];
    c++;
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char c;
  scanf("%c",&c);
  switch(c){
    case 'A':
      puts("T");
      break;
    case 'T':
      puts("A");
      break;
    case 'G':
      puts("C");
      break;
    case 'C':
      puts("G");
      break;
      
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;

#define MOD 1000000007ll
#define pb     push_back
#define mp     make_pair
#define MAX 100005
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()

int main(int argc, char const *argv[])
{
  int a , b;
  cin >> a >> b;
  int c = a + b;

  if(c < 10)
  	cout << c;
  else
  	cout << "error";

  return 0;
}  

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

std::string name(const uint64_t p, const uint64_t x) {
  std::string p_s = std::to_string(p);
  p_s.insert(p_s.begin(), 6 - p_s.size(), '0');
  std::string x_s = std::to_string(x);
  x_s.insert(x_s.begin(), 6 - x_s.size(), '0');
  return p_s + x_s;
}

int main() {
  uint64_t n, m;
  std::cin >> n >> m;

  std::vector<std::map<uint64_t, uint64_t>> p(n + 1, std::map<uint64_t, uint64_t>());
  std::vector<std::pair<uint64_t, uint64_t>> c(m);
  std::vector<std::string> ans(m);

  uint64_t tmp = 0;
  for (auto &i : c) {
    std::cin >> i.first >> i.second;
    p[i.first].insert(std::make_pair(i.second, tmp));
    tmp++;
  }

  for (uint64_t i = 1; i < n + 1; i++) {
    uint64_t tmp = 1;
    for (const auto &j : p[i]) {
      ans[j.second] = name(i, tmp);
      tmp++;
    }
  }
  for (const auto &i : ans) {
    std::cout << i << std::endl;
  }
  return 0;
}

Measured memory_bytes: 22976
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int a, b; cin >> a >> b;
  if (abs(a+b)&1) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << abs(a+b)/2 << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}



int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);

int n;
cin>>n;

ll a=n%10;

if(a==1)a=9;
else if(a==9)a=1;

ll b=(n/10)%10;
if(b==1)b=9;
else if(b==9)b=1;
ll c=(n/100)%10;
if(c==1)c=9;
else if(c==9)c=1;

cout<<100*c+10*b+a<<"\n";

return 0;

}


Measured memory_bytes: 256
<?php

fscanf(STDIN,"%d",$n);
$a = explode(" ", rtrim(fgets(STDIN)));
$count = [];
foreach ($a as $key => $value) {
    $count[$key] = 0;
    while ((int)$value !== 0 && (int)$value %2 == 0) {
        $count[$key]++;
        $value = $value/2;
    }
}
echo(min($count));

Measured memory_bytes: 3828
x=[]
rikei=0
bunkei=0
for i in range(6):
    n=int(input())
    x.append(n)

y=x[0:4]
y.remove(min(y))
for j in range(3):
    rikei+=y[j]
#print(rikei)
    
    
z=x[4:6]
z.remove(min(z))
for k in range(1):
    bunkei+=z[k]
#print(bunkei)
 
    
print(rikei+bunkei)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

#define MAX_N 100000
int n, q;
ll arr[MAX_N + 1];

int main() {
    cin >> n;
    long long sum = 0;
    reps(i, n) {
        int a;
        cin >> a;
        arr[a]++;
        sum += a;
    }
    cin >> q;
    rep(i, q) {
        int b, c;
        cin >> b >> c;
        sum += arr[b] * (c - b);
        arr[c] += arr[b];
        arr[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4428
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359

int main(){
  ll N,M;
  cin>>N>>M;

  ll a[101005]={0};
  ll tmp;
  for(ll i=0;i<M;i++){
    cin>>tmp;
    a[tmp] = 1;
  }
  ll xxx[110000]={0};

xxx[0]=1;
xxx[1]=1;


for(ll i=0;i<=1;i++){
  if(a[i]){
    xxx[i]=0;
  }
}

for(ll i=2;i<=N+1;i++){
  xxx[i] = xxx[i-1]%MOD+xxx[i-2]%MOD;
  if(a[i]){
    xxx[i]=0;
  }
  xxx[i]%MOD;
  
}
cout<<xxx[N]%MOD<<endl;
}


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

using namespace std;

typedef long long int ll;

vector<ll> v, w;
vector<vector<ll> > dp;

void solve(int n, int wi) {
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= wi; j++) {
            if(i==0 || j==0)
                dp[i][j] = 0;
            else if(w[i] <= j)
                dp[i][j] = max(v[i]+dp[i-1][j-w[i]], dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][wi] << "\n";
}

int main() {
    int n, wi;
    cin >> n >> wi;
    v.resize(n+1);
    w.resize(n+1);
    dp.resize(n+1, vector<ll>(wi+1));
    for(int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    solve(n, wi);
}

Measured memory_bytes: 80256
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int a[22], b[22], c[22];

void Main() {
  int n; cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for(int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for(int i = 1; i <= n - 1; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    ans += b[a[i]];
    if(i != 1 && a[i] - a[i - 1] == 1) {
      ans += c[a[i] - 1];
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 256
fn main() {
    let n: usize = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line.trim().parse().unwrap()
    };
    let w: Vec<i32> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line.trim().split_whitespace().map(|e| e.parse().unwrap()).collect()
    };
    
    let mut ans = std::i32::MAX;
    for t in 0..(n - 1) {
        let s1 = (0..(t + 1)).fold(0, |sum, i| sum + w[i]);
        let s2 = ((t + 1)..n).fold(0, |sum, i| sum + w[i]);
        ans = std::cmp::min(ans, (s1 - s2).abs());
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())
TS = []
for i in range(N):
    X, L = map(int, input().split())
    TS.append((X + L, X - L))
TS = sorted(TS)
cur = -10**10
ans = 0
for i in range(N):
    if cur <= TS[i][1]:
        ans += 1
        cur = TS[i][0]
print(ans)

Measured memory_bytes: 17804
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };

    let n = sc.read();
    let c: i64 = sc.read();
    let xv: Vec<(i64, i64)> = (0..n).map(|_| (sc.read(), sc.read())).collect();

    let mut right_max = vec![0; n + 1];
    let mut right_back = vec![0; n + 1];
    let mut right_v = 0;
    for i in 0..n {
        let (x, v) = xv[i];
        right_v += v;
        right_max[i + 1] = cmp::max(right_max[i], right_v - x);
        right_back[i + 1] = cmp::max(right_back[i], right_v - 2 * x);
    }

    let mut left_max = vec![0; n + 1];
    let mut left_back = vec![0; n + 1];
    let mut left_v = 0;
    for i in 0..n {
        let (x, v) = xv[n - 1 - i];
        left_v += v;
        left_max[i + 1] = cmp::max(left_max[i], left_v - (c - x));
        left_back[i + 1] = cmp::max(left_back[i + 1], left_v - 2 * (c - x));
    }

    let mut ans = 0;
    for i in 0..n {
        ans = cmp::max(ans, left_max[i + 1]);
        ans = cmp::max(ans, right_max[i + 1]);

        ans = cmp::max(ans, right_back[i + 1] + left_max[n - 1 - i]);
        ans = cmp::max(ans, left_back[i + 1] + right_max[n - 1 - i]);
    }

    println!("{}", ans);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492