akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if (N <= 10 && M <= 10) {
        int A[N][M] = {};
        rep(i, N) {
            rep(j, M) {
                int x = i;
                int y = j;
                rep(k, 9) {
                    x = i + k / 3 - 1;
                    y = j + k % 3 - 1;
                    //dump(x); dump(y);
                    if (x < 0 || x >= N || y < 0 || y >= M) continue;
                    A[x][y] = 1 - A[x][y];
                }
                /*
                rep(a, N) {
                    rep(b, M) cout <<  A[a][b];
                    cout << endl;
                }
                cout << endl;
                cout << endl;
                */
            }
        }
        int cnt = 0;
        rep(i, N) rep(j, M) cnt += A[i][j];
        cout << cnt << endl;
        return 0;
    }
    if (N == 2 || M == 2) {
        cout << 0 << endl; return 0;
    }
    cout << max((ll)1, (N-2)) * max((ll)1, (M-2)) << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 100010
ll dp[310][N],a[N],n,m,k;
deque<pair<ll,ll> >Q;
int main(){
    cin>>n>>m>>k;
    lol(i,n)cin>>a[i];
    lol(i,k+1)lol(j,n+1)dp[i][j]=-1;
    lol(i,n)dp[1][i+1]=a[i];
    for(ll i=2;i<=k;i++){
	while(!Q.empty())Q.pop_front();
	for(ll j=0;j<=n;j++){
	    if(!Q.empty()&&Q.front().first!=-1){
		dp[i][j]=a[j-1]*i+Q.front().first;
	    }
	    while(!Q.empty()){
		if(Q.back().first<=dp[i-1][j]){
		    Q.pop_back();
		}
		else break;
	    }
	    Q.push_back(make_pair(dp[i-1][j],j));
	    while(!Q.empty()){
		if(Q.front().second<=j-m)Q.pop_front();
		else break;
	    }
	}
    }
    ll ans=0;
    lol(i,n+1)ans=max(ans,dp[k][i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 237824
import numpy as np


n,m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for i in range(m):
    b,c = map(int, input().split())
    bc.append([b,c])

bc = np.array(bc)
bc = bc[np.argsort(bc[:, 1])[::-1]]


bcin = 0
counter = 0

a.sort()
for i in range(len(a)):
    if a[i] < bc[bcin][1]:
        a[i] = bc[bcin][1]
        counter += 1
        if counter == bc[bcin][0]:
            bcin += 1
            counter = 0
            if bcin == len(bc):
                break

print(sum(a))
    


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

typedef long long LL;

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

    int N; cin >> N;
    vector<int> H(N);
    REP(i, N) cin >> H[i];

    int ret = 0;
    int h = 0;
    REP(i, N) {
        if (h <= H[i]) {
            ++ret;
            h = H[i];
        }
    }

    cout << ret << endl;

}


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



int main() {

    int n,k; cin >> n >> k;
    int prev = -1, cur = 0;
    int pos = -1;
    int ln;
    int ans = 0;
    vector<int> a(n);
    vector<int> b;
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());

    rep(i,n){
        cur = a[i];
        if(prev == cur) b[pos] ++;
        else{
            b.push_back(1);
            pos ++;
            prev = cur;
        }
    }

    pos = 0;
    sort(b.begin(),b.end());

    ln = b.size();
    if(ln <= k) cout << 0;
    else{
        while(ln > k) {
            ln--;
            ans += b[pos];
            pos++;
        }
        cout << ans;
    }
    return 0;
}











Measured memory_bytes: 5004
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
a = [[False] * 3 for _ in range(3)]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                a[i][j] = True
ans = False
for i in range(3):
    if a[i][0] and a[i][1] and a[i][2] or a[0][i] and a[1][i] and a[2][i]:
        print('Yes')
        exit()
if a[0][0] and a[1][1] and a[2][2] or a[2][0] and a[1][1] and a[0][2]:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 62084
#include<iostream>

using namespace std;

int selectionSort( int A[], int N )
{
    int count = 0;
    for( int i = 0; i < N; i++)
    {
        int minj = i;
        for( int j = i; j < N; j++)
        {
            if( A[j] < A[minj])
                minj = j;
        }
    swap( A[i], A[minj] );
    if( i != minj )
        count++;
    }
    return count;
}

int main()
{
    int A[100], N, count;
    cin >> N;
    for( int i = 0; i < N; i++)
        cin >> A[i];

    count = selectionSort( A, N );
    
    for( int i = 0; i < N; i++)
    {
        cout << A[i];
        if( i != N - 1)
            cout << ' ';
    }
    cout << '\n';
    cout << count << '\n';

    return 0;
}

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

int n, m;
vector<vector<int>> g;
vector<bool> visited;

bool flag;
int goal;

void dfs(int i) {
    if(visited[i]) return;
    if(i == goal) flag = true;
    visited[i] = true;
    for(auto j : g[i]){
        dfs(j);
    }
}

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

    int cnt = 0;
    for(int i=0;i<m;i++){
        g.clear();
        g.resize(n);

        // 枝i以外からなるグラフ(隣接リストg)をつくる
        for(int j=0;j<m;j++){
            if(i == j) continue;
            g[a[j]].push_back(b[j]);
            g[b[j]].push_back(a[j]);
        }

        // 連結性判定
        visited.clear();
        visited.resize(n, false);
        flag = false;
        goal = b[i];
        dfs(a[i]);
        if(!flag) cnt++;  // 探索
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 384
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[3100];
double x[3100];
double y[3100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	for(int i=0;i<a;i++){
		x[i]=cos(PI*p[i]/b);
		y[i]=sin(PI*p[i]/b);
	}
	double X=0;
	double Y=0;
	for(int i=0;i<a;i++){
		for(int j=i+1;j<a;j++){
			int L=j-i-1;
			int R=a-2-L;
			double tx=(x[i]*x[j]-y[i]*y[j]);
			double ty=(y[i]*x[j]+x[i]*y[j]);
			double gx=cos(PI*(p[i]+p[j])/b);
			double gy=sin(PI*(p[i]+p[j])/b);
			if((tx-gx)*(tx-gx)+(ty-gy)*(ty-gy)<(tx+gx)*(tx+gx)+(ty+gy)*(ty+gy))swap(L,R);
			X+=L*(x[i]*x[j]-y[i]*y[j]);
			Y+=L*(y[i]*x[j]+x[i]*y[j]);
			X-=R*(x[i]*x[j]-y[i]*y[j]);
			Y-=R*(y[i]*x[j]+x[i]*y[j]);
		}
	}
	X*=6;
	Y*=6;
	X/=a*(a-1);
	Y/=a*(a-1);
	X/=(a-2);
	Y/=(a-2);
	
	printf("%.12f %.12f\n",X,Y);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define D(x) cout<<#x<" = "<<x<<endl
#define sz 100010

int n, m, u, v, vis[sz];
vector<int>edge[sz];


void bfs(int src)
{
    vis[src] = 1;
    queue<int>Q;
    Q.push(src);
    while(!Q.empty()){
        u = Q.front();
        Q.pop();
        for(int x : edge[u]){
            if(!vis[x]){
                vis[x]=1;
                Q.push(x);
            }
        }
    }
}


int main()
{
    cin>>n>>m;
    while(m--){
        cin>>u>>v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    bfs(1);
    int cnt = 0;
    for(int i = 1;i<=n;i++){
        if(!vis[i]){
            cnt++;
            bfs(i);
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 9208
package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)

	var a, b, c int
	var count int

	for {
		if isOdd(A) || isOdd(B) || isOdd(C) {
			break
		}

		if A==B && A==C {
			count = -1
			break
		}

		a = B/2 + C/2
		b = A/2 + C/2
		c = A/2 + B/2

		A, B, C = a, b, c

		count++
	}

	fmt.Println(count)

}

func isOdd(num int) bool {
	if num%2 == 1 {
		return true
	}
	return false
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

ULL solve2(ULL a, ULL b, ULL c, ULL d, ULL e, ULL f) {
	if (a == 0 || f == 0) return 0;
	if (c >= a) {
		if (f > a) {
			ULL t = min(c, f) / a;
			return a * t * 2 + solve2(a, b, c - a * t, d, e, f - a * t);
		}
		return a + solve2(a, 0, f, e, d, c - a);
	}
	return c + solve2(c, 0, a, 0, c, d - f);
}

void solve() {
	ULL n, x; cin >> n >> x;
	ULL ans = x;
	ans += solve2(n - x, 0, n, 0, n - x, x);
	cout << ans << endl;
}

int main() {

	solve();

	return 0;
}


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

int main() {
  long long q,h,s,d,n,a;
  cin >> q >> h >> s >> d >> n;
  if (n%2==0) a = n * min(q*8,min(h*4,min(s*2,d))) / 2;
  else a = ((n-1) * min(q*8,min(h*4,min(s*2,d))) / 2) + min(q*4,min(h*2,s));
  cout << a << endl;
}

Measured memory_bytes: 256
def red_and_green_apples(X, Y, A, B, C, P, Q, R):
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)

    P = P[:X]
    Q = Q[:Y]
    q = P + Q + R
    q.sort(reverse=True)

    return sum(q[:X + Y])


X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

print(red_and_green_apples(X, Y, A, B, C, P, Q, R))

# red_and_green_apples(
#     1, 2, 2, 2, 1,
#     [2, 4],
#     [5, 1],
#     [3],
# )
#
# red_and_green_apples(
#     2, 2, 2, 2, 2,
#     [8, 6],
#     [9, 1],
#     [2, 1],
# )


Measured memory_bytes: 112236
#include <iostream>

using namespace std;

int main()
{
string S;
cin>>S;
int c=0,a=0;
if(S[0]=='A')
{
    for(int i=2;i<S.length()-1;i++)
        {
    if(S[i]=='C')c++;
        }
    for(int i=1;i<S.length();i++){
            if(S[i]!='C')
                {
                    if(isupper(S[i]))a++;
                }
    }
}
if(c==1 && a==0)cout<<"AC";
else cout<<"WA";
return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x,y,i;
	i=0;
	while(i<3000){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0){
			break;
		}
		if(x>y){
			printf("%d %d\n",y,x);
		}
		else{
			printf("%d %d\n",x,y);
		}
		i++;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<ll> l(N), r(N);
    for (int i=0; i<N; ++i) cin >> l[i] >> r[i];

    sort(l.rbegin(), l.rend());
    sort(r.begin(), r.end());
    for (int i=0; i<(int)l.size(); ++i) {
        l[i] *= 2;
        if (i > 0) l[i] += l[i-1];
    }
    for (int i=0; i<(int)r.size(); ++i) {
        r[i] *= 2;
        if (i > 0) r[i] += r[i-1];
    }
    ll ans = 0;
    for (int i=0; 2*i-1<=N; ++i) {
        if (2*i-1 <= N) chmax(ans, l[i] - r[i-1]);
        if (2*i <= N) chmax(ans, l[i] - r[i]);
        if (2*i+1 <= N) chmax(ans, l[i] - r[i+1]);
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define rep(x, a, b) for(auto x = a; x != b; ++x)

const int N = 1e5 + 5;

int n;
char s[N];
int a[N], comp[N], cnt[N];

bool possible(int k) {
  set<int> rem;
  for(int i = 1; i <= n+1; ++i) {
    rem.insert(i);
  }

  int tym = 0;

  while(rem.size()) {
    tym++;

    vector<int> Q = {*rem.begin()};
    rem.erase(rem.begin());

    for(int b = 0; b < (int)Q.size(); ++b) {
      int u = Q[b];
      comp[u] = tym;

      auto l = rem.upper_bound(u - k);
      rep(it, rem.begin(), l) Q.push_back(*it);
      rem.erase(rem.begin(), l);

      auto r = rem.lower_bound(u + k);
      rep(it, r, rem.end()) Q.push_back(*it);
      rem.erase(r, rem.end());
    }
  }
  memset(cnt, 0, sizeof cnt);
  for(int i = 1; i <= n+1; ++i) {
    if(a[i] & 1) cnt[comp[i]]++;
  }
  for(int i = 1; i <= tym; ++i) {
    if(cnt[i] & 1) return false;
  }
  return true;
}

int main(int argc, char const *argv[])
{
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  scanf("%s", s+1);
  n = strlen(s+1);
  a[1] = s[1] - '0';
  for(int i = 2; i <= n; ++i) {
    a[i] = (s[i-1] - '0') ^ (s[i] - '0');
  }
  a[n+1] = s[n] - '0';
  int lo = 1, hi = n, ans = -1;
  while(lo <= hi) {
    int mid = (lo + hi) >> 1;
    if(possible(mid)) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set   tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl          "\n"
#define pb            push_back
#define mp            make_pair
#define F             first
#define S             second
#define int             long long int

#define ALL(v)        v.begin(),v.end()
#define ALLR(v)       v.rbegin(),v.rend()
#define pii           3.14159265358979323
#define inf         LLONG_MAX
#define ones(x)       __builtin_popcount(x)
#define fill(a,b)     memset(a,b,sizeof(a))
#define mod       998244353

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)  
    {
        if(b&1)   
        {
          res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
  return mod_pow(a , mod-2);
}

void solve()
{
  int n, q;
  
  cin >> n;
  
  map<int ,int > m;
  
  int sm = 0;
  
  for(int i = 0; i < n; ++i) {
    int x;
    
    cin >> x;
    
    m[x]++;
    
    sm += x;
  }
  
  cin >> q;
  
  int x , y;
  
  while(q--) {
    cin >> x >> y;
    
    if(x == y) {
      continue;
    }
    
    sm = sm - m[x]*x + m[x]*y;
    
    int rem = m[x];
    
    m.erase(x);
    
    m[y] += rem;
    
    cout << sm  << endl;
  }
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 7464
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!(
        n: usize,
        ds: [(i32, i32); n],
    );
    for d3 in ds.windows(3) {
        if d3.iter().copied().all(|d| d.0 == d.1) {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2180
def main():
    N = int(input())
    S = input()

    rcs = [0] * N
    gcs = [0] * N
    bcs = [0] * N

    for i in range(N):
        if S[i] == 'R':
            rcs[i] = 1
        elif S[i] == 'G':
            gcs[i] = 1
        elif S[i] == 'B':
            bcs[i] = 1

    for i in range(1, N):
        rcs[i] += rcs[i - 1]
        gcs[i] += gcs[i - 1]
        bcs[i] += bcs[i - 1]

    result = 0
    for i in range(N):
        if S[i] == 'R':
            for j in range(i + 1, N):
                if S[j] == 'R':
                    continue
                elif S[j] == 'G':
                    result += bcs[N - 1] - bcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'B':
                        result -= 1
                elif S[j] == 'B':
                    result += gcs[N - 1] - gcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'G':
                        result -= 1
        elif S[i] == 'G':
            for j in range(i + 1, N):
                if S[j] == 'G':
                    continue
                elif S[j] == 'R':
                    result += bcs[N - 1] - bcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'B':
                        result -= 1
                elif S[j] == 'B':
                    result += rcs[N - 1] - rcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'R':
                        result -= 1
        elif S[i] == 'B':
            for j in range(i + 1, N):
                if S[j] == 'B':
                    continue
                elif S[j] == 'R':
                    result += gcs[N - 1] - gcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'G':
                        result -= 1
                elif S[j] == 'G':
                    result += rcs[N - 1] - rcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'R':
                        result -= 1
    print(result)


main()

Measured memory_bytes: 69148
#include <iostream>
#include<cmath>

using namespace std;

int N, W, w[100000+5], v[100000+5];
long long ans, DP[100+5][100000+5]={0}; //DP[N][W]

void solve(){

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= W; j++ ){
            if(j - w[i] >= 0)
                DP[i][j] = max(DP[i-1][j], DP[i-1][j-w[i]] + v[i]);
            else DP[i][j] = DP[i-1][j];
        }
    }

    cout << DP[N][W] << endl;
}

int main(){
    cin >> N >> W;
    for(int i = 1; i <= N; i++) cin >> w[i] >> v[i];

    solve();
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	vector <string> str( 2 );
	cin >> str[ 0 ];
	cin >> str[ 1 ];
	vector <int> vec;
	int index = 0;
	while(true){
		if(index >= N)
			break;
		if (str[ 0 ][ index ] == str[ 1 ][ index ]){
			vec.push_back( 0 );
			index++;
		}
		else {
			vec.push_back( 1 );
			index += 2;
		}
	}
	int status = vec[ 0 ];
	ll ans = 3;
	if (status == 1)
		ans*=2;
	rep( i, 1, vec.size()){
		if (status == 1){
			if (vec[ i ] == 1)
				ans *= 3;
		}
		else{
			ans *= 2;
		}
		status = vec[i];
		ans %= k_mod;
	}
	cout << ans << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
n,x,y=map(int,input().split())

a=[0]*n
# x-=1
# y-=1


for i in range(1,n+1):
    for j in range(i+1,n+1):
        s=min(j-i,abs(x-i)+abs(y-j)+1)
        a[s-1]+=1
        s=10000000

for i in range(n-1):
    print(a[i])


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

using namespace std;
typedef long long ll;

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

    if (N[0] == N[1] && N[1] == N[2]) {
        cout << "Yes";
    } else if (N[1] == N[2] && N[2] == N[3]) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

	using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


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

	ll t = 0, sum = 0, keta = 1;
	while (N / 10 != 0) {
		sum += N % 10;
		N /= 10;
		keta += 1;
	}
	
	
	cout << max((keta - 1) * 9 + N - 1, sum + N);


	return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = {i: 0 for i in range(1, n + 1)}
for x in range(1, 120):
    for y in range(1, 120):
        for z in range(1, 120):
            result = (x + y + z) ** 2 - x * y - y * z - z * x
            if result in ans:
                ans[result] += 1

for i in ans.values():
    print(i)


Measured memory_bytes: 9684
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
s,t=0,0
for i,j in zip(a,b):
    if i>j:t+=i-j
    else:s+=(j-i)//2
if s>=t:print('Yes')
else:print('No')

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
const int N=110;
const double inf=1e18;
const double pi=3.14159265357932384626433832795;
const double eps=1e-12;
int n,x[N],y[N],up[N][N];
double s[N][N];
inline double slope(int a,int b,int c,int d){
	if(b==d)return inf;
	return 1.0*(c-a)/(b-d);
}
inline double solve(int x){
	double lu=-90,ld=90,ru=-90,rd=90;
	for(int i=1; i<=n; ++i)
		if(i!=x){
			if(up[x][i])lu=max(lu,atan(-s[x][i])/pi*180),ru=max(ru,atan(s[x][i])/pi*180);
			else ld=min(ld,atan(-s[x][i])/pi*180),rd=min(rd,atan(s[x][i])/pi*180);
		}
	return (max(ld-lu,0.0)+max(rd-ru,0.0))/360;
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)scanf("%d%d",&x[i],&y[i]);
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=n; ++j)
			if(i!=j)s[i][j]=slope(x[i],y[i],x[j],y[j]),up[i][j]=(y[i]==y[j]?x[i]<x[j]:y[i]>y[j]);
	for(int i=1; i<=n; ++i)printf("%.5lf\n",solve(i));
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[105][10];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w,k; cin>>h>>w>>k; k--;
  
  dp[0][0]=1;
  rep(ki,h){
     for(ll bit=0; bit<(1<<(w-1)); bit++){
       bool flg=false;
       rep(i,w-2){
         if((bit>>i&1) && (bit>>(i+1)&1)){
           flg=true;
           break;
         }
       }
       if(flg) continue;
       
       rep(i,w){
         if(i==w-1){
           if(!(bit>>(i-1)&1)){
             (dp[ki+1][i]+=dp[ki][i])%=MOD;
           }
         }
         else if(bit>>i&1){
           (dp[ki+1][i]+=dp[ki][i+1])%=MOD;
           (dp[ki+1][i+1]+=dp[ki][i])%=MOD;
         }else{
           if(i==0){
             (dp[ki+1][i]+=dp[ki][i])%=MOD;
           }else{
             if(!(bit>>(i-1)&1)){
               (dp[ki+1][i]+=dp[ki][i])%=MOD;
             }
           }
         }
       }
     }
  }
  // rep(i,w){
  //   if(i) cout<<' ';
  //   cout<<dp[h][i];
  // }
  
  cout<<dp[h][k]<<endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(){
int a,b; cin>>a>>b;
if (1<=a&&a<=9&&1<=b&&b<=9){
    if(a>b){
        for(int i=0;i<a;i++){
            cout<<b;
        }
    }
    else{
        for(int i=0;i<b;i++){
            cout<<a;
    }
}
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll  powFac(ll a,ll b,ll m)
{
  ll temp1=1, ans=1;
  if(a<0)temp1=0;
  else {
  for(ll i=1;i<=a;i++)temp1=temp1*i%m;
}
   while(b>0)
   {
    if(b&1)ans=ans*temp1%m;
    temp1=temp1*temp1%m;
    b>>=1;
   }
 return ans;
} 




int main()
{
   
    ll i,j,n,k,flag=0,temp=0,count=0,temp3=0,m=1000000007,s1=0,s2=0;
   cin>>n;
   ll arr[n];

for(i=0;i<n;i++)
{
  cin>>arr[i];
  count+=arr[i];
}

count/=n;

for(i=0;i<n;i++)
{
  s1+=(count-arr[i])*(count-arr[i]);
  s2+=(count+1-arr[i])*(count+1-arr[i]);
}

temp=min(s1,s2);

cout<<temp<<endl;

 return 0;
  }

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N rune
	var S string
	fmt.Scan(&N, &S)

	for i := 0; i < len(S); i++ {
		converted := rune(S[i]) + N
		if converted > 90 {
			converted -= 26
		}

		fmt.Print(string(converted))
	}
	fmt.Println()
}


Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

struct UnionFind {
  vector<int> parent,s;
  UnionFind(int n): parent(n), s(n){
    rep(i,n) {
      parent[i] = i;
      s[i] = 1;
    }
  }
  int root(int x) { return parent[x]==x ? x : parent[x] = root(parent[x]); }
  bool same(int x, int y) { return root(x)==root(y); }
  int size(int x){ return s[root(x)]; }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (s[x] < s[y]) {
      parent[x] = y;
      s[y] += s[x];
    } else {
      parent[y] = x;
      s[x] += s[y];
    }   
  }
};

int main() {
  int n,m;
  cin >> n >> m;
  vector<P> e(m);
  rep(i,m) cin >> e[i].first >> e[i].second;
  
  UnionFind u(n);
  vector<ll> d(m,0LL);
  rep(i,m){
    int a = e[m-1-i].first, b = e[m-1-i].second;
    --a; --b;
    if(u.same(a,b)) continue;
    d[m-1-i] = u.size(a)*u.size(b);
    u.unite(a,b);
  }
  ll ans = 0;
  rep(i,m){
    ans += d[i];
    cout << ans << endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> Vector;
typedef vector<vector<ll>> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX/3
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define rep(i,n)    repl(i,0,n-1)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<int>())
#define mkp(x,y)    make_pair(x,y)

int main() {
  cin.sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  double k = pow(2,m);
  cout << (1900 * m + 100 * (n-m))*k << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int num(char c){
	if(c=='I') return 1;
	else if(c=='V') return 5;
	else if(c=='X') return 10;
	else if(c=='L') return 50;
	else if(c=='C') return 100;
	else if(c=='D') return 500;
	else if(c=='M') return 1000;
	else{
		return 0;
	}
}
int y[110];
int main() {
	string s;
	int n=0;
	while(true){
		cin>>s;
		if (cin.eof())break; 
		for(int i=0;i<s.size();i++){
			y[i]=num(s[i]);
		}
		for(int i=0;i<s.size();i++){
			if(y[i]>=y[i+1]){
				n+=y[i];
			}
			else{
				n-=y[i];
			}
		}
		cout<<n<<endl;
		n=0;
		for(int i=0;i<110;i++){
			y[i]=0;
		}
	}
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//以上テンプレ
int main(){
    vvl vec(3,vl(3));
    rep(i,3){
        rep(j,3){
            cin>>vec.at(i).at(j);
        }
    }
    rep(i,2){
        if(vec.at(i).at(0)-vec.at(i).at(1)!=vec.at(i+1).at(0)-vec.at(i+1).at(1)){
            cN;
            return 0;
        }else if(vec.at(i).at(1)-vec.at(i).at(2)!=vec.at(i+1).at(1)-vec.at(i+1).at(2)){
            cN;
            return 0;
        }
    }
    cY;
    }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <set>
#include <map>

#define M_PI 3.14159265358979323846

#define err 1e-7
#define INF 2e9 

#define mp make_pair
#define pb push_back

#define tr(container, iterator) \
	for(typeof(container.begin()) iterator=container.begin(); \
		it != container.end(); it++)

using namespace std;

int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);	

	int x1, x2, y1, y2;

	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	if (x2 < x1 || (x2 == x1 && y2 < y1)) {
		swap(x1, x2);
		swap(y1, y2);
	}

	int n;

	scanf("%d", &n);

	vector< pair<int, int> > a(n);

	for(int i = 0; i < n; i++)
		scanf("%d%d", &a[i].first, &a[i].second);

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

	vector< int > b(0);

	for (int i = 0; i < n; i++) {
		if (a[i].first <= max(x1, x2) && a[i].first >= min(x1, x2) && a[i].second >= min(y1, y2) && a[i].second <= max(y1, y2))
			b.pb(a[i].second);
	}

	if (y1 > y2) {
		for (int i = 0; i < b.size(); i++)
			b[i] *= -1;
	}

	vector<int> c(0);

	for (int i = 0; i < b.size(); i++) {
		int j = upper_bound(c.begin(), c.end(), b[i]) - c.begin();

		if (j == c.size())
			c.pb(b[i]);
		else
			c[j] = min(c[j], b[i]);
	}
	/*
	for (int i = 0; i < c.size(); i++)
		printf("%d ", c[i]);
	*/    /*
	if (abs(x1 - x2) == 0 || abs(y1 - y2) == 0)
		printf("%.13f", (abs(x1 - x2) + abs(y1 - y2)) * 100ll - c.size() * 20 + c.size() * 10 * M_PI);
	else*/ 
	if (c.size() == min(abs(y2 - y1), abs(x1 - x2)) + 1)
	    printf("%.13f", (abs(x1 - x2) + abs(y1 - y2)) * 100ll - c.size() * 20 + (10 + (c.size() - 1) * 5) * M_PI);
	else
		printf("%.13f", (abs(x1 - x2) + abs(y1 - y2)) * 100ll - c.size() * 20 + c.size() * 5 * M_PI);

	return 0;
}

Measured memory_bytes: 4084
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import fractions

def main():
    x,n = map(int, input().split())
    P = list(map(int, input().split()))

    ans = INF
    array = set(range(x-n-1,x+n+1))
    array = array - set(P)
    array = list(array)
    for i in range(len(array)):
        ans = min(ans, abs(array[i]-x))
    if (x-ans) in P:
        print(x+ans)
    else:
        print(x-ans)




if __name__ == '__main__':
    main()


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

typedef struct { double x, y; } R;

void koch(int n, R a, R b) {
	if (n == 0) return;

	R i, j, k;
	double th = M_PI * 60.0 / 180.0;

	i.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	i.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	j.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	j.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	k.x = (j.x - i.x) * cos(th) - (j.y - i.y) * sin(th) + i.x;
	k.y = (j.x - i.x) * sin(th) - (j.y - i.y) * cos(th) + j.y;

	koch(n - 1, a, i);
	printf("%.8f %.8f\n", i.x, i.y);
	koch(n - 1, i, k);
	printf("%.8f %.8f\n", k.x, k.y);
	koch(n - 1, k, j);
	printf("%.8f %.8f\n", j.x, j.y);
	koch(n - 1, j, b);
}

int main() {

	R a, b;
	int n;

	scanf("%d", &n);
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);

	return 0;
}


Measured memory_bytes: 2072
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

static inline void MainTask() {
  int32_t A, B;
  cin >> A >> B;
  uint32_t res = 0;
  if (B == 1) {
    cout << 0 << endl;
    return;
  }
  B -= A;
  ++res;
  if (B < 1) {
    cout << res << endl;
  } else {
    --A;
    res += B / A;
    if (B % A) ++res;
    cout << res << endl;
  }
}

int main() {
  MainTask();
  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
money = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            money = i * 500 + j * 100 + k * 50
            if money == x:
                cnt += 1

print(cnt)


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

int fact(int n){
    int sum = 1;
    for(int i = 2;i <= n;i++)sum *= i;
    return sum;
}

int main(void){
    int n;
    double ans = 0;
    cin >> n;
    vector<double> a(n),x(n),y(n);
    for(int i = 0;i < n;i++){
        cin >> x[i] >> y[i];
        a[i] = i;
    }
    do{
        for(int i = 0;i < n-1;i++){
            ans += sqrt(pow(x[a[i]] - x[a[i+1]],2) + pow(y[a[i]] - y[a[i+1]],2));
        }
    } while(next_permutation(a.begin(),a.end()));
    printf("%.10lf\n",double(ans / fact(n)));
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b;
  cin >> a >> b;
  bool r = false;
  if(a > b){
    int tmp = a; a = b; b = tmp;
    r = true;
  }

  bool tab[100][100];
  for(int i = 0; i < 50; i++){
    fill(tab[i], tab[i] + 100, true);
  }
  for(int i = 50; i < 100; i++){
    fill(tab[i], tab[i] + 100, false);
  }

  int count = 0;
  int h = 0;
  while(count < a - 1){
    for(int j = 0;
        count < a - 1 && j < 100; j += 2){
      tab[h][j] = false;
      ++count;
    }
    h += 2;
  }
  h = 99;
  count = 0;
  while(count < b - 1){
    for(int j = 0;
        count < b - 1 && j < 100; j += 2){
      tab[h][j] = true;
      ++count;
    }
    h -= 2;
  }

  string ans;
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      if(tab[i][j]) ans.append((!r) ? "#" : ".");
      else ans.append((!r) ? "." : "#");
    }
    ans.append("\n");
  }

  cout << to_string(100) + " " + to_string(100) << endl;
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int n,l;

void solve(){
    int i,j,k;
    cin >> l >> n;
    vector<int> x(n);
    vector<long long> xp(n+1),xi(n+1);
    xp[0] = 0;
    xi[n] = 0;
    for(i = 0;i < n;i++){
        cin >> x[i];
        xp[i+1] = xp[i] + x[i];
    }
    for(i = n-1;i >= 0;i--){
        xi[i] = xi[i+1] + (l-x[i]);
    }
    long long ans = 0;
    long long a = 0;
    a = l-x[0];
    if(a > ans) ans = a;
    a = x[n-1];
    if(a > ans) ans = a;
    for(i = 1;i < n;i++){
        k = min(i,n-i-1);
        a = l-x[i];
        a += 2*(xi[i+1]-xi[i+1+k]);
        a += 2*(xp[i]-xp[i-k]);
        if(i > n-i-1) a += 2*x[i-k-1];
        if(a > ans) ans = a;
        k = min(i-1,n-i);
        a = x[i-1];
        a += 2*(xi[i]-xi[i+k]);
        a += 2*(xp[i-1]-xp[i-1-k]);
        if(n-i > i-1) a += 2*(l-x[i+k]);
        if(a > ans) ans = a;
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
#define _USE_MATH_DEFINES

int main() {
	int a, b;
	char op;
	while (1) {
		cin >> a >> op >> b;
		if (op == '?')
			break;
		else if (op == '+')
			cout << a + b << endl;
		else if (op == '-')
			cout << a - b << endl;
		else if (op == '*')
			cout << a*b << endl;
		else if (op == '/')
			cout << a / b << endl;
	}
}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] h = new int[N];

		for (int i = 0; i < N; i++) 
			h[i] = sc.nextInt();

		int[] dp = new int[N];
		dp[0] = 0;
		dp[1] = Math.abs(h[0]-h[1]);	

		for (int i = 2; i < N; i++) {
			int a = dp[i-1] + Math.abs(h[i]-h[i-1]);
			int b = dp[i-2] + Math.abs(h[i]-h[i-2]);
			dp[i] = Math.min(a, b);
		}
		System.out.println(dp[N-1]);
	}

}






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

int main(){
    int n;
    cin >> n;
    if(n == 0)  cout << 1 << endl;
    else if(n == 1) cout << 2 << endl;
    else if(n == 2) cout << 1 << endl;
    else            cout << 0 << endl;
    return 0;
}


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

long long a, b;

int main()
{
    scanf("%lld%lld",&a,&b);
    int cnt = 0;
    while(a <= b)
    {
        cnt++;
        a*=2;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,k,ans=0;
  cin>>n>>k;
  vector<ll>v(n,0);
  ll sum=0;
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  for(ll i=0;i<n-k;i++){
    ans+=v[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int a;
	cin>>a;
	long long int b,c,flag=0;
	cin>>b>>c;
	forr(i,b,c+1)
	{
		if(i%a==0)
			flag=1;
	}
	cout<<(flag?"OK":"NG");
	
	return 0;
}


Measured memory_bytes: 3608
# Coding is about expressing your feeling, and
# there is always a better way to express your feeling_feelme
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=int(1e9 + 7)

n=ii1()
if n==1:
    print(1)
elif n%2==0:
    print(1/2)
else:
    print((n//2 +1)/n)


Measured memory_bytes: 9292
n, x = map(int, input().split())
a = list(map(int,input().split()))

ans = 0
for i in range(n-1):
    if a[i] > x:
        ans += a[i]-x
        a[i] = x
    if a[i]+a[i+1] > x:
        ans += a[i+1] - (x-a[i])
        a[i+1] = x-a[i]

print(ans)

Measured memory_bytes: 14056
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define eps 1e-15
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main() {
	fio
	int n, mid; cin >> n;
  int res = 0;
  for(int i = 0; i < n; ++i) {
    cin >> mid;
    res ^= mid;
  } 
  if(!res) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
ll a[100006];
int main(){
    ll n,m;
    scanf("%lld%lld",&n,&m);
    int lcm1=1;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        if(lcm1>m){
            continue;
        }
        lcm1=lcm(lcm1,a[i]/2);
    }
    int flag=0;
    for(int i=1;i<=n;i++){
        int temp=lcm1*2/a[i];
        if(temp%2==0){
            flag=1;
            break;
        }
    }
    if(flag){
        puts("0");
        return 0;
    }
    int cnt=m/lcm1;
    if(cnt&1){
        cnt=cnt/2+1;
    }
    else{
        cnt=cnt/2;
    }
    printf("%lld\n",cnt);
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, T;
    cin >> n >> T;
    vector<ll> t(n);
    rep(i, n) cin >> t[i];
    ll count = 0;

    int i;
    while (i < n)
    {
        if (i < n - 1)
        {
            if (t[i + 1] - t[i] > T)
            {
                count += T;
                i++;
            }
            else
            {
                count += t[i + 1] - t[i];
                i++;
            }
        }
        else
        {
            count += T;
            break;
        }
    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int N=S.size();
	int bitall=(1<<(N-1));
	ll ans=0;
	rep(bit,bitall){
		ll sum=0;
		vint pl;
		pl.push_back(0);
		rep(i,N-1){
			if((bit>>i)&1){
				pl.push_back(i+1);
			}
		}
		pl.push_back(N);
		/*rep(j,pl.size()){
			printf("%d ",pl[j]);
		}
		kaigyo;*/
		rep(j,pl.size()-1){
			int fi=pl[j],la=pl[j+1];
			string sub=S.substr(fi,la-fi);
			//prin(sub);
			sum+=atol(sub.c_str());
		}
		ans+=sum;
	}
	prin(ans);
	return 0;
}


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


int main(){


long long N;
cin>>N;


for(long long h=1;h<=3500;h++){
    for(long long n=1;n<=3500;n++){
        long double w =(N*h*n)/(long double)(4*n*h-N*n-N*h);
        if(w>=1 && w<=3500 && w==(long long)(w)){
            cout<<h<<" "<<n<<" "<<w<<endl;
            return 0;
        }
    }
}

 return 0;
}
/*
2

1 2 2

3485

872 1012974 1539173474040

4664

3498 3498 3498
*/

Measured memory_bytes: 256