akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python

flips = []

die = input().split()
for i in range(6):
    die[i] = [i + 1, die[i]]
text = input()
for x in text:
    flips.append(x)

for x in flips:
    if x == 'S':
        for y in die:
            if 5 in y:
                y[0] = 1
            elif 1 in y:
                y[0] = 2
            elif 2 in y:
                y[0] = 6
            elif 6 in y:
                y[0] = 5
    elif x == 'N':
        for y in die:
            if 5 in y:
                y[0] = 6
            elif 1 in y:
                y[0] = 5
            elif 2 in y:
                y[0] = 1
            elif 6 in y:
                y[0] = 2
    elif x == 'E':
        for y in die:
            if 4 in y:
                y[0] = 1
            elif 1 in y:
                y[0] = 3
            elif 3 in y:
                y[0] = 6
            elif 6 in y:
                y[0] = 4
    else:
        for y in die:
            if 4 in y:
                y[0] = 6
            elif 1 in y:
                y[0] = 4
            elif 3 in y:
                y[0] = 1
            elif 6 in y:
                y[0] = 3

for x in die:
    if x[0] == 1:
        print(x[1])
        

Measured memory_bytes: 7452
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr LL inv(LL x, LL m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr LL mpow(LL a, LL k, LL m) { LL r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }

const int N = 1e5 + 5;
int n, A[N], B[N];
LL sa, sb;

int main() {
    cin >> n;
    FI(i, 1, n) scanf("%d", &A[i]), sa += A[i];
    FI(i, 1, n) scanf("%d", &B[i]), sb += B[i];
    if (sa < sb) return puts("-1"), 0;
    vector<int> X;
    LL need = 0;
    int ans = 0;
    FI(i, 1, n) {
        if (A[i] < B[i]) {
            need += B[i] - A[i];
            ans++;
        } else X.push_back(A[i] - B[i]);
    }
    sort(X.begin(), X.end(), greater<int>());
    for (auto x : X) {
        if (need <= 0) break;
        need -= x;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int ans;
  if (K<N) ans = K*X+(N-K)*Y;
  else ans = N*X;
  cout << ans << endl;
}

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

int a[501][501] = {};

void solve(int left, int right, int level){
    if(left == right) return;
    if(left == right-1){
        a[left][right] = level;
        return;
    }
    int mid = (left+right+1)/2;
    for(int l=left;l<mid;l++){
        for(int r=mid;r<=right;r++){
            a[l][r] = level;
        }
    }
    solve(left, mid-1, level+1);
    solve(mid, right, level+1);
}

int main(){
    int N;

    cin >> N;
    solve(1, N, 1);
    for(int i=1;i<=N-1;i++){
        for(int j=1;j<=N;j++){
            if(j>i) cout << a[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

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

int X[100002],Y[100002];
int main(){
	
	int N,W,H;
	cin>>N>>W>>H;
	for(int i=0;i<N;i++){
		int x,y,w;
		cin>>x>>y>>w;
		X[max(x-w,0)]++;
		X[min(x+w,W+1)]--;
		Y[max(y-w,0)]++;
		Y[min(y+w,H+1)]--;
	}
	int flg=X[0];
	for(int i=1;i<W;i++){
		X[i]+=X[i-1];
		if(X[i]<=0)flg=0;
	}
	
	
	int flg2=Y[0];
	for(int i=1;i<H;i++){
		Y[i]+=Y[i-1];
		if(Y[i]<=0)flg2=0;
	}
	cout<<(flg||flg2?"Yes\n":"No\n");
	
	/*
	cout<<endl;
	for(int i=0;i<=W;i++)cout<<X[i]<<endl;
	cout<<endl;
	cout<<endl;
	for(int i=0;i<=H;i++)cout<<Y[i]<<endl;
	cout<<endl;
	*/
	return 0;
}


Measured memory_bytes: 1908
s = [input() for i in range(1)] 
li = list(map(int, s[0].split()))
mod = li[0] % 10
if mod in (2,4,5,7,9):
    print('hon')
if mod in (0,1,6,8):
    print('pon')
if mod == 3:
    print('bon')

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
int a[100000],f[100000];
int main()
{
    int n,m;
    cin >> n >> m;
  for (int i = 1, x; i <= m; i++) {
    cin >> x, a[x] = 1;
  }
  f[0] = 1;f[-1]=0;
  for (int i = 1; i <= n; i++) {
  f[i] = (f[i - 1] + f[i - 2]) % p;
    if (a[i])
      f[i] = 0;
  }
  cout << f[n] << endl;
  return 0;
}/*
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 400010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

int a[maxn], f[maxn], n, m;
const int p = 1e9 + 7;

int main() {
  cin >> n >> m;
  int a[n+10],f[n+10]]
  for (int i = 1, x; i <= m; i++) {
    cin >> x, a[x] = 1;
  }
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = (f[i - 1] + f[i - 2]) % p;
    if (a[i])
      f[i] = 0;
  }
  cout << f[n] << endl;
  return 0;
}
*/


Measured memory_bytes: 1024
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase


"""def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)"""

"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""



def inpt():
    return [int(k) for k in input().split()]


def main():
    divisor=[False]*(1000010)
    n=int(input())
    d=defaultdict(int)
    ar=inpt()
    for i in ar:
        d[i]+=1

    ar.sort()
    for i in range(n):
        if(not divisor[ar[i]]):
            temp=2*ar[i]
            while(temp<=ar[n-1]):
                divisor[temp]=True
                temp+=ar[i]
    ct=0
    for i in ar:
        if(divisor[i]==False and d[i]==1):
            ct+=1
    print(ct)













BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


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

int main() {

  vector<vector<int>> A(3, vector<int>(3));
  vector<vector<bool>> check(3, vector<bool>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (A[i][j] == b){
          check[i][j] = true;
        }
      }
    }
  }

  string answer = "No";
  for (int i = 0; i < 3; i++) {
    int count = 0;
    for (int j = 0; j < 3; j++) {
      if (check[i][j]){
        count++;
      }
    }
    if (count == 3) {
      answer = "Yes";
      break;
    }
  }

  if (answer == "No") {
    for (int i = 0; i < 3; i++) {
      int count = 0;
      for (int j = 0; j < 3; j++) {
        if (check[j][i]){
          count++;
        }
      }
      if (count == 3) {
        answer = "Yes";
        break;
      }
    }
  }

  if (answer == "No") {
    if (check[0][0] == true && check[1][1] == true && check[2][2] == true) {
      answer = "Yes";
    }
    if (check[0][2] == true && check[1][1] == true && check[2][0] == true) {
      answer = "Yes";
    }
  }
  
  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<limits.h>
using namespace std;
#define INF LLONG_MAX
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<int, int> P;
ll GCD(ll a, ll b) {
	if (b == 0)return a;
	return GCD(b, a%b);
}
ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}
ll mypow(ll a, ll b) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1)*a;
	else return mypow(a, b / 2)*mypow(a, b / 2) ;
}
/*
//Conbination!
ll c[51][51];
void comb(int n) {
	rep(i, 51) {
		rep(j, i + 1) {
			if (j == 0 || j == i)c[i][j] = 1;
			else c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
		}
	}
}
*/
int main() {
	ll n, x;
	cin >> n >> x;
	cout << (n - GCD(n, x)) * 3 << endl;
	return 0;
}

Measured memory_bytes: 256
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout<<a+b+c-max(a,max(b,c))<<endl;

    return 0;
}


Measured memory_bytes: 256
def check1(H1, H2, W1, W2):
    S_min = 2 ** 50
    S_max = 0
    res1 = H1 * W1
    res2 = H1 * W2
    res3 = H2 * (W1 + W2)
    S_min = min(S_min, res1)
    S_min = min(S_min, res2)
    S_min = min(S_min, res3)
    S_max = max(S_max, res1)
    S_max = max(S_max, res2)
    S_max = max(S_max, res3)
    return S_max - S_min

def check2(H1, H2, W1, W2):
    S_min = 2 ** 50
    S_max = 0
    res1 = H1 * (W1 + W2)
    res2 = H2 * (W1)
    res3 = H2 * W2
    S_min = min(S_min, res1)
    S_min = min(S_min, res2)
    S_min = min(S_min, res3)
    S_max = max(S_max, res1)
    S_max = max(S_max, res2)
    S_max = max(S_max, res3)
    return S_max - S_min

def check3(H1, H2, W1, W2):
    S_min = 2 ** 50
    S_max = 0
    res1 = W1 * (H1 + H2)
    res2 = W2 * H1
    res3 = W2 * H2
    S_min = min(S_min, res1)
    S_min = min(S_min, res2)
    S_min = min(S_min, res3)
    S_max = max(S_max, res1)
    S_max = max(S_max, res2)
    S_max = max(S_max, res3)
    return S_max - S_min

def check4(H1, H2, W1, W2):
    S_min = 2 ** 50
    S_max = 0
    res1 = W2 * (H1 + H2)
    res2 = W1 * H1
    res3 = W1 * H2
    S_min = min(S_min, res1)
    S_min = min(S_min, res2)
    S_min = min(S_min, res3)
    S_max = max(S_max, res1)
    S_max = max(S_max, res2)
    S_max = max(S_max, res3)
    return S_max - S_min

def check_s(tmp1, tmp2, tmp3):
    S_min = 2 ** 50
    S_max = 0
    S_min = min(S_min, tmp1, tmp2, tmp3)
    S_max = max(S_max, tmp1, tmp2, tmp3)
    return S_max - S_min

if __name__ == "__main__":
    H,W = map(int, input().split())
    if (H > W):
        H,W = W,H
    if (H % 3 == 0 or W % 3 == 0):
        print (0)
        exit()

    H1 = H // 2
    H2 = H - H1
    W1 = W // 2
    W2 = W - W1
    result = 2 ** 50
    result = min(result, check1(H1, H2, W1, W2))
    result = min(result, check2(H1, H2, W1, W2))
    result = min(result, check3(H1, H2, W1, W2))
    result = min(result, check4(H1, H2, W1, W2))

    for x in range(1, W + 1):
        H1 = H // 2
        H2 = H - H1

        W1 = x
        W2 = W - W1

        W3 = W2 // 2
        W4 = W2 - W3

        tmp1 = W1 * H
        tmp2 = W3 * H
        tmp3 = W4 * H

        result = min(result, check_s(tmp1, tmp2, tmp3))
        tmp1 = W1 * H
        tmp2 = W2 * H1
        tmp3 = W2 * H2
        result = min(result, check_s(tmp1, tmp2, tmp3))

    for y in range(1,  H+ 1):
        H1 = y
        H2 = H - H1

        H3 = H2 // 2
        H4 = H3 - H2

        W1 = W // 2
        W2 = W - W1


        tmp1 = H1 * W
        tmp2 = H3 * W
        tmp3 = H4 * W

        result = min(result, check_s(tmp1, tmp2, tmp3))
        tmp1 = H1 * W
        tmp2 = H2 * W1
        tmp3 = H2 * W2
        result = min(result, check_s(tmp1, tmp2, tmp3))


    print (result)


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

const int N = 2e5 + 5;
int par[N], sz[N];
int n, m;

void init() {
    for (int i = 1; i < N; i++) {
        par[i] = i;
        sz[i] = 1;
    }
}

int find(int u) {
    return par[u] == u ? u : par[u] = find(par[u]);
}

void make(int u, int v) {
    u = find(u);
    v = find(v);
    if (u == v) return;
    if (sz[u] < sz[v]) swap(u, v);
    sz[u] += sz[v];
    par[v] = u;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    init();
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        make(u, v);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, sz[find(i)]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define MAX 100000000
using namespace std;

int main()
{
	int n, res = 0;
	cin >> n;
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp;
		for (int j = 2; j * j <= tmp; j++) {
			if (tmp % j == 0) {
				res++;
				break;
			}
		}
	}
	cout << n - res << endl;
	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
using namespace std;
main(){
string b[] = {"* = ****","* =* ***","* =** **","* =*** *","* =**** "," *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "},i;
int f=0,k,l;
while(cin>>i,!cin.eof()){
f&&cout<<endl;
f?:f=1;
while(i.size()<5)i='0'+i;
for(k=0;k<8;k++){
for(l=0;l<5;l++)cout<<b[i[l]-'0'][k];
cout<<endl;
}
}
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,k;
    cin>>n>>k;
    ve <ll> arr(n);
    rep (i,0,n)
    {
        cin>>arr[i];
    }
    sort (all(arr));
    reverse(all(arr));
    ll ans=0;
    rep (i,k,n)
    {
        ans+=arr[i];
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long mod=1000000007;

int main() {
  int N, M;
  cin >> N >> M;  
  
  vector<int> oks(N+1, true);
  for(int i=0; i<M; i++){
    int a; cin >> a;
    oks[a] = false;
  }
  vector<long long int> dp(N+1);
  dp[0] = 1;
  for(int now=0; now<N; now++){
    for(int next=now+1; next<=min(N,now+2); next++){
      if(oks[next]){
        dp[next]+=dp[now];
        dp[next]%=mod;
      }
    }
  }
      
  
  
  cout << dp[N] << endl;
}





Measured memory_bytes: 1408
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
string st;
int a=-1,b;
int main()
{
	cin>>st;
	for(int i=0;i<st.size();i++)
	{
		if(st[i]=='C')a=i;
		if(st[i]=='F')
		{
			b=i;
			if(a!=-1)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MOD 1000000007
#define MAXN 100000

LL fastExponentiation(LL base, LL p) {
    if (p == 0)
        return 1;

    LL half = fastExponentiation(base, p/2);
    LL halfhalf = (half * half)%MOD;

    if (p%2 == 0)
        return halfhalf;
    else
        return (halfhalf * base)%MOD;
}

int N, K;
LL F[MAXN + 3]; //F[i] -> How many tuples whose gcd is i

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

    F[K] = 1;
    for (int g = K - 1; g >= 1; g--) {
        F[g] = fastExponentiation(K/g, N);
        for (int gg = 2 * g; gg <= K; gg += g)
            F[g] = (F[g] - F[gg] + MOD)%MOD;
    }

    LL answer = 0;
    for (int g = 1; g <= K; g++)
        answer = (answer + (F[g] * g)%MOD)%MOD;

    cout << answer << endl;
}


Measured memory_bytes: 4364
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<vector<int>> d(n, vector<int>(n-1,0));
  vector<int> cnt(n*n,0);
  vector<int> v[n*n];
  rep(i,n)rep(j,n-1){
    cin >> d[i][j];
    d[i][j]--;
    if(j!=0){
      int a = i, b = d[i][j-1];
      if(a>b) swap(a,b);
      int c = i, e = d[i][j];
      if(c>e) swap(c,e);
      v[a*n+b].emplace_back(c*n+e);
      cnt[c*n+e]++;
    }
  }

  int ans = 0;
  int vs = 0;
  int pre = -1;
  queue<int> q;
  rep(i,n)rep(j,i){
    if(cnt[j*n+i]==0){
      q.push(j*n+i);
      vs++;
    }
  }
  while(pre!=vs){
    ans++;
    pre = vs;
    queue<int> nq;
    while(!q.empty()){
      int p = q.front(); q.pop();
      for(auto it:v[p]){
        cnt[it]--;
        if(cnt[it]==0){
          nq.push(it);
          vs++;
        }
      }
    }
    swap(q,nq);
  }
  if(vs!=n*(n-1)/2){cout << -1 << endl; return 0;}
  cout << ans << endl;
  return 0;
}

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  ll ans = 0;
  int ar=0;
  int br=0;
  int cr=0;
  for(int c=0;c<=100000;c++){
    int a = max(0, X-c);
    int b = max(0, Y-c);
    ll result = c * 2 * C + a*A+b*B;
    if(ans==0){
      ans = result;
    }else{
      ans = min(ans, result);
    }
  }
  printl(ans);
}


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

using namespace std;


const int DIM = 1e5 + 7;

int viz[DIM];

int v[DIM];

unsigned long long euclid(unsigned long long a, unsigned long long b)
{
    long long c;
    while (b) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}


unsigned long long lgput(unsigned long long N, unsigned long long P)
{
   unsigned long long rez = 1;
    while(P > 0)
    {
        if(P & 1)
        {
            rez *= N;

            P--;
        }
        N*=N;

        P /= 2;
    }
    return rez;
}

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

      int n,m;

      cin >> n >> m;

       unsigned long long y = 0;
      long long put = 0;

      for(int i = 1; i <= n; i++)
        {
          unsigned long long x;
          cin >> v[i];
          x = v[i];
          x /= 2;

            long long cnt = 1;
            while(x % 2 == 0)
            {
                cnt++;
                x/= 2;
            }

            if(put == 0)
            put = cnt;
            else
            if(put != cnt)
            {
                cout << 0;
                return 0;
            }

        }

        unsigned long long z = lgput(2,put);


         y = v[1] / z;
        for(int i = 2; i <= n; i++)
        {
          v[i] /= z;
          y /=  euclid(y,v[i]);
          y *= v[i];
        }
    y *= z / 2;

    unsigned long long rez = ( (m / y) + 1) / 2;


    cout << rez;
    return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        sc.close();
        System.out.println(collatz(N));
    }

    private static int collatz(int x) {
        List<Integer> list = new ArrayList<>();
        int n = x;
        while(true) {
            list.add(n);
            int num = 0;
            if(n%2 == 0) {
                num= n/2;
            } else {
                num = 3 * n + 1;
            }
            if(list.contains(num)) {
                return list.size() + 1;
            }

            n = num;
        }
    }

}



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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int x,p=100,step=0;
	cin>>x;
	while(x>p)
	{
	    p+=p/100;
	    step++;
	}
	cout<<step<<endl;
	return 0; 
} 


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
 
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}

