akhauriyash/Code-Regression huggingface dataset:
//////////////////////////////
// Author: whatisit
// Date: 2020-05-14 21:28 
//////////////////////////////
#include <bits/stdc++.h>
using namespace std;

void solve_fast() {
	int n, sum = 0, x;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		sum += v[i]; 
	}
	sum = (sum + (n/2))/n;
	int ans = 0;
	for (int i = 0; i < n; ++i) 
		ans += (v[i] - sum) * (v[i] - sum);
	cout << ans;

}

// brute-force
const int N = 101;
int x[N], ans = 1e9, n;

void solve() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x[i];
	}
	for (int i = 1; i <= 100; ++i) {
		int cur_dist = 0;
		for (int j = 0; j < n; ++j) {
			cur_dist += (x[j] - i) * (x[j] - i);
		}
		ans = min(cur_dist, ans);
	}
	cout << ans;
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(0);
	//solve();
	solve_fast();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long R,D,X;
	cin>>R>>D>>X;
	for(int i=0;i<10;i++)
	{
		X*=R;
		X-=D;
		cout<<X<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int l;
	cin >> l;
	
	double ans = l * l * l / (double)27.0;
	printf("%.14f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; 
    if(key > A[mid]) left = mid + 1; 
    else if(key < A[mid]) right = mid; 
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2236
use proconio::{
    fastout, input,
    marker::{Bytes, Usize1},
};
use std::cmp::Reverse;
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        ci: Usize1,
        cj: Usize1,
        di: Usize1,
        dj: Usize1,
        s: [Bytes; h],
    }

    let mut costs = vec![vec![u32::max_value(); w]; h];
    costs[ci][cj] = 0;

    static WARPS: &[(usize, usize)] = &[
        (1, 1),
        (1, !0),
        (!0, 1),
        (!0, !0),
        (!0 - 1, !0 - 1),
        (!0 - 1, !0),
        (!0 - 1, 0),
        (!0 - 1, 1),
        (!0 - 1, 2),
        (!0, !0 - 1),
        (!0, 2),
        (0, !0 - 1),
        (0, 2),
        (1, !0 - 1),
        (1, 2),
        (2, !0 - 1),
        (2, !0),
        (2, 0),
        (2, 1),
        (2, 2),
    ];

    let mut queue = BinaryHeap::from(vec![(Reverse(0), ci, cj)]);
    while let Some((_, from_i, from_j)) = queue.pop() {
        if (from_i, from_j) == (di, dj) {
            continue;
        }

        for &(di, dj) in &[(0, 1), (1, 0), (0, !0), (!0, 0)] {
            let to_i = from_i.wrapping_add(di);
            let to_j = from_j.wrapping_add(dj);

            if to_i < h
                && to_j < w
                && s[to_i][to_j] == b'.'
                && costs[from_i][from_j] < costs[to_i][to_j]
            {
                costs[to_i][to_j] = costs[from_i][from_j];
                queue.push((Reverse(costs[to_i][to_j]), to_i, to_j));
            }
        }

        for &(di, dj) in WARPS {
            let to_i = from_i.wrapping_add(di);
            let to_j = from_j.wrapping_add(dj);

            if to_i < h
                && to_j < w
                && s[to_i][to_j] == b'.'
                && costs[from_i][from_j] + 1 < costs[to_i][to_j]
            {
                costs[to_i][to_j] = costs[from_i][from_j] + 1;
                queue.push((Reverse(costs[to_i][to_j]), to_i, to_j));
            }
        }
    }

    let ans = costs[di][dj];
    if ans == u32::max_value() {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 8248
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


long saidaikouyakusuu(long a, long b) {
	if (a < b) swap(a, b);
	while (a%b > 0) {
		long c = a % b;
		a = b; b = c;
	}
	return b;
}


int main()
{
	long n;
	cin >> n;
	long x;
	cin >> x;
	long answer = 0;
	for (long i = 0; i < n; i++) {
		if (i == 0) {
			cin >> answer;
			answer = abs(answer-x);
			continue;
		}
		long d;
		cin >> d;
		answer = saidaikouyakusuu(answer, abs(d-x));
	}
	cout << answer << endl;
    return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef pair<ll, int> ll_i;
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
struct edge { int v, w; };

int main() {
	string s; cin >> s;
	int N = s.length();
	vector<int> a(26);
	rep(i, N) a[s[i] - 'a']++;
	ll ans = 1;
	rep(k, 26) rep(_k, k) ans += (ll)a[k] * a[_k];
	cout << ans << endl;
}


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

using namespace std;

const string L = "qwertasdfgzxcvb";

int main(){
    string s;
    while(cin >> s, s != "#"){
        int ans = 0;
        bool prev = L.find(s[0]) != string::npos; 
        for(int i=1; i<(int)s.size(); ++i){
            bool cur = L.find(s[i]) != string::npos;
            ans += cur != prev;
            prev = cur;
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 1188
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    digit_count_one = [0] * 61
    nums = N * (N-1) // 2
    cnt = 0
    for a in A:
        for i in range(61):
            c = (a >> i) & 1
            if c == 1:
                digit_count_one[i] += 1
    for ix, count in enumerate(digit_count_one):
        freq = count * (N - count)
        cnt += ((1 << ix) * freq) % mod
        cnt %= mod
    print(cnt % mod)
main()



Measured memory_bytes: 121068
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		String[] s = new String[n];
		int m = 0, min = 50;
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
			if (s[i].length() < min) {
				min = s[i].length();
				m = i;
			}
		}

		boolean flag;
		String a;
		int l = 0;
		List<String> ans = new ArrayList<String>();
		for (int j = 0; j < min; j++) {
			a = s[m].substring(0, 1);
			flag = true;
			for (int i = 0; i < n; i++) {
				if (s[i].length() == s[i].replaceFirst(a, "").length()) {
					flag = false;
				}
				s[i] = s[i].replaceFirst(a, "");
			}
			if (flag) {
				ans.add(a);
			}
		}
		Collections.sort(ans);
		System.out.print("");
		for (String str:ans) {
			System.out.print(str);
		}
		System.out.println();
		sc.close();
	}

}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0;
    rep(i, N) {
        ll a = A[i];
        ll c = 0;
        while (a % 2 == 0) {
            a /= 2;
            c++;
        }
        ans += c;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int N;
	cin >> N;
	int ans = (int)pow(3, N);
	int sum = 1;
	fx(N) {
		int a;
		cin >> a;
		if (a%2==0) {
			sum *= 2;
		}
		else {
			sum *= 1;
		}
	}
	ce(ans-sum)
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  map<int, int> mp;
  rep(i, n) {
    int a; cin >> a;
    ++mp[a];
  }
  int ans = 0;
  for(auto x : mp) {
    if(x.first <= x.second) ans += x.second - x.first;
    else ans += x.second;
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
 ios_base::sync_with_stdio(false);
 long long r, D, x2k;
 cin >> r >> D >> x2k;
 long long x[20];
 x[0] = x2k;
 for(int i=1; i<20; ++i){
    x[i] = r*x[i-1] - D;
 }
 for(int i=1; i<=10; ++i)
   cout << x[i] << "\n";
 return 0;
}


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

#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)
unsigned int gcd(unsigned int a,unsigned int b){return b?gcd(b,a%b):a;}

int main(){
    int n;cin >> n;
    vector<unsigned int> v(n);
    rep(i,n) cin >> v[i];

    vector<unsigned int> dpl(n-1),dpr(n-1);
    dpl[0] = v[0];
    for(int i=1;i<n-1;i++){
        dpl[i] = gcd(dpl[i-1],v[i]);
    }
    dpr[n-2] = v[n-1];
    for(int i=n-3;i>=0;i--){
        dpr[i] = gcd(dpr[i+1],v[i+1]);
    }

    vector<unsigned int> sum(n);
    rep(i,n){
        if(i==0){
            sum[i] = dpr[0];
        }else if(i==n-1){
            sum[i] = dpl[i-1];
        }else{
            sum[i] = gcd(dpl[i-1],dpr[i]);
        }
    }

    cout << *max_element(sum.begin(),sum.end()) << "\n";
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define INF 10e8
using namespace std;
const int dx[] = { 0, 1, 0,-1};
const int dy[] = {-1, 0, 1, 0};
int H, W;
vector< vector<char> > grid;
bool throughable(int x, int y){
  return 0 <= x && x < W && 0 <= y && y < H && grid[y][x] != '#';
}
int getFlat(int x, int y){
  return y*W + x;
}

int main(void){
  cin >> H >> W;
  grid = vector< vector<char> >(H, vector<char>(W));
  for(int i=0; i < H; i++){
    string tmp; cin >> tmp;
    for(int j=0; j < W; j++){
      grid[i][j] = tmp[j];
    }
  }
  vector< vector<int> > G(H*W, vector<int>(H*W, INF));
  int st, gl;
  for(int i=0; i < H; i++){
    for(int j=0; j < W; j++){
      if(grid[i][j] == 'S') st = getFlat(j, i);
      if(grid[i][j] == 'G') gl = getFlat(j, i);

      for(int d=0; d < 4; d++){
        int nx[3], ny[3];
        for(int n = 1; n <= 3; n++){
          nx[n-1] = j + n*dx[d];
          ny[n-1] = i + n*dy[d];
        }
        int cost = 0;
        for(int n=0; n < 3; n++){
          if(!throughable(nx[n], ny[n])) break;
          int pick = INF;
          if(grid[ny[n]][nx[n]] == 'o'){
            pick = min(pick, 1 + cost);
          }else if(grid[ny[n]][nx[n]] == '.' || grid[ny[n]][nx[n]] == 'S' || grid[ny[n]][nx[n]] == 'G'){
            pick = min(pick, 2 + cost);
          }else{

          }
          G[getFlat(j, i)][getFlat(nx[n], ny[n])] = pick;
          cost = pick;
        }
        for(int n=0; n < 3; n++){
          if(!throughable(nx[n], ny[n])) break;
          G[getFlat(j, i)][getFlat(nx[n], ny[n])] = min(G[getFlat(j, i)][getFlat(nx[n], ny[n])], (n+1) + 2);
        }
      }
    }
  }
  
  int minv;
  int d[H*W], used[H*W];
  for(int i=0; i < H*W; i++){
    d[i] = INF; used[i] = false;
  }

  d[st] = 0;
  while(1){
    minv = INF;
    int u = -1;
    for(int i=0; i < H*W; i++){
      if(minv > d[i] && used[i] == false){
        minv = d[i];
        u = i;
      }
    }
    if(u == -1) break;
    used[u] = true;
    for(int v=0; v < H*W; v++){
      if(used[v] == false && G[u][v] != INF){
        if(d[v] > d[u] + G[u][v]){
          d[v] = d[u] + G[u][v];
        }
      }
    }
  }

  cout << d[gl] << endl;

  return 0;
}

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

int calc(string s, string t) {
  int ret = 0;
  rep(i, s.length()) {
    if (s[i] != t[i]) ret++;
  }
  return ret;
}

int main() {
  string s, t;
  cin >> s >> t;
  int ans = INF;
  int sLength = s.length();
  int tLength = t.length();
  rep(i, sLength - tLength + 1) {
    ans = min(ans, calc(s.substr(i, tLength), t));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
def gcd (a, b):
    while b!=0:
        a, b = b, a%b
    return a

def lcm(a, b):
    return (a*b) // gcd(a, b)

input = input().split(' ')
A = int(input[0])
B = int(input[1])
C = int(input[2])
D = int(input[3])

div_c = B//C - (A-1)//C
div_d = B//D - (A-1)//D
div_cd = B//lcm(C, D) - (A-1)//lcm(C, D)

print(B-A+1-(div_c+div_d-div_cd))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var NM = ReadSplitInt();

            var LR = new List<List<int>>();
            var Lmax = 0;
            var Rmin = int.MaxValue;
            for (int i = 0; i < NM[1]; i++)
            {
                var lr = ReadSplitInt();
                Lmax = Max(Lmax, lr[0]);
                Rmin = Min(Rmin, lr[1]);
            }

            var ans = 0;
            for (int i = 1; i <= NM[0]; i++)
            {
                if (Lmax <= i && i <= Rmin)
                    ans++;
            }

            Println(ans);
        }

        static List<int> ReadLines(int n)
        {
            var l = new List<int>();
            for (int i = 0; i < n; i++)
            {
                l.Add(ReadInt());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 15440
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define int  long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
 
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define mod %1000000009
#define pi 3.14159265358979323846//20 decimals
#define ld long double
#define inf 1000000000
bool less_vectors(const vector<int>& a,const vector<int>& b) 
{
  return a.size() < b.size();
}
#define N 1000000

int32_t main()
{                
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif*/
    int n;
    cin>>n;
    string s;
    cin>>s;
    vi wf(n);
    vi wb(n);
    vi ef(n),eb(n);
    int w=0;
    int e=0;
    for(int i=0;i<s.length();i++)
    {
        wf[i]=w;
        ef[i]=e;
        if(s[i]=='W')
            w++;
        else
            e++;
    }
    w=0;
    e=0;
    for(int i=s.length()-1;i>=0;i--)
    {
        wb[i]=w;
        eb[i]=e;
        if(s[i]=='W')
            w++;
        else
            e++;
    }
    int ans=n;
    for(int i=0;i<n;i++)
    {
        
            ans=min(ans,wf[i]+eb[i]);
        
    }
    cout<<ans;


    return 0;
}

Measured memory_bytes: 10004
n=int(input())
d=list(map(int,input().split()))
num=[0 for i in range(n)]
ans=1
flag=0
for i in d:
  num[i]+=1
if d[0]>=1:
  ans=0
else:
  for i in range(1,n-1):
      ans*=num[i]**num[i+1]
      while ans>998244353:
        ans=ans%998244353
for i in range(1,n):
  if d[i]==0 and ans>0:
    ans=0
#  if d[i]==0:
#    flag=1
#  if flag==1 and d[i]>0:
#    ans=0
print(ans)

Measured memory_bytes: 56152
public class Main {
	public static void main(String[] args) {
		java.util.Scanner in = new java.util.Scanner(System.in);
		int[] a = new int [10];
		for (int n = 0; n < 10; n++) {
			a[n] = in.nextInt();
		}
		java.util.Arrays.sort(a);
		for (int n = 0; n < 3; n++) {
			System.out.println(a[9 - n]);
		}
	}
	
}

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

int main(){
  int N,M;
  cin >> N >> M;
  bool a[M][N];
  rep(i,M)rep(j,N) a[i][j]=false;
  rep(i,M){
    int k;
    cin >> k;
    rep(j,k){
      int x;
      cin >> x;
      x--;
      a[i][x]=true;
    }
  }
  int b[M];
  rep(i,M){
    cin >> b[i];
  }
  
  int ans=0;
  rep(i,(1<<N)){
    bool f=true;
    rep(j,M){
      int cnt=0;
      rep(k,N){
        if((i>>k)&1==1) if(a[j][k]==true) cnt++;
      }
      if(cnt%2!=b[j]) f=false;
    }
    if (f) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool isprime(int p)
{
	if(p<2)return 0;
	for(int i=2;i*i<=p;i++)if(p%i<1)return 0;
	return 1;
}
int a,d,n;
main()
{
	while(cin>>a>>d>>n,n)
	{
		int cnt=0;
		for(int i=0;;i++)
		{
			if(isprime(a+d*i))
			{
				cnt++;
				if(cnt==n)
				{
					cout<<a+d*i<<endl;
					break;
				}
			}
		}
	}
}



Measured memory_bytes: 3096
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
p = list(lf())

dp = [0]*(n+1)
dp[0] = 1-p[0]
dp[1] = p[0]
for i in range(2,n+1):
    for j in range(i, 0, -1):
        dp[j] = p[i-1]*dp[j-1] + (1-p[i-1])*dp[j]
        
    dp[0] *= (1-p[i-1])
    
print(sum(dp[(n+1)//2:]))

Measured memory_bytes: 41324
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		long count = S.chars().filter(c -> c == '0').count();
		System.out.println(Math.min(count, S.length() - count) * 2);
	}

}


Measured memory_bytes: 27092
#include<stdio.h>

#define LENGTH_N 500000

void merge(int*, int, int, int);
void mergeSort(int*, int, int);

int mergenum = 0;

int main() {
  int i, nl, ql, arrayN[LENGTH_N], q;

  scanf("%d", &nl);
  for(i=0 ; i < nl ; i++) { scanf("%d", &arrayN[i]); }

  mergeSort(arrayN, 0, nl);
  
  for(i=0 ; i < nl ; i++) {
    printf("%d", arrayN[i]);
    if(i != nl-1) { printf(" "); }
  }
  printf("\n");
  printf("%d\n", mergenum);
  
  return 0;
}

void merge(int *array, int left, int mid, int right) {
  int i, j, k, n1, n2, L[LENGTH_N], R[LENGTH_N];

  n1 = mid - left;
  n2 = right - mid;

  for(i=0 ; i < n1 ; i++) { L[i] = array[left + i]; }
  for(i=0 ; i < n2 ; i++) { R[i] = array[mid + i]; }

  L[n1] = 1000000001; //10^9 + 1
  R[n2] = 1000000001; //10^9 + 1

  i=0;
  j=0;
  
  for(k=left ; k < right ; k++) {
    if(L[i] <= R[j]) {
      array[k] = L[i];
      i++;
    } else {
      array[k] = R[j];
      j++;
    }
    mergenum++;
  }
}

void mergeSort(int *array, int left, int right) {
  int mid = 0;
  
  if(left+1 < right) {
    mid = (left + right) / 2;
    mergeSort(array, left, mid);
    mergeSort(array, mid, right);
    merge(array, left, mid, right);
  }
}



Measured memory_bytes: 6596
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> p;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<int> a;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        a.pb(temp);
        sum += temp;
    }
    std::vector<int> suma;
    suma.pb(a[0]);
    for (int i = 0; i < n - 1; i++) {
        suma.pb(suma[i] + a[i + 1]);
    }
    int mi = INF;
    for (int i = 0; i < n - 1; i++) {
        chmin(mi, abs(suma[i] - (sum - suma[i])));
    }
    cout << mi << std::endl;
    return 0;
}

Measured memory_bytes: 4848
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    long int x,i,j;
    
    scanf("%ld",&x);
    
    i = x/500;
    
    x = x-i*500;
    
    j = x/5;
    
    printf("%ld\n",i*1000+j*5);
    
    
    return 0;
}


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

int main() {
	string s1, s2,moji;
	int i = -1;

	cin >> s1 >> s2;

	moji = s1 + s1;

	i = moji.find(s2);

	if (i != -1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  string s;
  cin >> s;
  
  int t = 0;
  int c = 0;
  if(s.at(0) == 'A') {
    for(int i = 2; i < s.size()-1; i++) {
      if(s.at(i) == 'C') {
        c++;
        t = i;
      }
    }
    if(c == 1) {
      c = 0;
      for(int i = 1; i < s.size(); i++) {
        if(i == t) continue;
        else if(islower(s.at(i))) {
          c++;
        }
      }
    }
  }
  if(s.size() - 2 == c) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
'''input
3 5
1 2 1
2 3 0
'''
# connected components
from sys import stdin, setrecursionlimit
from bisect import bisect_left


def solve(string):
    dp = [[0 for x in range(3)] for y in range(len(string))]
    if string[0] == 'r':
        dp[0] = [0, 0, paper]
    elif string[0] == 's':
        dp[0] = [rock, 0, 0]
    else:
        dp[0] = [0, scissor, 0]

    for i in range(1, len(string)):
        if string[i] == 'r':
            dp[i][0] = max(dp[i - 1][1], dp[i - 1][2])
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][2])
            dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + paper
        elif string[i] == 's':
            dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + rock
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][2])
            dp[i][2] = max(dp[i - 1][0], dp[i - 1][1])
        else:
            dp[i][0] = max(dp[i - 1][1], dp[i - 1][2])
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + scissor
            dp[i][2] = max(dp[i - 1][0], dp[i - 1][1])
    # print(dp)
    return max(dp[-1])

# main starts
n, k = list(map(int, stdin.readline().split()))
rock, scissor, paper = list(map(int, stdin.readline().split()))
string = stdin.readline().strip()
cost = 0
for i in range(k):
    temp = []
    j = i
    while j < n:
        temp.append(string[j])
        j += k
    cost += solve(temp)
print(cost)

Measured memory_bytes: 71772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(s[i][j] == '#') continue;
            int cnt = 0;
            for (int d = 0; d < 8; ++d) {
                int ni = i+dy[d];
                int nj = j+dx[d];
                if(ni < 0 || ni >= h) continue;
                if(nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') cnt++;
            }
            s[i][j] = (char)(cnt+'0');
        }
    }
    for (int i = 0; i < h; ++i) {
        cout << s[i] << endl;
    }
    return 0;
}

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

int main(){

    int n;
    cin >> n;
    vector<pair<double,string>> o(n);
    for (int i = 0; i < n;++i){
        double x;
        string u;
        cin >> x >> u;
        o[i].first = x;
        o[i].second = u;
    }
    double sum = 0;
    for (int i = 0; i < n; ++i)
    {
        if(o[i].second=="JPY"){
            sum += o[i].first;
        }
        else if(o[i].second=="BTC"){
            sum += o[i].first * 380000.0;
        }
    }
    cout << sum << endl;
    return 0;
}


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

const int inf = 1000000009;

int dfs(vector<vector<int>> &graph, bitset<101> &used, int flow, int pos, int t) {
    if (pos == t) return flow;
    for (int i=0; i<graph[pos].size(); i++) {
        if (used[i] == 0 && graph[pos][i] > 0) {
            used[i] = 1;
            int maxflow = dfs(graph, used, min(flow, graph[pos][i]), i, t);
            if (maxflow > 0) {
                graph[i][pos] = graph[i][pos] + maxflow;
                graph[pos][i] = graph[pos][i] - maxflow;
                return maxflow;
            }
        }
    }
    return 0;
}

int maxflow(vector<vector<int>> graph, int s, int t) {
    bool f = true;
    int sum = 0;
    while (f) {
        bitset<101> b(0); b[s] = 1;
        int current = dfs(graph, b, inf, s, t);
        sum += current;
        f &= current != 0;
    }
    return sum;
}

int main() {
    int v, e;
    cin >> v >> e;
    vector<vector<int>> graph(v);
    for(auto &l: graph) l.resize(v, 0);

    for(int i=0; i<e; i++) {
        int u, v, c; cin >> u >> v >> c;
        graph[u][v] = c;
    }
    
    cout << maxflow(graph, 0, v-1) << endl;
}


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

long long N;
vector<ll> checked;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;  // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

void solve(long long N) {
    if (N == 1) {
        cout << 0 << endl;
        return;
    }
    vector<pair<long long, long long> > primes = prime_factorize(N);
    ll ans = 0;
    for (ll i = 0; i < primes.size(); i++) {
        ll tmp = 1;
        ll cnt = 1;
        for (ll j = 2;; j++) {
            if ((tmp + j) > primes[i].second) {
                ans += cnt;
                break;
            } else {
                tmp += j;
                cnt++;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3656
N = int(input())
aA=[int(_) for _ in input().split()]
iMin = min(aA)
iMax = max(aA)

def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a

if iMin  == 1:
    print(1)
else:
    iDm = [ _ % iMin for _ in aA]
    if max(iDm) == 0:
        print(iMin)
    else:
        b = aA[0]
        for _ in aA[1:]:
            b = fgcd(_,b)
            if b == 1:
                print(1)
                exit()
        print(b)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }



int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if(abs(x - a) < abs(x - b)) {
		puts("A");
	}
	else {
		puts("B");
	}
}


Measured memory_bytes: 3552
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int a[N];
    int count = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        
        int num = a[i];
        while(true){
            if(num % 2 == 0){
                num /= 2;
                count += 1;
            }else{
                break;
            }
        }
        
    }
    cout << count << endl;

        return 0;
}

Measured memory_bytes: 256
/**
 *    Author:  AKASH-ALAM       
**/
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define Fast_io    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 
using namespace std;

int main(){
    Fast_io;
    long long n, m;  cin >> n >> m;
    long long s = n, c = m;
    n = n * 2;
    m = m - n;
    m = m / 4;
    long long cnt = m + s;
    if(c < 2) cnt = 0;
    if(s >= c) cnt = c / 2;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N+1,0);
    for (int i = 1; i < N; i++)
    {
        cin >> A.at(i);
        B.at(A.at(i))++;
    }
    for (int i = 1; i < N+1; i++)
    {
        cout << B.at(i) <<endl;
    }
}

Measured memory_bytes: 4788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int a,b;
int dp[20][20];
bool no[20][20];

void init(){
  rep(i,20){
    rep(j,20){
      dp[i][j]=no[i][j]=0;
    }
  }
}

void DP(){
  REP(i,1,a+1){
    REP(j,1,b+1){
      if(no[i][j])dp[i][j]=0;
      else if(i==1&&j==1)dp[i][j]=1;
      else dp[i][j]=dp[i-1][j]+dp[i][j-1];
    }
  }
}

int main(){
  int n,x,y;
  while(1){
    scanf("%d%d",&a,&b);
    if(a==0&&b==0)break;
    init();
    cin>>n;
    rep(i,n){
      scanf("%d%d",&x,&y);
      no[x][y]=true;
    }
    DP();
    cout<<dp[a][b]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  string s; cin>>s;
  vector<int> e(n+1,0),w(n+1,0);
  for(int i=1; i<n+1; ++i){
    e[i]=e[i-1]; w[i]=w[i-1];
    if(s[i-1]=='E') ++e[i]; else ++w[i];
  }
  int res=2147483647;
  for(int i=1; i<n+1; ++i) res=min(res,w[i-1]+e[n]-e[i]);
  cout<<res;
  return 0;
}


Measured memory_bytes: 6148
#include <cstdio>

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

  int ofs = 0;
  for (int i = 0; i < Q; ++i) {
    int q, k;
    scanf("%d %d", &q, &k);
    if (q == 0) {
      int res = (ofs+k) % N;
      if (res == 0) res = N;
      printf("%d\n", res);
    } else if (q == 1) {
      ofs += k;
      if (ofs >= N) ofs -= N;
    }
  }
}



Measured memory_bytes: 2760
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	string p;
	cin >> p;
	p[3] = '8';
	cout << p << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

int selectionSort(char A[50][3], int N)
{
	int minj;
	int i,j;
	char tmp[3];
	for(i=0;i<N;i++){
		minj=i;
		
		for(j=i+1;j<N;j++){
			if(A[j][1]<A[minj][1]){
				minj=j;
			}
		}
		if(i!=minj){
			strcpy(tmp,A[i]);//tmp = A[i];
			strcpy(A[i],A[minj]);//A[i]=A[minj];
			strcpy(A[minj],tmp);//A[minj]=tmp;
			//cnt++;
		}
	}
	//printf("%s %s %s\n",A[0],A[1],tmp);
	return 0;
}

static int cnt;
int bubbleSort(char A[50][3], int N)
{
	int flag=1;
	int i;
	char tmp[3];
	while(flag){
		flag = 0;
		
		for(i=N-1;i>0;i--){
			if(A[i][1]<A[i-1][1]){
				strcpy(tmp,A[i]);//tmp = A[i];
				strcpy(A[i],A[i-1]);//A[i]=A[i-1];
				strcpy(A[i-1],tmp);//A[i-1]=tmp;
				flag=1;
				//cnt++;
			}
		}
	}
	return 0;
}

int 
main(){
	int N;
	char B[50][3];char C[50][3];
	int s_stable=0;
	scanf("%d",&N);
	int i;
	for(i=0;i<N;i++){
		scanf("%s",B[i]);
		strcpy(C[i],B[i]);
	}
	//////////////////////////////////////
	bubbleSort(C,N);
	s_stable=0;
		for(i=0;i<N;i++){
	    if(i<N-1)printf("%s ",C[i]);
	    else printf("%s\n",C[i]);
		
	}
	printf("%s\n",(s_stable>0? "Not stable":"Stable")); 
///////////////////////////////////////	
	selectionSort(B,N);


	for(i=0;i<N;i++){
	    if(i<N-1)printf("%s ",B[i]);
	    else printf("%s\n",B[i]);
		
		if(B[i][0]!=C[i][0]) s_stable++;
	}
	printf("%s\n",(s_stable>0? "Not stable":"Stable")); 


 return 0;
}


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

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, a, b;

	cin >> n >> a >> b;

	if (abs(b - a) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
}

Measured memory_bytes: 256
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b,c] <- getInts
  ; print (sum [ 1 | x <- [a .. b], mod c x == 0])
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

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

public class Main {
// ???????????´??° x ?????????????????§???x ?????????????¨????????????????????????????????????°?????????????????????????????????
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int x = Integer.parseInt(br.readLine());
			
			int answer = x*x*x;
			System.out.println(answer);
			
			
		}  catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}

	}

}

