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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int N, K; cin >> N >> K;
  vi32 x(N), y(N);
  rep(i, N) cin >> x[i] >> y[i];

  set<pair<int, int>> se;
  rep(i, N) se.emplace(x[i], y[i]);
  
  vi32 ox = x, oy = y;
  sort(all(ox)), sort(all(oy));
  vector<vi32> sums(N + 1, vi32(N + 1));
  rep(i, N) rep(j, N) {
    int a = 0;
    int x = ox[i], y = oy[j];
    if (se.count(make_pair(x, y))) a = 1;
    sums[i + 1][j + 1] = sums[i][j + 1] + sums[i + 1][j] - sums[i][j] + a;
  }

  i64 ans = numeric_limits<i64>::max();
  rep(i, N) rep(j, N) reps(k, N) reps(l, N) {
    if (i >= k || j >= l) continue;
    int c = sums[k][l] - sums[i][l] - sums[k][j] + sums[i][j];
    if (c < K) continue;
    amin(ans, (i64) (ox[k - 1] - ox[i]) * (oy[l - 1] - oy[j]));
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,i,j,c=0;string s;
	cin>>s;n=s.size();i=0,j=n-1;
	while(i<j){
		if(s[i]-s[j]) c++;
		i++,j--;
	}cout<<c<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main(void)
{
    int n , t ; cin >> n >> t ;
    int ar[n] , i , sum = 0 ;
    for(i = 0 ; i < n ; ++i) cin >> ar[i] ;
    sort(ar , ar + n) ;
    for(i = 0 ; i < t ; ++i) sum += ar[i] ;
    cout << sum << endl ;
    return 0 ;
}


Measured memory_bytes: 3484
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn main(){
    let (n, m): (usize, usize) = readln();
    let mut exists: Vec<bool> = vec![false;m];
    let mut uf = UnionFind::new(m);
    for _ in 0..n {
        let xs: Vec<usize> = readln();
        let k = xs[0];
        let x = xs[1] - 1;
        exists[x] = true;
        for i in 2..k+1 {
            exists[xs[i]-1] = true;
            uf.unite(x, xs[i]-1);
        }
    }

    let mut origin = 0;
    for i in 0..m {
        if exists[i] {
            origin = i;
            break;
        }
    }

    for i in 0..m {
        if uf.equiv(origin, i) || !exists[i]{
            continue;
        } else {
            println!("NO");
            return;
        }
    }
    println!("YES");
}


#[allow(dead_code)]
fn get_line() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_string()
}

#[allow(dead_code)]
fn get_chars() -> Vec<char>{
    get_line().chars().collect()
}

#[allow(dead_code)]
fn readln<T: Read>() -> T{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

trait Read{
    fn read(s: &str) -> Self;
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl<T: Read> Read for Vec<T>{
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B){
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C){
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

struct UnionFind{
    parent: Vec<usize>,
    rank: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut parent: Vec<usize> = Vec::with_capacity(n);
        for i in 0..n{
            parent.push(i)
        }
        UnionFind{parent: parent, rank: vec![0; n]}
    }

    fn find(&mut self, x: usize) -> usize{
        if self.parent[x] == x {
            x
        } else {
            let px = self.parent[x];
            let root = self.find(px);
            self.parent[x] = root;
            root
        }
    }

    fn unite(&mut self, x: usize, y: usize){
        let px = self.find(x);
        let py = self.find(y);

        if px == py {return}

        if self.rank[px] < self.rank[py] {
            self.parent[px] = py;
        } else {
            self.parent[py] = px;
            if self.rank[px] == self.rank[py] {
                self.rank[px] += 1;
            }
        }

    }

    #[allow(dead_code)]
    fn equiv(&mut self, x: usize, y: usize) -> bool{
        self.find(x) == self.find(y)
    }

}

Measured memory_bytes: 2300
H, W = map(int, input().split())
used = [[False]*W for i in range(H)]
used[0][0]=True
stuck = [(0,0)]
state = [[0]*W for i in range(H)]
way = []
ans = []
for i in range(H):
  inf = input().split()
  for j in range(W):
    state[i][j] = int(inf[j])
for i in range(H):
  ls = [(j,i) for j in range(W)]
  if i%2==0:
    ls.reverse()
  way += ls
ps = way[0]

for T in way[1:]:
  x, y = ps
  nx, ny = T
  if state[y][x]%2==1:
    ans += [(y+1,x+1,ny+1,nx+1)]
    state[y][x] -= 1
    state[ny][nx] += 1
  ps = T
print(len(ans))
for a in ans:
  print(*a)

Measured memory_bytes: 50004
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  int snum = 0;
  int tnum = 0;
  int res = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'T'){
      if(i == 0 || s[i - 1] == 'S'){
        tnum = 1;
      }else{
        tnum++;
      }
    }else{
      if(i == 0 || s[i - 1] == 'T'){
        res += 2 * min(snum, tnum);
        if(snum > tnum)snum = snum - tnum + 1;
        else snum = 1;
        tnum = 0;
      }else{
        snum++;
      }
    }
  }
  res += 2 * min(snum, tnum);
  cout << s.size() - res << endl;
	return 0;
}