int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   string s;
   cin>>s;
   int n = s.size();
   int l=0,r=n-1;
   while(l<r){
       if(s[l]!=s[r]){
           cout << "No";
           return 0;
       }
       l++;r--;
   }
   l = 0;
   r = (n - 1) / 2 - 1;
   while(l<r){
       if(s[l]!=s[r]){
           cout << "No";
           return 0;
       }
       l++;r--;
   }
   cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

int main(){

  int n = in();
  int k = in();

  if(k <= (n + 1) / 2){
    puts("YES");
  } else {
    puts("NO");
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    
    char[][] G;
    int N;

    int next(int i){ return ((N-i-1)+N)%N;}

    boolean getState(int i, int j){
	return  G[i][j] == G[i][next(j)] &&
	    G[i][j] == G[next(i)][j] &&
	    G[i][j] == G[next(i)][next(j)];
    }
    
    int getInit(){
	int i, j, dcnt = 0;
	for ( i = 0; i < N/2; i++ ){
	    for ( j = 0; j < N/2; j++ ){
		if (!getState(i, j)) dcnt++;
	    }
	}
	return dcnt;
    }
    
    void solve(){
	Scanner sc = new Scanner(System.in);
	int dcnt;
	int ans = 0;
	int C = sc.nextInt();
	N = sc.nextInt();

	G = new char[N][N];
	
	for ( int i = 0; i < N; i++ ){
	    String str = sc.next();
	    for ( int j = 0; j < N; j++ ){
		G[i][j] = str.charAt(j);
	    }
	}
	
	dcnt = getInit();
	if (dcnt == 0 ) ans++;
	for ( int i = 0; i < C-1; i++ ){
	    int k = sc.nextInt();
	    for ( int j = 0; j < k; j++ ){
		int r = sc.nextInt();
		int c = sc.nextInt();
		r--; c--;
		boolean pre = getState(r, c);
		G[r][c] = G[r][c]=='1'?'0':'1';
		boolean post = getState(r, c);
		if ( !pre && post ) dcnt--;
		else if ( pre && !post ) dcnt++;
	    }
	    if ( dcnt == 0 ) ans++;
	}

	System.out.println(ans);
    }

    public static void main(String[] args){
	new Main().solve();
    }
}



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

int main(){
  string s;
  while(std::cin >> s, s != "0"){
    int a = 0, b = 0;
    for (int i = 1; i < s.length(); i++) {
      if(s[i] == 'A')a++;
      else b++;
    }
    std::cout << (a + (a > b)) << " " << (b + (b > a)) << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3012
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dpsheet
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] arr = new int[n];
            int[] temp = new int[n];
            string [] st = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                temp[i] = -1;
            for (int i = 0; i < n; i++)
                arr[i] = int.Parse(st[i]);
            Console.WriteLine(frog(arr, 0, n,temp));
            
             
        }
        static int frog(int[]arr,int i,int n,int[] temp)
        {
            int k = int.MaxValue;
            int l = int.MaxValue;
            if (temp[i] != -1)
                return temp[i];
            if (i==n||i==n-1)
                return temp[i]=0;
            if (i + 1 < n)
                 k= frog(arr, i + 1, n, temp) + Math.Abs(arr[i] - arr[i + 1]);
            if (i + 2 < n)
                 l = frog(arr, i + 2, n, temp) + Math.Abs(arr[i] - arr[i + 2]);
            temp[i] = Math.Min(k, l); 
            return temp[i];
        }
    }
}