Measured memory_bytes: 24440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n,m;cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
    
    return 0;
}






Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    if(m==1){ println(1); return }
    val p = primeFact(m).groupBy { it }.map { it.value.size }
    val (f,g) = mFactTable( n + p.max()!! )
    val ans = p.fold(1){acc, i ->
        acc.mMul(f[n-1+i]).mMul(g[i]).mMul(g[n-1])
    }
    println(ans)

}

fun primeFact(a:Int):List<Int>{
    if(a==1) return listOf(1)
    val primes= mutableListOf<Int>()
    var x=a
    val rtx=Math.sqrt(x.toDouble()).toInt()
    for(p in 2..a){
        if(p>rtx && primes.isEmpty()) return listOf(a)
        if(x==1) return primes
        while(x%p==0){
            primes.add(p)
            x/=p
        }
    }
    return primes
}

const val mod = 1000000007
fun Int.mAdd(a : Int) = if(this+a<mod) this+a else this+a-mod
fun Int.mSub(a : Int) = if(this-a>=0 ) this-a else this-a+mod
fun Int.mMul(a : Int) = (this*a.toLong()%mod).toInt()
fun Int.mInv() = this.mPow(mod-2)
fun Int.mPow(a : Int) :Int {
    var x=this; var y=a; var ret = 1
    while (y>0) {
        if(y.and(1)==1) ret=ret.mMul(x)
        x=x.mMul(x)
        y=y.shr(1)
    }
    return ret
}

