akhauriyash/Code-Regression huggingface dataset:
from collections import deque

s = input()
q = int(input())
Q = [list(map(str, input().split())) for i in range(q)]

ans = deque(s)

reverse_num = 0
for i in range(q):
  if int(Q[i][0]) == 1:
    reverse_num += 1
  else:
    if int(Q[i][1]) == 1:
      if reverse_num % 2 == 0:
        ans.appendleft(Q[i][2])
      else:
        ans.append(Q[i][2])
    else:
      if reverse_num % 2 != 0:
        ans.appendleft(Q[i][2])
      else:
        ans.append(Q[i][2])

res = ''
if reverse_num % 2 == 0: 
  for i in range(len(ans)):
    res += ans.popleft()
  print(res)
else:
  for i in range(len(ans)):
    res += ans.pop()
  print(res)


Measured memory_bytes: 42380
from itertools import accumulate, combinations
while True:
    n = int(input())
    if n == 0:
        break
    L = [None]*n
    for i in range(n):
        L[i] = int(input())

    M = []
    M.append(0)
    M.extend(list(accumulate(L)))
    K = [ M[j] - M[i] for i, j in combinations(range(n+1),2)]
    print(max(K))
    
    
        


Measured memory_bytes: 201932
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int h, w;
    int n;
    ll a[10010];
    cin >> h >> w >> n;
    rep(i, n){
        cin >> a[i];
    }

    int g[110][110];
    rep(i, h){
        rep(j, w){
            g[i][j] = 0;
        }
    }

    int hh=0, ww=0;
    int dire = 1;
    rep(i, n){
        int cnt=0;
        while(cnt < a[i]){
            g[hh][ww] = i+1;
            if((ww == 0 && g[hh][ww+1] != 0) || (ww == w-1 && g[hh][ww-1] != 0) || (w == 1)){
                hh++;
                dire = (ww == 0) ? 1 : -1;
            }else{
                ww += dire;
            }
            cnt++;
        }
    }

    rep(i, h){
        rep(j, w){
            cout << g[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		long c=n/k;
		if(k%2==0){
			int t=k/2;
			long p=0;
			if(n%k>=t){
				p++;
			}
			System.out.println(c*c*c+(c+p)*(c+p)*(c+p));
		}else{
			System.out.println(c*c*c);
		}
	}
}


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

int main(){
    int n,k;
    ll sum=0;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    //cout << "1" <<endl;
    sort(a.begin(),a.end());
    //for(auto i:a)cout << i <<endl;
    rep(i,k){
        a.pop_back();
    }
    for(int i=0; i<n-k; i++){
        sum+=a[i];
    }
    cout << sum << endl;
    return 0;

}

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

int totalizer(vector<int>& data, int& dataLength) {
	int total = 0;
	int max = data[0];
	int min = data[0];

	for (int i = 0; i < dataLength; ++i) {
		total += data[i];

		if (data[i] > max) max = data[i];
		if (data[i] < min) min = data[i];
	}
	total -= (max + min);
	return total / (dataLength - 2);
}

int main() {
	vector<int> v(100);

	int n;
	cin >> n;

	while (n != 0) {
		for (int i = 0; i < n; ++i) {
			cin >> v[i];
		}
		cout << totalizer(v, n) << endl;
		cin >> n;
	}

	return 0;
}

Measured memory_bytes: 3092
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

void solve() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  vector<ll> v(n);
  rep(i, 0, n) cin >> v[i];
  sort(all(v));
  for (int i = 0; i < k; i++) ans += v[i];
  cout << ans;
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


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


const int N = 3005, MOD = 1e9 + 7;




int n, dp[N][N], pref[N][N];
char s[N];

inline void upd(int &x, int y){
    x += y;
    if(x < 0){
        x += MOD;
    }
    if(x >= MOD){
        x -= MOD;
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 2; i <= n; i++){
        cin >> s[i];
    }
    dp[1][1] = 1;
    for(int i = 1; i <= n; i++){
        upd(pref[1][i], pref[1][i - 1]);
        upd(pref[1][i], dp[1][i]);
    }
    for(int i = 2; i <= n; i++){
        if(s[i] == '<'){
            for(int j = 1; j <= i; j++){
                upd(dp[i][j], pref[i - 1][j - 1]);
            }
        }
        else{
            for(int j = 1; j <= i; j++){
                upd(dp[i][j], pref[i - 1][n]);
                upd(dp[i][j], -pref[i - 1][j - 1]);
            }
        }
        for(int j = 1; j <= n; j++){
            upd(pref[i][j], pref[i][j - 1]);
            upd(pref[i][j], dp[i][j]);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        upd(ans, dp[n][i]);
    }
    cout << ans;
}


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

int main(){
	int n;
	string in, out;
	vector<string> trans(10);
	trans[0] = "";
	trans[1] = ".,!? ";		trans[2] = "abc";	trans[3] = "def";
	trans[4] = "ghi";		trans[5] = "jkl";	trans[6] = "mno";
	trans[7] = "pqrs";		trans[8] = "tuv";	trans[9] = "wxyz";
	cin >> n;
	for( int k=0; k<n; k++ ){
		cin >> in;
		out = "";
		int cnt=0;
		for( int i=0; i<in.length(); i++ ){
			if( in[i] == '0' ){
				if( cnt > 0 ){
//					cout << "out:trans[" << in[i-1] << "][" << cnt << "%trans[" << in[i-1] << "].length]" << endl;
					out += trans[in[i-1]-'0'][(cnt-1)%trans[in[i-1]-'0'].length()];
					cnt = 0;
				}
			}else	cnt++;
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 0
from math import fabs
x, y = map(int, input().split())
ans = int(fabs(fabs(x)-fabs(y)))
if x*y >= 0 and x <= y:
	print(ans)
elif x*y < 0 or (x*y == 0 and y < x):
	print(ans+1)
else:
	print(ans+2)

Measured memory_bytes: 3192
from collections import deque
d = deque()
for a in range(int(input())):
    com = input().split()
    if com[0] == "insert":
        d.appendleft(com[1])
    elif com[0] == "delete":
        if com[1] in d:
            d.remove(com[1])
    elif com[0] == "deleteFirst":
        d.popleft()
    elif com[0] == "deleteLast":
        d.pop()
    else:
        break
print(*d)



Measured memory_bytes: 69728
from collections import defaultdict
import sys
sys.setrecursionlimit(110000)

def dfs(i):
	if i not in H: return 0
	if memo[i]>=0: return memo[i]
	a=sorted(-dfs(e) for e in H[i])
	memo[i]=max(i+1-a[i]for i in xrange(len(a)))
	return memo[i]
     
N=int(sys.stdin.readline())
memo=[-1]*N
H=defaultdict(list)
for i,e in enumerate(xrange(N-1)):H[int(sys.stdin.readline())-1].append(i+1)
dfs(N//2)
print(dfs(0))

Measured memory_bytes: 152760
from fractions import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))

g = A[0]
m = A[0]
for i in range(1, N):
  g = gcd(g, A[i])
  m = max(m, A[i])

if m < K or (g > 1 and K % g > 0):
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Measured memory_bytes: 16240
count = int(input())
numbers = input().split(" ")
for i in range(len(numbers)):
    numbers[i] = int(numbers[i])


if __name__ == "__main__":
    swap_count = 0

    flag = True
    while flag:
        flag = False
        for j in range(count-1, 0, -1):
            if numbers[j] < numbers[j-1]:
                numbers[j], numbers[j-1] = numbers[j-1], numbers[j]
                swap_count += 1
                flag = True

    print(*numbers)
    print(swap_count)



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

int main(){
	int c, tc, hc;
	string t, h;
	cin >> c;
	for(int i=0;i<c;i++){ 
		cin >> t >> h;
		if(t>h){tc+=3;}
		else if(t<h){hc+=3;}
		else{tc++;hc++;}
	}

	cout << tc << " " << hc << endl;



return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    int N, Y;
    std::cin >> N >> Y;

    Y /= 1000;
    for(int i=0;i<=N;++i){
        for(int j=0;j<=N-i;++j){
            int k = N - i - j;
            if(i + 5 * j + 10 * k == Y){
                std::cout << k << " " << j << " " << i << std::endl;
                return 0;
            }
        }
    }

    std::cout << "-1 -1 -1" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
  i64 from, to, cost;
  edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
  edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin >> n;
	int ans = 0, m = -1;
	for(int i = 0; i < n; ++i){
		int tmp;
		cin >> tmp;
		ans += tmp;
		m = max(m, tmp);
	}
	cout << ans - m / 2  << endl;
}

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

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

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

    ll x = a[n-1];
    cout << x << " ";

    if (x%2 == 0){
        vector<pair<ll,ll>> b(n-1);
        for (ll i = 0; i < n-1; i++){
            b[i] = make_pair(abs(a[i]-(x/2)),a[i]);
        }
        sort(b.begin(), b.end());
        cout << b[0].second << endl;
    }
    else{
        vector<pair<ll,ll>> b(n-1);
        for (ll i = 0; i < n-1; i++){
            if (a[i] <= x/2){
                b[i] = make_pair(abs(a[i]-(x/2)),a[i]);
            }
            else{
                b[i] = make_pair(abs(a[i]-((x/2)+1)),a[i]);
            }
        }
        sort(b.begin(), b.end());
        cout << b[0].second << endl;
    }

}

Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  int k = 0;
  cin >> N;
  vector<int> A(N);
  for(int a = 0;a < N;a++)cin >> A[a];
  for(int a = 1;a < N-1;a++){
    if(A[a] > A[a-1]&&A[a] < A[a+1])k++;
    if(A[a] < A[a-1]&&A[a] > A[a+1])k++;
    
  }
  cout << k;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    long long a;
    cin >> a;
    vector<long long> s(a);
    vector<long long> ans(a);
    long long b = 0;
    long long d = 0;
        for (int i = 0; i < a; i++) {
            cin >> s.at(i);
            b += s.at(i);
        }
        for (int i = 0; i < a; i += 2) {
            d += s.at(i);
        }
        ans.at(0) = (2 * d - b)/2;
        for (int i = 0; i < a-1; i++) {
            ans.at(i + 1) = s.at(i) - ans.at(i);
        }
        for (int i = 0; i < a - 1; i++) {
            cout << ans.at(i)*2 << " ";
        }
        cout << ans.at(a-1)*2 << endl;
}

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

#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
using namespace std;

template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << ": " << arg1 << endl;
}

template<typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = (int) 5e5 + 2;
int ar[NN];
int b[NN];
int n, m, k;
string s;


int f(int x, int y, int z){
    return x * x + y * y + z * z + x * y + y * z + x * z;
}

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

//    cin >> n;
//    int ans = 0;
//    for (int i = 1; i <= n; i++){
//        cin >> ar[i];
//        if (i % 2 == 1 && ar[i] % 2 == 1) ans++;
//    }
//    cout << ans;
    n = 10000;
    cin >> n;
    for (int x = 1; f(x, 1, 1) <= n; x++){
        for (int y = 1; f(x, y, 1) <= n; y++){
            for (int z = 1; f(x, y, z) <= n; z++){
                int a = f(x, y, z);
                ar[a]++;
            }
        }
    }
    for (int i = 1; i <= n; i++){
        cout << ar[i] << endl;
    }

}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