Measured memory_bytes: 26592
#include <stdio.h>

int main(void)
{
	int a[4], b[4];
	int i, j;
	int hit, blow;
	
	while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF){
		scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
		
		hit = 0;
		blow = 0;
		
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[j] && i == j){
					hit++;
				}
				
				else if (a[i] == b[j] && i != j){
					blow++;
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	
	return (0);
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 987654321
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int n, t, arr[200010];

int main() {
	fastio;
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> t;
		arr[t]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << arr[i] << endl;
	}
}

Measured memory_bytes: 4372
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		int L_count=0;
		int L_ok=0;
		int D_count=0;
		int D_ok=0;
		int M_count=0;
		int M_ok=0;
		for(int i=0;i<n;i++){
			int h,m,d;
			scanf("%d:%d %d",&h,&m,&d);
			int time = (d-m >= 0 ? d-m : (60+d-m));
			bool isok = (time <= 8 ? true : false);

			int t = h*60+m;

			if(11*60 <= t && t <= 14*60 + 59){
				if(isok) L_ok++;
				L_count++;
			}
			else if(18*60 <= t && t <= 20*60 + 59){
				if(isok) D_ok++;
				D_count++;
			}
			else if((21*60 <= t && t <= 24*60)
				|| (24*60 <= t && t <= (24+1)*60+59)
				|| (0 <= t && t <= 1*60+59)){
					if(isok) M_ok++;
					M_count++;
			}
		}
		
		if(L_count==0){
			printf("lunch no guest\n");
		}
		else{
			printf("lunch %.0lf\n",floor(((L_ok)/(double)L_count + EPS) * 100.0));
		}

		if(D_count==0){
			printf("dinner no guest\n");
		}
		else{
			printf("dinner %.0lf\n",floor(((D_ok)/(double)D_count + EPS) * 100.0));
		}

		if(M_count==0){
			printf("midnight no guest\n");
		}
		else{
			printf("midnight %.0lf\n",floor(((M_ok)/(double)M_count + EPS) * 100.0));
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}
const int N=410;
int n,h,in[N],out[N];
int fa[N];
bool ok[N];