Measured memory_bytes: 640
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
	int d, n;
	cin >> d >> n;
	int cnt = 0;
	int divise = 1;
	for (int i = 0; i < d; ++i) {
		divise *= 100;
	}
	for (int i = 1; i >= 0; ++i) {
		if (i % divise == 0) {
			int hoge = i / divise;
			if (hoge % 100 != 0) {
				cnt++;
				if (cnt == n) {
					cout << i << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>

using namespace std;

int main()
{
	int_least32_t n;
	cin >> n;

	int_least32_t temp, cntodd{ 0 }, cnteven{ 0 };
	for(;n > 0; --n) {
		cin >> temp;
		if(temp & 1 == 1) {
			++cntodd;
		}
		else {
			++cnteven;
		}
	}

	cnteven += cntodd / 2;
	if(cntodd & 1 == 1 && cnteven > 0) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 384
<?php

$n = (int)trim(fgets(STDIN));
$an = explode(' ', trim(fgets(STDIN)));

arsort($an);

$result = 0;

$index = 0;
foreach ($an as $value)
{
    $add_value = ($index % 2 === 0)? $value : -$value;
    $result += $add_value;

    $index++;
}

echo $result;


Measured memory_bytes: 4856
#include <iostream>


using namespace std;


int main()
{
        int vmin, vmax;
        int tmp;

        cin >> vmin;
        vmax = vmin;

        cin >> tmp;
        if (tmp > vmax) {
                vmax = tmp;
        } else if (tmp < vmin) {
                vmin = tmp;
        }

        cin >> tmp;
        if (tmp > vmax) {
                vmax = tmp;
        } else if (tmp < vmin) {
                vmin = tmp;
        }

        cout << vmax - vmin << endl;





        return 0;
}

Measured memory_bytes: 888
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli h, ans = 0, cnt = 1;
    cin >> h;
    while(h>1){
        h /= 2;
        ans += cnt;
        cnt *= 2;
    }
    ans += cnt;
    out(ans);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;

#define endl "\n"

const int MOD = 1000000007;


int main()
{

    	int a;
        cin>> a;
        if( a >= 400 && a <= 599){
        	cout << "8" << endl;
        }
        else if ( a >= 600 && a<=799){
        	cout << "7" << endl;
        }
        else if(a >= 800 && a <= 999){
        	cout << "6" << endl;
        }
        else if( a >= 1000 && a <= 1199){
        	cout << "5" << endl;
        }
        else if( a >= 1200 && a <= 1399){
        	cout << "4"  << endl;
        }
        else if( a >= 1400 && a <= 1599){
        	cout << "3" << endl;
        }
        else if ( a>= 1600 && a <= 1799){
        	cout << "2" << endl;
        }
        else if( a >= 1800 && a <= 1999){
        	cout << "1" << endl;
        }

	return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
int main(void){
    int n,x,i,j,m,count;
    while(1){
        count=0;
    scanf("%d %d",&n,&x);
    if(x == 0 && n == 0)    break;
    else{
    for(i=1;i<=n;i++){
        
        for(j=i+1;j<=n;j++){
            
            for(m=j+1;m<=n;m++){
                
                if(i+j+m==x)
                            count++;
                }
            }
        }
    }
    printf("%d\n",count);
    }
}


Measured memory_bytes: 2112
#!/usr/bin/env ruby

roma = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
while line = gets
  a = line.chomp!.split('')

  bfr = 0
  sum = 0
  a.each do |chr|
    now = roma[chr.to_sym]
    now -= (bfr*2) if bfr < now
    bfr = now

    sum += now
  end

  puts sum
end

Measured memory_bytes: 8652
#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int n,q,vis[N];
int main()
{
    for(int i=1;i<=10000000;i++)
        for(int j=i;j<=10000000;j+=i)
        vis[j]++;
    int n;scanf("%d",&n);
    long long ans=0;
    for(int i=1;i<=n;i++)
        ans=ans+(long long)i*vis[i];
    printf("%lld\n",ans);
}


Measured memory_bytes: 42864
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
char c[6];
rep(i,6)cin>>c[i];
if((c[0]==c[5])&&(c[1]==c[4])&&(c[2]==c[3]))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

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

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int x,a,b; cin >> x>> a >> b;
    cout << ((abs(x-a) < abs(x-b)) ? "A" : "B") << endl;
  
    return 0;
}



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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define endl "\n"

const ll N = 1e6 + 7;
const double PI = acos(-1);
ll mod = 998244353;


int32_t main()
{
	
	IOS
	
	ll n, a;
	cin>>n;
	vector<ll> v;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.pb(a);
	}
	ll cnt = 0;
	for(int i=1;i<n-1;i++)
	{
		ll mn = min(v[i-1], min(v[i], v[i+1]));
		ll mx = max(v[i-1], max(v[i], v[i+1]));
		if(v[i] != mn && v[i] != mx)
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prll(a,sz)  cout<<a[0];for(ll i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<ll,ll>pi;
typedef pair<ll,ll>pll;
//ll fx[]={0,0,1,-1};
//ll fy[]={1,-1,0,0};
//ll gx[]={0,0,1,1,1,-1,-1,-1};
//ll gy[]={1,-1,0,1,-1,0,1,-1};
const ll N=100010;
ll n;
ll check(ll b)
{
    if(b-1==0)return 0;
    if(n%(b-1)==0)return 0;
    return b-1;
}
int main()
{
    IOS;
    cin>>n;
    ll res=0;
    ll sq=sqrt(n);
    for(ll i=1;i<=sq;i++)
    {

        ll b=(n/i)-1;
        if(b==0)continue;
        if(n%b==n/b)
        {
            res+=b;
//            cout<<"b = "<<b<<endl;
        }
    }
    cout<<res<<endl;
}








Measured memory_bytes: 3660
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define ceil(a,b) ((a+b-1)/b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int N,i;
    cin >> N >> i;
    cout << N-i+1;
}

Measured memory_bytes: 888
def main():
    S = input()
    op = ['+', '-']

    def calc(cur):
        ret = int(S[0])
        for i in range(3):
            if cur[i] == "+":
                ret += int(S[i+1])
            else:
                ret -= int(S[i+1])
        return ret
    for i in range(1 << 3):
        cur = []
        for j in range(3):
            if i & (1 << j):
                cur.append(op[0])
            else:
                cur.append(op[1])
        if calc(cur) == 7:
            print("".join(S[i]+cur[i] for i in range(3)) + S[3] + "=7")
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static java.util.stream.Collectors.joining;

public class Main {
    private static final String WHITE = ".";
    private static final String BLACK = "#";

    public static List<String> process(int H, int W, List<String> a) {
        final List<String> removedBlankRows = a.stream().filter(Main::keepRowWithAnyBlack).collect(Collectors.toList());
        final List<String> transposed = transpose(removedBlankRows);
        final List<String> compressedTranspose = transposed.stream().filter(Main::keepRowWithAnyBlack).collect(Collectors.toList());

        return transpose(compressedTranspose);
    }

    private static boolean keepRowWithAnyBlack(String row) {
        return row.chars().anyMatch(Main::isBlack);
    }

    private static boolean isBlack(int c) {
        return c == BLACK.codePointAt(0);
    }

    private static List<String> transpose(List<String> grid) {
        if (grid.isEmpty()) {
            return new ArrayList<>();
        } else {
//            final int H = grid.size();
            final int W = grid.get(0).length();

            return IntStream.range(0, W)
                    .boxed()
                    .map(i -> grid.stream().map(row -> row.substring(i, i + 1)).collect(joining()))
                    .collect(Collectors.toList());
        }
    }

    // Util Func

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

        final List<String> a = IntStream.range(0, H).mapToObj(i -> sc.next()).collect(Collectors.toList());

        // process
        final List<String> result = process(H, W, a);

        // output
        result.forEach(System.out::println);
    }
}

Measured memory_bytes: 28500
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define INF_LL 1000000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<ll, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

int main() {
    int n, m;
    cin >> n >> m;
    scc_graph g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    vector<vector<int>> scc = g.scc();
    cout << scc.size() << endl;
    for(auto v : scc) {
        cout << v.size() << " ";
        for(int x : v)
            cout << x << " ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 40600
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int a,b,t,ans = 0; cin >> a >> b >> t;
	FOR(i,1,t+1){
		if(i%a==0) ans += b;
	}
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] num = new int[3]; 
        num[0] = scan.nextInt();
        num[1] = scan.nextInt();
        num[2] = scan.nextInt();
        Arrays.sort(num);
        System.out.println(num[0] + " " + num[1] + " " + num[2]);
        scan.close();
    }
}


Measured memory_bytes: 26256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut dp: Vec<usize> = vec![0; w + 1];
    for i in 0..n {
        for j in (a[i].0..w + 1).rev() {
            dp[j] = max(dp[j], dp[j - a[i].0] + a[i].1);
        }
    }
    println!("{}", dp[w]);
}


Measured memory_bytes: 4352
l = [list(map(int, input().split())) for _ in range(3)]
l_ans = [[0, 0, 0] for _ in range(3)]
n = int(input())

for ans in range(n):
  ans = int(input())
  for i in range(3):
    for j in range(3):
      if l[i][j] == ans:
        l_ans[i][j] = 1

flag = 0
for i in l_ans:
  if sum(i) == 3:
    flag += 1

for i in range(3):
  temp = 0
  for j in range(3):
    temp += l_ans[j][i]
  if temp == 3:
    flag += 1

temp = 0
for i in range(3):
  temp += l_ans[i][i]
if temp == 3:
  flag += 1

temp = 0
for i in range(3):
  temp += l_ans[i][2 - i]
if temp == 3:
  flag += 1

if flag >= 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  double x1,y1,x2,y2,x3,y3,x4,y4;
  
  while(n--){
    cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    if(abs((y2-y1)*(x4-x3)-(x2-x1)*(y4-y3))<0.000000000001) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
    
  return 0;
}


Measured memory_bytes: 3140
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>
#include<list>
#include<cstdio>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)


using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1e9+7;


/******************************************************************************************/


vector<int> G[100005];
int pa[100005];
int d[100005];
int in[100005];
int h[100005];
int sib[100005];

int dfs(int par, int now, int dpt) {


	pa[now] = par;
	d[now] = dpt;

	int height = -1;

	if (G[now].size() > 0) {

		int left = 0;
		int right = 0;

		if (G[now].size() == 1) {
			left = G[now][0];
			sib[left] = -1;

			if (pa[left] == -INF) {
				height = max(height, dfs(now, left, dpt + 1));
			}
		}
		else {
			left = G[now][0];
			right = G[now][1];

			sib[left] = right;
			sib[right] = left;

			if (pa[left] == -INF) {
				height = max(height, dfs(now, left, dpt + 1));
			}
			if (pa[right] == -INF) {
				height = max(height, dfs(now, right, dpt + 1));
			}
		}
	
	}
	return h[now] = height + 1;
}



int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int v, l, r;
		cin >> v >> l >> r;

		if (l != -1) {
			G[v].push_back(l);
			in[l]++;
		}
		if (r != -1) {
			G[v].push_back(r);
			in[r]++;
		}
	}

	for (int i = 0; i < 100005; i++)
	{
		pa[i] = -INF;
		sib[i] = -1;
	}

	int node = 0;

	//親を探す
	for (int i = 0; i < 100005; i++)
	{
		if (in[i] == 0) {
			node = i;
			break;
		}
	}

	dfs(-1, node, 0);//（親番号，今いる番号，深さ）

	for (int i = 0; i < n; i++)
	{
		cout << "node " << i << ": parent = " << pa[i] << ", sibling = " << sib[i] << ", degree = " << G[i].size() << ", depth = " << d[i] << ", height = " << h[i];
		
	
		if (d[i] == 0) {
			cout << ", root";
		}else if (G[i].size() == 0) {
			cout << ", leaf";
		}
		else
		{
			cout << ", internal node";
		}
	
		cout << endl;
	}


	return 0;
}



Measured memory_bytes: 6352
k = list(map(int, input().split()))
if k[1] == 0:
  print(k[0])
else:
  l = list(map(int, input().split()))
  a = [i for i in range(102) if not i in l]
  m = []
  for i in a:
    m.append(abs(i - k[0]))
  print(a[m.index(min(m))])

Measured memory_bytes: 9224
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

int A[100] = {0};

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

  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int d = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      d = max(d, abs(A[i] - A[j]));
    }
  }
  cout << d << endl;

  return 0;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    arr = list(map(int, input().split()))

    res = 0
    while True:
        exist_odd = False
        for num in arr:
            if num % 2 != 0:
                exist_odd = True

        if exist_odd:
            break

        arr = list(map(lambda x: int(x/2), arr))
        res += 1

    print(res)