#define int long long
typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 + 10;

vector<ll> vec;

struct node {
    node *l = 0, *r = 0;
    int key, prior, siz = 0;
    node(int _key) { key = _key, prior = rand(), siz = 1; }
};

typedef pair<node*, node*> pairn;

ll size(node* v) {
    if (!v) return 0;
    else return v->siz;
}
node* rt = 0;

void upd(node* v) {
    if (!v) return;

    v->siz = size(v->l) + size(v->r) + 1;
}
pairn split(node* v, ll x) {
    if (!v) return { 0, 0 };

    if (v->key <= x) {
        pairn q = split(v->r, x);
        v->r = q.first;
        upd(v);
        return { v, q.second };
    }
    else {
        pairn q = split(v->l, x);
        v->l = q.second;
        upd(v);
        return { q.first, v };
    }
}

node* merge(node* l, node* r) {
    if (!l) return r;
    if (!r) return l;

    if (l->prior > r->prior) {
        l->r = merge(l->r, r);
        upd(l);
        return l;
    }
    else {
        r->l = merge(l, r->l);
        upd(r);
        return r;
    }
}

ll find(node* rt, ll val) {
    if (!rt) return 0;

    ll q = 0;
    if (rt->key <= val) {
        q = size(rt->l) + 1 + find(rt->r, val);
    }
    else {
        q = find(rt->l, val);
    }

    return q;
}

