akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

vector<ll> divisor(ll n){
    vector<ll> v;
    for(ll i=1; i*i<=n; i++){
        if(n % i == 0){
            v.emplace_back(i);
            v.emplace_back(n / i);
        }
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    return v;
}

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

    ll n; cin>>n;
    
    int ans = divisor(n - 1).size() - 1;

    for(ll i=2; i*i<=n; i++){
        ll num = n;
        while(num % i == 0) num /= i;
        if(num % i == 1 && num != n) ans++;
    }

    cout << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;



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

	string s, t, u;
	cin >> s >> t;

	int a,b;
	cin >> a >> b;

	cin >> u;

	if (u == s) {
		cout << a - 1 << " " << b << endl;
	}
	else {
		cout << a << " " << b - 1 << endl;
	}


	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

template <class Key, class T>
using gp_hash_table = __gnu_pbds::gp_hash_table<Key, T>;

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 K;
  cin >> K;
  int i = 1;
  int m = 7;
  set<int> seen;
  for (;; ++i) {
    m %= K;
    if (m == 0) {
      cout << i << endl;
      return 0;
    }
    if (seen.count(m)) {
      cout << -1 << endl;
      return 0;
    }
    seen.insert(m);
    m = m * 10 + 7;
  }
}


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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<string> s(N);
    for(int i = 0; i < N; i++) cin >> s[i];
    int in = 0;
    int a = 0, b = 0, ab = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < s[i].length() - 1; j++){
            if(s[i][j] == 'A' && s[i][j + 1] == 'B') in++;
        }
        if(*s[i].begin() == 'B' && *s[i].rbegin() == 'A'){
            ab++;
        }else{
            if(*s[i].begin() == 'B') b++;
            if(*s[i].rbegin() == 'A') a++;
        }
    }
    if(a == 0 && ab > 0){
        a++;
        ab--;
    }
    if(b == 0 && ab > 0){
        b++;
        ab--;
    }
    cout << in + min(min(a, b) + ab, N - 1) << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;

	string s,t;
	ll lcs[3010][3010],n,m;
	stack<char> res;

	ll LCS(ll m, ll n) {
		if(m < 0 || n < 0) {
			return 0;
		}
		if(lcs[m][n] != -1) {
			return lcs[m][n];
		}
		if(s[m] == t[n]) {
			return lcs[m][n] = 1 + LCS(m-1,n-1);
			
		}
		else {
			
			return lcs[m][n] = max(LCS(m-1,n), LCS(m,n-1));
			
		}
	}


	void computeLCS(ll m, ll n) {
		if(m < 0 || n < 0) {
			return;
		}
		
		if(s[m] == t[n]) {
			res.push(s[m]);
			computeLCS(m-1,n-1);
			return;
		}
		else {
			if(LCS(m-1,n) > LCS(m,n-1)) {
				computeLCS(m-1,n); 
			}
			else {
				computeLCS(m,n-1);	
			}
			
		}
	}

	int main()
	{
		memset(lcs,-1,sizeof(lcs));
		std::ios::sync_with_stdio(false);
		cin>>s>>t;
		m = s.size();
		n = t.size();
		computeLCS(m-1,n-1);
		while(!res.empty()) {
			cout<<res.top();
			res.pop();
		}
		cout<<endl;
		return 0;
	}


Measured memory_bytes: 74640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll n;
    cin>>n;
    if(n%1000!=0)cout<<1000-n%1000;
    else cout<<0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <string>
#define ll long long
using namespace std;

int main() {
	int n, x;
	cin >> n >> x;
	for (int i = 0; i < 2 * n - 1; i++) {
		cout << x - n + 1 + i << " ";
	}
	return 0;
}

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

public class Main {
    public static void main (String[] args) throws IOException
    {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);
        String str = br.readLine();
        int x = Integer.parseInt(str);
        
        x =x * x * x ;
        
        System.out.println(x);

	}
}

Measured memory_bytes: 17004
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
D = [list(map(int, input().split())) for _ in range(N)]

ret = -float('inf')
for i in range(1, 1024):
    k = 0
    for a in range(N):
        count = 0
        for j in range(10):
            if F[a][j] == 1 and i & (1 << j) > 0:
                count += 1
        k += D[a][count]

    ret = max(ret, k)

print(ret)


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