resolve()

Measured memory_bytes: 3060
//IOI 2021

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100 * 1000 + 17;

ll n, a, b, h[MAXN], ans, l = -1, r;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++)
		cin >> h[i];
	sort(h + 1, h + n + 1, greater<int>());
	for (int i = 1; i <= n; i++) {
		if (h[i] <= r * b)
			break;
		r += (h[i] - r * b + a - 1) / a;
	}
	while (l + 1 < r) {
		ll mid = (l + r) / 2, res = 0;
		for (int i = 1; i <= n; i++)
			if (h[i] - mid * b > 0)
				res += (h[i] - mid * b + (a - b - 1)) / (a - b);
		if (res > mid)
			l = mid;
		else
			r = mid;
	}
	cout << r << endl;	
	return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
int main(){
  int N,A,B;
  int count = 0;
  int dig = 0,sum = 0,num = 0;
  scanf("%d",&N);
  scanf("%d",&A);
  scanf("%d",&B);
  for(int i=1;i<=N;i++){
    num = i;
    while(num){
      dig = num % 10;
      sum = sum + dig;
      num = num / 10;
    }
    if(A<=sum&&sum<=B){
      count = count + i;
    }
    dig = 0;
    sum = 0;
  }
  printf("%d",count);
  return 0;
}

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

