akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class C {
public:
	void solve(istream& in, ostream& out) {
	    int n;
	    in >> n;
	    vector<ll> v(n),a,b;
	    rep(i,n){
	        in >> v[i];
	        v[i]--;
	    }
	    for(int i=0;i<n;i+=2) a.pb(v[i]);
	    for(int i=1;i<n;i+=2) b.pb(v[i]);

	    vector<pair<ll,ll>> ap(1e5+5),bp(1e5+5);
	    rep(i,1e5){
	        ap[i].first = 0; ap[i].second = 0;
	        bp[i].first = 0; bp[i].second = 0;
	    }


	    for(int i=0;i<n/2;i++){
	        ap[a[i]].first++;
	        ap[a[i]].second = a[i];
	        bp[b[i]].first++;
	        bp[b[i]].second = b[i];
	    }
	    sort(ap.rbegin(),ap.rend());
	    sort(bp.rbegin(),bp.rend());

	    ll ans = 0;
	    if(ap[0].second != bp[0].second){
            for(int i=1;i<1e5+5;i++){
                ans += ap[i].first;
                ans += bp[i].first;
            }
	    }else{
	        if(ap[0].first > bp[0].first){
	            for(int i=1;i<1e5+5;i++) ans += ap[i].first;
	            ans += bp[0].first;
	            for(int i=2;i<1e5+5;i++) ans += bp[i].first;
	        }else if(bp[0].first > ap[0].first){
                for(int i=1;i<1e5+5;i++) ans += bp[i].first;
                ans += ap[0].first;
                for(int i=2;i<1e5+5;i++) ans += ap[i].first;
	        }else{
	            if(ap[1].first > bp[1].first){
	                ans += ap[0].first;
                    for(int i=2;i<1e5+5;i++) ans += ap[i].first;
                    for(int i=1;i<1e5+5;i++) ans += bp[i].first;
	            }else{
                    ans += bp[0].first;
                    for(int i=2;i<1e5+5;i++) ans += bp[i].first;
                    for(int i=1;i<1e5+5;i++) ans += ap[i].first;
	            }
	        }
	    }
	    out << ans << endl;
	}
};

int main() {
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 5112
n = int(input())
num = list(map(int, input().split()))
m = int(input())
num2 = list(map(int, input().split()))

for k in num2:

    low = 0
    high = len(num)
    t = (low + high) // 2

    if k > num[-1]:
        print(0)
        break

    while low <= high:
        if k == num[t]:
            break
        elif k > num[t]:
            low = t + 1
        elif k < num[t]:
            high = t - 1
        t = (low + high) // 2

    if k != num[t]:
        print(0)
        break
else:
    print(1)



Measured memory_bytes: 35276
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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")
    };
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64
    }
    let g = gcd(c, d);
    let ac  = (a-1) / c;
    let ad  = (a-1) / d;
    let adc = (a-1) / (c * d / g);
    let bc  = b / c;
    let bd  = b / d;
    let bdc = b / (c * d /g);
    /*
    let mut cnt = 0;
    for i in a / d.. {
        if d * i > b {
            break;
        }
        if d * i >= a && d * i <= b {
            for j in v.iter() {
                if &(d * i) == j {
                    cnt+=1;
                }
            }
        }
    }
    */
    println!("{}", b - a + 1 - ((bc+bd-bdc)-(ac + ad - adc)));
    //println!("{}", b - a + 1 - ((bc+bd-bdc)-(ac + ad - adc)));
}

Measured memory_bytes: 4352
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();
        if(a>b){
            System.out.println("a > b");
        }else if(a<b){
            System.out.println("a < b");
        }else if(a==b){
            System.out.println("a == b");
        }
        sc.close();
    }
}


Measured memory_bytes: 26280
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, K;
        cin >> N >> K;
        vll A(N);
        rep(i, 0, N) cin >> A[i];
        sort(all(A));

        if (binary_search(all(A), K)) {
                cout << "POSSIBLE" << endl;
                return 0;
        }

        if (A.back() < K) {
                cout << "IMPOSSIBLE" << endl;
                return 0;
        }

        rep(i, 0, N) {
                ll num = A[i];
                if (binary_search(all(A), K - num)) {
                        cout << "POSSIBLE" << endl;
                        return 0;
                }
        }

        cout << "IMPOSSIBLE" << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;