int find(const int &x){return fa[x]==x?x:fa[x]=find(fa[x]);}

int main()
{
    n=read();h=read();
    for(int i=1;i<=(h<<1);i++) fa[i]=i;
    for(int i=1;i<=n;i++)
    {
        int A=read(),B=read(),C=read(),D=read();
        int x=C?C+h:A,y=D?D:B+h;
        out[x]++;in[y]++;
        x=find(x);y=find(y);
        if(x!=y) fa[x]=y;
    }
    for(int i=1;i<=h;i++) if(in[i]>out[i]) return !puts("NO");
    for(int i=h+1;i<=(h<<1);i++) if(in[i]<out[i]) return !puts("NO");
    for(int i=1;i<=(h<<1);i++) if(in[i]!=out[i]||!in[i]&&!out[i]) ok[find(i)]=1;
    for(int i=1;i<=(h<<1);i++) if(fa[i]==i&&!ok[i]) return !puts("NO");
    return !puts("YES");
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    vector<vector<int>> fi(H, vector<int>(W));
    int cur = 0;
    REP(i,H){
        if(i % 2 == 0){
            REP(j,W){
                if(a[cur] == 0){
                    cur++;
                }
                fi[i][j] = cur + 1;
                a[cur]--;
            }
        }
        else{
            for(int j=W-1;j>=0;j--){
                if(a[cur] == 0){
                    cur++;
                }
                fi[i][j] = cur + 1;
                a[cur]--;
            }
        }
    }
    REP(i,H){
        REP(j,W) cout << fi[i][j] << " ";
        cout << endl;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n;
  std::cin >> n;
  int prev = read(), cnt = 0, ans = 0;
  REP(i, n - 1) {
    int h = read();
    if (prev >= h)
      cnt++;
    else {
      chmax(ans, cnt);
      cnt = 0;
    }
    prev = h;
  }
  chmax(ans, cnt);
  print(ans);
}


Measured memory_bytes: 256
def main():
    n = 4
    a = [int(input()) for i in range(n)]
    A = a[0]
    B = a[1]
    C = a[2]
    X = a[3]
    result = 0
    for i in range(A+1):
        for j in range(B+1):
            for k in range(C+1):
                value = 500 * i + 100 * j + 50 * k
                if value == X:
                    result += 1
    print(result)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n=io.read("*n")
p={}

for i=1,n do
  table.insert(p, io.read("*n"))
end

c=0
j=0
for i=1,n do
  if p[i]~=j+1 then
    c=c+1
  end
  j=j+1
end

if c<=2 then
  print("YES")
else
  print("NO")
end

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

vector<string> vec;
vector<string> cnt;
set<ll> st;
map<string, ll> mp;

int main(void){
    // Your code here!
    int N;
    cin >> N;
    string s;
    for(int i = 0; i < N; i++){
        cin >> s;
        sort(s.begin(), s.end());
        mp[s] += 1;
    }
    
    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ans += (itr->second) * (itr->second - 1) / 2;
    }
    cout << ans << endl;

  
}