using namespace std;
using ll = long long;

const int N = 1e6 + 5, MOD = 1e9 + 7;
const ll INF = 1e18 + 17;

int n, x[N], y[N], p[N], sz[N];

int get(int v) {
	if (p[v] == v) {
		return v;
	}
	return p[v] = get(p[v]);
}

void unite(int a, int b) {
	a = get(a), b = get(b);
	if (sz[a] < sz[b]) {
		swap(a, b);
	}
	sz[a] += sz[b];
	p[b] = a;
}

void solve() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		p[i] = i;
		sz[i] = 1;
	}
	for (int i = 1; i <= n; ++i) {
		cin >> x[i] >> y[i];
	}
	vector <pair <pair <int, int>, int> > pr;
	for (int i = 1; i <= n; ++i) {
		pr.push_back({{x[i], y[i]}, i});
	}
	sort(pr.begin(), pr.end());
	set <pair <pair <int, int>, int> > st;
	for (int i = n - 1; i >= 0; i--) {
		auto p = pr[i].first;
		auto it = st.upper_bound({{p.second, 0}, 0});
		while (it != st.end() && get(pr[i].second) != get(it -> second)) {
			unite(pr[i].second, it -> second);
			++it;
		}
		st.insert({{p.second, p.first}, pr[i].second});
	
	}
	pr.clear();
	st.clear();
	for (int i = 1; i <= n; ++i) {
		pr.push_back({{y[i], x[i]}, i});
	}
	sort(pr.begin(), pr.end());
	for (int i = n - 1; i >= 0; i--) {
		auto p = pr[i].first;
		auto it = st.upper_bound({{p.second, 0}, 0});
		while (it != st.end() && get(pr[i].second) != get(it -> second)) {
			unite(pr[i].second, it -> second);
			++it;
		}
		st.insert({{p.second, p.first}, pr[i].second});
	
	}