void ins(int x) {
    pairn q = split(rt, x);
    node* t = new node(x);
    rt = merge(merge(q.first, t), q.second);
}

signed main() {
    fastInp;

    ll n, k;
    cin >> n >> k;
    vec.resize(n);
    for (int i = 0; i < n; i++) cin >> vec[i];

    ll ans = 0, add = 0;
    for (int i = 0; i < n; i++) {
        add += vec[i];
        ins(vec[i] - add + i * k);
        ll q = find(rt, k * (i + 1) - add - 1);
        ans += size(rt) - q;
    }

    cout << ans;
    return 0;
}



Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int ans;
int k;

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

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(2, vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t h = 0;
    dp[h][0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        auto&& prev = dp[h];
        auto&& next = dp[!h];
        h = !h;

        for (auto j : irange(0L, k + 1) | reversed) {
            int64_t ss = 0;
            for (auto c : irange(a[i + 1], a.back() + 1)) {
                next[j][c] = ss + prev[j][a[i] + (c - a[i + 1])];
                ss += prev[j][a[i] + (c - a[i + 1])];
                next[j][c] %= M;
            }

            for (auto c : irange(a[i + 1], a.back() + 1)) {
                for (auto b : irange(a[i] + (c - a[i + 1]) + 1, c + 1)) {
                    auto w = j + b - (a[i] + (c - a[i + 1]));
                    if (w > k) {
                        break;
                    }
                    next[w][c] += prev[j][b];
                    next[w][c] %= M;
                }
            }
        }
    }

    int64_t ans = 0;
    for (auto i : irange(0L, k + 1)) {
        ans += dp[h][i][a.back()];
        ans %= M;
    }

    cout << ans << endl;
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

#define MAX_V 100
#define INF INT_MAX

long long int fact(long long int n){
    long long ans;
    if(n==1){
        return 1;
    }else{
        ans=n*fact(n-1);
    }
    ans=ans%(1000000000+7);
    return ans;
}

int main()
{
   int n,m;
   cin>>n>>m;
   if( 1<abs(n-m)){
       cout<<0<<endl;
       return  0;
   }
   int a,b;
   a=max(n,m);
   b=min(n,m);
   long long int ans;
   if(abs(n-m)==0){
       //mdmdパターン
       ans=fact(a);
       ans=ans*fact(b);
       ans=(ans*2)%(1000000000+7);
   }
   if(abs(n-m)==1){
       ans=fact(a);
       ans=ans*(fact(b))%(1000000000+7);
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);


int main()
{
int n,x,t;
cin>>n>>x>>t;int ans;
if(n%x==0){


	ans=((n/x)*t);}else{
		ans=((n/x)*t)+t;
	}
cout<<ans<<endl;
    return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


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


Measured memory_bytes: 3596
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define MAX 200000000000

long long absll(long long a) {
  if (a>0) {
    return a;
  } else {
    return -a;
  }
}

int main() {
  long long n;
  scanf("%llu", &n);
  long long A[n];
  for (int i = 0; i < n; i++) {
    scanf("%llu", &A[i]);
  }
  sort(A, A + n);
  long long res1 = 0, res2 = 0;
  for (long long i = 0; i < n-1; i++) {
    if (i%2==0) {
      res1 += absll(A[n-(i/2+1)]-A[i/2]);
    } else {
      res1 += absll(A[n-(i/2+1)]-A[i/2+1]);
    }
  }
  res1 += absll(A[0]-A[n/2-1]);

  for (long long i = 0; i < n-1; i++) {
    if (i%2==0) {
      res2 += absll(A[n-(i/2+1)]-A[i/2]);
    } else {
      res2 += absll(A[n-((i+1)/2+1)]-A[i/2]);
    }
  }
  if (n%2 == 0) {
    res2 += absll(A[n-1]-A[n/2]);
  } else {
    res2 += absll(A[n-1]-A[n/2+1]);
  }


  printf("%llu\n", max(res1,res2));

  return 0;
}


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

int main() {

  int n,k=0;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    if (i%2) k++; 
  }

  // cout << k << " " << n << endl;

  cout << (double)k/n;

}

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

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int a = 0,b = 0,c = 0;
  if(A >= K){
    a = K;
    cout << a << endl;
    return 0;
  }
  K -= A;
  if(B >= K){
    a = A;
    b = K;
    cout << a << endl;
    return 0;
  }
  K -= B;
  if(C >= K){
    a = A;
    b = B;
    c = K;
    cout << a - c << endl;
    return 0;
  }
  cout << A - C << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
vector<int> s;
int cnt;
int n;
int main() {
	cin>>n;
	s.resize(n);
	for(int i=0; i<n; i++) {
		cin>>s[i];
	}
	if(n<3) {
		cout<<0<<endl;
		return 0;
	}
	vector<int> t(3);
	for(int i=0; i<n; i++) {
		for(int j=i+1; j<n; j++) {
			for(int k=j+1; k<n; k++) {
				t[0]=s[i],t[1]=s[j],t[2]=s[k];
				sort(t.begin(),t.end());
				if(t[0]+t[1]>t[2] and t[2]-t[0]<t[1] and t[0]!=t[1] and t[1]!=t[2]and t[0]!=t[2]) {
					cnt++;
				}
			}
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        long n = scanner.nextLong();

        int limit = (int)Math.sqrt((double)n);

        for(long i=limit;i>0;i--) {
        	if(n%i==0) {
        		System.out.println((i-1)+(n/i-1));
        		break;
        	}
        }

    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 22484
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    long long n, h, i;

    long long t = 0;

    
    cin >> n >> h;

    vector <long long> a(n + 1);

    vector <long long> b(n + 1);


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> a.at(i) >> b.at(i);

         }

    sort( a.rbegin(), a.rend() );

    sort( b.rbegin(), b.rend() );


    for( i = 0 ; i < n ; i = i + 1 ){

        if( 0 < h && b.at(i) > a.at(0) ){

            h -= b.at(i);

            t += 1;

            }

        if( 0 >= h ){

            cout << t << endl;

            return 0;

            }

        }

    if( h % a.at(0) == 0 ){

        t += h / a.at(0);

        }

    else t += ( h / a.at(0) ) + 1;       


    cout << t << endl;


    return 0;

}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,n2=1,a[200010],dat[800010],ans[200010],num[200010],x,y;
vector <int> g[200010];
vector <pii> v;
map <int,int> mp;

void upd(int k,int val)
{
	dat[k]=val;
	while(k>0)
	{
		k=(k-1)/2;
		dat[k]=max(dat[k*2+1],dat[k*2+2]);
	}
}

int query(int k,int lb,int ub,int tlb,int tub)
{
	if(ub<tlb||tub<lb) return 0;
	if(tlb<=lb&&ub<=tub) return dat[k];
	return max(query(k*2+1,lb,(lb+ub)/2,tlb,tub),query(k*2+2,(lb+ub)/2+1,ub,tlb,tub));
}

void dfs(int pos,int no)
{
	if(no!=0) ans[pos]=ans[no];
	int tmp=query(0,0,n2-1,0,mp[a[pos]]-1);
	ans[pos]=max(ans[pos],tmp+1);
	upd(num[pos]+n2-1,tmp+1);
	rep(i,g[pos].size())
	{
		if(g[pos][i]==no) continue;
		dfs(g[pos][i],pos);
	}
	upd(num[pos]+n2-1,0);
}

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin>>n;
	repn(i,n)
	{
		scanf("%d",&a[i]);
		v.pb(mpr(a[i],i));
	}
	sort(v.begin(),v.end());
	rep(i,n)
	{
		num[v[i].se]=i;
		if(mp.find(v[i].fi)==mp.end()) mp[v[i].fi]=i;
	}
	rep(i,n-1)
	{
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	while(n2<n) n2*=2;
	dfs(1,0);
	repn(i,n) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 40624
#include <iostream>
#include <string>

using namespace std;

int main() {
  string n; cin >> n;
  if ((n[1] == n[2]) and (n[0] == n[1] or n[2] == n[3])) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readValue;
    while ((readValue = reader.readLine()) != null) {
      int leftVal = Integer.parseInt(readValue.split(" ")[0]);
      String op = readValue.split(" ")[1];
      int rightVal = Integer.parseInt(readValue.split(" ")[2]);
      int result;
      if (op.equals("?"))
        break;
      if (op.equals("+"))
        result = leftVal + rightVal;
      else if (op.equals("-"))
        result = leftVal - rightVal;
      else if (op.equals("*"))
        result = leftVal * rightVal;
      else if (op.equals("/"))
        result = leftVal / rightVal;
      else
        result = Integer.MIN_VALUE;
      System.out.println(result);
    }
  }

}

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


void solve(long long H, long long W){
    if(H == 1 || W == 1){
        cout << 1 << endl;
        return;
    }
    if(H % 2 == 0){
        cout << (H / 2) * W << endl;
    }else{
        cout << (H / 2) * W + (W + 1) / 2 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    solve(H, W);
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A)

    while True:
        v = A[0]
        tmp = [v]
        for i in range(len(A)):
            if A[i] % v == 1:
                print(1)
                return
            if A[i] % v == 0:
                pass
            else:
                tmp.append(A[i] % v)

        if len(A) == 1:
            print(A[0])
            return

        A = sorted(tmp)
        # print(A)


if __name__ == '__main__':
    main()


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

auto sum (const std::vector <int> & xs) -> int
{
    auto res = 0;
    for (auto && elem : xs)
    {
        res += elem;
    }
    return res;
}

auto sum (const std::vector <std::vector <int>> & xs) -> std::vector <int>
{
    std::vector <int> res (xs [0].size () , 0);
    for (auto i = 0u; i < res.size (); ++ i)
    {
        for (auto j = 0u; j < xs.size (); ++ j)
        {
            res [i] += xs [j] [i];
        }
    }
    return res;
}

auto main () -> int
{
    int h , w;
    std::cin >> h >> w;
    std::vector <std::vector <int>> a (h , std::vector <int> (w));
    for (auto && lines : a)
    {
        for (auto && elem : lines)
        {
            std::cin >> elem;
        }
    }
    for (auto && lines : a)
    {
        for (auto && elem : lines)
        {
            std::cout << elem << ' ';
        }
        std::cout << sum (lines) << std::endl;
    }
    auto sa = sum (a);
    for (auto && elem : sa)
    {
        std::cout << elem << ' ';
    }
    std::cout << sum (sa) << std::endl;
}

Measured memory_bytes: 3176
S=input()
T=input()
ans=0
if S==T: print(0); exit()
for i in range(len(S)-len(T)+1):
    tmp = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            tmp += 1
    ans = max(ans, tmp)
if not len(S) == ans:
  ans = len(T) - ans
print(ans)

Measured memory_bytes: 67576
#include <bits/stdc++.h>
using namespace std;
int main(){
    int l, r, d; cin >> l >> r >> d;
    int res = 0;
    for(int i=l; i<=r; ++i){
        if(i%d==0){res++;}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main{
	public static void main(String[] args) throws NumberFormatException, IOException{
		int[] mountains = new int[10];
		int[] big = new int[4];
		int cursor=0;

		BufferedReader d= new BufferedReader(new InputStreamReader(System.in));
		for(int i=0; i<10; i++){
			mountains[i]=Integer.valueOf(d.readLine());
		}

		for(int i=0;i<10;i++){
			for(int j=0;j<3;j++){
				if(big[j]<=mountains[i]){
					for(int k=2;k>j;k--){
						big[k]=big[k-1];
					}
					big[j]=mountains[i];
					mountains[i]=0;
				}
			}
		}


		for(int i=0;i<3;i++){
			System.out.println(big[i]);
		}
	}

}

Measured memory_bytes: 9464
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  char c;
  cin >> c;
  set<char> st{'a', 'i', 'u', 'e', 'o'};
  cout << (st.count(c) ? "vowel" : "consonant") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            double p = sc.nextDouble() * 0.01;
            if (n + m + p == 0) {
                break;
            }
            int sumMoney = 0;
            int electedNumberOfPeople = 0;
            for (int i = 0; i < n; i++) {
                int inputTmp = sc.nextInt();
                sumMoney += inputTmp * 100;
                if (m == i + 1) {
                    electedNumberOfPeople = inputTmp;
                }
            }
            int deductedMoney = sumMoney - (int) (sumMoney * p);
            if (0 < electedNumberOfPeople) {
                int ans = (int) Math.floor(deductedMoney
                        / (electedNumberOfPeople * 1.0));
                System.out.println(ans);
            } else {
                System.out.println("0");
            }
        }
    }

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

Measured memory_bytes: 30048
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	int ans_x=100*A, ans_y=0;
	for(int na=0; na<=30; na++){
		if(100*A*na > F) continue;
		for(int nb=0; nb<=30; nb++){
			if(100*(A*na+B*nb) > F) continue;
			for(int nc=0; C*nc<=(A*na+B*nb)*E; nc++){
				if(100*(A*na+B*nb)+C*nc > F) continue;
				for(int nd=0; D*nd<=(A*na+B*nb)*E-C*nc; nd++){
					int x = 100*(A*na+B*nb);
					int y = C*nc+D*nd;
					if(x+y > F) continue;
					if(y > x*E/100) continue;
					//cout << na << " " << nb << " " << nc << " " << nd << endl;
					if((double)ans_y/ans_x < (double)y/(x+y)){
						ans_x = x+y;
						ans_y = y;
					}
				}
			}
		}
	}

	cout << ans_x << " " << ans_y << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int n, a, i, max=0, min=1000;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d", &a);
    if(a>max) max=a;
    if(a<min) min=a;
  }

  printf("%d\n", max-min);


  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

int main()
{
    int n,m;
    long long ans=0;
    std::cin>>n>>m;
    std::vector<int> a(n);
    for(int i=0;i<n;i++)std::cin>>a[i];
    std::priority_queue<int> que;
    for(int i=0;i<n;i++)que.push(a[i]);
    for(int i=0;i<m;i++){
        int top = que.top();
        que.pop();
        que.push(top/2);
    }
    for(int i=0;i<n;i++){
        ans += que.top();
        que.pop();
    }
    std::cout<<ans<<std::endl;
    return 0;
}

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

int main () {
  int N;
  string s,t;
  cin >> N >> s >> t;
  
  for (int i = 0; i < N; i++) {
    int ans = N * 2;
    for (int j = 0; j < N-i; j++) {
      if (t.at(j) == s.at(i+j)){
        ans--;
        if (j == N-i-1){
          cout << ans << endl;
          return 0;
        }
      }
      else {
        break;
      }
    }
  }
  cout << N*2 << endl;
}
  

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string S;
    cin >> N >> S;
    int cnt = 0;
    for (int i = 0; i < 1000; i++) {
        int num[3] = { i / 100, (i / 10) % 10, i % 10 };
        int f = 0;
        for (int j = 0; j < N; j++) {
            if (S[j] == ('0' + num[f])) {
                f++;
            }
            if (f == 3) {
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
	int N;
	std::cin >> N;
	std::vector<int> vec;
	vec.resize(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> vec[i];
	}
	int patha = abs(vec[0] - vec[1]);
	int pathb = 0;
	for (int i = 0; i < N; ++i) {
		if (i%2) {
			if (i + 1 < N && patha + abs(vec[i] - vec[i + 1]) <= pathb) {
				pathb = patha + abs(vec[i] - vec[i + 1]);
			}
			if (i+2 < N) {
				patha+= abs(vec[i] - vec[i + 2]);
			} else if (i + 2 == N) {
				patha+= abs(vec[i] - vec[i + 1]);
			}
		} else {
			if (i + 1 < N && pathb + abs(vec[i] - vec[i + 1]) <= patha) {
				patha = pathb + abs(vec[i] - vec[i + 1]);
			}
			if (i+2 < N) {
				pathb+= abs(vec[i] - vec[i + 2]);
			} else if (i + 2 == N) {
				pathb+= abs(vec[i] - vec[i + 1]);
			}
		}
	}
	std::cout << std::min(patha, pathb) << "\n";
}

Measured memory_bytes: 640
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <iomanip>
using namespace std;

const int mod = 998244353;
#ifdef __cplusplus
extern "C" {
#endif
__attribute__((always_inline, optimize(3)))
__inline__ int add(int x, const int &y) {
  return (x += y) >= mod ? x - mod : x;
}
__attribute__((always_inline, optimize(3)))
__inline__ int mul(const int &x, const int &y) {
  return 1LL * x * y - 1LL * x * y / mod * mod;
}
#ifdef __cplusplus
}
#endif
unordered_map <string, int> dp;
int dfs(const string &now) {
  if (now.empty()) return 1;
  if (dp.find(now) != dp.end()) return dp[now];
  int &res = dp[now], n = now.size();
  res = dfs(now.substr(1));
  if (now[0] == '1') res = add(res, res);
  for (int i = 1; i < n; ++ i) {
    string s = now.substr(0, i);
    for (int j = i; j + i <= n; j += i) {
      for (int k = 0; k < i; ++ k)
        if (now[j + k] == '0') s[k] = '0';
      res = add(res, mul(dfs(s), dfs(now.substr(j + i))));
    }
  }
  return res;
}
int main(int argc, const char *argv[]) {
  ios_base :: sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cout << fixed << setprecision(12);
  string s; cin >> s; cout << dfs(s) << endl;
  return 0;
}

Measured memory_bytes: 5388
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N=110;

int n,m,a[N],b[N];

int main(){
  scanf("%d%d",&n,&m);
  int iodd=0;
  for(int i=1;i<=m;i++)
    scanf("%d",&a[i]),iodd+=(a[i]&1);
  if(m==1){
    if(a[1]==1) printf("%d\n1\n%d\n",1,1);
    else printf("%d\n2\n%d %d\n",a[1],a[1]-1,1);
    return 0;
  }
  if(iodd>2) puts("Impossible");
  else{
    for(int i=2;i<=m;i++)
      if(a[i]&1) (a[1]&1)?swap(a[m],a[i]):swap(a[1],a[i]);
    int t=0; if(a[1]>1) b[++t]=a[1]-1;
    for(int i=2;i<m;i++) b[++t]=a[i];
    b[++t]=a[m]+1;
    for(int i=1;i<=m;i++) printf("%d ",a[i]); putchar('\n');
    printf("%d\n",t);
    for(int i=1;i<=t;i++) printf("%d ",b[i]);
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		ArrayList<Long> one = nextLongArray();
		long max = Math.max(one.get(0), one.get(1));
		long min = Math.min(one.get(0), one.get(1));
		if(max <= 1){
			myout("Brown");
		}else if(max - 2 >= min){
			myout("Alice");
		}else{
			myout("Brown");
		}
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 32892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,m,cap;
  while(cin>>n>>m>>cap,n||m||cap){
    map<string,int> ms;
    string src,dst;
    cin>>src>>dst;
    ms[src]=0;ms[dst]=1;
    vector<P> G[10000];
    for(int i=0;i<n;i++){
      string a,b;
      int c;
      cin>>a>>b>>c;
      if(!ms.count(a)){int k=ms.size();ms[a]=k;}
      if(!ms.count(b)){int k=ms.size();ms[b]=k;}
      G[ms[a]].push_back(P(ms[b],c));
      G[ms[b]].push_back(P(ms[a],c));
    }
    
    int v=ms.size(),inf=1<<25;
    int dp[m+2][v];
    vector<string> vs(m+2);
    for(int i=0;i<m+2;i++){
      for(int j=0;j<v;j++) dp[i][j]=inf;
      if(i<m) cin>>vs[i];
      else if(i==m) vs[i]=src;
      else vs[i]=dst;
      int u=ms[vs[i]];
      priority_queue<P> q;
      dp[i][u]=0;
      q.push(P(0,u));
      while(!q.empty()){
	P p=q.top();q.pop();
	int x=p.second;
	if(dp[i][x]<-p.first) continue;
	for(P y:G[x]){
	  if(dp[i][x]+y.second<dp[i][y.first]){
	    dp[i][y.first]=dp[i][x]+y.second;
	    q.push(P(-dp[i][y.first],y.first));
	  }
	}
      }
    }

    int e[m+2][m+2];
    for(int i=0;i<m+2;i++)
      for(int j=0;j<m+2;j++)
	if(dp[i][ms[vs[j]]]<=cap*10)
	  e[i][j]=dp[i][ms[vs[j]]];
	else e[i][j]=inf*(i!=j);
    
    for(int k=0;k<m+2;k++)
      for(int i=0;i<m+2;i++)
	for(int j=0;j<m+2;j++)
	  e[i][j]=min(e[i][j],e[i][k]+e[k][j]);

    cout<<(e[m][m+1]<inf?e[m][m+1]:-1)<<endl;
    
  }
  return 0;
}

Measured memory_bytes: 8132
#include <stdio.h>

#define N_MAX 1000

void solve(int n, int x, int m[]);
int findMin(int size, int intArray[]);

int main()
{
  int n, x, m[N_MAX];
  int i;
  int start, end;
  int total = 0;

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

  return 0;
}

void solve(int n, int x, int m[])
{
  int i, sumOfAllKind, rest, maxCanMadeByRest;

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

  rest = x - sumOfAllKind;
  maxCanMadeByRest = rest / findMin(n, m);

  printf("%d\n", n + maxCanMadeByRest);
}

int findMin(int size, int intArray[])
{
  int i, min;

  min = intArray[0];
  for (i = 0; i < size; i++)
    {
      if (min > intArray[i])
	{
	  min = intArray[i];
	}
    }

  return min;
}


Measured memory_bytes: 128
a, b, c, x, y = map(int, input().split())
ans = 0
if a + b < c * 2:
    ans = x * a + y * b
else:
    if x <= y:
        # 余計にできる場合も考える
        ans = min(2 * c * x + b * (y - x), 2 * c * y)
    else:
        ans = min(2 * c * y + a * (x - y), 2 * c * x)
print(ans)


Measured memory_bytes: 3060