char s[maxN];
int main()
{
	scanf("%s",s+1);
	int n = strlen(s+1);
	ll sum = 0;
	for(int i=1;i<=n;i++)
	{
		sum = (sum + s[i]-'0')%9;
	}
	if(sum == 0)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 3872
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int H[4],W[4];
vector<string> tet[4];

int N=4,M=10;
vector<string> S;

int paid[3];

bool dfs(int now){
  if(now==3){
    return true;
  }

  int tar=paid[now];
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(i+H[tar]-1>=N) break;
      if(j+W[tar]-1>=M) continue;
      bool ok=true;
      for(int k=0;k<H[tar];k++){
        for(int l=0;l<W[tar];l++){
          if((S[i+k][j+l]=='#'&&tet[tar][k][l]=='#')){
            ok=false;
            break;
          }
        }
      }

      if(ok){
        for(int k=0;k<H[tar];k++){
          for(int l=0;l<W[tar];l++){
            if(tet[tar][k][l]=='#') S[i+k][j+l]='#';
          }
        }

        if(dfs(now+1)) return true;

        for(int k=0;k<H[tar];k++){
          for(int l=0;l<W[tar];l++){
            if(tet[tar][k][l]=='#') S[i+k][j+l]='.';
          }
        }
      }
    }
  }
  return false;
}

void solve(){
  S.clear();
  S.resize(N);
  for(int i=0;i<N;i++) cin>>S[i];

  vector<int> v;
  for(int i=0;i<4;i++) v.push_back(i);

  do{
    for(int j=0;j<3;j++) paid[j]=v[j];
    if(dfs(0)){
      cout<<"Yes"<<endl;
      return;
    }
  }while(next_permutation(v.begin(),v.end()));

  cout<<"No"<<endl;
}

int main(){
  for(int i=0;i<4;i++){
    cin>>H[i]>>W[i];
    tet[i].resize(H[i]);
    for(int j=0;j<H[i];j++) cin>>tet[i][j];
  }

  int T;
  cin>>T;
  for(int i=0;i<T;i++){
    solve();
  }

  return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

int chokkei(const V<V<int>> &G) {
    int n = G.size();
    V<int> d(n, -1);
    d[0] = 0;
    queue<int> que;
    que.push(0);
    int v;
    while(!que.empty()) {
        v = que.front();
        que.pop();
        for(int u : G[v]) {
            if(d[u] == -1) {
                d[u] = d[v] + 1;
                que.push(u);
            }
        }
    }
    d.assign(n, -1);
    d[v] = 0;
    que.push(v);
    while(!que.empty()) {
        v = que.front();
        que.pop();
        for(int u : G[v]) {
            if(d[u] == -1) {
                d[u] = d[v] + 1;
                que.push(u);
            }
        }
    }
    return d[v];
}

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

    int n;
    cin >> n;
    V<V<int>> G(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    puts(chokkei(G) % 3 == 1 ? "Second" : "First");

    return 0;
}

Measured memory_bytes: 13556
import java.util.Scanner;

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

        String s = sc.next();
        long k = sc.nextLong();

        if (k == 1) {
            System.out.println(s.charAt(0));
        } else {
            char ans = 0;
            for (int i = 0; i < k; i++) {
                if (s.charAt(i) != '1') {
                    ans = s.charAt(i);
                    break;
                }
            }
            if (ans == 0)
                ans = '1';
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21716
#include <cstdio>

int n, a[333][333];
long long s;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            int flag = 0;
            for (int k = 0; k < n; k++) {
                if (k == i || k == j) {
                    continue;
                }
                if (a[i][k] + a[k][j] < a[i][j]) {
                    puts("-1");
                    return 0;
                }
                if (a[i][k] + a[k][j] == a[i][j]) {
                    flag = 1;
                }
            }
            if (!flag) {
                s += a[i][j];
            }
        }
    }

    printf("%lld", s);

    return 0;
}

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