Measured memory_bytes: 11136
use std::io::prelude::*;

fn main() {
    let mut input_str = String::new();
    std::io::stdin().read_to_string(&mut input_str).unwrap();

    let input_parts = input_str.split_whitespace().collect::<Vec<_>>();
    let mut input_parts_it = input_parts.iter().cloned();
    let mut next = || input_parts_it.next().unwrap();

    let s = next();
    let bytes = s.as_bytes();

    let count = (0isize..s.len() as isize).filter(|&a|{
        let b = s.len() as isize - 1 - a;
        a < b && bytes[a as usize] != bytes[b as usize]
    }).count();

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


Measured memory_bytes: 4352
a, b = gets.chomp.split(" ").map(&:to_i)
(1..10000).each do |i|
    hachi = i * 8 / 100
    zyuu = i *10 / 100
    if hachi.floor == a && zyuu.floor == b
        puts i
        exit
    end
end
puts "-1"

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

int main(){
	int X, Y;

	cin >> hex >> X;
	cin >> hex >> Y;

	if (X < Y){
		cout << "<" << endl;
	}
	else if (X > Y){
		cout << ">" << endl;
	}
	else{
		cout << "=" << endl;
	}
	return 0;
}	


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

int main(void){
    long long n, a, b, blue;
    cin >> n >> a >> b;

    blue = n/(a + b)*a;
    if(n%(a + b) > a) blue += a;
    else blue += n%(a + b);

    cout << blue << endl;
    return 0;
}

Measured memory_bytes: 256
K,N = map(int,input().split())
len = []
a = [int(x) for x in input().split()]
for i in range(N):
  if i == N-1:
    if a[0] == 0:
      len.append(K - a[i])
    else:
      len.append((K - a[i]) + a[0])
  else:
    len.append(a[i+1] - a[i])
len.sort(reverse=True)
print(K-len[0])

Measured memory_bytes: 26444
#include<iostream>
#include<algorithm>
using namespace std;
long long n,k,a[51],lj;
int cmp(long long a,long long b)
{
	return a>b;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=k;i++)
		lj+=a[i];
	cout<<lj<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        long K = Long.parseLong(scanner.next());
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = Long.parseLong(scanner.next());
        }

        int[] bitCnt = new int[60];
        for (long n: A) {
            for (int i = 0; i < 60; i++) {
                if ((n & (1L << i)) > 0) {
                    bitCnt[i]++;
                }
            }
        }

        long[][] dp = new long[60][2];
        boolean started = false;
        for (int i = 58; i >= 0; i--) {
            long mask = 1L << i;
            if (started) {
                dp[i][1] = Math.max(dp[i][1], dp[i + 1][1] + mask * (N - bitCnt[i]));
                dp[i][1] = Math.max(dp[i][1], dp[i + 1][1] + mask * bitCnt[i]);
            }
            if ((K & mask) > 0) {
                dp[i][0] = dp[i + 1][0] + mask * (N - bitCnt[i]);
                dp[i][1] = Math.max(dp[i][1], dp[i + 1][0] + mask * bitCnt[i]);
                started = true;
            } else {
                dp[i][0] = dp[i + 1][0] + mask * bitCnt[i];
            }
        }
        System.out.println(Math.max(dp[0][0], dp[0][1]));
    }
}