int main() {
  ll a,b; cin >> a >> b;
  if((a+b) % 2 == 0)
    cout << (a+b) / 2 << endl;
  else
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3600
import sys
sys.setrecursionlimit(10 ** 6)

N, *A = map(int, open(0))

E = [[] for _ in range(N + 1)]
for i, v in enumerate(A, 1):
    E[v - 1].append(i)

def dfs(v):
    D = sorted(map(dfs, E[v]))
    return max([0] + [len(D) - i + d for i, d in enumerate(D)])

print(dfs(0))


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

using namespace std;
const int N = 220;

long long a[N];
set <long long> dp[N];


const int LOG = 60;

long long basis[LOG];

/* https://codeforces.com/blog/entry/68953 */
bool checkXor(long long mask) {
	for (int i = 0; i < LOG; i++) {
		if ((mask & (1LL << i)) == 0) continue;
 
		if (!basis[i]) return false;
 
		mask ^= basis[i];
	}
 
	return true;
}
void insertVector(long long mask) {
	for (int i = 0; i < LOG; i++) {
		if ((mask & (1LL << i)) == 0) continue;

		if (!basis[i]) {
			basis[i] = mask;
			
			return;
		}

		mask ^= basis[i];
	}
}

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

	for (int test = 0; test < t; ++test) {
		int n;
		cin >> n;
		for (int i = 0; i < LOG; ++i) {
			basis[i] = 0;
		}

		for (int i = 0; i < n; ++i) {
			cin >> a[i];
			dp[i].clear();
		}
		dp[n].clear();

		string s;
		cin >> s;
		
		int ok = 1;

		for (int i = n-1; i >= 0; --i) {
			if(s[i] == '0') {
				insertVector(a[i]);
			} else {
				int find = checkXor(a[i]);
				
				if(find == 0) {
					ok = 0;
				}
			}
		}
		if(ok) {
			printf("0\n");
		} else {
			printf("1\n");
		}



	}


}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

double n, m;

