akhauriyash/Code-Regression huggingface dataset:
//by Tipa_Top1
#include <bits/stdc++.h>                   

#define f first
#define s second
#define ll long long 
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, n) for (int i = 1; i <= n; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return
#define rep(i, a, b) for(int i = a; i <= b; i++) 

using namespace std;

const int mod = 1e9 + 7;
const int maxn = 1e6 + 111;

int n, a[maxn], sum;

main(){
	cin >> n;

	rep(i, 1, n){
		cin >> a[i];
		sum += a[i];
	}

	if (sum % (n * (n + 1) / 2) != 0){
		puts("NO");
		return 0;
	}

	int k = sum / (n * (n + 1) / 2), cur = 0;

	a[n + 1] = a[1];

	for (int i = 2; i <= n + 1; i++){
		if (abs(a[i] - a[i - 1] - k) % n){
			puts("NO");
			return 0;
		}
		cur += abs(a[i] - a[i - 1] - k);
	}

	if (cur != k * n)
		puts("NO");
	else
		puts("YES");
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll K; cin>>K;
  ll k = K;
  string S; cin>>S;
  
  ll i=0;
  while (S[i] && k>0){
    cout<<S[i];
    k--;
    i++;
  }
  if (S.size() > K)
    cout<<"..."<<endl;
  else
    cout<<endl;
}


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

int main() {
  int n, s1, s2, s3;
  
  cin >> n;
  s1 = n/100;
  s2 = (n-s1*100)/10;
  s3 = n%10;
  
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
// include {{{
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <cstdio>
#include <vector>
#include <complex>
#include <iostream>
#include <algorithm>

using namespace std;

// }}}
/* cpp template {{{*/


#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)

typedef double D;      // ??§?¨?????????????double???long double?????????
typedef long long ll;
typedef long double lb;
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y, int x, int H, int W){return (y >= 0 && x >= 0 && y < H && x < W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}

/* ?????° */
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


/* }}} */

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

  int n = in();
  while (n--){
    string a, b, y;
    int cnt;
    cin >> a >> b;

    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    while (a.size() < b.size()) a += '0';
    while (b.size() < a.size()) b += '0';

    cnt = 0;
    REP(i, a.size()){
      cnt = a[i] - '0' + b[i] - '0' + cnt;
      y += (cnt % 10 + '0');
      cnt /= 10;
    }
    if (cnt) y += '1';
    reverse(y.begin(), y.end());
    if (y.size() > 80) y = "overflow";
    cout << y << endl;
  }


  return (0);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const string YES = "Yes";
const string NO = "No";

void solve(std::string N){
    ll S = N.size();
    ll ans =0;
    for(int i=0;i<S;i++){
        ans += (N[i]-'0');
    }
    if(ans%9==0){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string N;
    std::cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3832
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll A, B, K;
  cin >> A >> B >> K;
  REP(i, A, min(B, A + K - 1) + 1) {
    cout << i << endl;
  }
  REP(i, max(B - K + 1, A + K), B + 1) {
    cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  int N, M;
  cin >> N;
  map<string, int> ans{};
  string s_tmp;
  for (int i = 0; i < N; i++) {
    cin >> s_tmp;
    ans[s_tmp]++;
  }

  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> s_tmp;
    ans[s_tmp]--;
  }
  int max = 0;
  for (auto t : ans) {
    if (t.second > max) {
      max = t.second;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>


using namespace std;

int main()
{
	int n, ans1=0, x[300][300]={};
	long long int a[300][300], ans=0;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			scanf("%lld", &a[i][j]);
		}
	}
	if(n==1){
		printf("%d\n", 0);
	}else if(n==2){
		printf("%lld\n", a[0][1]);
	}else{
		for(int i=1;i<n; i++){
			for(int j=0; j<i; j++){
				for(int k=0; k<n; k++){
					if(a[i][j]>a[i][k]+a[j][k] || a[i][k]>a[i][j]+a[j][k] || a[j][k]>a[i][j]+a[i][k]){
						ans1=-1;
					}
					if(k!=i && k!=j && a[i][j]==a[i][k]+a[k][j]){
						x[i][j]=1;
					}
				}
				if(x[i][j]==0){
					ans=ans+a[i][j];
				}
			}
		}
		if(ans1==-1){
			printf("%d\n", ans1);
		}else{
			printf("%lld\n", ans);
		}
	}

	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
int main()
{
   fast ;
   ///Mission-500
   ll n ;
   cin>>n ;
   ll ans=0 ;
   ll c=1 ;
   for(ll i=0;i<n;i++)
   {
       ll x ;
       cin>>x ;
       if(x==c)
       {
           c++ ;
       }
       else
       {
           ans++ ;
       }
   }
   if(ans==n)
    cout<<"-1" ;
   else
    cout<<ans ;


}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		int[] array = new int[] { a, b, c, d, e };

		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array.length; j++) {
				if (i == j) {
					continue;
				}

				if (Math.abs(array[i] - array[j]) > k) {
					System.out.println(":(");
					return;
				}
			}
		}

		System.out.println("Yay!");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Pair {
		private int A;
		private int B;

		public Pair(int a, int b) {
			super();
			A = a;
			B = b;
		}

		public int getA() {
			return A;
		}

		public int getB() {
			return B;
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 23252
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
//typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 1000020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e16;

ll dp[303][303][303];
void solve() {
	int N, K; cin >> N >> K;
	vector<int>H(N + 2);
	REP(i, 303)REP(j, 303)REP(k, 303)dp[i][j][k] = INF;
	REP(i, N)cin >> H[i + 1];
	ll ans = INF;
	dp[0][0][0] = 0;
	FOR(i, 1, N + 1) {
		REP(idx, i) {
			REP(cnt, K+1) {
				dp[i][i][cnt] = min(dp[i][i][cnt], dp[i - 1][idx][cnt] + max((ll)0,H[i]-H[idx]));
				//dp[i][idx][cnt+1]= min(dp[i][i][cnt+1], dp[i - 1][idx][cnt]);
				dp[i][idx][cnt + 1] = dp[i - 1][idx][cnt];
				//pe(i); pe(i); pe(cnt); print(dp[i][i][cnt]);
				//pe(i); pe(idx); pe(cnt + 1); print(dp[i][idx][cnt + 1]);
			}
		}
	}
	REP(idx, N + 1) {
		REP(cnt, K + 1) {
			ans = min(ans, dp[N][idx][cnt]);
		}
	}
	print(ans);
}

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

	solve();

}



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

using namespace std;

char str[100100];
int n;

int main() {
    int i, res, p;

    scanf("%s",str);
    n = strlen(str);
    res = (n+1)/2;
    p = str[n/2];
    for (i=n/2-1;i>=0;i--,res++) {
        if (str[i]!=str[n-1-i]||str[i]!=p) break;
    }
    printf("%d\n",res);

    return 0;
}


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


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

    vi c(26);
    rep(i, 26) cin >> c[i];

    vvi s(d, vi(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];

    rep(i, d) {
        ll ans = 0;
        ll m = 0;
        rep(j, 26) {
            if (umax(m, s[i][j]))
                ans = j;
        }
        prt(ans + 1);
    }

    return 0;
}


Measured memory_bytes: 3680
def bfs(field,H,W,start_x,start_y,tmp_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    que = []
    que.append([start_x,start_y])
    INF = 1000000
    min_path = [[INF] * W for i in range(H)]
    min_path[start_y][start_x] = 0
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] != "X" and min_path[ny][nx] == INF:
                min_path[ny][nx] = min_path[current[1]][current[0]] + 1
                if field[ny][nx] == tmp_N:
                    return nx,ny,min_path[ny][nx]
                else:
                    que.append([nx,ny])

def getField():
    matrix = []
    first = input().strip()
    H,W,N = map(int,first.split())
    for i in range(H):
        row = list(input().strip())
        for j in range(W):
            if row[j].isdigit():
                row[j] = int(row[j])
        matrix.append(row)
    return matrix,H,W,N

def getStart(field):
    for y in range(len(field)):
        for x in range(len(field[0])):
            if field[y][x] == "S":
                return x,y

def main():
    matrix,H,W,N = getField()
    sx,sy = getStart(matrix)
    distance = 0
    tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,sx,sy,1)
    distance += tmp_dist
    tmps = [tmp_x,tmp_y]
    for k in range(N-1):
        tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,tmps[0],tmps[1],k+2)
        distance += tmp_dist
        tmps = [tmp_x,tmp_y]
    print(distance)

if __name__=='__main__':
    main()

Measured memory_bytes: 36896
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N,K,C;cin >> N >> K >> C;
    string S;cin >> S;
    //i日目に働かなきゃいけない=i日目を除いたときにK-1日しか働けない→判定問題を解く
    vector<int> left(N+1),right(N+1);
    int rest = C+1;
    for(int i = 0;i<N;i++){
        if(S.at(i) == 'o' && rest >= C){
            rest = 0;
            left.at(i+1) = left.at(i) + 1;
        }
        else{
            left.at(i+1) = left.at(i);
            rest++;
        }
    }
    rest = C+1;
    for(int i = N-1;i>=0;i--){
        if(S.at(i) == 'o' && rest >= C){
            rest = 0;
            right.at(i) = right.at(i+1) + 1;
        }
        else{
            right.at(i) = right.at(i+1);
            rest++;
        }
    }
    /*for(int V : left) cout << V << " ";
    cout << endl;
    for(int V : right) cout << V << " ";
    cout << endl;*/
    for(int i = 1;i<=N;i++){
        if(S.at(i-1) == 'x') continue;
        int canWork = 0;
        canWork += left.at(i-1);
        canWork += right.at(i);
        if(canWork == K-1){
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 5176
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;


ll a[100005];
ll tmplist[100005];


int main(){
	ll n;
	cin >> n;
	rep(i,n) cin >> a[i];
	ll q;
	cin >> q;
	ll ans = 0;
	rep(i,n){
		tmplist[a[i]]++;
		ans+=a[i];
	}
	vll anslist;
	rep(i,q){
		ll b,c;
		cin >> b >> c;
		ans+=tmplist[b]*(c-b);
		tmplist[c]+=tmplist[b];
		tmplist[b] = 0;
		anslist.push_back(ans);
	}
	for(const auto& x : anslist){
		prints(x);
	}







    return 0;
}




Measured memory_bytes: 5760
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int n, m;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        m = int.Parse(input[1]);
        int p = 998244353;

        Mod mod = new Mod(3000000);
        long ans = p - n;
        ans *= mod.Ncr(m + n - 2, n - 1);
        ans %= p;
        ans += mod.Ncr(m * 3 + n - 1, n - 1);
        ans %= p;
        /*
        if (n > m + 1)
        {
            ans += p;
            ans -= mod.Ncr(n + m - 3, n - m - 2);
            ans %= p;
        }
        */
        if(n > m + 1)
        {
            int c = 0;
            long ans2;
            for (int i = 0; m + 2 + i <= n; i = i + 2)
            {
                if (m - 1 - i / 2 < 0) break;
                ans2 = mod.Ncr(n, m + 2 + i);
                ans2 *= mod.Ncr(n + m - 2 - i / 2, n - 1);
                ans2 %= p;
                ans += p;
                ans -= ans2;
                ans %= p;
            }
        }
        

        Console.WriteLine(ans);
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}

// Mod(int n)
// int[] fac: factors (1-indexed)
// int n: the length of fac

// int .Ncr(n,r): nCr
// int .Fac(n): n!%p
// int .Pow(n,m): n^m%p

public class Mod
{
    const int p = 998244353;
    int[] fac;

    public Mod(int n)
    {
        fac = new int[n + 1];
        fac[0] = 1;
        long tmp = 0;
        for (int i = 1; i <= n; i++)
        {
            tmp = fac[i - 1];
            tmp *= i;
            tmp %= p;
            fac[i] = (int)tmp;
        }


    }

    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (r == 0 | n == r) return 1;
        long a = Fac(n);
        a = a * Pow(Fac(n - r), p - 2) % p;
        a = a * Pow(Fac(r), p - 2) % p;
        return (int)a;
    }

    public int Fac(int n)
    {
        if (fac[n] >= 0) return fac[n];
        long k = 1;
        for (long i = 1; i <= n; i++)
        {
            k = k * i % p;
        }
        fac[n] = (int)k;
        return fac[n];
    }

    public int Pow(int n, int m)
    {
        if (m == 0) return 1;
        if (m == 1) return n;
        long a = 1;
        if (m % 2 == 0)
        {
            a = Pow(n, m / 2);
            a = a * a % p;
        }
        else
        {
            a = Pow(n, m / 2);
            a = a * a % p;
            a = a * n % p;
        }
        return (int)a;
    }
}

Measured memory_bytes: 22624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  string C[H];
  for(int i=0;i<H;i++) cin>>C[i];
  for(int i=0;i<H;i++) cout<<C[i]<<endl<<C[i]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
  int w,a,b;
  int dist;
  scanf("%d %d %d", &w,&a,&b);
  if(b-w>a){
    dist=b-a-w;
  } else if(b<a-w){
    dist=a-b-w;
  } else {
    dist=0;
  }
  printf("%d\n",dist);
}


Measured memory_bytes: 128
#input
n = int(input())
blue = []
for i in range(n):
    s = input()
    blue.append(s)
m = int(input())
red = []
for i in range(m):
    t = input()
    red.append(t)
#maniplate
ans = [0]
for word in (blue + red):
    count = sum([s == word for s in blue])
    count -= sum([t == word for t in red])
    ans.append(count)
#output
print(max(ans))

Measured memory_bytes: 3064
#include<iostream>
int main()
{
	int number;
	std::cin >> number;
	int*values = new int[number];
	for(int i = 0; i < number; i++)
	{
		std::cin >> values[i];
	}
	for(int i = number - 1; i >= 0; i--)
	{
		std::cout << values[i];
		if(i != 0)
		{
			std::cout << ' ';
		}
	}
	std::cout << std::endl;
	return 0;
}


Measured memory_bytes: 3080
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void calc(int i, const ll* s, ll& min00, ll& max00)
{
    assert(i >= 2);
    min00 = LINF; max00 = -LINF;

    ll tmp0 = s[0]+(s[i]-s[0]) / 2;
    int k = lower_bound(s + 0, s + i, tmp0) - s;
    ll  min0 = LINF;
    int mini0 = 0;
    if (k - 1 >= 1 && k-1 < i) {
        ll tmp = MAX(s[k-1]-s[0], s[i] - s[k-1]) - MIN(s[k-1]-s[0], s[i] - s[k-1]);
        if (tmp < min0) {
            min0 = tmp;
            mini0 = k - 1;
        }

    }
    if (k>=1 &&  k< i) {
        ll tmp = MAX(s[k]-s[0], s[i] - s[k]) - MIN(s[k]-s[0], s[i] - s[k]);
        if (tmp < min0) {
            min0 = tmp;
            mini0 = k;
        }
    }
    if (min0 < LINF) {
        min00 = MIN(s[mini0]-s[0], s[i] - s[mini0]);
        max00 = MAX(s[mini0]-s[0], s[i] - s[mini0]);
    }
    return;
}

void solve()
{
    int n;
    scanf("%d", &n);
    vector<ll> a(n);
    vector<ll> s(n+1);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        s[i + 1] = s[i] + a[i];
    }
    ll ans = LINF;
    for (i = 2; i <= n-2; i++) {
        ll min0, max0, min1, max1;
        calc(i, &s[0], min0, max0);
        calc(n-i, &s[i], min1, max1);

        ll tmp = MAX(max0, max1) - MIN(min0, min1);
        ans = MIN(ans, tmp);
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    deque<int> dq;

    bool flag = true;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(flag){
            dq.push_front(a);
        }
        else{
            dq.push_back(a);
        }
        flag = !flag;
    }
    if(n % 2 == 0){
        reverse(dq.begin(), dq.end());
    }

    cout << dq.front();
    for(auto itr = dq.begin()+1; itr != dq.end(); ++itr){
        cout << ' ' << *itr;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int N;
    cin >> N;

    switch (N%10)
    {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            break;
        case 3:
            cout << "bon";
            break;
        default:
            cout << "pon";
            break;
    }

    return 0;
}


Measured memory_bytes: 3108
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=0;i<26;i++){
			if(S[0] == (char)('a' + i)){
				Console.WriteLine("a");
				return;
			}
		}
		
		Console.WriteLine("A");
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main(){
  int n;
  cin >> n;
  double ans;

  rep(i,n){
    double k;
    cin >> k;
    ans += 1/k;
  }
  
  ans = 1 / ans;
  cout << ans;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 500000000;
constexpr auto MOD = 1000000007;


int gcd(int i, int j) {
	if (i < j) swap(i,j);
	while (i % j) {
		int k;
		k = i % j;
		i = j;
		j = k;
	}
	return j;
}

int gc[200][200];

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



	ll ans=0;
	
	rep(p,200)rep(q,200){
		gc[p][q]= gcd(p+1, q+1);
	}

	rep(a, k)rep(b, k)rep(c, k) {
		ans += gc[gc[a][b]-1][c];
	}

	cout << ans << endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
int main() {
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	int M = std::max({ a, c });
	int N = std::min({ b, d });
	if (M < N) {
		std::cout << N - M << std::endl;
	}
	else {
		std::cout << 0;
	}
	return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main{
	static int[][] map;
	static int[][] used;
	static int w, h;
	public static void main(String[] args) throws IOException{
		Scanner in = new Scanner(System.in);
		while(true){
			w = in.nextInt();
			h = in.nextInt();
			if(w == 0) break;
			map = new int[h][w];
			used = new int[h][w];
			checked = new int[h][w];
			for(int i=0; i<h; i++){
				char[] s = in.next().toCharArray();
				for(int j=0; j<w; j++){
					map[i][j] = s[j]=='.'?0:s[j]=='W'?1:2;
				}
			}
			turn = 1;
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(map[i][j] == 0) continue;
					int color = map[i][j];
					for(int k=0; k<4; k++){
						int nx = j+dx[k];
						int ny = i+dy[k];
						if(out(nx, ny) || map[ny][nx] != 0) continue;
						if(checked[ny][nx] != 0) continue;
						if(dfs(nx, ny, color)){
							check(nx, ny, color);
						}
						turn++;
					}
				}
			}
			int white = 0;
			int black = 0;
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(used[i][j] == 1) white++;
					else if(used[i][j] == 2) black++;
				}
			}
			System.out.println(black+" "+white);
		}
	}
	static int turn;
	static String dump(int[][] map){
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				sb.append(map[i][j]+" ");
			}
			sb.append("\n");
		}
		return sb.toString();
	}
	static void check(int x, int y, int color){
		if(used[y][x] != 0) return;
		used[y][x] = color;
		for(int i=0; i<4; i++){
			int nx = x+dx[i];
			int ny = y+dy[i];
			if(out(nx, ny) || map[ny][nx] == color) continue;
			check(nx, ny, color);
		}
	}
	
	static final int[] dx = {0, 1, 0, -1};
	static final int[] dy = {1, 0, -1, 0};
	static int[][] checked;
	static boolean dfs(int x, int y, int color){
		if(checked[y][x] == turn) return true;
		else if(checked[y][x] != 0) return false;
		checked[y][x] = turn;
		for(int i=0; i<4; i++){
			int nx = x+dx[i];
			int ny = y+dy[i];
			if(out(nx, ny) || map[ny][nx] == color){
				continue;
			}
			if(map[ny][nx] == 0){
				if(!dfs(nx, ny, color)) return false;
				continue;
			}
			return false;
		}
		return true;
	}
	
	static boolean out(int x, int y){
		return x<0||x>=w||y<0||y>=h;
	}
}