Measured memory_bytes: 48652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int ans=1001;
  string s,t;
  cin>>s>>t;
  for(int i=0;i<=s.size()-t.size();i++){
    int cnt=0;
    for(int j=0;j<t.size();j++) cnt+=(s[i+j]!=t[j]);
    ans=min(ans,cnt);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3616
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int k;
  cin >> k;
  int odd,even;
  if(k%2 == 0){
    odd = k/2;
    even = k/2;
  }
  else{
    odd = k/2;
    even = k/2+1;
  }
  cout << odd*even << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin>>S;
    
    string ans;
    
    if(S.size()!=26){
        for(int i=0;i<26;i++){
            char word='a'+i;
            if(S.find(word)==-1){
                ans=S+word;
                break;
            }
        }
    }else{
        char word=S[S.size()-1];
        int p=-1;
        for(int i=S.size()-1;i>=0;i--){
            if(S[i]<word){word=S[i];p=i;break;}
            word=S[i];
        }
        char min_word=S[p+1];
        for(int i=p+1;i<S.size();i++){
            if(S[i]>word){
                min_word=min(min_word,S[i]);
            }
        }
 
        if(p>=0){
            ans=S.substr(0,p);
            ans+=min_word;
        }else{
            ans="-1";
        }
    }
    
    cout<<ans<<endl;
}

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

