akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int N;
int input[200000];

int last(int K)
{
	int left = input[N - 2] >= K ? 1 : 0;
	int center = input[N - 1] >= K ? 1 : 0;
	int right = input[N] >= K ? 1 : 0;

	if (center == left || center == right) return center;

	int before = left;
	int left_time = -1, left_num;
	int right_time = -1, right_num;

	for (int i = N - 3; i >= 0; i--)
	{
		int cur = input[i] >= K ? 1 : 0;

		if (before == cur)
		{
			left_time = N - 1 - (i + 1);
			left_num = cur;
			break;
		}

		before = cur;
	}

	before = right;

	for (int i = N + 1; i < 2 * N - 1; i++)
	{
		int cur = input[i] >= K ? 1 : 0;

		if (before == cur)
		{
			right_time = i - 1 - (N - 1);
			right_num = cur;
			break;
		}

		before = cur;
	}

	if (left_time == -1 && right_time == -1) return input[0] >= K ? 1 : 0;

	if (left_time == -1) return right_num;
	if (right_time == -1) return left_num;

	if (left_num == right_num) return left_num;

	if (left_time < right_time) return left_num;
	else return right_num;
}

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

	for (int i = 0; i < 2*N-1; i++) scanf("%d", &input[i]);

	int low = 1, high = 2 * N - 1;

	while (low <= high)
	{
		if (high - low > 1)
		{
			int mid = (low + high) / 2;

			if (last(mid) == 1) low = mid;
			else high = mid - 1;
		}
		else
		{
			if (high == low) break;
			else
			{
				if (last(high) == 1) low = high;
				break;
			}
		}
	}

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

	return 0;
}

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

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    int arr1[n][m], arr2[m][l];
    long res[n][l];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> arr1[i][j];
        }
    }
    for(int i=0; i<m; i++){
        for(int j=0; j<l; j++){
            cin >> arr2[i][j];
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            for(int k=0; k<m ;k++){
                if(k==0){
                    res[i][j] = arr1[i][k] * arr2[k][j];
                }else{
                    res[i][j] += arr1[i][k] * arr2[k][j];
                }
                
            }
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int k = 0; k < l - 1; k++){
            cout << res[i][k] << " ";
        }
        cout << res[i][l - 1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  int N,M; cin >> N >> M;
  int res_N = 0, res_M = 0;
  if (N < 1) res_N = 0;
  else res_N = nCr(N,2);
  if (M < 1) res_M = 0;
  else res_M = nCr(M,2);
  cout << res_N+res_M << endl;
  
  return 0;
}


Measured memory_bytes: 256
while True : 
    try :
        temp = [int(_) for _ in input().split(',')]
        length = len(set(temp))
        
        if length == 2 :
            if temp.count(temp[0]) == 1 or temp.count(temp[0]) == 4 : print('four card')
            else : print('full house')
        elif length == 3 :
            for _ in set(temp) :
                if temp.count(_) == 2 :
                    print('two pair')
                    break
                elif temp.count(_) == 3 :
                    print('three card')
                    break
        elif length == 4 : print('one pair')
        else : 
            temp.sort(reverse = True)
            test = [(temp[0] - _) for _ in range(5)]
            if temp == test or temp == [13, 12, 11, 10, 1] : print('straight')
            else : print('null')
    except :
        break

Measured memory_bytes: 7716
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 101010
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pi pair<int ,int>
#define pii pair <int,pi>
using namespace std;
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
 int a,b,c;
 cin >> a >> b >> c;
 cout<<min(a+b,min(b+c,c+a));
  return 0;
}
 

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

typedef long long ll;