Measured memory_bytes: 27860
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

N=int(input())

ans=num2alpha(N)


print(ans.lower())

Measured memory_bytes: 9912
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <cstdlib>
#include <vector>
#include <ctime>
#include <set>
#include <list>
#include <cctype>
#include <utility>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <memory>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <complex>
#include <cfloat>
#include <climits>
#include <csignal>
#include <cstddef>
using namespace std;

int main(){
  string s ,add ,key;
  cin >> key;
  int n ,cont=0;
  cin >> n;
  for( int i=0 ; i<n ; i++ ){
    cin >> s;
    s += s;
    if( s.find( key ) != string::npos ){
      cont++;
    }
  }
  cout << cont << endl;
}

Measured memory_bytes: 1212
a, b = gets.split.map(&:to_i)

if a.even?
    ans = 0
else
    ans = a
    a += 1
end

case (b - a + 1) % 4
when 0
    puts ans
when 1
    puts ans ^ b
when 2
    puts ans ^ 1
when 3
    puts ans ^ 1 ^ b
end

Measured memory_bytes: 1788
n = gets.to_i
list = Array.new(n, nil)
first = 0
last = -1

n.times {
	d = gets.chomp.split(" ")
	cmd,v = d[0],d[-1]

	case cmd
	when "insert"
		last += 1
		list[last] = v.to_i
	when "delete"
		v = v.to_i
		last.downto(first) { |i|
			if list[i] == v
				list[i] = nil
				first += 1 if i == first
				last  -= 1 if i == last
				break
			end
		}
	when "deleteFirst"
		list[last] = nil
		last -= 1
	when "deleteLast"
		list[first] = nil
		first += 1
	end
}
list = list[first..last].compact.reverse!

