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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
vector<ll> G[2 * e5];
vector<ll> ans(2 * e5);
unordered_map<ll, ll> pl;
vector<bool> seen(2 * e5);

void dfs(ll now, ll value) {
    seen[now] = true;
    ans[now] = value;
    each(e, G[now]) {
        if (!seen[e]) {
            dfs(e, value + pl[e]);
        }
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, q;
        cin >> n >> q;
        rep(i, n - 1) {
            ll a, b;
            cin >> a >> b;
            a--, b--;
            G[a].eb(b);
            G[b].eb(a);
        }

        rep(i, q) {
            ll p, x;
            cin >> p >> x;
            p--;
            pl[p] += x;
        }
        dfs(0, pl[0]);

        rep(i, n) cout << ans[i] << " ";

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main(){
    string tap;
    cin >> tap;
    int n=(int)(tap.length());
    string res="Yes";
    for(int i=0;i<n;i++){
        if(i%2==0){
            if(tap[i]=='L') res= "No";
        }else{
            if(tap[i]=='R') res= "No"; 
        }
    } 
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
L=raw_input()
l=len(L)

mod=10**9+7

ans=0
cnt=0	#　L内の1の出現回数をカウント
for i, x in enumerate(L):
	if x=="1":
		nokori_keta=l-i-1
		ans+=pow(2,cnt,mod)*( pow(3,nokori_keta,mod ))
		cnt+=1

t=1
for x in L:
	if x=="1":
		t*=2
		t%=mod

print (ans+t)%mod

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<ll> a(3*n);
	for (int i=0; i<3*n; i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	ll ret=0;
	for (int i=n; i<3*n; i+=2)
		ret+=a[i];
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  if ((a*b*1)%2 == 1){
    cout << "Yes" << endl;
  }
  else if ((a*b*2)%2 == 1){
    cout << "Yes" << endl;
  }
  else if ((a*b*3)%2 == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
import kotlin.random.Random

fun main() {
    val d = readLine()!!.toInt()
    val c = readLine()!!.split(" ").map { it.toInt() }
    val list = (0 until d).map { readLine()!!.split(" ").map { it.toInt() } }

    fun score(examList: IntArray): Int {
        val executeDate = IntArray(d) { 0 }
        var last = 0
        return (0 until 26).map { date ->
            val exam = examList[date]
            executeDate[exam] = date

            last += list[date][exam] - (0 until 26).map { i ->
                c[i] * (date + 1 - executeDate[i])
            }.sum()

            last
        }.sum()
    }

    var result = IntArray(d) { Random.nextInt(26) }
    var score = score(result)
    repeat(50000) {
        val copy = result.clone()
        copy[Random.nextInt(d)] = Random.nextInt(26)
        val newScore = score(copy)
        if (newScore > score) {
            result = copy
            score = newScore
        }
    }


    result.forEach {
        println(it + 1)
    }
}

Measured memory_bytes: 62448
#include <cstdlib>
#include <cstdio>
#include <algorithm>
using namespace std;

int a,testcase;
int input[3];

int main()
{
	scanf("%d",&testcase);
	for(a=1;a<=testcase;a++)
	{
		scanf("%d %d %d",&input[0],&input[1],&input[2]);
		sort(input,input+3);
		if(input[0]*input[0]+input[1]*input[1]==input[2]*input[2])
		{
			printf("YES\n");
		}
		else
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  std::string s;
  std::cin>>s;
  std::cout<<s[0]<<s[1]<<s[2]<<"\n";

  return 0;
}

Measured memory_bytes: 3616
N = gets.chomp.to_i
strs = gets.split.map(&:to_i)
for i in 0..N
i+=1
end
min = 100000000000000000
for t in -100..100
sum = 0
strs.each{|x|
 sum+=(x-t)*(x-t)}
min = [min,sum].min
end

puts min


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    int i=0,j=0;
    string str;
    cin>>str;
    sort(str.begin(), str.end());

    if(str[i] == str[i+1] && str[i+1] != str[i+2] && str[i+2] == str[i+3]) j++;

    if(j==0) printf("No\n");
    else printf("Yes\n");

    return 0;
}


Measured memory_bytes: 256
/*
*AOJ2224: Save your cat
**問題概要
[http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2224:title]
N個の頂点とM個の辺を持った無向グラフがある。グラフの閉路がすべてなくなるように辺を取り除きたい。辺のコストは辺の長さである。取り除く辺のコストの最小値を求めよ。
2 <= N <= 10000
1 <= M
**解法
辺を取り除くと考えるのではなく、残す辺で全域木を作ると考えれば、これも最大全域木問題になる。クラスカル法で解く。
*/
#include <typeinfo>
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
struct edge{ int u, v; double cost; };
vector<edge> es;
int V, E; // 頂点数と辺数

//--------Union-Find木------------
vector<int> par; // 親
vector<int> rnk; // 深さ

// Union-Find木の初期化
void init_union_find(int n) {
  par  = vector<int>(n);
  rnk = vector<int>(n);
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rnk[i] = 0;
  }
}

// 木の根を求める
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

// xとyの属する集合を併合
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rnk[x] < rnk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) {
  return find(x) == find(y);
}

//----------クラスカル法------------
bool comp(const edge& e1, const edge& e2) {
  return e1.cost > e2.cost; // 大きい順
}
double kruskal() {
  sort(es.begin(), es.end(), comp); // edge.costの大きい順
  init_union_find(V); // Union-Findの初期化
  double res = 0;
  for (int i = 0; i < E; i++) {
    edge e = es[i];
    if (!same(e.u, e.v)) {
      unite(e.u, e.v);
      res += e.cost;
      // cout << e.u+1 << " " << e.v+1 << endl;
    }
  }
  return res;
}

int main() {
  // 初期化
  cin >> V >> E;
  vector<int> vx = vector<int>(V);
  vector<int> vy = vector<int>(V);
  es = vector<edge>(E);
  for (int i = 0; i < V; i++) {
    cin >> vx[i] >> vy[i];
  }
  double l;
  int p, q;
  double total_cost = 0;
  for (int i = 0; i < E; i++) {
    cin >> p >> q;
    p--; q--;
    l = sqrt(static_cast<double>((vx[p] - vx[q])*(vx[p] - vx[q]) + (vy[p] - vy[q])*(vy[p] - vy[q])));
    // cout << typeid(l).name() << " ";
    // cout << l << endl;
    edge e = {p, q, l};
    es[i] = e;
    total_cost += l;
  }
  // クラスカル法で最大全域木のコストを計算
  double kr = kruskal();
  // 出力
  printf("%.4f\n", total_cost - kr);
}

Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
string s,t;
     int ms(string a,string b){
		 int c=0;
		 for(int i=0;i<a.size();i++){
			 if(a[i]!=b[i])
				 c++;
		 }
		 return c;
	 }
	void solve(){
		int ans=1e9;
		cin>>s>>t;
		for(int i=0;i+t.size()<=s.size();i++){
			ans=min(ans,ms(s.substr(i,t.size()),t));
		}
		cout<<ans;
	}
int main(){
	solve();
}


Measured memory_bytes: 3576
import copy
N=input()

def nine(m):
	if m<9: return m
	for i in range(1000):
		t=9**i
		if t>m:
			t1=9**(i-1)
			return m-t1
def six(m):
	if m<6: return m
	for i in range(1000):
		t=6**i
		if t>m:
			t2=6**(i-1)
			return m-t2


Z=15
k=1<<Z

b=set()
for i in range(k):

	n=copy.deepcopy(N)
	ans=0
	for j in range(Z):
		if n<6:
			b.add(ans+n)
			break
		if i&(1<<j)!=0:
			#9
			n=nine(n)
			ans+=1
		else:
			#6
			n=six(n)
			ans+=1


print min(b)




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

using namespace std;

int main()
{
    int A,B,C,D;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    int d,e;
    d = A*B;
    e = C*D;
    if(d>e)
    {
        cout << d <<endl;
    }
    else if (e>d)
    {
        cout << e <<endl;
    }
    else if(d == e)
    {
        cout <<d <<endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s;
    cin >> s;
    int n = s.size();
    int res;
    REP(i, n){
        if(!s.empty()) s.pop_back();
        int size = s.size();
        if(size%2 != 0) continue;
        string ss = s.substr(0, size/2);
        string sss = s.substr(size/2);
        //cout << ss << " " << sss << endl;
        if(ss == sss){
            res = size;
            break;
        }
    } 
    cout << res << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s == "Sunny")
	{
		cout << "Cloudy" << endl;
	}
	else if (s == "Cloudy")
	{
		cout << "Rainy" << endl;
	}
	else
	{
		cout << "Sunny" << endl;
	}
}


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

long long N, S;

int main() {
	cin >> N;
	for (long long i = 1; i <= 2000000; i++) {
		// a がお気に入りの数であるかどうか判定

		if (N % i != 0) continue;
		long long E = N / i; E--; // E はあまり
		if (E > i) S += E;
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int H, N;
  cin>>H>>N;
  for(int i=0; i<N;i++){
    int A[N];
    cin>>A[i];
    H=H-A[i];
  }
  if(H<=0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

using namespace std;

int main() {
    vector<bool> r(10, false);
    for (int i = 0; i < 4; i++) {
        int n;
        cin >> n;
        r[n] = true;
    }

    cout << (r[1] && r[9] && r[7] && r[4] ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
from itertools import combinations
n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0
for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
print(count)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B, C; cin >> A >> B >> C;
    if (A+B >= C) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
 UL N; ULL A[300];
 scanf("%u",&N);
 rep(i,N) scanf("%llu",&A[i]);
 ULL X=0;
 for(UL i=2; i<N; i++) X^=A[i];
 ULL S=A[0]+A[1];

 ULL D=(S-X)/2;
 if((S-X) & 1) { printf("-1\n"); return 0; }
 if(D & X) { printf("-1\n"); return 0; }
 if(A[0]<D){ printf("-1\n"); return 0; }
 A[0]-=D; A[1]-=D;
 for(ULL d=(1ull<<40); d!=0; d>>=1){
  if((X&d) == 0) continue;
  if(d<=A[0]){ A[0]-=d; D+=d; }
 }

 if(D==0){ printf("-1\n"); return 0; }
 printf("%llu\n",A[0]);

 return 0;
}



Measured memory_bytes: 3772
// https://atcoder.jp/contests/agc021/tasks/agc021_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        s: chars,
        c: usize
    };

    let n = s.len();

    let mut dp = vec![vec![vec![-1; c+1]; n+1]; n];
    dp[0][n-1][0] = 0;
    for i in 0..n {
        for j in (0..n).rev() {
            if i > j {
                continue;
            }
            for k in 0..c+1 {
                let base = dp[i][j][k];
                if base == -1 {
                    continue;
                }

                if i == j {
                    dp[0][n][k] = max(dp[0][n][k], base+1);
                    continue;
                }

                if s[i] == s[j] {
                    dp[i+1][j-1][k] = max(dp[i+1][j-1][k], base+2);
                } else if k+1 <= c {
                    dp[i+1][j-1][k+1] = max(dp[i+1][j-1][k+1], base+2);
                }
                if i+1 < n {
                    dp[i+1][j][k] = max(dp[i+1][j][k], base);
                }
                if j-1 >= 0 {
                    dp[i][j-1][k] = max(dp[i][j-1][k], base);
                }
            }
        }
    }

    let mut ans = 0;
    for i in 0..n {
        for j in 0..n+1 {
            for k in 0..c+1 {
                ans = max(ans, dp[i][j][k]);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 121084
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
constexpr uint64_t L1 = 1ull;
constexpr ull bit(int n){ return 1ull << n;}

// for(auto && i : Range(l,r))
// -> i = [l..r)
class Range {
private: struct It{ int x; int operator*(){return x;}
 bool operator!=(It& lhs){ return x<lhs.x;} void operator++(){++x;} }; It l,r;
public: Range(int n):l({0}),r({n}){} Range(int i,int n):l({i}),r({n})
 {}It& begin(){return l;} It& end(){return r;} };

void solve(istream& cin) {
    map<int, bool> A;
    int N;
    
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        A[a] = !A[a];
    }
    int ans = 0;
    for (auto &&item : A) {
        if(item.second) ans++;
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]) {
    string FileName("C1"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    if(sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size()-ExecutionName.size(), ExecutionName.size());
    cerr << sub << endl;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        solve(cin);
    }
    else {
        string inFile = "sample.txt";
        auto fs = fstream(inFile, fstream::in);
        solve(fs);
    }
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D ;
  int ansA =min(A,B);
  int ansB =min(C,D);
  cout << ansA + ansB <<endl;
}

   
  
   
 


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll N, X;
	cin >> N >> X;
	vector<ll> L(N);
	REP(i, N)cin >> L[i];

	int res = 1;
	int cnt = 0;
	REP(i, N) {
		cnt += L[i];
		if (cnt <= X)res++;
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
    int x;
    cin>>x;
    int a=x/500;
    int b=x%500;
    b=b/5;
    int c=a*1000+b*5;
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int mareitaso(int hayaminn) {
	int mikakosi = 0;
	while (hayaminn > 0) {
		mikakosi += hayaminn % 10;
		hayaminn /= 10;
	}
	return mikakosi;
}

int main(void) {
	int N, A, B;
	int nakagawasyouko = 0;
	int i;
	if (scanf("%d%d%d", &N, &A, &B) != 3) return 1;
	for (i = 1; i <= N; i++) {
		int satorina = mareitaso(i);
		if (A <= satorina && satorina <= B) nakagawasyouko += i;
	}
	printf("%d\n", nakagawasyouko);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
   
class Cube{
public:
 int f[6];
 Cube(){}
 void roll_z(){ roll(1,2,4,3);}
 void roll_y(){ roll(0,2,5,3);}
 void roll_x(){ roll(0,1,5,4);}
 void roll(int i,int j,int k,int l){
   int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
 }
};
   
int getRight( Cube c1,int f1,int f2 ){
 for(int i=0;i<6;i++){
   for(int j=0;j<4;j++){
     if( c1.f[0]==f1 && c1.f[1]==f2 ) return c1.f[2];
     c1.roll_z();
   }
   if( i%2 == 0 )c1.roll_y();
   else c1.roll_x();
 }
 return -1;
}
   
int main(){
 Cube c;
 int f1,f2;
 for(int i=0;i<6;i++)cin>>c.f[i];
 int q; cin>>q;
 for(int i=0;i<q;i++){
   cin>>f1>>f2;
   cout<<getRight(c,f1,f2)<<endl;
 }
 return 0;
}


Measured memory_bytes: 3096
from operator import itemgetter

N = int(input())
R = [0]*N
for i in range(N):
    X_i, L_i = map(int, input().split())
    R[i] = (X_i-L_i,X_i+L_i)
R.sort(key=itemgetter(1))

ans, loc = 0, -(float('inf'))
for i in range(len(R)):
    if loc <= R[i][0]:
        ans += 1
        loc = R[i][1]
print(ans)

Measured memory_bytes: 18276
<?php
$a = array();
$b = array();

list($n, $m) = explode(' ', trim(fgets(STDIN)));

for($i = 0; $i < $n; ++$i) {
  $a[] = explode(' ', trim(fgets(STDIN)));
}
for($i = 0; $i < $m; ++$i) {
  $b[] = trim(fgets(STDIN));
}
foreach ($a as $row) {
  echo (array_sum(array_map(function($x, $y){return $x*$y;}, $row, $b))),PHP_EOL;
}

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

using namespace std;

typedef pair<int, int> P;

const int MAX_N = 100000;
const int MAX_V = 1000000000;

int N;
int X[MAX_N];
int L[MAX_N];

void input() {
	scanf("%d", &N);
	for (int i=0; i < N; ++i) {
		scanf("%d%d", X + i, L + i);
	}
}

P ps[MAX_N];

int solve() {
	for (int i=0; i<N; ++i){
		ps[i] = P(X[i]+L[i], X[i]-L[i]);
	}
	
	sort(ps, ps+N);
	int cur = -MAX_V;
	int ans = 0;
	
	for (int i = 0; i < N; ++i) {
		if (cur <= ps[i].second) {
			ans++;
			cur  = ps[i].first;
		}
	}
	return ans;
}

int main() {
	input();
	printf("%d\n", solve());
	return 0;
} 













Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int main(int argc, char **argv){
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a+b+1;i++) cin>>s[i];
    for(int i=1;i<=a+b+1;i++)
    {
        if(s[i]<48&&i!=a+1||s[i]>58&&i!=a+1)
        {
            cout<<"No"<<endl;
            exit(0);
        }
        if(i==a+1&&s[i]!='-')
        {
            cout<<"No\r\n";
            return 0;
        }
    }
    cout<<"Yes";
putchar('\n');
}

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

int main() {
  string s;
  cin>>s;
  ll k;
  cin>>k;
  int INF_n=1;
  int tmp;
  rep(i,s.size()){
    if(s[i]!='1'){
      INF_n=s[i]-48;
      tmp=i+1;
      break;
    }
  }
  int ans=1;
  if(INF_n!=1){
    if(k>=tmp){
      ans=INF_n;
    }
  }
  cout<<ans<<endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    cpp_int n; cin >> n;
    cout << (n % 9 == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3788
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<iomanip>
#define maxk 300010
using namespace std;
int n,k,a[maxk];
int main()
{
	scanf("%d%d",&n,&k);
	if(n&1) {
		for(int i=1;i<=k;++i)
		a[i]=n/2+1;
		int tail=k,num=k/2;
		for(int i=1;i<=num;++i)
			if(a[tail]==1) tail--;
			else
			{
				a[tail]--;
				for(int j=tail+1;j<=k;++j)
				a[j]=n;
				tail=k;
			}
		
		for(int i=1;i<=tail;++i)
		cout<<a[i]<<' ';cout<<endl;
		return 0;
	}
	else{
		cout<<n/2<<' ';
		for(int i=1;i<k;++i)
		cout<<n<<' ';
		return 0; 
	}
}


Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        int ans = solve(a, b);
        System.out.println(ans);
    }

    private static int solve(int a, int b) {
        int d = b - a;
        int sum = 0;

        for (int i=1; i<d; i++) {
            sum += i;
        }

        return sum - a;
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
const ll N=310;
ll Ans,n,ans[N];char s[N][N],t[N][N];
int main(){
	n=rd();
	Rep(i,1,n)scanf("%s",s[i]+1);
	rep(i,0,n)ans[i]=1;
	Rep(i,1,n)Rep(j,1,n){
		rep(k,0,n){
			ll x=i+k,y=j-k+n+n;
			while(x>n) x-=n;
			while(y>n) y-=n;
			ans[(i-j+k+n*2)%n]&=(s[i][j]==s[x][y]);
		}
	}
	rep(i,0,n)Ans+=ans[i]*n;
	writeln(Ans);
}


/*
1 2 3 ans = 0
1 3 2 
2 1 3
2 3 1


f[i][i] <- f[i-1][k]
f[i][j]
枚举第几次转移(k)
f[i][j] -> f[i][max(j,k)]

f[i][max(i,j)] = \sum j = 0 to n 
	   			 \sum k = 0 to n	f[i-1][j] * g[k]

f[i][j] = \sum f[i-1][j] * g[j]



 
	 
*/

Measured memory_bytes: 384
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collections;
import java.awt.Point;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int n = Integer.parseInt(br.readLine());
            if (n == 0) break;
            long[] dp = new long[n+1];
            dp[0] = 1;
            if (n >= 2) dp[1] = 1;
            if (n >= 3) dp[2] = 2;
            //if (n >= 4) dp[3] = 2;
            
            for (int i = 3; i <= n; i++) {
                dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
            }
            
            System.out.println(dp[n]/10/365+1);
        }
        
    }
}




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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    cin >> k;
    int res = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            res += (i % 2 == 0 && j % 2 == 1);
            res += (i % 2 == 1 && j % 2 == 0);
        }
    }
    cout << res / 2 << '\n';
    return 0;
}


Measured memory_bytes: 256
def ppow(x, n)
    return 1 if n == 0
    a = 1
    n.times do
        a = (a * x) % 998244353
    end
    return a
end

n = gets.to_i
d = gets.split.map(&:to_i)

if d[0] != 0 || d[1..-1].include?(0)
    puts 0
    exit
end

c = []
max = 0
d.each do |x|
    a = c[x] || 0
    c[x] = a + 1
end

if c.include?(nil)
    puts 0
    exit
end

ans = 1
prev = 1
c.each do |n|
    ans *= ppow(prev, n)
    ans %= 998244353
    prev = n
end

puts ans


Measured memory_bytes: 8844
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) cnt++;
    }
    if (cnt == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// 問題URL
// https://atcoder.jp/contests/abc136/tasks/abc136_a

import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer x = Integer.parseInt(scanner.next());
        Integer y = Integer.parseInt(scanner.next());
        Integer z = Integer.parseInt(scanner.next());
        Integer abs = Math.abs(x-y);
        if (abs >= z) {
            System.out.println(0);
        } else {
            System.out.println(Math.abs((x - y) - z));
        }

    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const int inf = 1<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int main () {
  int N; cin >> N;
  vi H(N); rep(i,N) cin >> H.at(i);

  bool flag = true;
  bool cantsage = false;
  rep(i,N-1) {
    if(H.at(i)-H.at(i+1)<0) {
      cantsage = false;
    }
    else if(H.at(i)-H.at(i+1)==1) {
      if(cantsage) {
        flag = false;
        break;
      }
      H.at(i) -= 1;
      cantsage = true;
    }
    else if(H.at(i)-H.at(i+1)>1) {
      flag = false;
    }
  }
  cout << (flag?"Yes":"No") << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int Check(char S[100]){
  int i;
  for(i = 0;i < strlen(S);i++) if((i % 2 == 0 && S[i] == 'L') || (i % 2 == 1 && S[i] == 'R'))  return 1;
  return 0;
}

int main(void){
  char S[100];
  scanf("%s", S);
  if(Check(S) == 1) printf("No\n");
  else printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
import sys
N,Y = map(int,input().split())

for i in range(N+1):

    for j in range(N-i+1):

        k = N - i - j

        if i * 10000 + j * 5000 + k * 1000 == Y:
            print (i,j,k)
            sys.exit()

print (-1,-1,-1)


Measured memory_bytes: 40684
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b==c+d) puts("Balanced");
    else puts(a+b>c+d?"Left":"Right");
    return 0;
}

Measured memory_bytes: 256
a=list(map(int," ".join([input() for i in range(3)]).split()))
n=int(input())
b=[int(input())for i in range(n)]
for i in b:
    if i in a:
        p=a.index(i)
        a[p]="*"
p=0
for i in range(3):
    if a[i]==a[i+3]==a[i+6]=="*":
        p+=1
for i in range(3):
    if a[3*i]==a[3*i+1]==a[3*i+2]=="*":
        p+=1
if a[0]==a[4]==a[8]=="*" or a[2]==a[4]==a[6]=="*":
    p+=1
print("Yes") if p>0 else print("No")

Measured memory_bytes: 3064
from math import sqrt
N, D = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i in range(N):
  dist =  sqrt(P[i][0]**2 + P[i][1]**2)
  if dist <= D:
    ans += 1
print(ans)

Measured memory_bytes: 107096
#include <stdio.h>

int main(void)
{
    int n=0;
    scanf("%d",&n);

    if(n%10==3){
        printf("bon");
    }
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
        printf("pon");
    }
    else {
        printf("hon");
    }

    return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
const int mod=(int)1e9+7;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); 
   	int n;
   	cin>>n; int z[100001]; mem(z,0);
   	int a[n];
   	for(int x=0;x<n;x++){
   		cin>>a[x]; z[a[x]]++;
   		z[a[x]+1]++; if(a[x]-1>=0) z[a[x]-1]++;
   	}
   	int m=-1;
   	for(int x=0;x<100001;x++) m=max(m,z[x]);
   		cout<<m;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

void dfs(int i, const std::vector<std::vector<int>>& edges, std::vector<bool>& memo, std::vector<int>& ans) {
    memo[i] = true;
    for(auto v: edges[i]) {
        if(!memo[v])dfs(v, edges, memo, ans);
    }
    ans.push_back(i);
}

int main() {
    int V, E;
    std::cin >> V >> E;

    std::vector<std::vector<int>> edges(V, std::vector<int>());
    std::vector<bool> memo(V, false);

    while(E--){
        int s, t;
        std::cin >> s >> t;
        edges[s].push_back(t);
    }

    std::vector<int> ans;
    ans.reserve(V);

    for(int i = 0; i < V; ++i) {
        if(!memo[i]) {

            dfs(i, edges, memo, ans);

        }
    }

    for(auto itr = rbegin(ans); itr != rend(ans); ++itr) {
        std::cout << *itr;
        if(itr + 1 != rend(ans)) std::cout << " ";
    }

    std::cout << std::flush;

    return 0;
}



Measured memory_bytes: 3676
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;
int mod = 998244353;
long long dp[3001][3001];

int main(){
   int pow[3001];
   pow[0]=1;
   for(int i = 1 ; i < 3001; i++){
      long long p = pow[i-1];
      p*=2;
      p%=mod;
      pow[i]=p;
   }

   int N,S;
   cin >> N >>S;
   int A[N];
   for (int i = 0; i < N; i++) {
      cin >> A[i];
   }
   memset(dp,0,sizeof(dp));
   dp[0][0]=1;
   for(int i = 0 ; i < N; i++){
      for(int s=S; s>=0; s--){
         int nxt = s+A[i];
         if(dp[i][s]>0){
            if(nxt<=S){
               dp[i+1][nxt]+=dp[i][s];
               dp[i+1][nxt]%=mod;
            }
            dp[i+1][s]+=dp[i][s]*2;
            dp[i+1][s]%=mod;
         }
      }
   }
   cout << dp[N][S] << endl;
   return 0;
}


Measured memory_bytes: 74008
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int a, b; //年齢, 金額
	cin >> a >> b;

	if (a >= 13) {
		cout << b << endl;
	}
	else if (6 <= a && a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vd vector<double>
#define vvd vector<vd >
#define vd vector<double>
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// BIT avl cmd cusum dijkstra dinic geo2 gin graph kruskal lca lcm matrix ncm next_combination segtree st tmp topcoder uf vi 

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << Decimal;

    while (1) {
        int2(n, m);
        int3(p, a, b);
        a--; b--;
        if (!n) break;
        vvi table(m, vi(m, INF));
        vi uma(n);
        rep(i, n) {
            cin >> uma[i];
        }
        rep(i, p) {
            int3(x, y, z); x--; y--;
            table[x][y] = z;
            table[y][x] = z;
        }

        vvd funami(m, vd(1 << n, (double)INF));
        funami[a][(1 << n)-1] = 0;

        using State = tuple<double, int, int>; //始点からの最短距離 子 親
        priority_queue<State> pq;
        pq.emplace(0.0, a, (1 << n)-1);
    
        while (pq.size()) {
            double d; int v, u; tie(d, v, u) = pq.top(); pq.pop();
            if (funami[v][u] < d) continue;
            rep(i, m) {
                if (table[v][i] == INF) continue;
                rep(j, n) {
                    if (u & (1 << j)) {
                        double ncost = (double)table[v][i] / (double)uma[j];
                        if (funami[i][u - (1 << j)] >
                                funami[v][u] + ncost) {
                            funami[i][u - (1 << j)] = funami[v][u] + ncost;
                            pq.emplace(funami[i][u-(1<<j)], i, u-(1<<j));
                        }
                    }
                }
            }
        }

        double ans = INF+1.0;
        rep(i, funami[b].size()) {
            ans = min(ans, funami[b][i]);
        }
        if (ans < INF) {
            cout << ans << endl;
        } else {
            cout << "Impossible" << endl;
        }
    }

    return 0;
}








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

int main(){
	char ch;
	int counter[26]={},num;
	
	while(scanf("%c",&ch)!=EOF){
		if(isupper(ch)){
			ch=tolower(ch);
		}
		num = ch -'a';
		counter[num]++;
	}
	
	for(int i=0;i<26;i++){
		cout << char('a'+i) << " : " << counter[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (n % 2 == 0) {
    cout << s << endl;
  } else {
    cout << s[2] << s[1] << s[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 3592
c_f = False
f_f = False
S = input()
for i in range(len(S)):
	if S[i] == "C":
		c_f = True
	if c_f == True and S[i] == "F":
		f_f = True
if c_f == True and f_f == True:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 2940
#include "bits/stdc++.h" // {{{
using namespace std; typedef long long ll; typedef pair<int,int> pii;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define repr(i,h,l) for(int i=(h); i >= (int)(l); --i)
#define reps(i,s,t) for(int i=(s); i <= (int)(t); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#ifdef  DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t\t= " << (x) << '\n'
#define show2(x,y)  clog << '(' << #x << ',' << #y << ")\t\t= " << '(' << (x) << "\t, " << (y) << ")\n"
#define LN()        fputs("\n--------------------------------\n", stderr)
#define YDK(f,a,b)  ((f)? (a):(b))
#else
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
#endif
#define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; }
template<class T> struct Ordered
{ virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); };
#undef def
struct NullpointerException{ NullpointerException(){
#ifndef DEBUG
  cin.tie(nullptr); ios::sync_with_stdio(false);
#endif
}};
namespace {
  constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL; ostringstream _oss;
  TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
  { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
  TMPLT(T,U) inline bool chmax(T &a, const U &b){return b>a ? a=b,1 : 0;}
  TMPLT(T,U) inline bool chmin(T &a, const U &b){return b<a ? a=b,1 : 0;}
  TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
  template<class T>   string toString(const T &x){ _oss.str(""); _oss << x; return _oss.str(); }
  template<class Itr> string mkString(Itr begin, Itr end, const char *sp = " ") {
    _oss.str(""); for(Itr i=begin; i != end; ++i) { if(i != begin)_oss << sp; _oss << *i; }
    return _oss.str();
  }
  // }}}

constexpr int MX = ten(5) + 10;


void Xx_main_xX(const vector<char*> &args)
{
  ll x, y;
  cin >> x >> y;

  bool p = (x >= 0);
  bool q = (y > 0);

  ll ans = LINF;


  if (p && !q) { // 5 -3
    ans = 1 + abs(x - abs(y));
  }
  else if (!p && q) { // -3 5
    ans = 1 + abs(y - abs(x));
  }
  else if (p && q) {
    if (x < y) {
      ans = y - x;
    } else {  // 9 3
      ans = 1 + 1 + (x - y);
    }
  }
  else if (!p && !q){
    if (x < y) { // -9 -1
      ans = y - x;
    } else {  // -2 -9
      ans = 2 + (x - y);
    }
  }
  else {
    exit(1);
  }

  outl(ans);
}

} // {{{
signed main(signed argc, char *argv[]) {
  NullpointerException();
  cout << fixed << setprecision(9); Xx_main_xX(vector<char*>(argv, argv+argc)); return 0;
} // }}}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

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

	bool hasDirect[4] = {false,false,false,false};

	FOR(i,0,s.length()){
		if(s[i] == 'N') hasDirect[0] = true;
		else if (s[i] == 'E') hasDirect[1] = true;
		else if (s[i] == 'W') hasDirect[2] = true;
		else hasDirect[3] = true;
	}

	string ret = "Yes";
	if(hasDirect[0] ^ hasDirect[3]) ret = "No";
	if(hasDirect[1] ^ hasDirect[2]) ret = "No";

	cout << ret << endl;
	return 0;

}


Measured memory_bytes: 256
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    X, Y = MII()

    if (Y % 2 == 0 and Y / 2 - X >= 0 and 2 * X - Y / 2 >= 0):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <random>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main(){
    ll c[3][3];
    rep(i, 3)rep(j, 3) cin>>c[i][j];
    bool x = c[1][1]==c[0][1]+c[1][0]-c[0][0];
    bool y = c[1][2]==c[0][2]+c[1][0]-c[0][0];
    bool z = c[2][1]==c[0][1]+c[2][0]-c[0][0];
    bool w = c[2][2]==c[1][2]+c[2][1]-c[1][1];
    x & y & z & w ? pr("Yes") : pr("No");
}


Measured memory_bytes: 256
use std::io::{stdin, BufRead, BufReader};

fn main() {
    let mut stack = vec![];
    let input = BufReader::new(stdin());
    for line in input.lines() {
        let n = line.unwrap().trim().parse::<u32>().unwrap();
        if n == 0 {
            println!("{}", stack.last().unwrap());
            let last_idx = stack.len() - 1;
            stack.remove(last_idx);
        } else {
            stack.push(n);
        }
    }
}



Measured memory_bytes: 5036
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();    
    int a = sc.nextInt();
    int b = sc.nextInt();
    String u = sc.next();
    if(s.equals(u)) a--;
    if(t.equals(u)) b--;
    System.out.println(a + " " + b);
  }
}

Measured memory_bytes: 23252