int main()
{
    int ans = 0;
    string w;
    cin >> w;
    while(true){
        string s;
        cin >> s;
        if(s == "END_OF_TEXT"){
            cout << ans << endl;
            return 0;
        }
        for (int i = 0; i < s.size(); ++i) {
            if(s.at(i) <= 90){
                s.at(i) += 32;
            }
        }
        if(s == w){
            ++ans;
        }
    }
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ull Psize[51];
ull ALLsize[51];

int main()
{
	int N, level;
	ull X, pos, ans = 0;

	Psize[0] = 1;
	ALLsize[0] = 1;

	cin >> N >> X;

	repc(i, 1, N) {
		ALLsize[i] = ALLsize[i - 1] * 2 + 3;
		Psize[i] = Psize[i - 1] * 2 + 1;
	}

	level = N;

	while (X > 0) {
		if (level == 0) {
			ans++;
			break;
		}

		pos = ALLsize[level] / 2 + 1;

		if (pos <= X) {
			ans += Psize[level - 1] + 1;
			X -= pos;
		}
		else {
			X--;
		}
		level--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
inline ll divceil(ll a, ll b){return (a+b-1) / b;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans;
    if(a >= 13) ans = b;
    else if(a >= 6) ans = b/2;
    else ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from itertools import groupby

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    print(len(list(groupby(S))) - 1)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20880
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
using namespace std;
int main(void){
    ll N,X;cin>>N>>X;
    ll x[N+1];x[0]=X;
    REPS(i,N)cin>>x[i];
    ll d[N];
    REP(i,N){
        d[i]=abs(x[i+1]-x[i]);
    }
    //GCD;
    ll gcd=0;
    REP(i,N){
        gcd=GCD(gcd,d[i]);
    }
    cout<<gcd<<"\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

int A,B;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{	
		int sx,sy,tx,ty;
		int cnt = 0;
		cin >> sx>>sy>>tx>>ty;
		string ans;
		//１回目
		for (int i = sx; i < tx; i++)
		{
			ans += "R";
		}
		for (int i = sy; i < ty; i++)
		{
			ans += "U";
		}
		//２回目
		for (int i = tx; i > sx; i--)
		{
			ans += "L";
		}
		for (int i = ty; i > sy; i--)
		{
			ans += "D";
		}
		//３回目
		ans += "D";
		for (int i = sx; i < tx+1; i++)
		{
			ans += "R";
		}
		for (int i = sy-1; i < ty; i++)
		{
			ans += "U";
		}
		ans += "L";
		//４回目
		ans += "U";
		for (int i = tx; i > sx-1; i--)
		{
			ans += "L";
		}
		for (int i = ty+1; i > sy; i--)
		{
			ans += "D";
		}
		ans += "R";

		cout << ans << endl;

		
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc159/tasks/abc159_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll H, W, K;
  cin >> H >> W >> K;

  V<string> mat(H);
  rep(i, H) cin >> mat[i];

  char BL = '0';
  char WH = '1';

  ll res = INF;

  rep(bit, 1 << (H - 1)) {
    VL h_to_id(H);

    rep(i, H - 1) h_to_id[i + 1] = h_to_id[i] + !!(bit & (1 << i));

    bool possible = true;
    ll ope_ct = 0;
    VL id_to_ct(H);

    rep(w, W) {
      VL col_id_to_ct(H);

      bool ope_necessary = false;

      rep(h, H) {
        ll id = h_to_id[h];

        id_to_ct[id] += mat[h][w] == WH;
        col_id_to_ct[id] += mat[h][w] == WH;

        if (col_id_to_ct[id] > K) {
          possible = false;
          break;
        }

        if (id_to_ct[id] > K) {
          ope_necessary = true;
        }
      }

      if (!possible) break;

      if (ope_necessary) {
        ++ope_ct;
        id_to_ct = col_id_to_ct;
      }
    }

    if (!possible) continue;

    ll horizontal_ope_ct = __builtin_popcountll(bit);
    chmin(res, horizontal_ope_ct + ope_ct);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

template <typename T> using rev_priority_queue = priority_queue<T,vector<T>,greater<T>>;

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

  int Q;
  while(cin >> Q){
    LLI B = 0;

    LLI s1 = 0, s2 = 0;
    priority_queue<LLI> q1;
    rev_priority_queue<LLI> q2;

    REP(i,Q){
      int c; cin >> c;

      if(c == 1){
	LLI a,b; cin >> a >> b;

	B += b;

	if(q1.size() == q2.size()){
	  q2.push(a); s2 += a;
	  auto p = q2.top(); q2.pop(); s2 -= p;

	  q1.push(p); s1 += p;
	}else{
	  q1.push(a); s1 += a;
	  auto p = q1.top(); q1.pop(); s1 -= p;

	  q2.push(p); s2 += p;
	}

	if(not (q2.empty() or q1.top() <= q2.top())) assert(false);
	
      }else{
	if(q1.size() == q2.size()){
	  LLI x1 = q1.top();
	  LLI x2 = q2.top();

	  LLI ans1 = abs(s1-x1*(int)q1.size())+abs(s2-x1*(int)q2.size()) + B;
	  LLI ans2 = abs(s1-x2*(int)q1.size())+abs(s2-x2*(int)q2.size()) + B;
	
	  if(ans1 <= ans2)
	    cout << x1 << " " << ans1 << endl;
	  else
	    cout << x2 << " " << ans2 << endl;
	}else{
	  LLI x = q1.top();
	  LLI ans = abs(s1-x*(int)q1.size())+abs(s2-x*(int)q2.size()) + B;
	  cout << x << " " << ans << endl;
	}
      }
    }
    
  }
  
  return 0;
}


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

int main() {
  int N;
  cin >> N ;
  vector<int> A(N),B(N-1);
  for(int i=0;i<N-1;i++){
    cin >>B.at(i);
  }
  A.at(0)=B.at(0);
  A.at(1)=B.at(0);
  for(int i=1;i<N-1;i++){
    if (B.at(i)>=B.at(i-1)){
      A.at(i+1)=B.at(i);
    }
    else{
      A.at(i)=B.at(i);
      A.at(i+1)=B.at(i);
    }
  }
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=A.at(i);
  }
  cout << sum <<endl;
}

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

int main () {
	
	int h=0, w=0, n=0, x=0, y=0, i=0, j=0;
	string s1="", s2="";

	cin >> h >> w >> n >> x >> y >> s1 >> s2;

	int pos1[4] = {0,0,0,0};
	int pos2[4] = {0,0,0,0};

	for (i=0; i<n; i++) {
		if (s1[i] == 'R') pos1[0]++;
		else if (s1[i] == 'L') pos1[1]++;
		else if (s1[i] == 'U') pos1[2]++;
		else if (s1[i] == 'D') pos1[3]++;
	}

	bool flag = 0;
	int c1=0;

	//for (i=0; i<4; i++) cout << pos1[i] << " " ; cout << endl;

	c1 = y;
	if (c1+pos1[0] > w) {
		//flag = 1;
		//cout << "0" << endl;
		for (i=0; i<n; i++) {
			if (s1[i] == 'R') c1++;
			if (c1 > w) { flag=1; break;}
			else {
				if (s2[i] == 'L') {
					if(c1-1 >= 1) c1--;
				}
			}
		}
	}
	
	c1 = y;
	if (c1-pos1[1] <= 0) {
		//flag = 1;
		//cout << "1" << endl;
		for (i=0; i<n; i++) {
			if (s1[i] == 'L') c1--;
			if (c1 <= 0) { flag=1; break;}
			else {
				if (s2[i] == 'R') {
					if (c1+1 <= w) c1++;
				}
			}
		}
	}
	
	c1 = x;
	if (c1+pos1[3] > h) {
		//flag = 1;
		//cout << "2" << endl;
		for (i=0; i<n; i++) {
			if (s1[i] == 'D') c1++;
			if (c1 > h) { flag=1; break;}
			else {
				if (s2[i] == 'U') {
					if (c1-1 >= 1) c1--;
				}
			}
		}
	}
	
	c1=x;
	if (c1-pos1[2] <= 0) {
		//flag =1;
		//cout << "3" << endl; 
		for (i=0; i<n; i++) {
			if (s1[i] == 'U') c1--;
			if (c1 <= 0) { flag=1; break;}
			else {
				if (s2[i] == 'D'){
					if(c1+1 <= h) c1++;
				}
			}
		}
	}

	if (flag==1) cout << "NO" << endl;
	else cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 776
program sample
    implicit none
    character(100)::s
    integer(8) :: i,j,m,n,x(26),y(26),z(26),a,b
  
    read(*,*) s
    n=len_trim(s)
    x(:)=0
    y(:)=-1
    do i=1,n
        x(:)=x(:)+1
        a=ichar(s(i:i))-96 
        x(a)=x(a)-1
        y(a)=max(x(a),y(a))
        x(a)=0
    end do
    do i=1,26
        y(i)=max(x(i),y(i))
    end do
    write(*,*)minval(y)
    
    stop
end program sample
  



Measured memory_bytes: 2836
x,n=map(int, input().split())
p=list(map(int, input().split()))

if len(p) == 0:
    print(x)
    exit(0)

for i in range(0,100):
    if not x-i in p:
        print(x-i)
        break

    if not x+i in p:
        print(x+i)
        break


Measured memory_bytes: 61872
// Ambition without ammunition is dangerous
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}
ll Sum(ll n)
{
    ll d=n*(n+1);
    d/=2;
    return d;
}
int main()
{
    double R;
    cin>>R;
    double ans=2*PI*R;
    cout<<fixed<<setprecision(12)<<ans;

}


Measured memory_bytes: 3776
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ch() getchar()
#define pc(x) putchar(x)
template<typename T>inline void read(T&x){
	int f;char c;
	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;
	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;
}
template<typename T>inline void write(T x){
	static char q[64];int cnt=0;
	if(!x)pc('0');if(x<0)pc('-'),x=-x;
	while(x)q[cnt++]=x%10+'0',x/=10;
	while(cnt--)pc(q[cnt]);
}
int main(){
	int n,ans=0,cnt=0;read(n);
	for(int i=1;i<=n;++i){
		int a,b;read(a),read(b);
		ans=max(ans,cnt=(a==b?cnt+1:0));
	}
	puts(ans>=3?"Yes":"No");
	return 0;
}


Measured memory_bytes: 3632
dice = gets.split(" ").map{|i| i.to_i}
dirs = gets.split("")

def roll(dice,dir)
  case dir
  when "N" then dice[0],dice[1],dice[5],dice[4] = dice[1],dice[5],dice[4],dice[0]
  when "S" then dice[0],dice[1],dice[5],dice[4] = dice[4],dice[0],dice[1],dice[5]
  when "E" then dice[0],dice[2],dice[5],dice[3] = dice[3],dice[0],dice[2],dice[5]
  when "W" then dice[0],dice[2],dice[5],dice[3] = dice[2],dice[5],dice[3],dice[0]
  end
  dice
end

for i in 0..dirs.size-1
  dice = roll(dice,dirs[i])
end

puts dice[0]

Measured memory_bytes: 8720
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////
void solve(){
  ini(N); inl(x);
  vl a(N); in(a);
  ll ans = 0;
  if(a[0] > x){
    ans += a[0] - x; a[0] = x;
  }
  rep1(i , N - 1){
    if(a[i-1] + a[i] > x){
      ll cur = a[i-1] + a[i] - x;
      ans += cur ; a[i] -= cur;
    }
  }
  out(ans);
}



Measured memory_bytes: 1024
A,B,C,D,E,F = map(int,input().split())

ws = []
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		x = a + b
		if x <= F:
			ws.append(x)
			
ss = []
for c in range(0,F+1,C):
	for d in range(0,F-c+1,D):
		y = c + d
		if y <= F:
			ss.append(y)
				
ans = [0,100*A,0]
for w in ws:
	for s in ss:
		ws = w+s
		
		if not ws <= F:
			continue
		
		if ws == 0:
			continue
		
		e = s/ws*100
				
		if not e <= E/(100+E)*100:
			continue
		
		if ans[0] < e:
			ans = [e,ws,s]
				
print(ans[1],ans[2])

Measured memory_bytes: 12464
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long num1 = scan.nextLong(), num2 = scan.nextLong();

        long multi = num1 * num2;

        if(num1 != 1 && num2 != 1){
            if(multi % 2 == 0){
                System.out.println(multi / 2);
            }else{
                System.out.println( (multi + 1) / 2);
            }
        }else{
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

ll modpow(ll x, ll y) {
  ll v = 1;
  REP(i,y) {
    v *= x; v %= MOD;
  }
  return v;
}

int main() {
  IOS;
  ll n; cin >> n;
  ll p1 = modpow(10, n);
  ll p2 = (modpow(9, n) * 2) % MOD;
  ll p3 = modpow(8, n);
  ll ans = p1 - (p2 - p3);
  ans %= MOD;
  ans = (ans + MOD) % MOD;
  COUT(ans);

  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	ll N,K;

	scanf("%lld %lld",&N,&K);

	if(N > K){
		printf("0\n");
	}else{
		printf("1\n");
	}

	return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];

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

    cout << d[d.size()/2] - d[d.size()/2-1] << endl;
}


Measured memory_bytes: 640
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int a,b,c,k; 
    cin>>a>>b>>c>>k;
    cout << (((k&1)^1)?(a-b):(b-a)) << endl; 
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    string s;
    IN(s);
    int tmp0=0;
    int tmp1=0;
    REP(i,SZ(s)){
        if(s[i]-'0'!=i%2)tmp0++;
        else tmp1++;
    }
    int ans=min(tmp0,tmp1);
    OUT(ans);
    return 0;
}

Measured memory_bytes: 512
H, W = [int(i) for i in input().split()]
S = [input() for _ in range(H)]
for j in range(W + 2):
    print('#', end='')
print()
for i in range(H):
    print('#%s#' % S[i])
for j in range(W + 2):
    print('#', end='')
print()


Measured memory_bytes: 9188
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

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

    int N, K; cin >> N >> K;
    vi V(N); REP(i, N) cin >> V[i];

    int ans = 0;
    for (int l=0; l<=K; l++) {
        for(int r = 0; r<=K-l; r++) {
            if (l + r > N) continue;
            int d = K - l - r;
            vi a;
            int sum = 0;
            REP(i, l) {
                a.push_back(V[i]);
                sum += V[i];
            }
            REP(i, r) {
                a.push_back(V[N - 1 - i]);
                sum += V[N - 1 - i];
            } 
            sort(a.begin(), a.end());

            REP(i,d) {
                if (i >= a.size()) break;
                if (a[i] > 0) break;
                sum -= a[i];
            }

            ans = max(ans, sum);
        }
    }
 
    cout << ans << endl;

    return 0;
}

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

int main()
{
    vector<int> a(6);

    int i,j,k,n;

    for (k = 0; k <= 5; ++k) {
        cin >> a.at(k);
    }

    cin >> n;

        for (k = 1; k <= n; ++k) {

            cin >> i >> j;

            if (i == a.at(0) && j == a.at(1)) { cout << a.at(2) << endl; }
            else if (i == a.at(0) && j == a.at(2)) { cout << a.at(4) << endl; }
            else if (i == a.at(0) && j == a.at(3)) { cout << a.at(1) << endl; }
            else if (i == a.at(0) && j == a.at(4)) { cout << a.at(3) << endl; }
            else if (i == a.at(1) && j == a.at(0)) { cout << a.at(3) << endl; }
            else if (i == a.at(1) && j == a.at(2)) { cout << a.at(0) << endl; }
            else if (i == a.at(1) && j == a.at(3)) { cout << a.at(5) << endl; }
            else if (i == a.at(1) && j == a.at(5)) { cout << a.at(2) << endl; }
            else if (i == a.at(2) && j == a.at(0)) { cout << a.at(1) << endl; }
            else if (i == a.at(2) && j == a.at(1)) { cout << a.at(5) << endl; }
            else if (i == a.at(2) && j == a.at(4)) { cout << a.at(0) << endl; }
            else if (i == a.at(2) && j == a.at(5)) { cout << a.at(4) << endl; }
            else if (i == a.at(3) && j == a.at(0)) { cout << a.at(4) << endl; }
            else if (i == a.at(3) && j == a.at(1)) { cout << a.at(0) << endl; }
            else if (i == a.at(3) && j == a.at(4)) { cout << a.at(5) << endl; }
            else if (i == a.at(3) && j == a.at(5)) { cout << a.at(1) << endl; }
            else if (i == a.at(4) && j == a.at(0)) { cout << a.at(2) << endl; }
            else if (i == a.at(4) && j == a.at(2)) { cout << a.at(5) << endl; }
            else if (i == a.at(4) && j == a.at(3)) { cout << a.at(0) << endl; }
            else if (i == a.at(4) && j == a.at(5)) { cout << a.at(3) << endl; }
            else if (i == a.at(5) && j == a.at(1)) { cout << a.at(3) << endl; }
            else if (i == a.at(5) && j == a.at(2)) { cout << a.at(1) << endl; }
            else if (i == a.at(5) && j == a.at(3)) { cout << a.at(4) << endl; }
            else if (i == a.at(5) && j == a.at(4)) { cout << a.at(2) << endl; }
        }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define X first
#define Y second
#define fw(i, start, end) for (ll i = start; i < end; ++i)
#define fe(i, start, end) for (ll i = start; i <= end; ++i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define endl "\n"
#define mem(a, i) memset(a, i, sizeof(a))
int main()
{
    FASTIO
    ll n, m;
    cin >> n >> m;
    cout << n * m << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N; cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll prev = 10001, cnt = 0, ans = 0;
  for(int i=0; i<N; ++i) {
    if(prev != A[i]) {
      ans += cnt/2;
      prev = A[i];
      cnt = 1;
    } else {
      ++cnt;
    }
  }
  ans += cnt/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;

static const auto do_fast_io = [] {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return nullptr;
}();

/*
 * There are two approaches to understand this logic,
 *
 * * First
 * - https://codeforces.com/blog/entry/64250?#comment-482888 along with
 * - https://codeforces.com/blog/entry/64250?#comment-482888
 *
 * * Second
 * - https://codeforces.com/blog/entry/64250?#comment-482841 along with
 * - https://codeforces.com/blog/entry/64250?#comment-483017
 */

int main() {
    int n;
    cin >> n;
    int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x == 1) {
            ++c1;
        } else if (x == 2) {
            ++c2;
        } else {
            ++c3;
        }
    }
    // cout << c1 << c2 << c3 << endl;
    double dp[n + 1][n + 1][n + 1] = {0};
    for (int i = 0; i <= c3; ++i) {
        for (int j = 0; i + j <= c2 + c3; ++j) {
            for (int k = 0; i + j + k <= c1 + c2 + c3; ++k) {
                if (not i and not j and not k) {
                    continue;
                }
                int non_empty = i + j + k;
                double pi = i / double(non_empty);
                double pj = j / double(non_empty);
                double pk = k / double(non_empty);
                double pe = n / double(non_empty);
                // cout << "next iteration" << endl;
                // cout << i << " " << j << " " << k << endl;
                // cout << pi << " " << pj << " " << pk << " " << pe << endl;
                if (i) {
                    double ii = dp[i - 1][j + 1][k] * pi;
                    // cout << "i" << ii << endl;
                    dp[i][j][k] += ii;
                }
                if (j) {
                    double jj = dp[i][j - 1][k + 1] * pj;
                    // cout << "j" << jj << endl;
                    dp[i][j][k] += jj;
                }
                if (k) {
                    double kk = dp[i][j][k - 1] * pk;
                    // cout << "k" << kk << endl;
                    dp[i][j][k] += kk;
                }
                dp[i][j][k] += pe;
                // cout << "dp " << dp[i][j][k] << endl;
            }
        }
    }
    cout << fixed << setprecision(10) << dp[c3][c2][c1] << endl;
    return 0;
}


Measured memory_bytes: 213376
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);

int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	ll a,b,n;
	cin>>a>>b>>n;
	cout<<(a*(min(n,b-1))/b - a*(min(n,b-1)/b))<<endl;
	return 0;
} 


Measured memory_bytes: 3656
n=int(input())
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(A[n-1])


Measured memory_bytes: 2940
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N; cin >> N;
	
	int A[N], B[N], C[N-1]; F0R(i, N) cin>>A[i];
	
	F0R(i, N) cin >> B[i];
	
	F0R(i, N-1) cin >> C[i];
	
	int ans = 0; F0R(i, N) ans += B[i];
	
	FOR(i, 1, N) if (A[i] - 1 == A[i-1]) ans += C[A[i-1]-1];
	
	cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int x[MAXN],M,N,a[MAXN];
int64 l[MAXN],K;
struct node {
    int p[MAXN];
    friend node operator * (const node &a,const node &b) {
        node c;
        for(int i = 1 ; i < N ; ++i) c.p[i] = b.p[a.p[i]];
        return c;
    }
}f,ans;
node fpow(node x,int64 c) {
    node res,t = x;
    for(int i = 1 ; i < N ; ++i) res.p[i] = i;
    while(c) {
        if(c & 1) res = res * t;
        t = t * t;
        c >>= 1;
    }
    return res;
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(x[i]);
    read(M);read(K);
    for(int i = 1 ; i < N ; ++i) a[i] = i;
    int t;
    for(int i = 1 ; i <= M ; ++i) {
        read(t);
        swap(a[t - 1],a[t]);
    }
    for(int i = 1 ; i < N ; ++i) f.p[a[i]] = i;
    ans = fpow(f,K);
    l[1] = x[1];
    for(int i = 1 ; i < N ; ++i) {
        l[ans.p[i] + 1] = x[i + 1] - x[i];
    }
    for(int i = 1 ; i <= N ; ++i) {
        l[i] += l[i - 1];
        out(l[i]);enter;
    }

}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n + 2, vector<int>(m + 2));
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    char c; cin >> c;
    a[i][j] = (c == '#');
  }
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    if (a[i][j] == 1) {
      int cnt = a[i - 1][j] + a[i][j - 1] + a[i + 1][j] + a[i][j + 1];
      if (cnt == 0) {
        cout << "No" << '\n';
        return;
      }
    }
  }
  cout << "Yes" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3684