list.length.times { |i|
	print " " if not i == 0
	print list[i]
}
puts

Measured memory_bytes: 25924
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define int long long
#define ull unsigned long long
#define pii pair<int,int>
#define vii vector<int>
#define f first
#define s second
#define endl "\n"
#define all(container) container.begin(), container.end()
#define onlyunique(v) v.erase(unique(all(v)), v.end());

#define TRACE
#ifdef AYUSH
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

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

int power(int x, int y, int mod = 2e18) { int ans = 1; x %= mod; while (y) {if (y & 1)ans = (x * ans) % mod; x = (x * x) % mod; y >>= 1;} return ans;}
int modinv(int a, int m) {return power(a, m - 2, m);}

void solve() {
    string s;cin>>s;
    int n = s.size();
    for(int i=0;i<n;++i){
        if(s[i] == '?' && (i == 0 || i == n-1)){
            s[i] = 'D';
        }
        else if(s[i] == '?'){
            if(s[i-1] == 'P'){
                s[i] = 'D';
            }
            else if(s[i+1] == 'D'){
                s[i] = 'P';
            }
            else{
                s[i] = 'D';
            }
        }
    }
    cout<<s<<endl;

}
signed main() {
    IOS
    int t = 1, T = 1;
    // cin>>t;
    while (t--) {
        // cout<<"Case #"<<T<<": ";
        solve();
        // ++T;
    }
    return 0;
}

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

