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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct QuickFind {
  vint i2g;
  vector<vint> g2i;
  QuickFind(int n) {
    i2g.clear(); i2g.resize(n);
    g2i.clear(); g2i.resize(n);
    rep(i, n) i2g[i] = i, g2i[i].assign(1, i);
  }
  void merge(int ia, int ib) {
    if(g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) swap(ia, ib);

    int ga = i2g[ia], gb = i2g[ib];
    if(ga == gb) return;
    for(int j : g2i[gb]) i2g[j] = ga;
    g2i[ga].insert(g2i[ga].end(), all(g2i[gb]));
    g2i[gb].clear();
  }
  bool is_same_group(int ia, int ib) {
    return i2g[ia] == i2g[ib];
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint w(n);
  rep(i, n) cin >> w[i];
  vint v = w;
  sort(all(v));
  QuickFind qf(n);
  rep(i, n) qf.merge(lower_bound(all(v), w[i])-v.begin(), i);
  int ans = 0;
  rep(i, n) {
    int sum = 0;
    int mn = inf;
    int sz = qf.g2i[i].size();
    if(sz == 0) continue;
    rep(j, sz) {
      sum += v[qf.g2i[i][j]];
      chmin(mn, v[qf.g2i[i][j]]);
    }
    ans += min((sum-mn)+(sz-1)*mn, (sum-mn)+(sz-1)*v[0]+(v[0]+mn)*2);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std; 
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
 
typedef long long int ll; 
typedef long double ld; 

ll mod = 1e9+7;

ll add(ll a, ll b){
	a = a%mod;
	b = b%mod;
	return (mod+(a+b)%mod)%mod;
}

ll mul(ll a, ll b){
	a = a%mod;
	b = b%mod;
	return (mod+(a*b)%mod)%mod;
}

ll solve(ll node, vector<ll> vec[], vector<ll> &flg){
	flg[node] = 1;
	ll cnt = 1;
	for(ll i: vec[node]){
		if(flg[i]==0){
			cnt += solve(i, vec, flg);
		}
	}
	return cnt;
}

int main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n, m;
	cin>>n>>m;
	
	vector<ll> vec[n+1];
	vector<ll> flg(n+1, 0);
	
	for(ll i=0;i<m;i++){
		ll a, b;
		cin>>a>>b;
		a--;
		b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	ll ans = 0;
	for(ll i=0;i<n;i++){
		if(flg[i]==0){
			ans = max(ans,solve(i, vec, flg)); 
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 31352
n,m,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

sum_a = Array.new(n+1, 0)
1.upto(n) do |i|
  sum_a[i] = a[i - 1] + sum_a[i - 1]
end

sum_b = Array.new(m+1, 0)
1.upto(m) do |i|
  sum_b[i] = b[i - 1] + sum_b[i - 1]
end

ans = 0
0.upto(n) do |i|
  remain = k - sum_a[i]
  next if remain < 0

  b_cnt = sum_b.bsearch_index { |x| x > remain }
  if b_cnt.nil?
    b_cnt = m
  else
    b_cnt -= 1
  end
  ans = [ans, i + b_cnt].max
end

puts ans


Measured memory_bytes: 44780
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

int main(){
    // FILE;
    SPEED;
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3608
// problem: "https://atcoder.jp/contests/abc127/tasks/abc127_f"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

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

    priority_queue<int>q1;
    priority_queue<int,vector<int>,greater<int>>q2;

    ll a,b,B,l,r;
    l = r = B = 0;
    while(q--)
    {
        int x;

        cin>>x;

        if(x==1)
        {
            cin>>a>>b;

            B += b;

            if(q1.empty())
            {
                l += a;
                q1.push(a);
            }
            else if(q1.top()<a)
            {
                if(q1.size() == q2.size())
                {
                    q2.push(a);
                    r -= q2.top();
                    r += a;
                    l += q2.top();
                    q1.push(q2.top());
                    q2.pop();
                }
                else
                {
                    r += a;
                    q2.push(a);
                }
            }
            else
            {
                if(q1.size() == q2.size())
                {
                    q1.push(a);
                    l += a;
                }
                else
                {
                    q1.push(a);
                    l += a;
                    l -= q1.top();
                    r += q1.top();
                    q2.push(q1.top());
                    q1.pop();
                }
            }
        }

        else
        {
            ll s = B + (q1.size()*q1.top()) - l + r - (q2.size()*q1.top());
            cout<<q1.top()<<' '<<s<<'\n';
        }
    }

    return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=2e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        cout<<fixed<<setprecision(10)<<(2.00 * acos(-1.00) * n)<<endl;
    }
    return 0;
}


















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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		int min = Math.min(A,B);
		int j = 0;
		for (int i = min; i > 0; i--) {
			if (A % i == 0  && B % i == 0) j += 1;
			if ( j == K) {
			System.out.println(i);
			break;
			}
		}
	}

}


Measured memory_bytes: 21716
use io::*;
use std::*;

fn solve(X: i64) {
    let mut money = 100;
    let mut step = 0;
    while X > money {
        money += money / 100;
        step += 1;
    }
    println!("{}", step);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut X: i64;
    X = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(X)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 2236
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
    //最悪のケースからかかる時間を予測する
    long long N; //32bit seisu
    std::cin >> N;
    std::vector<long long> trafic_cap(5);
    for (int i = 0; i < 5; ++i)
    {
        std::cin >> trafic_cap[i];
        if(i == 0){
            if(trafic_cap[i] > N) trafic_cap[i] = N;
            continue;
        }
        if(trafic_cap[i] > trafic_cap[i-1]) trafic_cap[i] = trafic_cap[i-1];
        // std::cout << i << "pppp" << trafic_cap[i] << "\n";
    }
    // std::cout << N/2 + N%2 + 4<< "\n";
    // std::cout << 3%3 << "\n";
    long long time = (N + trafic_cap[4] - 1)/trafic_cap[4] + 4;
    std::cout << time << "\n";
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

const int MAXN = 100, MAXK = 1e5 + 5;

ll dp[MAXN][MAXK];

ll recur(vector<pl>& v, int ind, ll k) {
    if (ind < 0 or k < 0) {
        return 0;
    }
    if (dp[ind][k] != -1) {
        return dp[ind][k];
    }
    dp[ind][k] = recur(v, ind - 1, k);
    if (k - v[ind].ff >= 0) {
        dp[ind][k] = max(recur(v, ind - 1, k - v[ind].ff) + v[ind].ss, dp[ind][k]);
    }
    return dp[ind][k];
}

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<pl> v(n);
    forn(n) {
        cin >> v[i].ff >> v[i].ss;
    }
    memset(dp, -1, sizeof(dp));
    cout << recur(v, n - 1, k) << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 n;
    cin >> n;
    map<i64, i64> cnt;
    i64 amax = 0, amin = INF;
    for (i64 i = 0; i < n; i++) {
        i64 a;
        cin >> a;
        cnt[a]++;
        amax = max(a, amax);
        amin = min(a, amin);
    }

    if (amin != (amax + 1) / 2) {
        cout << "Impossible" << endl;
        return;
    }

    if (cnt[amin] != (amax % 2 ? 2 : 1)) {
        cout << "Impossible" << endl;
        return;
    }

    for (i64 ai = amin + 1; ai <= amax; ai++) {
        if (cnt[ai] < 2) {
            cout << "Impossible" << endl;
            return;
        }
    }
    cout << "Possible" << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main() {
  string s, t; cin >> s >> t;
  rep(i, s.size()) {
    if (i>t.size()-1) {
      cout<<s[i];
      break;
    }
    cout<<s[i]<<t[i];
  }
  cout<<endl;
}


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

int main()
{
	int room = 10;
	int flr = 3;
	int building = 4;

	int n;
	cin >> n;

	int redidents[building][flr][room];
	int i, j, k;
	for (i = 0; i < building; i++)
		for (j = 0; j < flr; j++)
			for (k = 0; k < room; k++)
				redidents[i][j][k] = 0;

	int b, f, r, v;
	for (i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		redidents[b-1][f-1][r-1] += v;
	}

	for (i = 0; i < building; i++) {
		for (j = 0; j < flr; j++) {
			for (k = 0; k < room; k++) {
				cout << " ";
				cout << redidents[i][j][k];
			}
			cout << "\n";
		}
		int l;
		if (i != building-1) {
			for (l = 0; l < 2*room; l++) cout << "#";
			cout << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath> 
#include <algorithm>
using namespace std;
int main(){
	int n;
	vector<long long> a;
	long long x;
	long long ncount=0;
	cin >>n;
	for(int i=0;i<n;i++){
		cin >> x;
		if (x<0){
			ncount++;
		}
		x=abs(x);
		a.push_back(x);
	
		
	}
	long long sum=0;
	sort(a.begin(),a.end());
	for (int j=0;j<n;j++){
		sum+=a[j];
	}

	if((ncount%2)!= 0){
	
		
	  	if (a[0]> 0){
	  		
	  		sum=sum-(2*a[0]);
	  	}
	
	}
	cout <<sum <<endl;
	
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int p, q, r; cin >> p >> q >> r;
	priority_queue<int, vector<int>, greater<int>> pq;
	pq.push(p); pq.push(q); pq.push(r);
	int res = pq.top();
	pq.pop();
	cout << res + pq.top() << endl;
}

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


Measured memory_bytes: 256
X, Y = map(int, input().split())

kame = (2 * X) - (Y //2)
tsuru = (-1 * X) + (Y //2)

if Y % 2 == 0:
  if kame >= 0 and tsuru >= 0:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 9184
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <limits>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

void Print() { cout << endl; }
template <class Head, class... Args> void Print(Head &&head, Args&&... args)
{
    cout << head;
    Print(args...);
}

#define Repeat(x, i, j) for (size_t x = i; x < j; ++x)

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif


using ull_t = unsigned long long;


int main()
{
    long N, K;
    cin >> N >> K;

    vector<long> X(N);
    for (auto i = 0; i < N; ++i)
        cin >> X[i];

    auto get = [](long x1, long x2) -> long
    {
        if (x1 == x2)
            return abs(x1);
        else if (x1 * x2 >= 0)
            return max(abs(x1), abs(x2));
        else
            return 2 * min(abs(x1), abs(x2)) + max(abs(x1), abs(x2));
    };

    long v_min = numeric_limits<long>::max();
    for (int i = 0; i < N - K + 1; ++i)
        v_min = min(v_min, get(X[i], X[i + K - 1]));
    
    cout << v_min << endl;
}


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

int gcd(int a,int b){
  if(a < b)swap(a,b);
  if(a % b == 0)return b;
  else return gcd(b, a%b);
}

int main(void){
  int n,k;
  vector<int> a;
  cin >> n >> k;
  a.resize(n);
  for(int i = 0;i < n;++i){
    cin >> a[i];
  }
  if(n == 1){
    if(a[0] == k){
      puts("POSSIBLE");
    }else{
      puts("IMPOSSIBLE");
    }
    return 0;
  }
  int d = a[0];
  for(int i = 1;i < n;++i){
    d = gcd(d,a[i]);
  }
  for(int i = 0;i < n;++i){
    if(a[i] >= k && (a[i] - k) % d == 0){
      puts("POSSIBLE");
      return 0;
    }
  }
  puts("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	double a, b;
		while(cin >> a >> b){
		double c = a, d = b;
		while(c != d){
			if(c > d) c = c - d;
			else d = d - c;
		}
		d = a * b / c;
		printf("%.0lf %.0lf\n", c, d);
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN maxn

using namespace std;

int n;

signed main()
{
	IO;
	cin >> n;
	while (n--) {
		cout << "ACL";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
int main() {
  int N; cin >> N;
  vector<int> B(N);
  for (int i = 1; i <= N; ++i) {
    int x; cin >> x; --x;
    B[x] = i;
  }
  cout << B << endl;
}


Measured memory_bytes: 3732
S = input()
key = 'keyence'
index_num = -1
for i in range(len(key)):
    if S[i] != key[i]:
        index_num = i
        break
else:
    print('YES')
    exit()
string = S[:index_num] + S[-len(key)+index_num:]
print('YES' if string == key else 'NO')

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n=s.size();
    int ans=0;
    rep(i,n-1){
        if (s[i]!=s[i+1]) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 512
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>

using namespace std;


int main(){
 int N;
 cin >> N;
 int a[N];
 int b[N-1];
 int i;
 int sum = 0;
 for(i=0;i<N-1;++i){
     cin >> b[i];
   }
 if(N==2)cout << b[0]*2 << endl;
 else{
  sum += b[0];
  for(i=1;i<N-1;++i){
   sum += min(b[i-1],b[i]);}
  sum += b[N-2];
  cout << sum << endl;
 }
 return 0;
}

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

char a,b,c,d;
string s;


int main(){
    cin>>s;
    a=s[2];
    b=s[3];
    c=s[4];
    d=s[5];
    if((a==b) && (c==d)){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
}

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

int main(){
	double n, t, a;
	cin >> n >> t >> a;
	vector<double> h(n);
	rep(i,n) cin >> h[i];
	double m = INF;
	int res;
	rep(i,n){
		if(m>abs(a-(t-h[i]*0.006))){
			m = abs(a-(t-h[i]*0.006));
			res = i+1;
		}

	}
	cout << res << endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

int main()
{
	std::map<char, char> c;
	c['A'] = 'T';
	c['G'] = 'C';
	c['T'] = 'A';
	c['C'] = 'G';

	char ch; std::cin >> ch;
	std::cout << c[ch] << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

const int DAT_SIZE=(1<<18)-1;

ll data[DAT_SIZE],datb[DAT_SIZE];

void add(int a,int b,int x,int k,int l,int r){
  if(a<=l&&r<=b){
    data[k]+=x;
  }
  else if(l<b&&a<r){
    datb[k]+=(min(b,r)-max(a,l))*x;
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
}

//[a,b),[l,r)
ll sum(int a,int b,int k,int l,int r){
  if(b<=l||r<=a){
    return 0;
  }
  else if(a<=l&&r<=b){
    return data[k]*(r-l)+datb[k];
  }
  else{
    ll res=(min(b,r)-max(a,l))*data[k];
    res+=sum(a,b,k*2+1,l,(l+r)/2);
    res+=sum(a,b,k*2+2,(l+r)/2,r);
    return res;
  }
}


int N,M;

int main(){
  cin>>N>>M;
  vector<int> L(N),R(N);
  for(int i=0;i<N;i++) cin>>L[i]>>R[i];

  vector<pair<int,int>> v;
  for(int i=0;i<N;i++){
      v.push_back(mkp(R[i]-L[i]+1,i));
  }

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

  int cnt=0;
  vector<int> ans(M+1,0);
  for(int i=1;i<=M;i++){
      ans[i]=N-cnt;
      for(int j=1;i*j<=M;j++){
          ans[i]+=sum(i*j,i*j+1,0,0,M+1);
      }

      while(cnt<N){
          if(v[cnt].first==i){
              int now=v[cnt].second;
              add(L[now],R[now]+1,1,0,0,M+1);
              cnt++;
          }else break;
      }
  }

  for(int i=1;i<=M;i++) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 10732
N = int(input())
h = list(map(int, input().split()))

dp = [0] * (N)

for i in range(N):
    if i > 1:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
    elif i == 1:
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])

print(dp[-1])

Measured memory_bytes: 13928
n = int(input())
cand_judge = lambda x: (1 + x) * x / 2
cand_i = 0

for i in range(10 ** 5):
    if cand_judge(i) >= n:
        cand_i = i
        break

ans = list(range(1, cand_i + 1))
for i in ans:
    if i != abs(n - cand_judge(cand_i)):
        print(i)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
  
  string s; cin >> s;
  
  string s1,s2,s3;
  
  s1 = s.substr(0,5);
  s2 = s.substr(6,7);
  s3 = s.substr(14,5);
  
  cout << s1 << " "<< s2 << " "<< s3 << endl;
  
  return 0;
}

Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 10000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b,a[li],k,flag,mx=inf;
lo cev;
string s;
vector<lo> v;

void YES(int xxxxxxx){
	if(xxxxxxx==1){cout<<"YES\n";exit(0);}
	printf("YES\n");
	exit(0);
}

void NO(int xxxxxxx){
	if(xxxxxxx==1){cout<<"NO\n";exit(0);}
	printf("NO\n");
	exit(0);
}

int main(void){
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
	}
	//~ cev=inf;
	for(lo j=1;j<n;j++){
		cev=0;
		lo cev1=0;
		for(lo i=1;i<=j;i++){
			cev+=a[i];
		}
		for(lo i=j+1;i<=n;i++) cev1+=a[i];
		mx=min(mx,abs(cev-cev1));
	}
	printf("%lld\n",mx);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int a,b[100000][10];
int c[100000][10];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);    
    cin>>a;
    int d=0;
    for(int i=0;i<a;i++){
      for(int j=0;j<3;j++) cin>>b[i][j];
    }
    c[0][0]=b[0][0],c[0][1]=b[0][1],c[0][2]=b[0][2];
    for(int i=1;i<a;i++){
      c[i][0]=b[i][0]+max(c[i-1][1],c[i-1][2]);
      c[i][1]=b[i][1]+max(c[i-1][0],c[i-1][2]);
      c[i][2]=b[i][2]+max(c[i-1][0],c[i-1][1]);
    }
    for(int i=0;i<3;i++)d=max(d,c[a-1][i]);
    cout<<d<<"\n";
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int a[1000001],k,n,i,j,sum,temp,ans;
int main()
{
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		cin>>temp;
		a[temp]++;
	}
	i=500;
	while(sum<k)
	{
		i--;
		for(j=1;j<=a[i];j++)
		{
			ans=ans+i;
			sum++;
		}
	}
	cout<<ans;
 } 

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		for (int i = 0; i < k; i++) {
			if (i % 2 == 0) {
				a = a / 2;
				b += a;
			} else {
				b = b / 2;
				a += b;
			}
		}
		
		pr.printf("%d %d%n", a, b);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
# include<bits/stdc++.h>
# define LL long long
using namespace std;
int n;
LL ans=1e16,A[10],sum[200001],x;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	  cin>>x,sum[i]=sum[i-1]+x;
	int l=1,r=3;
	for(int i=3;i<=n;++i)
	  {
		while(l<=i-3&&abs(sum[l]-(sum[i-1]-sum[l]))>=abs(sum[l+1]-(sum[i-1]-sum[l+1])))
		++l;
		while(r<=n-2&&abs(sum[r]-sum[i-1]-(sum[n]-sum[r]))>=abs(sum[r+1]-sum[i-1]-(sum[n]-sum[r+1])))
		++r;
		A[1]=sum[l],A[2]=sum[i-1]-sum[l],A[3]=sum[r]-sum[i-1],A[4]=sum[n]-sum[r];
		sort(A+1,A+4+1);
		ans=min(ans,A[4]-A[1]);
	  }
	cout<<ans;
} 


Measured memory_bytes: 1792
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << 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;
}

struct Edge {
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};

using Graph = vector<vector<Edge>>;

vector<int> color;

void dfs(Graph &G, int v, int cur, int pre) {
    color[v] = cur;

    for(auto next_edge : G[v]) {
        if(next_edge.to == pre) continue;
        if(next_edge.weight % 2 == 0)
            dfs(G, next_edge.to, cur, v);
        else
            dfs(G, next_edge.to, 1 - cur, v);
    }
}

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

    int N;
    cin >> N;
    Graph G(N);
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    color.assign(N, -1); // -1は未確定
    dfs(G, 0, 1, -1);

    rep(i, N) { COUT(color[i]); }
}


Measured memory_bytes: 9728
# 解説を観たのでそれをやってみるバージョン
# （最初に解いたやつは愚直に毎回最大値を求めていた（なんかしらんけど通った））
n = int(input())
cur = 0
target = 0
for i in range(1, n + 1):
    if i + cur >= n:
        target = i
        break
    cur += i

remove_num = sum([i for i in range(1, target + 1)]) - n
for i in range(1, target + 1):
    if i != remove_num:
        print(i)



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

int main(int argc, char** argv){
  int N, K;
  cin >> N >> K;
  priority_queue<pair<ll, int>> menu; // <美味しさ, 種類> 美味しさでソートしたいので。
  vector<pair<ll, int>> order;
  map<int, int> used;
  ll ans = 0;
  
  for(int cnt0=0; cnt0<N; cnt0++) {
    int tmpt;
    ll tmpd;
    cin >> tmpt >> tmpd;
    menu.push(make_pair(tmpd, tmpt));
  }
//  sort(menu, menu+N, greater<pair<ll, int>>());
//  menu.reverse();
  
  for(int cnt0=0; cnt0<K; cnt0++){
    auto tmp = menu.top(); menu.pop();
    order.push_back(tmp);
    ans += tmp.first;
    used[tmp.second]++;
  }
  ll sz = (ll)used.size();
  ans += sz*sz;

  ll tmpAns = ans;
  

  for(int i=K-1; i >= 0; i--){
    if(used[order[i].second] == 1) continue;
    while(menu.size() > 0){
      auto tmp = menu.top(); menu.pop();
      if(used[tmp.second] == 0) {
        // 現在注文しているうち、2品以上のものを探す
        auto tmpOut = order[i];
        used[tmpOut.second]--;      
        used[tmp.second]++;
        tmpAns = tmpAns -tmpOut.first + tmp.first - sz*sz + (sz+1)*(sz+1);      
        sz++;      
        ans = max(ans, tmpAns);      
        order[i] = tmp;       
        break;
      }
    }
  }
  
  cout << ans << endl;
  
  
  
  
  return 0;
}


Measured memory_bytes: 6512
#!/usr/bin/env python3
import math
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N, K = MI()
    ans = 0
    for n in range(1, N + 1):
        k = math.ceil(math.log2(K / n))
        ans += (1 / N) * min((1 / 2) ** k, 1)

    print(ans)


main()


Measured memory_bytes: 65152
import string

H, W = list(map(int, input().split()))
S = [input().split() for i in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == 'snuke':
            ans = string.ascii_uppercase[j] + str(i + 1)
            break


print(ans)



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

int main() {
  int N;
  vector<char> S(100);
  
  cin >> N;
  
  for (int i = 0; i < N; i++){
  	cin >> S.at(i);
  }
  
  int x = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'Y'){
      x++;
    }
  }
  
  if (x == 0){
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	/*int n,m;
	while(cin>>n>>m){
		if(n==0&&m==0) break;
		int a[m][3];
		for(int i=0;i<m;i++){
			cin>>a[i][0]>>a[i][1]>>a[i][2];
		}
		int b[n+1];
		for(int i=2;i<=n;i++){
			b[i]=0;
		}
		b[1]=1;
		int t=0,k=0,ct=1;
		while(k<m){
			t++;
			for(int i=0;i<m;i++){
				if(a[i][0]==t){
					k++;
					if(b[a[i][1]]==1&&b[a[i][2]]==0){
						ct++;
						b[a[i][2]]=1;
					}
				}
			}
		}
		cout<<ct<<endl;
	}*/
	int n,m;
	while(cin>>n>>m){
		if(n==0&&m==0) break;
		int a[m][3],t,s,d;
		for(int i=0;i<m;i++){
			a[i][0]=0;
			a[i][1]=0;
			a[i][2]=0;
		}
		for(int i=0;i<m;i++){
			cin>>t>>s>>d;
			for(int j=i;j>=1;j--){
				if(a[j-1][0]>t){
					a[j][0]=a[j-1][0];
					a[j][1]=a[j-1][1];
					a[j][2]=a[j-1][2];
				}
				else if(a[j-1][0]<=t){
					a[j][0]=t;
					a[j][1]=s;
					a[j][2]=d;
					goto end;
				}
			}
			a[0][0]=t;
			a[0][1]=s;
			a[0][2]=d;
			end:;
		}
		int b[n+1];
		for(int i=2;i<=n;i++){
			b[i]=0;
		}
		b[1]=1;
		int ct=1;
		for(int i=0;i<m;i++){
			if(b[a[i][1]]==1&&b[a[i][2]]==0){
				ct++;
				b[a[i][2]]=1;
			}
		}
		cout<<ct<<endl;
	}
    return 0;
}

Measured memory_bytes: 1472
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long
//ll a[20005],dp[20005],s[100];//这里需要定义为2倍，不然会内存不够，出现runtime
int main()
{
	int a,b,c,i,n;
	cin>>a>>b;
	cout<<100<<' '<<100<<endl;
	int j;
	for(i = 0;i < 50;i++){
        for(j = 0;j < 100;j++){
            if(i%2&&j%2&&a>1){
                cout<<'.';
                a--;
            }
            else{
                cout<<'#';
            }
        }
        cout<<endl;
	}
	for(i = 0;i < 50;i++){
        for(j = 0;j < 100;j++){
            if(i%2&&j%2&&b>1){
                cout<<'#';
                b--;
            }
            else{
                cout<<'.';
            }
        }
        cout<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	final long MOD = (long) (1e9 + 7);
	int NMAX = 100000;
	long[] fac = new long[NMAX];
	long[] ifac = new long[NMAX];
	long[] inv = new long[NMAX];
	{
		fac[0] = fac[1] = ifac[0] = ifac[1] = inv[0] = inv[1] = 1;
		for (int i = 2; i < NMAX; ++i) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[(int) (MOD % i)] * (MOD / i) % MOD;
			ifac[i] = ifac[i - 1] * inv[i] % MOD;
		}
	}

	long comb(int n, int k) {
		if (n >= k) {
			return fac[n] * ifac[k] % MOD * ifac[n - k] % MOD;
		} else {
			return 0;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; ++i)
			A[i] = sc.nextInt();
		long[] v = new long[3];
		long ans = 1;
		for (int i = 0; i < N; ++i) {
			int same = 0;
			for (int j = 0; j < 3; ++j) {
				if (A[i] == v[j])
					++same;
			}
			ans = ans * same % MOD;
			for (int j = 0; j < 3; ++j) {
				if (A[i] == v[j]) {
					++v[j];
					break;
				}
			}
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 63244
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int m = min(x, y), M = max(x, y);

    if(a + b <= c*2){
        cout << a*x + b*y << endl;
    }else{
        int ans = 1001001001;
        for(int i = m; i <= M; i++){
            if(x >= y)
            ans = min(ans, c*i*2 + (M-i)*a);
            else
            ans = min(ans, c*i*2 + (M-i)*b);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {

	int a;
	char s[100];

	scanf("%d", &a);
	scanf("%s", s);

	if (a >= 3200) {
		printf("%s", s);
	}
	else {
		printf("red");
	}





}






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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

struct MaxFlowCalculator {
	int max_flow(int s, int t, const vector<vector<pair<int, int>>>& g) {
		struct edge_ { int to, cap, rev; };
		vector<bool> used(g.size(), false);
		vector<vector<edge_>> G(g.size());
		for (int i = 0; i < g.size(); i++) for (int j = 0; j < g[i].size(); j++)
		{
			int from = i, to = g[i][j].second;
			int cap = g[i][j].first;
			G[from].push_back({ to, cap, (int)G[to].size() });
			G[to].push_back({ from, 0, (int)G[from].size() - 1 });
		}
		auto dfs = [&](auto&& f, int v, int t, int fl)->int {
			if (v == t) return fl;
			used[v] = true;
			rep(i, G[v].size()) {
				edge_& e = G[v][i];
					if (!used[e.to] && e.cap > 0) {
					int d = f(f, e.to, t, min(fl, e.cap));
					if (d > 0) {
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		};
		int flow = 0;
		while (1) {
			used.assign(used.size(), false);
			int f = dfs(dfs, s, t, INT_MAX);
			if (f == 0) return flow;
			flow += f;
		}
	}
};

class modint {
	static constexpr std::int_fast64_t Modulus = 1e9 + 7;
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator*(const ll rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr operator u64() const { return a; }
};

int main() {
	string L;
	cin >> L;
	int n = L.size();
	vector<vector<modint>> dp(n + 1, vector<modint>(2, 0));
	//dp[i][1]...i番目にて、値が下回っていない
	//dp[i][0]...i番目にて、値が下回っている
	dp[0][1] = 2;//10, 01
	dp[0][0] = 1;//00
	for (int i = 1; i < n; i++) {
		bool one = L[i] == '1';
		if (one) {
			//10, 01
			dp[i][1] += dp[i - 1][1].a * 2;
			//00
			dp[i][0] += dp[i - 1][1];
			//00,10,01
			dp[i][0] += dp[i - 1][0].a * 3;
		}
		else {
			//00
			dp[i][1] += dp[i - 1][1];
			//00,10,01
			dp[i][0] += dp[i - 1][0].a * 3;
		}
	}
	cout << dp[n-1][0] + dp[n-1][1] << endl;
    return 0;
}


Measured memory_bytes: 8800
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count  = 0
for _ in range(n):
  a = list(map(int,input().split()))
  s = sum([x*y for x,y in zip(a,b)]) + c
  if s > 0:
    count += 1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void){
  int i;
  long long n,m,a[5],min=1e15;
  scanf("%lld",&n);
  for(i=0;i<5;i++){
    scanf("%lld",&a[i]);
    if(min>a[i]) min=a[i];
  }
  if(n%min==0) m=n/min;
  else m=n/min+1;
  printf("%lld\n",m+4);
  return 0;
}

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

using namespace std;

const int maxn = 105;
int a[maxn];
int dp[100010];
int k, n;

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i <= k; i++){
        for (int j = 0; j < n; j++){
            if (i - a[j] >= 0 && dp[i - a[j]] == 0){
                dp[i] = 1;
            }
        }
    }
    if (dp[k]){
        cout << "First";
    } else {
        cout << "Second";
    }
    return 0;
}


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

void bubbleSort(vector<int> &a,int n);

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n){
    cin>>a[i];
  }
  
bubbleSort(a,n);
  
}

void bubbleSort(vector<int> &a,int n){
  bool flag =1;  //逆の隣接要素
  int count=0;
  while(flag){
    flag=0;
    for(int i=n-1;i>0;i--){
      if(a[i]<a[i-1]){
        flag=1;
        swap(a[i],a[i-1]);
        count++;
      }
    }
    

  }
  rep(i,n){
    if(i>0)cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  cout<<count<<endl;
}



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

int main() {
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i; i<n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int A, B;
  for(int i; i<n; i++){
    if (i%2==0){
      A+=a.at(i);
    }
    else{
      B+=a.at(i);
    }
  }
  cout << A-B << endl;
}



Measured memory_bytes: 256
use std::io;
fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf);
    buf
}

fn strtovec(origin_text: String) -> Vec<i32> {
    let res: Vec<i32> = origin_text
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    res
}

fn exp1(x: i32, y: i32, z: i32) -> i32 {
    let mut n: i32 = 1;
    loop {
        if (z * (n + 1) + (y * n) > x) {
            break;
        }
        n += 1;
    }
    n - 1
}

fn main() {
    let text: String = read_line();
    let v: Vec<i32> = strtovec(text);
    println!("{}", exp1(v[0], v[1], v[2]));
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
    string n;
    cin>>n;
    int a=0,b=n.length()-1;
    int cnt=0;
    while(a!=b){
        if(a>b){
            break;
        }
        if(n[a]!=n[b]){
            cnt++;
        }
        a++;
        b--;
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ro(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
string sk;
int main(){
	vector<ll> vo(3);
	for(ll &i:vo) cin>>i;
	sort(ro(vo));
	for(ll i = 2;i>=1;i--) sk+=to_string(vo[i]);
	cout<<stoll(sk)+vo[0]<<'\n'; 
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
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; }

using Lint=long long;
using Graph=vector<vector<int>>;

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

    int N,M; cin>>N>>M;
    Graph G(N);
    for(int i=0;i<M;i++){
        int a,b; cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> ord(N,-1),sum(N);
    vector<pair<int,int>> bridges;
    function<void(int,int)> dfs=[&](int v,int p)
    {
        static int order=0;
        ord[v]=order++;
        for(int u:G[v]) if(u!=p){
            if(ord[u]<0){
                dfs(u,v);
                sum[v]+=sum[u];
                if(sum[u]==0) bridges.push_back(minmax(v,u));
            }else if(ord[v]>ord[u]){
                // cout<<v+1<<' '<<u+1<<endl;
                sum[v]++; sum[u]--;
            }
        }
    };
    dfs(0,-1);
    sort(bridges.begin(),bridges.end());
    for(auto p:bridges) cout<<p.first<<' '<<p.second<<endl;
    return 0;
}


Measured memory_bytes: 5004
inf = float('inf')

H,W = map(int,input().split())

def solve(h,w):
    res = inf
    for i in range(1,h):
        a = i
        b = h-i
        c = w//2
        d = -(-w//2)
        s1 = [a*w,b*c,b*d]
        d1 = max(s1) - min(s1)
        c = b//2
        d = -(-b//2)
        s2 = [a*w,c*w,d*w]
        d2 = max(s2) - min(s2)
        d = min(d1,d2)
        res = min(res,d)
    return res

ans = min(solve(H,W), solve(W,H))
print(ans)

Measured memory_bytes: 3064
n = gets.chomp.to_i
class TreeWalk
	attr_accessor :right, :left, :parent

	def initialize(left=-1,right=-1, parent = -1)
		@right = right
		@left = left
		@parent = parent
	end
end
$nodes = []

n.times{|i|$nodes[i] = TreeWalk.new}
n.times do
	id, left, right = gets.chomp.split(" ").map{|i|i.to_i}
	$nodes[id].left = left; $nodes[id].right = right
	$nodes[left].parent = id if left != -1
	$nodes[right].parent = id if right != -1
end
	def preorder(id)
		print " #{id}"
		preorder($nodes[id].left) if $nodes[id].left != -1
		preorder($nodes[id].right) if $nodes[id].right != -1
	end
	
	def inorder(id)
		inorder($nodes[id].left) if $nodes[id].left != -1
		print " #{id}"
		inorder($nodes[id].right) if $nodes[id].right != -1
	end
	
	def postorder(id)
		postorder($nodes[id].left) if $nodes[id].left != -1
		postorder($nodes[id].right) if $nodes[id].right != -1
		print " #{id}"
	end
	id = 0
	$nodes.each_with_index do |node,ix|
		if node.parent == -1
			id = ix
			break
		end
	end
puts "Preorder"
preorder(id)
print "\n"
puts "Inorder"
inorder(id)
print "\n"
puts "Postorder"
postorder(id)
print "\n"



Measured memory_bytes: 6876
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	static int dp[4010][4010] = {};
	for (string A, B; cin >> A >> B;) {
		memset(dp, 0, sizeof(dp));
		rep(i, 0, A.size()) rep(j, 0, B.size()) {
			if (A[i] == B[j])
				dp[i + 1][j + 1] = dp[i][j] + 1;
			else
				dp[i + 1][j + 1] = 0;
		}
		cout << *max_element(dp[0], dp[4010]) << endl;
	}
	return 0;
}

Measured memory_bytes: 65976