fun mFactTable(n:Int) : Pair<IntArray,IntArray>{
    val fact1 = IntArray(n+1)
    val fact2 = IntArray(n+1)
    fact1[0] = 1
    for (i in 1..n) fact1[i] = fact1[i-1].mMul(i)
    for (i in 0..n) fact2[i] = fact1[i].mInv()
    return Pair(fact1,fact2)
}



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

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n), c(n);
  for (int &i : p) {
    cin >> i;
    i--;
  }
  for (int &i : c) cin >> i;
  ll ans = -1001001001;
  for (int i = 0; i < n; i++) {
    int now = i;
    vector<ll> vs;
    ll res = 0;
    while (1) {
      now = p[now];
      res += c[now];
      vs.push_back(res);
      if (now == i) break;
    }
    int sz = vs.size();
    for (int j = 0; j < sz; j++) {
      if (j + 1 > k) break;
      ans = max(ans, vs[j] + ((k - j - 1) / sz) * max(0ll, res));
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    vector<int> vec(26);
    char ch;
    while (cin >> ch) {
        ch = tolower(ch);
        if ('a' <= ch && ch <= 'z')
            vec.at((int)ch-'a')++;
    }
    rep(i, vec.size()) {
        printf("%c : %d\n", (char)i+'a', vec.at(i));
    }
}


Measured memory_bytes: 3212
n = int(input())
a = input().split()
b = [0] * n
for i in range(n % 2, n, 2):
    b[(n + i) // 2] = a[i]
for i in range(n - 1, -1, -2):
    b[(n - i - 1) // 2] = a[i]
print(' '.join(b))


Measured memory_bytes: 25716
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,t[300001];
	int i,mx,flg,flg1;
	
	cin>>n;
	
	for(i=0;i<n;i++) cin>>t[i];
	
	flg=0,mx=-1;
	for(i=0;i<n;i++){
	
		mx=max(mx,t[i]+i*10);
			
		if(mx<(i+1)*10){
			flg=1;
			break;
		}
	}
	
	for(i=0;i<n/2;i++) swap(t[i],t[n-i-1]);
	
	flg1=0,mx=-1;
	for(i=0;i<n;i++){
	
		mx=max(mx,t[i]+i*10);
			
		if(mx<(i+1)*10){
			flg1=1;
			break;
		}
	}
	
//	cout<<flg<<" "<<flg1<<endl;
	
	if(flg==0&&flg1==0) cout<<"yes"<<endl; 
	else cout<<"no"<<endl;
	
	return 0;
}	


Measured memory_bytes: 4304