import math
a,b = map(str, input().split())
a = int(a)
b = b.replace(".","")
if len(b) == 2:
    b = b + '0'
b = int(b)
ans = a*b
if len(str(ans)) <= 2:
    print(math.floor(ans/100))
else:
    print(int(str(ans)[:-2]))

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/25  Problem: ARC 093 B / Link: http://arc093.contest.atcoder.jp/tasks/arc093_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, A, B;

LL ans = 0LL;

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

	cin >> A >> B;
	VVI m(100, VI(100, 0));
	FOR(i, 0, 100) {
		FOR(j, 50, 100) {
			m[i][j] = 1;
		}
	}

	//siro
	A--; B--;
	for (int i = 1; i < 100; i += 2) {
		for (int j = 51; j < 99; j += 2) {
			if (A > 0)m[i][j] = 0, A--;
		}
	}
	for (int i = 1; i < 100; i += 2) {
		for (int j = 1; j < 49; j += 2) {
			if (B > 0)m[i][j] = 1, B--;
		}
	}
	string str1 = ".#";
	cout << 100 << " " << 100 << endl;
	FOR(i, 0, 100) {
		FOR(j, 0, 100) {
			cout << str1[m[i][j]];
		}cout << endl;
	}

	return 0;
}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> ans(n);
    ans[0] = 0;
    REP(i, n) {
        cin >> A[i];
        ans[0] += A[i];
    }
    for(int i=1; i<n; i+=2) ans[0] -= 2*A[i];
    for(int i=1; i<n; i++) {
        ans[i] = 2*A[i-1] - ans[i-1];
    }
    REP(i, n) printf("%d ", ans[i]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 2048
using System;

namespace atCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            bool bad = false;
            int prevnum = -1;
            
            for(int n=0;n<4;n++)
            {
                if (num % 10 == prevnum)
                {
                    bad = true;
                    break;
                }
                prevnum = num % 10;
                num /= 10;
            }

            Console.WriteLine(bad ? "Bad" : "Good");
        }
    }
}