int main() {
	cin >> n >> m;
	double a = pow(2, m);
	double r = 1.0 - 1.0 / a;
	double num = (1900.0 * m + (n - m) * 100);
	cout << num / (a*(1.0 - r)*(1.0 - r)) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> d(10, vector<int>(10,0));
  rep(i,1,n+1) {
    if (i % 10 == 0) continue;
    int a = stoi(to_string(i).substr(0,1));
    int b = i % 10;
    d[a][b]++;
  }
  int ans = 0;
  rep(i,1,n+1) {
    if (i % 10 == 0) continue;
    int a = stoi(to_string(i).substr(0,1));
    int b = i % 10;
    ans += d[b][a];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3688
#include<stdio.h>

int main(){

int N,step=0,ans=0;
long ch,ch2;
scanf("%d",&N);
scanf("%ld",&ch);


while(N-1){
  scanf("%ld",&ch2);
  if(ch>=ch2){
    step++;
    ch = ch2;
    N--;
  }else
  {
    if(ans < step) ans = step;
    step=0;
    ch = ch2;
    N--;
  }
}
if(ans < step) ans = step;
printf("%d",ans);
return 0;
}

Measured memory_bytes: 1720
import sys
from collections import deque
input = sys.stdin.readline

h, m = map(int, input().split())
s = [0] * h
for i in range(h):
    s[i] = list(input())

def bfs(st_h, st_w):
    alr = [[-1] * m for _ in range(h)]
    alr[st_h][st_w] = 0
    que = deque([[st_h, st_w]])
    while len(que) > 0:
        now = que.popleft()
        # UP
        if alr[max(0, now[0]-1)][now[1]] == -1 and s[max(0, now[0]-1)][now[1]] == '.':
            que.append([now[0]-1, now[1]])
            alr[now[0]-1][now[1]] = alr[now[0]][now[1]] + 1
        # DOWN
        if alr[min(h-1, now[0]+1)][now[1]] == -1 and s[min(h-1, now[0]+1)][now[1]] == '.':
            que.append([now[0]+1, now[1]])
            alr[now[0]+1][now[1]] = alr[now[0]][now[1]] + 1
        # LEFT
        if alr[now[0]][max(0, now[1]-1)] == -1 and s[now[0]][max(0, now[1]-1)] == '.':
            que.append([now[0], now[1]-1])
            alr[now[0]][now[1]-1] = alr[now[0]][now[1]] + 1
        # RIGHT
        if alr[now[0]][min(m-1, now[1]+1)] == -1 and s[now[0]][min(m-1, now[1]+1)] == '.':
            que.append([now[0], now[1]+1])
            alr[now[0]][now[1]+1] = alr[now[0]][now[1]] + 1
    res = 0
    for x in alr:
        for y in x:
            res = max(res, y)
    return res

ans = 0

for a in range(h):
    for b in range(m):
        if s[a][b] == '.':
            ans = max(ans, bfs(a, b))

print(ans)


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

int binarySearch(long arr[], long arrLen, long key){
	long left = 0;
	long right = arrLen;
	long middle = (left + right) / 2;

	while(left <= right){
		if(arr[middle] > key){
			right = middle - 1;
			middle = (right + left)/2;
		}else if(arr[middle] < key){
			left = middle + 1;
			middle = (left + right)/2;
		}else if(arr[middle] == key){
			return 1;
		}
		//cout << "[" << left << "," << middle << "," << right << "]" << endl;
	}
	return 0;
}

int main(){
	long n, q;
	long S[100000], T[50000];
	int count = 0;

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> S[i];
	}
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> T[i];
	}

	for(int i = 0; i < q; i++){
		count += binarySearch(S, n-1, T[i]);
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 4260
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[114514];
int gcd( int m, int n )
{
	int a=max(m,n),b=min(m,n);
	if(m==0) return n;if(n==0) return m;
	if(a%b==0) return b;
	return gcd(b,a-b*(a/b));
}
int main()
{
	int n,k;
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	if(a[0]==a[n-1]){
		if(k!=a[0]) cout<<"IMPOSSIBLE"<<endl;else cout<<"POSSIBLE"<<endl;
	}
	else if(k>a[n-1]){
		cout<<"IMPOSSIBLE"<<endl;
	}
	else{
		int g=0;
		rep(i,n) g=gcd(g,a[i]);
		if(k%g==0) cout<<"POSSIBLE"<<endl;
		else cout<<"IMPOSSIBLE"<<endl;
	}
}


Measured memory_bytes: 640
import java.util.Scanner;
 
class Main{
  public static void main(String[] args){
    
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    int [] p = new int[N];
    for(int i = 0; i < N; i++){
      p[i] = scan.nextInt();
    }
    int k;
    for(int j = 0; j < N-1; j++){
      for(int l = j+1; l < N; l++){
        if(p[j] > p[l]){
          k = p[j];
          p[j] = p[l];
          p[l] = k;
        }
      }
    }
    
    int sum = 0;
    for(int m = 0; m < K; m++){
      sum += p[m];
    }
    
    System.out.println(sum);
    
    scan.close();
  }
}       

Measured memory_bytes: 38608
#include <stdio.h>
#include <math.h>

#define M_PI 3.14159265358979323846

int main(void)
{
	double a=0, b=0;
	double h=0, m=0;
	double aa=0, bb=0;
	double x=0;
	//float cosx=0;
	//float sinh,cosh,sinm, cosm, sinx, cos;
	
	double ans = 0;
	
	scanf("%lf",&a);
	scanf("%lf",&b);
	scanf("%lf",&h);
	scanf("%lf",&m);
	
	aa = (((60*h)+m)/720)*2*M_PI;
	bb = (m/60)*2*M_PI;
	x = fabs(aa-bb);
	
	//printf("%f %f %f %f\n",a, b, h, m);
	
	/*
	//θ分割
	if(h < 3){
		sinh = sin(((3-h)/3)*M_PI*0.5);
		printf("sinh = %f",sinh);
	}
	else if(h<6){
		sinh = sin(((h-3)/3)*M_PI*0.5);
		printf("sinh = %f",sinh);
	}
	else if(h<9){
		sinh = sin(((9-h)/3)*M_PI*0.5);
		printf("sinh = %f",sinh);
	}
	else{
		sinh = sin(((h-9)/3)*M_PI*0.5);
		printf("sinh = %f",sinh);
	}
	
	if(m <15){
		sinm = sin(((15-m)/15)*M_PI*0.5);
	}
	*/	
		
	
	//printf("aa = %f  bb = %f\n",aa,bb);
	
	//cosx = cos(aa)*cos(bb) + sin(aa)*sin(bb);
	//printf("cosx = %f\n",cos(x));
	
	ans = sqrt((a*a) + (b*b) - (2*a*b*cos(x)));
	
	printf("%15.14lf\n",ans);
	
	return 0;
}

Measured memory_bytes: 2584
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll h, w;
    cin >> h >> w;
    ll n;
    cin >> n;

    ll tmp = 0;
    if(h < w){
        tmp = w;
    }else{
        tmp = h;
    }

    if(n % tmp == 0){
        cout << n / tmp << endl;
    }else{
        cout << (n / tmp) + 1 << endl;
    }


    

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <unordered_map>

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_map<int, int> D;
  for (int i = 0; i < N; ++i) {
    int d;
    cin >> d;
    ++D[d];
  }
  int M;
  cin >> M;
  bool flg = true;
  for (int i = 0; i < M; ++i) {
    int t;
    cin >> t;
    if (D[t] <= 0) {
      flg = false;
    } else {
      --D[t];
    }
  }
  if (flg) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
}

Measured memory_bytes: 10648
tarop = hanap = 0
gets
while cards = gets do
  taro, hana = cards.split
  tarop += ( taro == hana )? 1 : ( taro > hana )? 3 : 0
  hanap += ( taro == hana )? 1 : ( hana > taro )? 3 : 0
end
puts "#{tarop} #{hanap}"

Measured memory_bytes: 8740
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

namespace Math {
// Generic modular integer.

    ll modpow(ll b, ll p, ll m) {
        ll r = 1;
        for (; p; p >>= 1, b = b * b % m)
            if (p & 1)
                r = r * b % m;
        return r;
    }

    ll modinv(ll b, ll m) { return modpow(b, m - 2, m); }

    template<int MOD, typename IntType = int>
    struct GModint {
        IntType val;

        GModint() : val(0) {}

        GModint(int v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        GModint(ll v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        explicit operator bool() const { return val != 0; }

        const bool operator==(const GModint &g) const { return val == g.val; }

        const bool operator!=(const GModint &g) const { return val != g.val; }

        const GModint operator+=(const GModint &g) { return *this = *this + g; }

        const GModint operator-=(const GModint &g) { return *this = *this - g; }

        const GModint operator*=(const GModint &g) { return *this = *this * g; }

        const GModint operator/=(const GModint &g) { return *this = *this / g; }

        const GModint operator^=(const GModint &g) { return *this = *this ^ g; }

        const GModint operator-() const { return GModint(val == 0 ? 0 : MOD - val, true); }

        const GModint operator+(const GModint &g) const {
            ll newval = val + g.val;
            if (newval >= MOD)
                newval -= MOD;
            return GModint(newval, true);
        }

        const GModint operator-(const GModint &g) const { return *this + (-g); }

        const GModint operator*(const GModint &g) const { return GModint(1ll * val * g.val); }

        const GModint operator/(const GModint &g) const { return *this * g.inv(); }

        template<class T>
        const GModint operator^(const T t) const { return GModint(modpow(val, t, MOD)); }

        const GModint inv() const { return GModint(modinv(val, MOD)); }
    };

    using Modint = GModint<1000000007>;
}

using Math::Modint;
Modint ncr(int n, int r) {
    Modint res = 1;
    for (int i = 1; i <= r; i++) res /= i;
    for (int i = n; i >= n - r + 1; i--) res *= i;

    return res;
}

int main() {
    ll n, a, b; cin >> n >> a >> b;
    Math::Modint ans = (Math::Modint(2) ^ n) - 1;
    ans -= ncr(n, a);
    ans -= ncr(n, b);

    cout << ans.val << endl;
}


Measured memory_bytes: 256
S = [i for i in input()]
S2=S[:]
result1=0
result2=0
for i in range(len(S)-1):
	if S[i] ==S[i+1]:
		S[i+1] = '0' if S[i] == '1' else '1'
		result1 += 1
for i in range(len(S2)-1,0,-1):
	if S2[i] == S2[i-1]:
		S2[i-1] = '0' if S2[i] == '1' else '1'
		result2 += 1
print(min(result1,result2))

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

int stack_num, S[1000];

int main(){
  int a, b, x;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);

    } else if ( s[0] == '-' ){
      b = pop();
      a = pop();
      push(a-b);
      
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a * b);
      
    } else {
      x = atoi(s);
      push(x);

    }
  }
  printf("%d\n", pop());
  return 0;
}