int keta(int i){
	int k=1;
	while(i>=10){
		k++;
		i=i/10;
	}
	return k;
}

int main(){
	int a,b;
	while(cin>>a>>b){
	cout << keta(a+b) << endl;
	}
	return 0;
}

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

max_1st_row = max(c[0])

for a1 in range(max_1st_row + 1):
    b = []

    for col in range(3):
        b.append(c[0][col] - a1)

    a2 = c[1][0] - b[0]

    if c[1][1] != (a2 + b[1]) or c[1][2] != (a2 + b[2]):
        continue

    a3 = c[2][0] - b[0]

    if c[2][1] != (a3 + b[1]) or c[2][2] != (a3 + b[2]):
        continue

    print('Yes')
    exit()

print('No')                


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod=1000000007;

int main() {
    int N;
    cin>>N;
    vi a(N);
    rep(i,N) cin>>a[i];
    rep(i,N) a[i]--;
    int b=0,ans=0;
    while(true) {
        b=a[b];
        ans++;
        if(b==1) break;
        if(ans>N+1) {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void) {
	string str;
	cin >> str;
	int depth = 0;
	for (int i = 0; i < str.length(); ++i) {
		if (str[i] == '(') {
			++depth;
		}
		else if (str[i] == ')') {
			--depth;
		}
		else {
			cout << depth << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3216
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI V(n), C(n);
        FOR(i,0,n) {
            cin >> V[i];            
        }
        FOR(i,0,n) {
            cin >> C[i];
        }
        int sum = 0;
        FOR(i,0,n) if (V[i]-C[i] > 0) {
            const int x = V[i]-C[i];
            sum += x;
        }
        cout << sum << endl;
    }
    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll a;double b;cin>>a>>b;
    ll buf=round(b*100);
    ll res=a*buf;
    res/=100;
    cout<<res<<endl;
}


Measured memory_bytes: 3724
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.array(read().split(),np.int64)

def F(d):
    # 公差を固定
    L = S[:-d:d].cumsum()
    R = S[::-1][:-d:d].cumsum()
    if (N-1)%d == 0:
        n = (N-1)//d
        x = np.arange(1,n+1)
        bl = (x+x <= n+1)
        L = L[bl]; R = R[bl]
    return (L+R).max()

def G(n):
    # 項数n+1を固定
    D = (N-1-n)//n
    L = np.zeros(D+1,np.int64)
    R = np.zeros(D+1,np.int64)
    for i in range(1,n+1):
        L += S[:i*(D+1):i]
        R += S[::-1][:i*(D+1):i]
    ok = np.ones(D+1,np.bool)
    overlap = (np.arange(D+1) * (n+n) >= N-1)
    overlap[1:] &= ((N-1)%np.arange(1,D+1) == 0)
    x = L+R
    x[overlap] = 0
    return x.max()

L = int((N-1)**.5 + 10)
L = min(N-1,L)

x = max(F(n) for n in range(1,L+1))
y = max(G(n) for n in range(1,L+1))
answer = max(x,y)
print(answer)

Measured memory_bytes: 18552
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

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

	int cnt=0;
	REP(i, s.size())
	{
		if (s[i] != t[i])cnt++;
	}

	cout << cnt;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int k; cin >> k;

  queue<ll> q; rep(i, 9) q.push(i+1);

  int cnt = 0;
  while(!q.empty()) {
    ll v = q.front(); q.pop();
    ++cnt;
    
    if(cnt == k) {
      cout << v << endl;
      return 0;
    }
    if(v%10 != 0) q.push(10*v + v%10 - 1);
    q.push(10*v + v%10);
    if(v%10 != 9) q.push(10*v + v%10 + 1);
  }
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
 
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()
 
#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))
 
 
#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)
 
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)
 
#define INF 1987654321
#define IINF 987654321987654321
 
int N,K,M;
ll p[100500]; int deg[100500];
ll a[100500], b[100500]; ll sum[100500]; ll cur[100500];
int root; bool vis[100500]; vector<int> E[100500]; 
bool ok = true;
 
ll dfs2(int x){
	vis[x] = true;
	int cnt = 0;
	for(auto  e : E[x]){
		if( vis[e] ) continue;
		ll t = dfs2(e); if( t > 2*p[x]-t ) ok = false;
		sum[x] += t;
		cnt++;
	}
	if( cnt == 0 ) return p[x];
	a[x] = sum[x] - p[x];
	b[x] = 2*p[x] - sum[x];
	if( a[x] < 0 || b[x] < 0 ) ok = false;
	return b[x];
}
 
int main()
{
	geti(N);
	repp(i,N) scanf("%lld",p+i);
	rep(i,N-1){
		int a,b; geti(a,b);
		deg[a]++; deg[b]++;
		E[a].pb(b); E[b].pb(a);
	}
 
	if( N == 2 ){
		if( p[1] == p[2] ){
			cout << "YES";
		}
		else{
			cout << "NO" ;
		}
		return 0;
	}
	repp(i,N) if( deg[i] >= 2 ) root = i;
	
	dfs2(root);
	/*
	repp(i,N){
		printf("%d: %d %d %d %d\n",i,a[i],b[i],sum[i],p[i]);
	}
	*/
	if( a[root] < 0 || b[root] != 0 ){
		ok = false;
	}
	if( ok ){
		cout << "YES" ;
	} else{
		cout << "NO" ;
	}
 
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mx (ll)1e18
const double esp = 1e-9;

void solve()
{
    ll a;
    double b;
    cin>>a>>b;
    ll c = (ll)(b*100+esp);
    cout<<(a*c)/100<<endl;
}


int main()
{
    solve();
}


Measured memory_bytes: 3720
n,*a=map(int,open(0).read().split())
a.sort()
u,d=a[-1],a[0]
print(sum(abs(i)for i in a)-2*min(abs(u),abs(d))*(u*d>0))
for i in a[1:-1]:
    if i<0:print(u,i);u-=i
    else:print(d,i);d-=i
print(u,d)

Measured memory_bytes: 20532
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
	ll n,m;cin>>n>>m;
	ll x[m];rep(i,0,m)cin>>x[i];
	if(n >= m){cout<<0<<endl;return 0;}
	
	sort(x,x+m);
	ll tmp[m-1];
	rep(i,0,m-1){tmp[i]=x[i+1]-x[i];}
	sort(tmp,tmp+m-1);
	
	ll res = 0;
	rep(i,0,m-n){res+=tmp[i];}
	cout << res << ednl;
	
}

Measured memory_bytes: 1792
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
const ll INF=1e13;
signed main()
{
	int n,W;
	cin>>n>>W;
	int weight[n+1]={0};
	int value[n+1]={0};
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>weight[i]>>value[i];
		sum+=value[i];
	}
	int dp[100010];
	dp[0]=0;
	for(int i=1;i<=sum;i++)
		dp[i]=INF;
	for(int item=1;item<=n;item++)
	{
		int w=weight[item];
		int v=value[item];
		for(int i=sum;i>=v;i--)
		{
			dp[i]=min(dp[i],w+dp[i-v]);
		}
	}
	for(int i=sum;i>=0;i--)
	{
		if(dp[i]<=W)
		{
			cout<<i<<endl;
			break;
		}
	}
}












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

template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  Int n;
  F f;
  G g;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(Int n_,F f,G g,T ti):
    f(f),g(g),ti(ti){
    init(n_);
  }
  void init(Int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
  }
  void build(Int n_, vector<T> v){
    for(Int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(Int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(Int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(Int a,Int b){
    T vl=ti,vr=ti;
    for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }

  Int find(Int a,Int b,function<bool(T)> &check,Int k,Int l,Int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n-1) return k-(n-1);
    Int m=(l+r)>>1;
    Int vl=find(a,b,check,k*2+1,l,m);
    if(~vl) return vl;
    return find(a,b,check,k*2+2,m,r);
  }
  
  Int find(Int a,Int b,function<bool(T)> &check){
    return find(a,b,check,0,0,n);
  }
  
};

//INSERT ABOVE HERE
signed main(){
  Int k,n,q;
  cin>>k>>n>>q;

  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i],a[i]*=-1;
  
  using P = pair<Int, Int>;
  SegmentTree<P, P>:: F f=
    [&](P a,P b){
      if(!b.first) return P(a.first,a.second+b.second);
      return P(a.first^b.first,-a.second+b.second);
    };
  SegmentTree<P, P>::G g=[&](P a,P b){a.first++;return b;};

  SegmentTree<P, P> seg(n,f,g,P(0,0));
  vector<P> v(n);
  for(Int i=0;i<n;i++) v[i]=P(!a[i],a[i]);
  seg.build(n,v);

  for(Int i=0;i<q;i++){
    Int l,r;
    cin>>l>>r;
    l--;r--;
    swap(a[l],a[r]);
    seg.update(l,P(!a[l],a[l]));
    seg.update(r,P(!a[r],a[r]));

    P p=seg.query(0,n);
    if(p.first) p.second*=-1;
    //cout<<p.first<<" "<<p.second<<endl;
    Int x=((p.second%k)+k)%k+1;
    if(p.first) x*=-1;
    cout<<x<<endl;
  }
  //cout<<count(a.begin(),a.end(),0)<<endl;
  return 0;
}



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

int main() {
  int k, s;
  cin >> k >> s;
  
  int count = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0+i; j <= k; j++) {
      for (int l = 0+j; l <= k; l++) {
        if (i+j+l == s) {
          if (i==j && j==l) count++;
          else if (i==j || j==l || i==l) count+=3;
          else count+=6;
        }
      }
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
S = list(map(int,input().split("/")))
if S[0]>2019:
  print("TBD")
elif S[0]<2019:
  print("Heisei")
else:
  if S[1]>4:
    print("TBD")
  elif S[1]<4:
    print("Heisei")
  else:
    if S[2]<=30:
      print("Heisei")
    else:
      print("TBD")
    

Measured memory_bytes: 2940
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;
    auto ta = readints;
    int t = ta[0], a = ta[1];
    auto hs = readints;

    int best = int.max;
    int ans = -1;
    for (int i = 0; i < hs.length; i++) {
        int s = t * 1000 - hs[i] * 6;
        // writeln(s);
        if (abs(s - a * 1000) < best) {
            best = abs(s - a * 1000);
            ans = i + 1;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 380
#include "stdio.h"
#include <stdlib.h>

int compare_int(const void *a, const void *b){
    return *(long long int*)b - *(long long int*)a;
}


int main(int argc, char const *argv[]) {
  int N,i,k;
  scanf("%d", &N);
  long long int A[N];
  long long int B[N];
  long long int D[N];
  for (i = 0; i < N; i++) {scanf("%lld", &A[i]);}
  for (i = 0; i < N; i++) {scanf("%lld", &B[i]);}

  long long int X=0;
  for ( i = 0; i < N; i++) {X=X+B[i]-A[i];}
  if (X>0) {printf("%d", -1);return 0;}

  X=0;k=0;
  int ka=0;
  for (i = 0; i < N; i++) {
    if (A[i]<B[i]) {X=X+B[i]-A[i];ka++;}
    if (A[i]>B[i]) {D[k]=A[i]-B[i];k++;}
  }
  qsort(D, k, sizeof(long long int), compare_int);
  int ans=N;
  int kk=0;
  while (X>0) {
    if (k<=kk) {printf("%d", -1);return 0;}
    X=X-D[kk];
    kk++;
  }
  ans=kk+ka;
  printf("%d", ans);
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7; ;
const ll inf=1e18;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll lcm(ll a,ll b){
    return a*(b/__gcd(a,b));
}

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}

int main()
{
    fast;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
          string s;
          cin>>s;
          ll n=s.length();
          for(int i=0;i<n;i++)cout<<"x";
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
alfa=[chr(i) for i in range(97, 97+26)]
words={}
for alf in alfa:
    words[alf]=0
for n_ in range(n):
    S=input()
    if n_==0:
        for s in S:
            words[s] = S.count(s)
    else:
        for k,v in words.items():
            words[k]=min(v,S.count(k))
answer=''
for key,value in words.items():
    answer+=key*value
print(answer)


Measured memory_bytes: 73984
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef std::vector<pii> vii;
#define INF 0x3f3f3f3f

map<int,pair<bool,int>> mp;
int main(int argc, char const *argv[])

{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in.txt" , "r", stdin);
 	//freopen("out.txt" , "w", stdout);

  	int n, k, q;
  	cin>>n>>k>>q;
  	int pos;
 	int ara[n+1]={k};
 	//for (int i = 0; i < n; i++) ara[i]=k;
 	for(int i=0; i<q; i++){
 		int pos;
 		cin>>pos;
 		pos-=1;
 		mp[pos].first=true;
 		mp[pos].second+=1;
 		//cout<<mp[pos].second<<" ";
 	}
 	//cout<<endl;
 	for(int i=0; i<n; i++){
 		if(mp[i].first==false){
 			if( (k + (-1*q) ) > 0) cout<<"Yes\n";
 			else cout<<"No\n";
 		}
 		else{
 			if(k + (-1 * (q-mp[i].second)) > 0 ) cout<<"Yes\n";
 			else
 				cout<<"No\n";
 		}
 	}
	return 0;
}

Measured memory_bytes: 7296
using System;

namespace aoj2b
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] num = str.Split(' ');
            int a = int.Parse(num[0]);
            int b = int.Parse(num[1]);
            int c = int.Parse(num[2]);

            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

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

using namespace std;

int main(){
    string A, B, C;
    cin >> A >> B >> C;
                                                                                      
    if(A[A.length()-1] == B[0] && B[B.length()-1] == C[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  ll Q; cin >> Q;
  vector<string> before;
  vector<string> after;
  bool rev = false;
  for (ll i = 0; i < Q; i++) {
    ll t; cin >> t;
    if (t == 1) {
      rev = ! rev;
    }else {
      ll f;
      string c;
      cin >> f >> c;
      if (f == 1) {
	if (!rev) before.push_back(c);
	else {
	  reverse(c.begin(), c.end());
	  after.push_back(c);
	}
      }else {
	if (!rev) after.push_back(c);
	else {
	  reverse(c.begin(), c.end());
	  before.push_back(c);
	}
      }
    }
  }
  string res = "";
  for (ll i = before.size() - 1; i >= 0; i--) {
    res += before.at(i);
  }
  res += S;
  for (ll i = 0; i < (ll)after.size(); i++) {
    res += after.at(i);
  }
  if (rev) reverse(res.begin(), res.end());
  cout << res << endl;


  return 0;
}



Measured memory_bytes: 12352
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
signed main(){
    int n,p,a[50],cnt=0;
    cin>>n>>p;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==1)cnt++;
    }
    if(cnt){
        cout<<((int)1<<(n-1))<<endl;
    }
    else if(p==1){
        cout<<0<<endl;
    }
    else cout<<((int)1<<n)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin>>N && N){
    vector<int> l(N);
    REP(i, N) cin>>l[i];
    int M = 256;
    int as, aa, ac;
    double ent = 1e32;
    REP(S, 16)REP(A, 16)REP(C, 16){
      vector<int> R(N + 1);
      R[0] = S;
      REP(i, N){
        R[i + 1] = (A * R[i] + C) % M;
      }
      REP(i, N){
        R[i + 1] += l[i];
        if(R[i + 1] >= M) R[i + 1] -= M;
      }
      double cnt[256] = {};
      REP(i, N) cnt[R[i + 1]] += 1.0;
      double e = 0;
      REP(i, 256)if(cnt[i] != 0){
        double c = cnt[i];
        e += -c/N * log(c/N);
        if(!(e + EPS < ent)) goto END;
      }
      ent = e;
      as = S, aa = A, ac = C;
END:;
    }
    printf("%d %d %d\n", as, aa, ac);
  }
  return 0;
}

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


int main(){
    int N;
    int P[200000];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> P[i];
    }

    int count = 0;

    int min = 100000000;

    for(int j=0; j<N; j++){
        if(P[j] <= min){
            min = P[j];
            count++;
        }
    }

    cout << count;


    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;

ll a[200005], s[200005], n, k;
map<int, int> m;

ll nmod(ll n)
{
    return ((n % k) + k) % k;
}

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    s[1] = a[1];
    for (int i = 2; i <= n; ++i)
        s[i] = s[i - 1] + a[i];
    ll sum = 0;
    if (k != 1)
        m[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
        //cout << m[nmod(s[i] - i)] << endl;
        sum += m[nmod(s[i] - i)];
        if (i >= k - 1)
            --m[nmod(s[i - k + 1] - (i - k + 1))];
        ++m[nmod(s[i] - i)];
    }
    cout << sum << endl;
}

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

int main(void){
   int n;
   cin >> n;
   vector<int> a(n);
   for(int i = 0;i < n;i++){
       cin >> a[i];
   }
   int t = a[0];
   int ans = 1;
   for(int i = 1;i < n;i++){
       if(t > a[i]){
           ans++;
           t = a[i];
       }
   }
   cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include<cstring>
#include <algorithm>
#include <queue>
using namespace std;
int main()
{
	priority_queue<int> q; 
	int m,n,t;
	cin >> n >> m;
	
	for(int i=0;i<n;i++)
	{
		cin>>t;
		q.push(t);    
	}
	
	long long tot=0;
	while(m)
	{
		t=q.top()/2;
		q.pop();
		q.push(t);
		m--;
	}
	
	while(!q.empty())
	{
		tot+=q.top();
		q.pop();
	}
	cout << tot;    
	
	return 0;
}


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

int main(){
  int city[4]={};
  for(int i=0; i<3; i++){
    int a, b; cin >> a >> b;
    city[a-1]++;
    city[b-1]++;
  }
  for(int i=0; i<4; i++){
    if(city[i]==0 || city[i]>=3){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

int main()
{
    int i,x,r;
    string S;
    cin >> S;
    x=S.size();
    r=0;
    
    for(i=0;i<x/2;i++){
        if(S.at(i)!=S.at(x-i-1)){
            r++;
        }
    }
    cout << r <<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> vec(N);
    rep(i, N) {
        int A, B;
        cin >> A >> B;
        vec[i] = make_pair(B, A);
    }
    sort(ALL(vec));
    int cnt = 0;
    string ans = "Yes";
    rep(i, N) {
        cnt += vec[i].second;
        if (cnt > vec[i].first) {
            ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
def main():
    a,b,m = map(int,input().split())
    reizouko = list(map(int,input().split()))
    mn_reizouko = min(reizouko)
    renji = list(map(int,input().split()))
    mn_renji = min(renji)
    mn = 20 ** 5 + 1
    for i in range(m):
        x,y,c = map(int,input().split())
        mn = min(mn,reizouko[x-1]+renji[y-1]-c)
    mn = min(mn,mn_reizouko+mn_renji)

    print(mn)




if __name__ == '__main__':
    main()


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


int main() {
    int N;cin >> N;
    float r = log2(N);
    int rui = r/1;
    int ans;
    ans = pow(2,rui);
    cout << ans << endl;
  }       

Measured memory_bytes: 256
#include <string>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>

using namespace std;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

int W,N;
int c[1000],w[1000];
int t[10000+10];

int main()
{
	for (int i = 1; ; i++){
		cin>>W;
		if(W == 0) break;
		cin>>N;
		for(int j =0 ; j < N; j++) scanf("%d,%d",c+j,w+j);
		printf("Case %d:\n",i);
		memset(t,-1,sizeof(t));
		t[0] = 0;
		for (int i = 0; i < N; i++){
			for (int j = W - w[i]; j >= 0; j--){
				if(t[j] == -1) continue;
				t[j+w[i]] = max(t[j+w[i]],t[j] + c[i]);
			}
		}
		int ans_id = max_element(t,t+W+1) - t;
		printf("%d\n%d\n",t[ans_id],ans_id);
	}

}

Measured memory_bytes: 0
// 2015/06/02 Tazoe

#include <iostream>
using namespace std;

// Nodeクラス
class Node{
public:
	Node* prev;	// 前のノードへのポインタ
	Node* next;	// 次のノードへのポインタ
	int data;	// データ
	Node(){prev = 0; next = 0; data = 0;}		// デフォルトコンストラクタ
};

// Listクラス
class List{
private:
	Node head;	// ヘッドノード（ダミー）
public:
	List(){head.prev = &head; head.next = &head;}	// デフォルトコンストラクタ
	int insert(int x);		// 挿入
	int del(int x);			// 削除
	int deleteFirst();		// 先頭を削除
	int deleteLast();		// 末尾を削除
	void print();			// 表示
};

// insertメソッド（挿入）
int List::insert(int x)
{
	Node* p = new Node();

	if(p==0)
		return -1;		// メモリ確保エラー

	Node* q = &head;
	Node* r = head.next;

	p->prev = q;
	p->next = r;
	p->data = x;

	q->next = p;
	r->prev = p;

	return 0;			// 正常終了
}

// delメソッド（削除）
int List::del(int x)
{
	Node* p;

	for(p=head.next; p!=&head; p=p->next){
		if(p->data==x)
			break;
	}

	if(p==&head)
		return -2;		// 探索エラー

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// 正常終了
}

// deleteFirstメソッド（先頭を削除）
int List::deleteFirst()
{
	Node* p = head.next;

	if(p==&head)
		return -2;		// エラー

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// 正常終了
}

// deleteLastメソッド（末尾を削除）
int List::deleteLast()
{
	Node* p = head.prev;

	if(p==&head)
		return -2;		// エラー

	Node* q = p->prev;
	Node* r = p->next;

	q->next = r;
	r->prev = q;

	delete p;

	return 0;			// 正常終了
}

// printメソッド（表示）
void List::print()
{
	for(Node* p=head.next; p!=&head; p=p->next){
		cout << p->data;

		if(p->next!=&head){
			cout << ' ';
		}
		else{
			cout << endl;
		}
	}
}


// main関数
int main()
{
	List L;

	int n;
	cin >> n;

	for(int i=0; i<n; i++){
		char com[20];		// C文字列
		cin >> com;

		if(com[0]=='i'){
			int x;
			cin >> x;

			L.insert(x);
		}
		else if(com[6]=='F'){
			L.deleteFirst();
		}
		else if(com[6]=='L'){
			L.deleteLast();
		}
		else{
			int x;
			cin >> x;

			L.del(x);
		}
	}

	L.print();

	return 0;
}

Measured memory_bytes: 32444
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

int main() {
  int N;
  ll A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  for (int i=0; i<N; i++) cin >> X[i];
  ll res = 0;
  for (int i=1; i<N; i++) res += min((X[i]-X[i-1])*A, B);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
H,W,M = map(int, input().split())
mx=[0] * W
my=[0] * H
bs ={}
mxx = 0
myy = 0
for i in range(M):
    y,x = map(int, input().split())
    mx[x-1] += 1
    my[y-1] += 1
    mxx = max(mx[x-1], mxx)
    myy = max(my[y-1], myy)
    if y-1 in bs:
        bs[y-1].add(x-1)
    else:
        bs[y-1] = set([x-1])

vx = []
vy = []
for i,x in enumerate(mx):
    if x == mxx:
        vx.append(i)
for i,y in enumerate(my):
    if y == myy:
        vy.append(i)

a = 1

for i in vx:
    for j in vy:
        if i not in bs[j]:
            a = 0
            break
    else:
        continue
    break

ans = mxx + myy - a
print(ans)


Measured memory_bytes: 223220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e16;
const ll mod=1000000007;
typedef pair<ll,ll> pi;

void solve()
{
ll n,x,t;
cin>>n>>x>>t;
ll temp=n/x;
if(n%x!=0) temp++;
ll ans=temp*t;
cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    t=1;
    for(ll i=1;i<=t;i++)
    {
        solve();
        cout<<endl;

    }
    return 0;
}


Measured memory_bytes: 3648