pr.clear();
	for (int i = 1; i <= n; ++i) {
		pr.push_back({{y[i], x[i]}, i});
	}
	st.clear();
	sort(pr.begin(), pr.end());
	for (int i = 0; i <= n - 1; ++i) {
		auto p = pr[i].first;
		auto it = st.lower_bound({{p.second, 0}, 0});
		if (it != st.begin()) {
			it--;
			while (get(pr[i].second) != get(it -> second)) {
				unite(pr[i].second, it -> second);
				if (it == st.begin()) {
					break;
				}
				it--;
			}
		}
		st.insert({{p.second, p.first}, pr[i].second});
	}
	pr.clear();
	for (int i = 1; i <= n; ++i) {
		pr.push_back({{x[i], y[i]}, i});
	}
	st.clear();
	sort(pr.begin(), pr.end());
	for (int i = 0; i <= n - 1; ++i) {
		auto p = pr[i].first;
		auto it = st.lower_bound({{p.second, 0}, 0});
		if (it != st.begin()) {
			it--;
			while (get(pr[i].second) != get(it -> second)) {
				unite(pr[i].second, it -> second);
				if (it == st.begin()) {
					break;
				}
				it--;
			}
		}
		st.insert({{p.second, p.first}, pr[i].second});
	}
	for (int i = 1; i <= n; ++i) {
		cout << sz[get(i)] << '\n';
	}
}