void push(int x){

  S[++stack_num] = x;

}

int pop(){
  
  stack_num--;
  return S[stack_num+1];

}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()
const ll MOD = 998244353;

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> X(N + 1);
	int a, b;
	for (int i = 0;i < M;i++) {
		cin >> a >> b;
		X[a].push_back(b);
		X[b].push_back(a);
	}
	for (int i : X[1]) {
		for (int j : X[i]) {
			if (j == N) {
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 12016
x = input().split()
for i in range(2):
  x[i] = int(x[i])
list = []
ans = 0
d = x[0] + x[1]
if x[1] == 0:
  print(x[0])
else:
  if x[1] % 2 == 0:
    for i in range(x[1]):
      list.append(x[0]+i-x[1]/2)
    ans = x[0] + x[1]/2
  else:
    for i in range(x[1]+1):
      list.append(x[0]+i-(x[1]+1)/2)
    ans = x[0] + (x[1]+1)/2
  line = input().split()
  for i in range(x[1]):
    line[i] = int(line[i])
    if line[i] in list:
      list.remove(line[i])
  if len(list) == 0:
    print(int(ans))
  else:
    for i in list:
      if abs(x[0] - i) < d:
        ans = i
        d = x[0] - i
    print(int(ans))


Measured memory_bytes: 9232
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct SegTree{
	vi data;
	int size;
	SegTree(int _size){
		for(int i=1;;i*=2)
			if(i>=_size){
				size=i;
				break;
			}
		data.assign(size*2,0);
	}
	void add(int i,int x){
		for(int j=size+i;j;j/=2)
			data[j]+=x;
	}
	int sum(int a,int b,int i,int l,int r){
		if(r<=a || b<=l) return 0;
		if(a<=l && r<=b) return data[i];
		int m=(a+b)/2,res=0;
		if(a<m) res+=sum(a,b,i*2+0,l,m);
		if(m<b) res+=sum(a,b,i*2+1,m,r);
		return res;
	}
	int ith(int i){
		int j=1;
		while(j<size){
			if(data[j*2+0]>i)
				j=j*2+0;
			else{
				i-=data[j*2+0];
				j=j*2+1;
			}
		}
		return j-size;
	}
};

int main()
{
	//for(int q,l;cin>>q>>l,q|l;){
	//	SegTree st(q);
	//	vi girls;
	//	map<int,int> m;
	//	rep(i,q){
	//		int qu,x; cin>>qu>>x;
	//		if(qu==0){
	//			st.add(girls.size(),1);
	//			m[x]=girls.size();
	//			girls.push_back(x);
	//			if(st.data[1]>l){
	//				int j=st.ith(0);
	//				st.add(j,-1);
	//			}
	//		}
	//		if(qu==1){
	//			int j=st.ith(x-1);
	//			st.add(j,-1);
	//		}
	//		if(qu==2){
	//			int j=st.ith(x-1);
	//			cout<<girls[j]<<endl;
	//		}
	//		if(qu==3){
	//			int j=m[x];
	//			st.add(j,-1);
	//		}
	//	}
	//	puts("end");
	//}
	
	static int girls[400000];
	for(int q,l;scanf("%d%d",&q,&l),q|l;){
		SegTree st(q);
		int gsize=0;
		map<int,int> m;
		rep(i,q){
			int qu,x; scanf("%d%d",&qu,&x);
			if(qu==0){
				st.add(gsize,1);
				m[x]=gsize;
				girls[gsize++]=x;
				if(st.data[1]>l){
					int j=st.ith(0);
					st.add(j,-1);
				}
			}
			else if(qu==1){
				int j=st.ith(x-1);
				st.add(j,-1);
			}
			else if(qu==2){
				int j=st.ith(x-1);
				printf("%d\n",girls[j]);
			}
			else if(qu==3){
				int j=m[x];
				st.add(j,-1);
			}
		}
		puts("end");
	}
	
	return 0;
}

Measured memory_bytes: 18000
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int s=a+b;
        int y=a-b;
        s=max(s,y);
            y=a*b;
        s=max(s,y);
        cout<<s<<endl;

    }
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin,exit
import  numpy as np
A = [stdin.readline().rstrip().split() for _ in range(3)]
A=sum(A,[])
n = int(stdin.readline().rstrip())
B= [stdin.readline().rstrip().split() for _ in range(n)]
B=sum(B,[])
if len(B)<=2:
    print("No")
    sys.exit()
for i in range(len(B)):
    try:
        A[A.index(B[i])]=0
    except:
        continue
A=[int(i) for i in A]
if A[1]+A[2]+A[0]==0 or A[0]+A[3]+A[6]==0 or A[2]+A[4]+A[6]==0 or A[3]+A[4]+A[5]==0 or A[1]+A[4]+A[7]==0 or A[0]+A[4]+A[8]==0 or A[6]+A[7]+A[8]==0 or A[2]+A[5]+A[8]==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

struct node {
	ll to, index;
};

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll a, b, c; cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}
	ll mi = TEN(18) + 2;
	if (a != 1 && b != 1) mi = min(a*b, mi);
	if (b != 1 && c != 1) mi = min(b*c, mi);
	if (c != 1 && b != 1) mi = min(a*c, mi);
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <sstream>
using namespace std;

#define namefile ""
#define inifile freopen(namefile".inp","r",stdin); freopen(namefile".out","w",stdout)
#define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef unsigned int uint;
typedef unsigned long ulong;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<string> VS;
typedef vector< VI > VVI;
typedef vector< VL > VVL;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;
typedef set<int> SETI;
typedef set<long> SETL;
typedef map<int,int> MII;
typedef map<long,long> MLL;

const long long MOD = 1e9+7;
const long long INFMAX = 1e9;
const long long INFMIN = -1e9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const double epsilon = 1e-9;
const double PI = acos(-1.00);
const int MAXN = 1e2+5;

int n,a[MAXN];

int main()
{
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i];

    double res(0);
    for (int i=1; i<=n; i++) res += ((double)1/a[i]);
    res = (double)1/res;

    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define MAX_V 1000
int V;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];//辺を逆にしたグラフ
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];//属する強連結成分のトポロジカル順序