Measured memory_bytes: 13140
from sys import stdin
N = int(stdin.readline().rstrip())
six_pows = [6**i for i in range(10)]
nine_pows = [9**i for i in range(10)]

ans = float("inf")

for i in range(N+1):
    count = 0
    tmp = i
    while tmp > 0:
        j = 0
        while six_pows[j] <= tmp:
            j += 1
        tmp -= six_pows[j-1]
        count += 1 

    tmp = N - i
    while tmp > 0:
        j = 0
        while nine_pows[j] <= tmp:
            j += 1
        tmp -= nine_pows[j-1]
        count += 1
    
    ans = min(ans, count)

print(ans)

Measured memory_bytes: 41452
while True:
	n, x = map(int, raw_input().split())
	if n + x == 0: break
	ans = 0
	for i in range(1,n-1):
		for j in range(i+1, n):
			for h in range(j+1, n+1):
				if i + j + h == x: ans += 1
	print ans

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,a,b,c,d,f,t,n,m;
    vector<int> v,s;
    string ss,vv;
    map<int,int> ma,sa;
    map<int,int> ::iterator it;
    cin>>n>>m;
    c = 0;
    t = 0;
    for(i=1; i<=m; i++)
    {
        cin>>a;
        cin>>ss;
        if(ss=="WA" && sa[a]==0)
        {
            ma[a]++;
        }
        else if(ss=="AC" && sa[a]==0)
        {
            sa[a] = 1;
            t++;
        }
    }
    f = 0;
    for(it = ma.begin(); it!=ma.end(); it++)
    {
        if((sa[(*it).first])==1)
        {
            f = f+(*it).second;
        }
    }
    cout<<t<<" "<<f<<endl;
    return 0;
}


Measured memory_bytes: 6144
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include<boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int N,M;
int a,b;
vector<ll> A;
void input(){
    cin>>N;
    A.resize(N);
    rep(i,N)cin>>A[i];
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    cpp_int ans = 1;
    sort(A.begin(),A.end());
    int tmp = 1e18;
    rep(i,N){
        ans*=A[i];
        if(ans>tmp){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3968