main() {
	ios :: sync_with_stdio(0);		
	cin.tie(0);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	} 
	return 0;
}

Measured memory_bytes: 21112
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		String oBefore = scanner.nextLine();
		String oBehind = scanner.nextLine();

		
		char[] before = oBefore.toCharArray();
		char[] behind = oBehind.toCharArray();
		
		Arrays.sort(before);
		Arrays.sort(behind);
		
		char[] reverse = new char[behind.length];
		for (int i = 0; i < reverse.length; i++) {
			reverse[reverse.length-i-1] = behind[i];			
		}
		
		String ans = "Yes";
		if (String.valueOf(before).compareToIgnoreCase(String.valueOf(reverse))>=0 ) {
			ans="No";
		}
		
		System.out.println(ans);
		scanner.close();
	}

}

Measured memory_bytes: 21844
N = int(input())

a, b = N//8, N%8

rep = [2, 3, 4, 6, 8, 9, 10, 12]

ans = []
for i in range(a):
    for r in rep:
        ans.append(12*i+r)

to = []
if b == 1:
    to = [6]
elif b == 2:
    to = [6, 12]
elif b == 3:
    to = [3, 6, 9]
elif b == 4:
    to = [2, 3, 4, 9]
elif b == 5:
    to = [2, 3, 4, 6, 9]
elif b == 6:
    to = [2, 3, 4, 8, 9, 10]
elif b == 7:
    to = [2, 3, 4, 6, 8, 9, 10]

for r in to:
    ans.append(12*a+r)

if N == 3:
    ans = [2, 5, 63]

for a in ans:
    print(a, end=' ')
print()

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

inline void mod(long long& a) {
	a = a % 1000000007;
}