void add_edge(int from, int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v){
    used[v] = true;
    for(int i = 0; i < G[v].size(); ++i){
        if(!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
}

void rdfs(int v, int k){
    used[v] = true;
    cmp[v] = k;
    for(int i = 0; i < rG[v].size(); ++i){
        if(!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
}
void scc(){
    memset(used, 0, sizeof(used));
    vs.clear();
    for(int v = 0; v < V; ++v){
        if(!used[v]) dfs(v);
    }
    memset(used, 0, sizeof(used));
    int k = 0;
    for(int i =(int) vs.size()-1; i >= 0; i--){
        if(!used[vs[i]]) rdfs(vs[i],k++);
    }
    return;
}
int num[1000][1000];//num[i][j] = iからjへの行き方の総数みたいなもの(2以上は無視して2にする)
int hoge[1000];//u->v辺を使ってきたやつを除外するため
void dfs(int now,const int u,const int v){
    num[u][now]++;
    if(num[u][now]>=3){
        //もう2回目なのでnow以降も2回目で無視
        num[u][now] = 2;
        return;
    }
    if(num[u][now]==2){
        if(hoge[now] == v){
            num[u][now] = 1;
            return;
        }
    }
    if(num[u][now]==1){
        hoge[now] = v;
    }
    rep(i,G[now].size()){
        if(G[now][i] != u){
            dfs(G[now][i],u,v);
        }
    }
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    V = n;
    vector<int>a(m),b(m);
    rep(i,m){
        scanf("%d%d",&a[i],&b[i]);
        a[i]--,b[i]--;
        add_edge(a[i],b[i]);
    }
    scc();
    rep(i,n){
        rep(k,n)hoge[k] = -1;
        rep(j,G[i].size()){
            dfs(G[i][j],i,G[i][j]);
        }
    }
    rep(i,m){
        bool flag = false;
        if(cmp[a[i]] == cmp[b[i]]){
            if(num[a[i]][b[i]]==2)flag = true;
        }else{
            if(num[a[i]][b[i]]==1)flag = true;
        }
        if(flag){
            puts("same");
        }else{
            puts("diff");
        }
    }
    return 0;
}

Measured memory_bytes: 9728
n, K = map(int, input().split())
MOD = 10**9+7
ans = 0
for k in range(K, n+2):
    L = k*(k-1)//2
    R = (n+n-k+1)*k//2
    ans += (R-L+1)%MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i=0; i<N; i++){
        cin >> H.at(i);
    }
    int m = H.at(0);
    int count =1;
    for(int i=1; i<N; i++){
        if( H.at(i) == max(m, H.at(i))){
            count++;
            m = max(m, H.at(i));
        }
    }
    cout << count << endl;


}

Measured memory_bytes: 256
s = input()
N = len(s)
s = s + 'D'

cnt = 0
ans = 0
A_num = 0
plus1 = 0
while cnt < N:
    if s[cnt] == 'A':
        A_num += 1
    elif s[cnt] == 'B':
        if s[cnt + 1] == 'C':
            ans += A_num
            plus1 = 1
        else:
            A_num = 0
    else:
        A_num = 0
    cnt += 1
    if plus1:
        cnt += 1
        plus1 = 0
print(ans)


Measured memory_bytes: 41072
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC060C_Sentou();
#if 1
int main()
{
	ABC060C_Sentou();
	fflush(stdout);
	return 0;
}
#endif

static void ABC060C_Sentou()
{
	int N, T;
	get2int(N, T);

	auto seqt = new LLONG[N];
	for (int i = 0; i < N; i++) {
		get1int(seqt[i]);
	}

	LLONG stime = 0;
	LLONG passed = 0;
	for (int i = 1; i < N; i++) {
		passed = seqt[i] - seqt[i - 1];
		stime += tp_min<LLONG>(passed, T);
	}
	stime += T;

	printf("%lld\n", stime);

	delete[] seqt;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

char s[30],ans[30];
int main(){
  scanf("%s",s);
  int len=strlen(s);
  rep(i,len) ans[s[i]-'a']++;
  bool res=true;
  rep(i,'z'-'a'){
    if(ans[i]%2!=0){
      res=false;
      break;
    }
  }
  if(res) printf("Yes\n");
  else printf("No\n");


  return 0;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int n,c;
	for (; fscanf(stdin, "%d", &n), n; P(d, c)) {
		n = 1000 - n;
		c = n / 500, n %= 500;
		c += n / 100, n %= 100;
		c += n / 50, n %= 50;
		c += n / 10, n %= 10;
		c += n / 5, c += n % 5;
	}
	return 0;
}

Measured memory_bytes: 604
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e3+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

char maze[maxn][maxn];
ll dp[maxn][maxn];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int n, m;
    scanf("%d%d", &n, &m);

    for(int i = 1; i <= n; i++) scanf("%s", maze[i] + 1);

    dp[1][1] = 1;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            if(maze[i][j] == '#')   continue;
            if(maze[i - 1][j] == '.')   dp[i][j] = (dp[i][j] + dp[i - 1][j]) % Mod;
            if(maze[i][j - 1] == '.')   dp[i][j] = (dp[i][j] + dp[i][j - 1]) % Mod;
        }
    }
    printf("%lld\n", dp[n][m] % Mod);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define pi 3.14159265358979323846
using namespace std;
int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double ang=abs(pi/30*(60*h+m)*(1/12.0-1));
	
	double c=sqrt(pow(a*cos(ang)-b,2)+pow(a*sin(ang),2));
	cout<<setprecision(25)<<c<<endl;
	
}