int main()
{
	int n = 0, a[52] = { 0 }, t = 0;
	char s = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s >> t;
		switch (s) {
			case 'S':
				break;

			case 'H':
				t += 13;
				break;

			case 'C':
				t += 26;
				break;

			case 'D':
				t += 39;
				break;
		}

		a[t - 1] = 1;
	}
		
	for (int i = 0; i < 52; i++) {
		if (a[i] == 0) {
			if (i < 13)
				s = 'S';
			else if (i < 26)
				s = 'H';
			else if (i < 39)
				s = 'C';
			else
				s = 'D';

			cout << s << " " << (i % 13) + 1 << endl;
		}			
	}

    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 29;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int q, h, s, d, n; cin >> q >> h >> s >> d >> n;
	cout << (n / 2)*min({ 8 * q,4 * h,2 * s,d }) + (n % 2)*min({ 4 * q,2 * h,s }) << endl;
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  t.pop_back();
  cout << ((s == t) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3548
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second


string ed;
int cur;

void head(){
  while(cur>0 && ed[cur-1]!='\n')--cur;
}

void tail(){
  while(cur<ed.size() && ed[cur]!='\n')++cur;
}

void pr(){
  rep(i,ed.size()){
    if(i==cur)cout<<"_";
    cout<<ed[i];
  }
}

main(){
  string str;
  string end="END_OF_TEXT";
  ed="";

  while(getline(cin,str)){
    if(end==str)break;
    ed+=str+"\n";
  }
  
  string buffer="";
  
  char c;
  while(cin>>c){
    if(c=='-')break;
    //pr();
    //cout<<c<<endl;
    switch(c){
    case 'a':
      head();
      break;
    case 'e':
      tail();
      break;
    case 'p':
      head();
      if(cur)--cur;
      head();
      break;
    case 'n':
      tail();
      if(cur+1<ed.size())cur++;
      head();
      break;
    case 'f':
      if(cur+1<ed.size())cur++;
      break;
    case 'b':
      if(cur)--cur;
      break;
    case 'd':
      if(cur<ed.size()-1)ed.erase(cur,1);
      break;
    case 'k':
      if(ed[cur]=='\n'){
        ed.erase(cur,1);
        buffer="\n";
      }else{
        int pos=0;
        while(ed[cur+pos]!='\n')++pos;
        buffer=ed.substr(cur,pos);
        ed.erase(cur,pos);
      }
      break;
    case 'y':
      ed.insert(cur,buffer);
      cur+=buffer.size();
      break;
    }
  }
  cout<<ed;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int unko(int n){
  int ans=0;
  while(n!=0){
    ans+=n%10;
    n=n/10;
  }
  return ans;
}
int main(){
  int n;
  cin >> n;
  if(n % unko(n)==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
def search(x,L,ans):
    if x<=1:
        return ans
    elif 1<x and x<=2**(L+1)-3:
        return search(x-1,L-1,ans)
    elif x==2**(L+1)-2:
        ans+=2**L-1
        return ans
    elif x==2**(L+1)-1:
        ans+=2**L
        return ans
    elif 2**(L+1)-1<x and x <= 2**(L+2)-5:
        ans+=2**L
        return search(x-2**(L+1)+1,L-1,ans)
    else:
        ans+=2**(L+1)-1
        return ans

N,X=list(map(int,input().split()))

ans=search(X,N,0)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c > 21) cout << "bust"; else cout << "win";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int a,b;
	cin>>a>>b;
	if(a%b==0){
        cout<<0<<endl;
	}else{
        cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n-1,-1,-1):
  b[i]=(a[i]+sum(b[i::i+1]))%2
l=[x+1 for x,y in enumerate(b) if y==1]
print(len(l))
print(*l)

Measured memory_bytes: 14132