const int INF = 1000;
const double EPS = 1e-10;

struct point {
	double x, y;
	point():x(0), y(0) {}
	point(double x, double y):x(x), y(y) {}
	point(const point& p):x(p.x), y(p.y) {}

	point operator+ (const point& p) const {
		return point(x + p.x, y + p.y);
	}

	point operator- (const point& p) const {
		return point(x - p.x, y - p.y);
	}

	point operator* (const double s) const {
		return point(x * s, y * s);
	}

	point operator* (const point& p) const {
		return point(x * p.x - y * p.y, x * p.y + y * p.x);
	}

	point operator/ (const double s) const {
		return point(x / s, y / s);
	}

	bool operator< (const point& p) const {
		return x + EPS < p.x || abs(x - p.x) < EPS && y + EPS < p.y;
	}

	bool operator== (const point& p) const {
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
};

inline double abs(const point& p) {
	return sqrt(p.x * p.x + p.y * p.y);
}

inline double norm(const point& p) {
	return p.x * p.x + p.y * p.y;
}

inline double dot(const point& l, const point& r) {
	return l.x * r.x + l.y * r.y;
}

inline double cross(const point& l, const point& r) {
	return l.x * r.y - l.y * r.x;
}

struct segment {
	point a, b;
	segment(point a, point b):a(a), b(b){}
};

inline int ccw(const point& a, point b, point c) {
	b = b - a;
	c = c - a;
	const double tmp = cross(b, c);
	if(tmp > EPS) return 1; // ccw
	if(tmp < -EPS) return -1; // cw
	if(dot(b, c) < 0) return 2; // c, a, b 順に一直線上
	if(norm(b) < norm(c)) return -2; // a, b, c 順に一直線上
	return 0; //a, c, b 順で一直線上
}

inline bool intersect(const segment& s, const segment& t) {
	return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
		ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

inline bool intersect(const segment& s, const point& p) {
	return ccw(s.a, s.b, p) == 0;
}

inline double dist(const point& a, const point& b) {
	return abs(a - b);
}

inline point crosspoint(const segment& s, const segment& t) {
	if(!intersect(s, t)) // 交点を持たない
		return point(INF, INF); // 用改善

	const double tmp = cross(s.b - s.a, t.b - t.a);
	if(abs(tmp) < EPS) { // 一直線上
		if(intersect(s, t.a)) return t.a;
		if(intersect(s, t.b)) return t.b;
		if(intersect(t, s.a)) return s.a;
		return s.b;
	}

	return t.a + (t.b - t.a) * cross(s.b - s.a, s.b - t.a) * (1.0 / tmp);
}

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

	for(int n; cin >> n, n;) {
		vector<segment> segments;
		segments.reserve(n);
		for(int i = 0; i < n; ++i) {
			int x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			segments.push_back(segment(point(x1, y1), point(x2, y2)));
		}

		int ans = 1;
		for(int i = 0; i < n; ++i) {
			vector<point> cp;
			cp.reserve(n - i - 1);			
			for(int j = i + 1; j < n; ++j) {
				const point tmp = crosspoint(segments[i], segments[j]);
				if(abs(tmp.x) + EPS < 100.0 && abs(tmp.y) + EPS < 100.0)
					cp.push_back(tmp);
			}

			sort(cp.begin(), cp.end());
			cp.erase(unique(cp.begin(), cp.end()), cp.end());
			ans += cp.size() + 1;
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> b(n-1);
  for (int i = 0; i < n-1; i++) cin >> b[i];

  int ans = b[0]+b[n-2];
  for (int i = 0; i < n-2; i++)
  {
    ans+=min(b[i],b[i+1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a,b = map(int,input().split())

if a > 0 and b > 0:
    print("Positive")
elif a <= 0 and b >= 0:
    print("Zero")
elif a < 0 and b < 0:
    if ((b-a)-1) % 2  != 0:
        print("Negative")
    else:
        print("Positive")

Measured memory_bytes: 9092
K, N = map( int, input().split(" "))
A =[]
ss = input().split(" ")
for sss in ss:
  A.append( int(sss))

mindis = K
for i in range( N ):
  startpt = A[i]
  endpt = A[(i+N-1)%N]
  if(endpt < startpt):
    endpt += K
  if(mindis>(endpt-startpt)):
    mindis = endpt-startpt

print( mindis )

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int xuan(int n,int k) 
{ 
	if (n<=k) return k-n; 
	return n-k+2; 
}
int main()
{
	int n,k;
    cin>>n>>k;
    cout<<min(xuan(n,k),min(xuan(-n,k)+1,min(xuan(n,-k)+1,xuan(-n,-k)+2)))<<endl;
    return 0;
}

Measured memory_bytes: 256
x=list(input())

answer=[]

for i in range(len(x)):
    if x[i]=="0":
        answer.append("0")

    elif x[i]=="1":
        answer.append("1")

    elif x[i]=="B":
        if len(answer):
            answer.pop()

        else:
            pass

print("".join(answer))


Measured memory_bytes: 3060