Measured memory_bytes: 4096
n = int(input())
inOut = list()

for _ in range(n):
  inOut.append(list(map(int, input().split())))

num = [[[0] * 10 for i in range(3)] for j in range(4) ]

for i in range(n):
  num[inOut[i][0]-1][inOut[i][1]-1][inOut[i][2]-1] += inOut[i][3]
      
for i in range(4):
  for j in range(3):
    for k in range(10):
      print(" {}".format(num[i][j][k]), end="")
    print()
  if i != 3:
    print('#'*20)


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

using namespace std;

int main()
{
  int sum = 0;
  int min = 1001;
  int N,X;

  cin >> N >> X;
  for ( int i = 0; i < N; ++i ) {
    int tmp;
    scanf("%d", &tmp);
    sum += tmp;
    if ( min > tmp ) min = tmp;
  }

  X -= sum;
  cout << N+X/min << endl;
}


Measured memory_bytes: 256
object Main extends App {
  import scala.math.abs
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  var A: Array[Int] = Array.fill(n)(sc.nextInt)
  A = 0 +: A :+ 0
  // 全経路いった場合を計算
  var total = 0
  for (i <- 1 to n + 1) {
      total += abs(A(i) - A(i - 1))
  }

  // 端折る箇所がi-1 i+1の間だった場合は全経路いった場合と同じ、違った場合はi と i-1の絶対値の2倍の額を合計から引く
  for (i <- 1 to n) {
    val before = A(i - 1)
    val after = A(i + 1)

    println(total - abs(A(i) - before) - abs(after - A(i)) + abs(after - before))
  }
 }