int main() {
	int n, m;
	cin >> n >> m;
	long long* count = new long long[n + 1]{};
	int* a = new int[m];
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	count[0] = 1;
	count[1] = a[0] == 1 ? 0 : 1;
	int j = a[0] == 1 ? 1 : 0;
	for (int i = 2; i < n + 1; i++) {
		count[i] = count[i - 1] + count[i - 2];
		if (i == a[j]) {
			count[i] = 0;
			j++;
		}
		mod(count[i]);
	}
	cout << count[n] << endl;
	delete[] count, a;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int canpas[60][60];

bool check(int tmp_i, int tmp_j){
    bool ans = false;
    if(canpas[tmp_i][tmp_j - 1] == 1 || canpas[tmp_i][tmp_j + 1] == 1 || canpas[tmp_i-1][tmp_j] == 1 || canpas[tmp_i + 1][tmp_j] == 1){
        ans = true;
    }
    return ans;
}


int main(void){
    //入力
    int H, W;
    cin >> H >> W;

    for(int i = 0; i < 60; i++){
        for(int j = 0; j < 60; j++){
            canpas[i][j] = 0;
        }
    }

    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            char x;
            cin >> x;
            if(x == '#'){
                canpas[i][j] = 1;
            }
        }
    }

    //計算
    bool ans = true;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(canpas[i][j] == 1){
                ans = check(i, j);
            }
            if(ans == false){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int ll
using pii = pair<int, int>;

vector <int> tree[101010];
bool visit[101010];
int parent[101010];
int visited_child[101010];
int n, k;
int ans = 1;
const int mod = 1000000007;
void dfs(int r, int par)
{
    parent[r] = par;
    visit[r] = true;
    if (par == 0) 
    {
        ans *= k;
        ans %= mod;
        //printf("%d : %d\n",r,k);
    }
    else
    {
        int ances = 1;
        if(parent[par]!=0) ances++;
        ans *= (max(0ll, (ll)(k-(visited_child[par]+ances)) ) );
        ans %= mod;
        //printf("%d : %d\n",r,max(0ll, (ll)(k-(visited_child[par]+1)) ) );
    }
    visited_child[par]++;
    for (auto it:tree[r])
    {
        if (!visit[it])
            dfs(it, r);
    }
}
int32_t main()
{
    usecppio
    cin >> n >> k;
    for (int i = 1; i<n; i++)
    {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    dfs(1, 0);
    cout << ans%mod << '\n';
}

Measured memory_bytes: 9728
#include <iostream>
using namespace std;
#define FOR(i,s,e) for(int i = (s);i <= (e);i++)
typedef long long ll;

ll gcd(ll a,ll b)
{
	if(b == 0)
	{
		return a;
	}
	return gcd(b, a % b);
}

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


int main()
{
	int N;
	ll T[100];
	cin >> N;
	FOR(i,0,N - 1)
	{
		cin >> T[i];
	}

	ll now_lcm = T[0];

	FOR(i,1,N - 1)
	{
		now_lcm = lcm(now_lcm,T[i]);
	}
	cout << now_lcm << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque

S = input()

q = deque(list(S))
# print(q)
out = []
answer = list("AKIHABARA")
p = 0
while p < 9:
    if q:
        letter = q.popleft()
    else:
        letter = "A"
    # print(p, q)
    if len(q) > 20:
        break
    if letter != answer[p]:
        q.appendleft(letter)
        q.appendleft("A")
    else:
        out.append(letter)
        p += 1

if answer == out and len(q) == 0:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 9304
import std.stdio : write, writeln;
import std.array;
import std.range;

const int INF = 1<<28;

void swap(T)(ref T a, ref T b){
	T tmp = a;
	a = b;
	b = tmp;
}


void main(){
	while(hasNext){
		int[8] p;
		foreach(ref v; p){
			v.next;
		}
		
		int[] c = [1, 4, 1, 4, 1, 2, 1, 2];
		int[8] best;
		int min_ = INF;
		for(int i=0; i<8; ++i){
			int sum = 0;
			for(int j=0; j<8; ++j){
				int v = p[j]-c[j];
				if(v>0){
					sum += v;
				}
			}
			
			if(sum < min_){
				min_ = sum;
				best = c;
			}else if(sum == min_){
				int a, b;
				for(int j=0; j<8; ++j){
					a += a*10 + best[j];
				}
				for(int j=0; j<8; ++j){
					b += b*10 + c[j];
				}
				if(b<a){
					best = c;
				}
			}

			c ~= c.front;
			c.popFront;
		}
		for(int i=0; i<8; ++i){
			write = best[i];
			if(i+1<8){
				write = " ";
			}
		}
		write = "\n";
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
int n,s;
cin>>n; 
for(int i=0; i<n; i++){
  int a;
  cin>>a;
if(a%2==0){
if(a%3!=0&&a%5!=0)
  s++;
}
}
if(s>0){
cout<<"DENIED"<<endl;
}
else{
cout<<"APPROVED"<<endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  string S;
  cin >> S;
  int nRed = 0, nBlue = 0;
  for(int i=0; i<S.size(); i++) {
    if(S[i] == '0')
      nRed++;
    else
      nBlue++;
  }
  cout << min(nRed, nBlue) * 2 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    int ans = 0;
    rep(i, 0, n){
        cin >> x[i];
        ans += min(x[i], k - x[i]);
    }
    cout << 2 * ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
 using namespace std;
 int main(){
 int D;
 cin >> D;
 string ans;
 if(D == 25) ans = "Christmas";
 else if(D == 24) ans = "Christmas Eve";
 else if(D == 23) ans = "Christmas Eve Eve";
 else ans = "Christmas Eve Eve Eve";
 cout << ans << endl;
 } 

Measured memory_bytes: 256
X, N, D = map(int, input().split())
X = abs(X)
maxD = N * D

if X > maxD :
  print(X - maxD)
else :
  N -= X // D
  num = N % 2
  if num == 0:
    print(X % D)
  else :
    print(D - X % D)

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

int main(){
  int D, N;
  int ans;
  cin >> D >> N;
  if(D == 0){
    if(N == 100) ans = 101;
    else ans = N;
  } else if(D == 1){
    if(N == 100) ans = 101*100;
    else ans = 100*N;
  } else if(D == 2){
    if(N == 100) ans = 101*100*100;
    else ans = 100*100*N;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
double num[1005][2];
int main(){
	num[2][0]=1.0;
	num[2][1]=1.0;
	for(int i=3;i<=1000;i++){
		double x,y;
		x=num[i-1][0];
		y=num[i-1][1];
		double t=sqrt(x*x+y*y);
		double w=-1.0*y/t+x;
		double p=y+1.0*x/t;
		num[i][0]=w;
		num[i][1]=p;
	}
	int n;
	while(scanf("%d",&n) && n!=-1){
		printf("%.2f\n%.2f\n",num[n][0],num[n][1]);
	}
}

Measured memory_bytes: 1240
def resolve():
    S = input()
    T = input()
    can_insert = False

    for start in range(len(S)-len(T),-1,-1):
        can_insert = True
        for i,c in enumerate(T):
            if S[start+i] != c and S[start+i] != "?":
                can_insert = False
        if can_insert:
            list_s = list(S)
            list_s[start:start+len(T)] = T
            S = "".join(list_s)
            print(S.replace("?","a"))
            break
    if not can_insert:
        print("UNRESTORABLE")
resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m, xi, yi;
	scanf("%d %d", &n, &m);
	vector<int> box(n,1);
	vector<int> memo(n, 0);
	memo[0] = 1;

	for(int i = 0; i < m; i++) {
		scanf("%d %d", &xi, &yi);
		xi--;
		yi--;
		if ((box[xi] == 1)&&(memo[xi] == 1)) {
			box[xi] = 0;
			memo[xi] = 0;
			box[yi]++;
			memo[yi] = 1;
		} else if ((box[xi] > 1)&&(memo[xi] == 1)) {
			box[xi]--;
			box[yi]++;
			memo[yi] = 1;
		} else {
			box[xi]--;
			box[yi]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += memo[i];
	}
	printf("%d\n", ans);

	return 0;
}

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

const int N = 2002;
                               
int main(){
  int n;
  cin >> n;
  vector<int>h(n);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  vector<int>dp(n);
  dp[0] = 0;
  for (int i = 1; i < n; i++){
    int mn = 1e9 + 5;
    for (int d : {1, 2}){
      if (i - d >= 0){
        mn = min(mn, dp[i - d] + abs(h[i] - h[i - d]));        
      }
    }
    dp[i] = mn;
  }            
  cout << dp[n - 1] << "\n"; 
  return 0;
}

Measured memory_bytes: 1024
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const M=input[0].split(' ')[1]-0;
  console.log((100*N+1800*M)*2**M);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29676
#data input
o = input()
e = input()
#processing
ans = ""
if len(o) - len(e) == 0 : #length equal
    for i in range(len(e)) :
        ans += (o[i] + e[i])
    print(ans)
elif len(o) - len(e) == 1 :
    for i in range(len(e)) :
        ans += (o[i] + e[i])
    ans += o[-1]
    print(ans)    

Measured memory_bytes: 3064