Measured memory_bytes: 65424
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);		
		int n = sc.nextInt();
		int[][] g = new int[n][n];
		for(int i = 0; i < n; i++) {
			int m = sc.nextInt();
			Arrays.fill(g[i], -1);
			for(int j = 0; j < m; j++) {
				int x = sc.nextInt()-1;
				int y = sc.nextInt();
				g[i][x] = y;
			}
		}
		int max = 0;
		for(int mask = 0; mask < (1 << n); mask++) {
			if(check(mask, g, n)) {
				max = Integer.max(count(mask), max);
			}
		}
		System.out.println(max);
	}
	static int count(int mask) {
		int res = 0;
		while(mask > 0) {
			if((mask & 1) > 0) res++;
			mask >>= 1;
		}
		return res;
	}

	static boolean check(int mask, int[][] g, int n) {
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(((1 << i) & mask) > 0) {
					int k = ((1 << j) & mask) > 0? 1:0;
					if(g[i][j] >= 0 && g[i][j] != k) return false;
				}
			}
		}
		return true;
	}
	
	
}


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

using namespace std;

constexpr int INF = (int)1e9;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, s;
  cin >> n >> k >> s;
  if (s == INF) {
    vector<int> ans(n, 1);
    for (int i = 0; i < k; i++) {
      ans[i] = INF;
    }
    for (const auto& e : ans) {
      cout << e << ' ';
    }
    cout << '\n';
    return 0;
  }
  vector<int> ans(n, INF);
  for (int i = 0; i < k; i++) {
    ans[i] = s;
  }
  for (const auto& e : ans) {
    cout << e << ' ';
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  ll p[n];
  for(int i=0;i<n;i++)cin >> p[i];

  ll s=0;

  for(int i=0;i<n;i++){
    if(p[i]==n)continue;
    ll a=i,b,c=i,d;
    ll q=0,r=0;
    while(a<n && p[a]<=p[i]){
      a++;
    }
    if(a==n){
      a--;
      q=1;
    }
    b=a+1;
    while(b<n && p[b]<=p[i]){
      b++;
    }
    /*if(b==n){
      q=2;
      b--;
    }*/
    while(c>-1 && p[c]<=p[i]){
      c--;
    }
    if(c==-1){
      r=1;
      c++;
    }
    d=c-1;
    while(d>-1 && p[d]<=p[i]){
      d--;
    }
    /*if(d==-1){
      r=2;
      d++;
    }*/
    if(q==1){
      s+=(a-i+1)*(c-d)*p[i];
    }
    else if(r==1){
      s+=(i-c+1)*(b-a)*p[i];
    }
    else{
      s+=((a-i)*(c-d)+(i-c)*(b-a))*p[i];
    }
  }
  cout << s << endl;

}

Measured memory_bytes: 4344
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int




int main()
{
   int D;

   scanf("%d",&D);

   if (D==25)printf("Christmas");
   else if (D==24)printf("Christmas Eve");
   else if (D==23)printf("Christmas Eve Eve");
   else if (D==22)printf("Christmas Eve Eve Eve");



    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
long dp[900][900];
int n;
long c[900],s[900],f[900];
main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)cin>>c[i]>>s[i]>>f[i];
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			dp[i][j]=max(s[j-1],(dp[i][j-1]+f[j-1]-1)/f[j-1]*f[j-1])+c[j-1];
		}
	}
	for(int i=0;i<n;i++)cout<<dp[i][n-1]<<endl;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;


const int mod = 998244353;

int add(int x) {  
  return x;
}

template<typename... T>
int add(int x, T... y) {  
  x += add(y...);
  if (x >= mod)
        x -= mod;
  return x;
}

template<typename... T>
int udd(int &x, T... y) { 
  return x = add(x, y...);
}

template<typename... T>
int sub(int x, T... y) { 
  return add(x, mod - add(y...));
}

int mul(int x) { 
  return x;
}

template<typename... T>
int mul(int x, T... y) { 
  return 1ll * x * mul(y...) % mod;
}

int bin(int x, int to) { 
  int y = 1;
  while (to) { 
        if (to & 1)
                  y = mul(x, y);
            x = mul(x, x);
                to >>= 1;
  }
  return y;
}

int inv(int x) { 
  assert(x != 0);
  return bin(x, mod - 2);
}

const int M = 4040;

int d[M][M];
string s;
int n;
int a[M], b[M];

void read() {
  cin >> s;
  n = s.length();

  a[0] = b[0] = 0;

  for (int i = 0; i < n; ++i) {
    int x = s[i] - '0';
    int y = 2 - x;
    a[i + 1] = a[i] + x;
    b[i + 1] = b[i] + y;
  }
  for (int i = n; i <= 2 * n; ++i) {
    a[i + 1] = a[i];
    b[i + 1] = b[i];
  }
}

void calc() {
  int x = a[n], y = b[n];


  for (int i = 0; i <= x; ++i)
    for (int j = 0; j <= y; ++j)
      d[i][j] = 0;

  d[0][0] = 1;

  for (int i = 0; i <= x; ++i)
    for (int j = 0; j <= y; ++j) {
      int curx = a[i + j + 1] - i;
      int cury = b[i + j + 1] - j;
      if (curx < 0 || cury < 0)
        continue;

      if (curx > 0) {
        udd(d[i + 1][j], d[i][j]);
      }

      if (cury > 0) {
        udd(d[i][j + 1], d[i][j]);
      }
    }

  //for (int i = 0; i <= x; ++i, cerr << "\n")
    //for (int j = 0; j <= y; ++j, cerr << " ")
      //cerr << d[i][j];

  cout << d[x][y] << "\n";
}

int main() {
#ifdef LOCAL
  assert(freopen("f.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);


  read();
  calc();
}



Measured memory_bytes: 62208
S=input()
ans=[0 for i in range(len(S))]
before='R'
kawari=[]
num=0
for i in S:
    num+=1
    if before!=i:
        kawari.append(num)
        before=i
kawari.append(len(S)+1)
mode='R'
before=1
for i in kawari:
    if mode=='R':
        ans[i-1]+=(i-before)//2
        ans[i-2]+=-(-(i-before)//2)
        mode='L'
    else:
        ans[before-1]+=-(-(i-before)//2)
        ans[before-2]+=(i-before)//2
        mode='R'
    before=i
for i in ans:
    print(i,end=' ')


Measured memory_bytes: 8688
#include<iostream>
#include<string>
#include<vector> 
using namespace std;
 
int main(){
	long long h,w;
	vector<string> s;
	int foo;
	string si;

	cin >> h >> w;

	for(int i = 0; i < h; i++){
		cin >> si;
		s.push_back(si);
	}

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			//cout << "befor s[i][j] = " << s[i][j] << endl;
			//地雷のマス以外
			if(s[i][j] != '#'){
				//"."だったら0に置き換える"
				if(s[i][j] == '.'){
					s[i][j] = '0';
					//cout << "mid s[i][j] = " << s[i][j] << endl;
				}
				//上を見る
				if(i != 0){
					if(s[i - 1][j] == '#'){
						foo = static_cast<int>(s[i][j]);
						foo++;
						s[i][j] = static_cast<char>(foo);
					}
				}
				//右上を見る
				if(i != 0 && j != w - 1){
					if(s[i - 1][j + 1] == '#'){
						foo = static_cast<int>(s[i][j]);
						foo++;
						s[i][j] = static_cast<char>(foo);
					}
				}

				//右を見る
				if(j != w - 1){
					if(s[i][j + 1] == '#'){
						foo = static_cast<int>(s[i][j]);
						foo++;
						s[i][j] = static_cast<char>(foo);
					}
				}

				//右下を見る
				if(i != h - 1 && j != w - 1){
					if(s[i + 1][j + 1] == '#'){
						foo = static_cast<int>(s[i][j]);
						foo++;
						s[i][j] = static_cast<char>(foo);
					}
				}
				
				//下を見る
				if(i != h - 1){
					if(s[i + 1][j] == '#'){
						foo = static_cast<int>(s[i][j]);
						foo++;
						s[i][j] = static_cast<char>(foo);
					}
				}

				//左下を見る
				if(i != h - 1 && j != 0){
					if(s[i + 1][j - 1] == '#'){
						foo = static_cast<int>(s[i][j]);
						foo++;
						s[i][j] = static_cast<char>(foo);
					}
				}

				//左を見る
				if(j != 0){
					if(s[i][j - 1] == '#'){
						foo = static_cast<int>(s[i][j]);
						foo++;
						s[i][j] = static_cast<char>(foo);
					}
				}

				//左上を見る
				if(i != 0 && j != 0){
					if(s[i - 1][j - 1] == '#'){
						foo = static_cast<int>(s[i][j]);
						foo++;
						s[i][j] = static_cast<char>(foo);
					}
				}

			}
			//cout << "after s[i][j] = " << s[i][j] << endl;
		}
	}

	for(int i = 0; i < h; i++){
		cout << s[i] << endl;
	}	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h(char word[]){
	int ans=0;
	for(int i=0;i<12;i++)
		switch(word[i]){
		case 'A': ans += 1*pow(5,i);
				  break;
		case 'C': ans += 2*pow(5,i);
				  break;
		case 'G': ans += 3*pow(5,i);
				  break;
		case 'T': ans += 4*pow(5,i);
				  break;
		default : break;
		}
	return ans;
}
bool dic[244140625]={0};
int main(){
	char cmd[10],word[15];
	int n; cin>>n;
	while(n--){
		memset(word,0,sizeof(word));
		scanf("%s%s",cmd,word);
		if(cmd[0]=='i') dic[h(word)] = 1;
		else cout<<(dic[h(word)] ? "yes\n":"no\n");
	}
    return 0;
}


Measured memory_bytes: 8496
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    rep(i, a + b + 1) {
        if (i == a) {
            if (s[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] == '-') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

ll N; ll dis[5];
int input()
{
    cin>>N;
    for(int i=0;i<5;++i){
        cin>>dis[i];
    }
}

int solve()
{
    ll mi=1e16;
    for(int i=0;i<5;++i) mi=min(mi,dis[i]);
    ll ans=(N-1)/mi+5ll;
    // if(!N%mi) ans--;
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256