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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll h,n;
    cin>>h>>n;
    Vec a(n);
    cin>>a;
    ll sum = 0;
    rep(i,n){
        sum += a[i];
    }
    Yes(sum>=h);
    return  0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  ll n;
  cin>>n;
  ll a[n];
  rep(i,n){cin>>a[i];}
  ll c=0;
  rep(i,n){ll j=0;
           while(a[i]%2==0){j++;a[i]/=2;}
           c+=j;}
  cout<<c<<endl;
}


Measured memory_bytes: 384
n = int(input())
lst = [int(i) for i in input().split()]
dic_odd = {}
dic_even = {}
for i in range(n):
  num = lst[i]
  if i % 2 == 0:
    if num not in dic_odd:
      dic_odd[num] = 1
    else:
      dic_odd[num] += 1
  else:
    if num not in dic_even:
      dic_even[num] = 1
    else:
      dic_even[num] += 1
lst_odd = sorted(dic_odd.items(), key=lambda x: x[1], reverse=True)
lst_even = sorted(dic_even.items(), key=lambda x: x[1], reverse=True)
#print(lst_odd)
#print(lst_even)
if lst_odd[0][0] != lst_even[0][0]:
  ans = n - lst_odd[0][1] - lst_even[0][1]
else:
  if lst_odd[0][1] > lst_even[0][1]:
    if len(lst_even) > 1:
      ans = n - lst_odd[0][1] - lst_even[1][1]
    else:
      ans = n - lst_odd[0][1]
  elif lst_odd[0][1] < lst_even[0][1]:
    if len(lst_odd) > 1:
      ans = n - lst_odd[1][1] - lst_even[0][1]
    else:
      ans = n - lst_even[0][1]
  else:
    if len(lst_odd) == 1 or len(lst_even) == 1:
      ans = n - lst_odd[0][1]
    else:
      if lst_odd[1][1] > lst_even[1][1]:
        ans = n - lst_even[0][1] - lst_odd[1][1]
      else:
        ans = n - lst_even[1][1] - lst_odd[0][1]
print(ans)

Measured memory_bytes: 26204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

void YN(bool x){
  if(x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

int main() {
  bool finish=true;
  int N; cin>>N;
  vector<int> A(N),B(N),C(N,0),D(N,0);
  rep(i,N){
    cin>>A.at(i);
    C.at(A.at(i)-1)++;
  }
  rep(i,N){
    cin>>B.at(i);
    D.at(B.at(i)-1)++;
  }
  rep(i,N){
    if(C.at(i)+D.at(i)>N) finish=false;
  }
  YN(finish);
  if(finish){
    reverse(B.begin(),B.end());
    int k=0;
    rep(i,N){
      if(A.at(i)==B.at(i)){
        k=0;
        while(A.at(i)==B.at(k)||A.at(i)==A.at(k)){
          k++;
          if(k==N) k=0;
        }
        swap(B.at(i),B.at(k));
      }
    }
    rep(i,N){
      if(i==N-1) cout<<B.at(i)<<endl;
      else cout<<B.at(i)<<' ';
    }
  }        
}


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


void solve(long long N, long long K){
  long double acc = 0;

  for(long long i = 1; i <= N; i++){
    long double loacc = (long double)1.0/N;
    long long count = i;

    while(count < K){
      count *= 2;
      loacc *= 0.5;
    }

    acc += loacc;
  }

  cout << std::setprecision(20) << acc << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int orzxy,a,b;
int main(){
	cin>>orzxy;
	a=orzxy/100;
	b=orzxy%100;
	if((a>=1&&a<=12)&&(b>=1&&b<=12)) cout<<"AMBIGUOUS";
	else if((b<=1||b>=12)&&(a>=1&&a<=12)) cout<<"MMYY";
	else if((a<=1||a>=12)&&(b>=1&&b<=12)) cout<<"YYMM";
	else cout<<"NA";
	return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
#[allow(dead_code)]
fn tansaku_fn(iti: usize, n: usize, kyori: &mut Vec<i32>, map: &Vec<Vec<bool>>, ans: &mut Vec<usize>) {
    let mut tansaku1: Vec<usize> = Vec::new();
    for j in 0..n {
        if map[iti][j] == true {
            tansaku1.push(j);
        }
    }
    let mut tansaku2: Vec<usize> = Vec::new();
    for j in tansaku1 {
        if kyori[j] > kyori[iti] + 1 {
            kyori[j] = kyori[iti] + 1;
            ans[j] = iti;
            tansaku2.push(j);
        }
    }
    for iti1 in tansaku2{
        tansaku_fn(iti1, n, kyori, map, ans);
    }
}

fn is_prime(i: i64) -> bool {
    for j in 2..i/2 {
        if i % j == 0 {
            return false
        }
    }
    return true
}
fn main() {
    let (n, x) = read_two::<i64>();
    let mut v: Vec<i64> = read_vec();
    v.sort();
    let sum: i64 = v.iter().fold(0, |sum, a| sum + a);
    if sum < x {
        println!("{}", n - 1);
        return
    }
    let mut temp = 0;
    for i in 0..n {
        let j = v[i as usize];
        if temp + j == x {
            println!("{}", i + 1);
            return
        }
        if temp + j > x {
            println!("{}", i);
            return
        }
        temp += j;
    }
    println!("{}", n);
}

Measured memory_bytes: 2184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
int cnt(int x, int y){
   int p = 0;
   int q = 0;
   while(p < y){
      p = (x+1)*pow(2, q);
      q++;
   }
   return q;
}
int main() {
   int n, k;
   cin >> n >> k;
   vector<int>q2(n);
   rep(i, 0, n){
      q2[i] = cnt(i,k);
   }
   ll bo = 0;
   rep(i, 0, n){
      bo += pow(2,(q2[0]-q2[i]));
   }
   cout << fixed << setprecision(10) << 2*(long double)(bo/(n*pow(2, q2[0]))) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int N;
	do {
		cin >> N;
	} while (N > 999 || N < 0);
	int n;
	n = N % 10;
	if (n == 2 || n == 4 || n == 5|| n== 7||n == 9) {
		cout << "hon";
	}
	else if (n ==3) {
		cout << "bon";
	}
	else {
		cout << "pon";
	}
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,wrongs;
    cin >>N;
    wrongs =0;
    vector<int> Nums(N);
    for (int i=0;i<N;i++){
        cin >> Nums[i];
        if(Nums[i] != i+1)
            wrongs += 1;
    }
    if(wrongs<=2){
        cout<< "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M,X;
  cin>>N>>M>>X;
  int C[N],A[N][M];
  REP(i,N){
    cin>>C[i];
    REP(j,M)cin>>A[i][j];
  }
  int ans=1e9;
  REP(t,1<<N){
    int Y[M];
    int temp=0;
    REP(i,M)Y[i]=0;
    REP(i,N){
      if(t & (1<<i)){
        temp+=C[i];
        REP(j,M)Y[j]+=A[i][j];
      }
    }
    bool f=true;
    REP(i,M){
      if(Y[i]<X)f=false;
    }
    if(f)ans=min(ans,temp);
  }
  if(ans==1e9)ans=-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3592
data = input().split(" ")
m = int(data[0])
d = int(data[1])
if d < 10:
	print(0)
else:
	d = str(d)
	d1 = int(d[0])
	d2 = int(d[1])
	ans = 0
	for i in range(2, d1):
		for j in range(0, 8):
			if i * (9-j) <= m:
				ans += 9-j-1
				break
	for j in range(0, d2-1):
		if d1 * (d2-j) <= m:
			ans += d2-j-1
			break
	print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <set>

using namespace std;

using ll =  long long;

bool check(const ll n, const ll k) {
    ll ab_sum = 2*n*k + (2*n-1) * (2*n) / 2;
    ll c_sum = n*(k+2*n) + (n-1) * n / 2;
    return ab_sum <= c_sum && k <= n;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    if(!check(n ,k)) {
        cout << -1 << endl;
        return 0;
    }

    set<ll> unused_c;
    for(ll i=k+2*n;i<k+3*n;++i) unused_c.insert(i);
    vector<tuple<ll, ll, ll>> ans;
    ll a = n, b = k+2*n-1, c = k+3*n-1;
    ans.emplace_back(a, b, c);
    while(--a >= k) {
        --b;
        c = *unused_c.lower_bound(a+b);
        ans.emplace_back(a, b, c);
        unused_c.erase(c);
    }
    a = k+n-1;
    --b;
    while(a > n) {
        c = *unused_c.lower_bound(a+b);
        ans.emplace_back(a, b, c);
        unused_c.erase(c);
        --a;
        --b;
    }

    for(auto t: ans) {
        cout << get<0>(t) << " " << get<1>(t) << " "  << get<2>(t) << endl;
    }

}


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

int main()
{

	int sum;
	int value[9];

	while(cin >> sum, sum != 0) {
		for (int i = 0; i < 9; i++) {
			cin >> value[i];
			sum -= value[i];
		}
		cout << sum <<  endl;
	}

	return 0;

}

Measured memory_bytes: 3096
n = int(input())
a = list(map(int,input().split()))
m = max(a) + 10
li = [0]*m 
for x in a:
    li[x] += 1
ans = 0
for i in range(1,m):
    if li[i]: 
        if li[i]==1: 
            ans += 1 
        for j in range(i,m,i): 
            li[j] = 0
print(ans)

Measured memory_bytes: 117128
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=int(input())
    if(n==7 or n==5 or n==3):
        print("YES")
    else:
        print("NO")
    #a=list(map(int,sys.stdin.readline().split(' ')))
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N;
vector<ll> A;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N){
        ll a;
        cin>>a;
        A.pb(a);
    }
    uniq(A);
    N=sz(A);
    ll ans=0;
    ll l=0,r=1;
    while(l<N){
        ans++;
        if(r<N&&A[r]>A[l]){
            while(r<N&&A[r]>A[r-1]){
                r++;
            }
        }
        else if(r<N&&A[r]<A[l]){
            while(r<N&&A[r]<A[r-1]){
                r++;
            }
        }
        r++;
        l=r-1;
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>

#include <map>
 
using namespace std;
typedef long long ll; 

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

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

ll ans,mx,sum,mn=1e10,flag;
ll a[10000000],b[1000000];
int main(){
	ll n,m;
	cin>>n>>m;
	for(ll i=0; i<m; i++){
		ll p;
		string s;
		cin>>p>>s;
		if(s=="AC"){
			a[p] = 1;
		}
		else if(s=="WA"){
			if(a[p]==0) b[p]++;
		}
	}
	for(ll i=1; i<1000000; i++){
		if(a[i] ==1) {
			ans += a[i];
			flag += b[i];
		}
	}
	cout<<ans << " " <<flag<<endl;
}



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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    cout<<(h-a)*(w-b)<<endl;
}

Measured memory_bytes: 3584
n=int(input())
a=list(map(int,input().split()))
num=[0]*63
for i in range(n):
    num1=a[i]
    for j in range(63):
        if num1==0:
            break
        if num1%2==1:
            num[j]+=1
        num1//=2
ans=0
for i in range(63):
    if num[i]!=0 and num[i]!=n:
        ans+=((2**i)*num[i]*(n-num[i]))%(10**9+7)
ans%=10**9+7
print(ans)


Measured memory_bytes: 124604
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        System.out.println(a <= c && c <= b ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                        ' '
#define EPS                        1e-9
#define P_INF                      2e9+17
#define N_INF                     -2e9-17
#define MOD                        1000000007
#define PI                         2*acos(0.0)
#define All(x)                     x.begin(),x.end()
#define Mem(Name, type)            memset(Name, type, sizeof(Name))

template<typename T>
T GCD(T a, T b) { return a ? GCD(b % a, a) : b; }

template<typename T>
T LCM(T a, T b) { return (a * b) / GCD(a, b); }

template<typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto ob : v) os << ob << " ";
    return os;
}

template<typename T, typename S>
std::ostream &operator<<(std::ostream &os, const std::map<T, S> &v) {
    for (auto ob : v) os << ob.first << " : " << ob.second << std::endl;
    return os;
}

using ld = double;
using ll = long long int;
using ul = unsigned long long int;
using namespace std;

class BGoToJail {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, cnt = 0;
        in >> n;
        bool flag = false;
        for (int i = 0; i < n; ++i) {
            int a, b;
            in >> a >> b;
            if (a == b) {
                cnt++;
            } else {
                cnt = 0;
            }
            if (cnt == 3) {
                flag = true;
            }
        }
        out << (flag ? "Yes" : "No") << endl;
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    BGoToJail solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
long long n, a = 1, b = 1, c, d, t;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		cin >> c >> d;
		t = max((a + c - 1) / c, (b + d - 1) / d);
		a = c * t;
		b = d * t;
	}
	cout << (a + b) << endl;
	return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;
package Scc;
sub new{
	return bless[map[],1..$_[1]],$_[0];
}
sub add_edge{
	my$self=shift;
	push@{$self->[$_[0]]},$_[1];
}
sub scc_ids{
	my$self=shift;
	my$now_ord=0;
	my$group_num=0;
	my@low;
	my@ord=(-1)x@{$self};
	my@ids;
	my@visited;
	my$dfs;
	$dfs=sub{
		my$v=shift;
		$low[$v]=$ord[$v]=$now_ord++;
		push@visited,$v;
		for my$to(@{$self->[$v]}){
			if($ord[$to]==-1){
				$dfs->($to);
				$low[$v]=$low[$to]if$low[$v]>$low[$to];
			}
			else{
				$low[$v]=$ord[$to]if$low[$v]>$ord[$to];
			}
		}
		if($low[$v]==$ord[$v]){
			my$u=-1;
			while($u!=$v){
				$u=pop@visited;
				$ord[$u]=@{$self};
				$ids[$u]=$group_num;
			}
			$group_num++;
		}
	};
	for(0..$#ord){
		$dfs->($_)if$ord[$_]==-1;
	}
	$_=$group_num-1-$_ for@ids;
	return($group_num,\@ids);
}
sub scc{
	my$self=shift;
	my($group_num,$ids)=$self->scc_ids();
	my@groups=map[],1..$group_num;
	for(0..$#{$ids}){
		push@{$groups[$ids->[$_]]},$_;
	}
	return\@groups;
}
package main;
my($N,$M)=split$",<>;
my$scc=Scc->new($N);
for(1..$M){
	my($a,$b)=split$",<>;
	$scc->add_edge($a,$b);
}
my$groups=$scc->scc();
print scalar(@{$groups}),$/;
for(@{$groups}){
	print scalar(@{$_}),$","@{$_}",$/;
}


Measured memory_bytes: 290032
//  यस्य स्मरणमात्रेण जन्मसंसारबन्धनात् ।  विमुच्यते नमस्तस्मै विष्णवे प्रभविष्णवे ॥
 
 
 
/****
*     Author- Indrajeet Mishra
*             MNNIT Allahabad, Prayagraj
*             Chemical Engineering undergraduate
 
 
 
****/
 
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
 
#include <bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)
 
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a=0,b=0;cin>>a>>b;
    if(a<=9 && b<=9)cout<<a*b;
    else cout<<"-1";
    return 0;
}

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int l[N];
    for(int i=0; i<N; i++) cin >> l[i];
    sort(l, l + N, greater<int>());
    
    int answer=0;
    for(int i=0; i<K; i++) answer+=l[i];
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long int li;
typedef long long ll;
typedef long double ld;

int main()
{
	int n;
	cin >> n;
	vector<int> v (n + 1, 0);
	int l = ceil(sqrt(n));
	for (int i = 1; i <= l; i++)
	{
		for (int j = 1; j <= l; j++)
		{
			for (int k = 1; k <= l; k++)
			{
				int t = i * i + j * j + k * k + i * j + i * k + j * k;
				if (t <= n)
				{
					v[t]++;
				}
			}
		}
	}
	for (int i = 1; i <= n; i++)
    {
		cout << v[i] << "\n";
    }
}


Measured memory_bytes: 3484
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double x1,y1,r1,x2,y2,r2,y,r,rs,a,b;
		int n;
		n=sc.nextInt();
		while(n--!=0){
			x1=sc.nextDouble();
			y1=sc.nextDouble();
			r1=sc.nextDouble();
			x2=sc.nextDouble();
			y2=sc.nextDouble();
			r2=sc.nextDouble();
			a=x2-x1;b=y2-y1;
			y=Math.sqrt(a*a+b*b);
			if(r2>r1)
				r=r2-r1;
			else
				r=r1-r2;

			rs=r1+r2;
			if(y<r){
				if(r2>r1){
					System.out.println("-2");
				}
				else{
					System.out.println("2");
				}
			}
			else if(y<=rs){
				System.out.println("1");
			}
			else{
				System.out.println("0");
			}
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  vector<int> x(5);
  rep(i,5)cin>>x[i];
  rep(i,5){
    if(x[i]==0){
      cout<<i+1<<endl;
    }
  }
  return 0;
}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    map<int,ll> mpa;
    for(int i = 0; i < n; i++) {
        int tmpkey;
        ll tmpval;
        cin >> tmpkey >> tmpval;
        mpa[tmpkey]+=tmpval;
    }

    ll count=0;
    for(auto itr = mpa.begin(); itr != mpa.end(); itr++) {
        ll val=itr->second;
        count+=val;
//        cout << count << "\n";
        if(count>=k){
            ll key=itr->first;
            cout << key << "\n";
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 4224
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
if em: sys.stdin = open('/dev/tty')
N = int(input())
import math
facts = []
for i in range(1, math.ceil(math.sqrt(N))+1):
  if N % i == 0:
    facts.append([i, N//i])
sums = []
for fact in facts:
  sums.append(sum(fact))
if em : embed()
print(min(sums)-2)


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K){
    cout << S;
  }
  else {
    for (int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "...";
  }
}

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

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define fastIO ios_base::sync_with_stdio(false); cin.tie(false);
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; vector<long long>vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

template<typename T>
T gcd(T __m, T __n)
{
	while (__n != 0)
	{
		T __t = __m % __n;
		__m = __n;
		__n = __t;
	}
	return __m;
}
vi v,vv;
int main() {	
	int n, k, t; in(n); in(k);
	while (n--) { in(t); v.push_back(t); }
	int fac=accumulate(v.begin(), v.end(),*v.begin(), gcd<int>);
	itr(v) { 
		if (*i>=k)
	{
		if((*i - k) %fac==0)
		{
			std::cout << "POSSIBLE";
			break;
		}
	} 
		if (i == v.end() - 1)std::cout << "IMPOSSIBLE";
	}
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<vector>
#include<set>

using namespace std;

int main(){
  int n,flag=0;
  cin>>n;
  vector<string> w(n);
  set<string> s;
  for(int i=0;i<n;i++){
    cin>>w.at(i);
    if(s.count(w.at(i))) flag=1;
    s.insert(w.at(i));
  }
  for(int i=0;i<n-1;i++){
    if(w[i][w[i].size()-1]!=w[i+1][0]){
      flag=1;
      break;
    }
  }
  if(flag) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 2019
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
string s;
int r[200005];
unordered_map<int,int> mp;
int qpow(int a,int k)
{
	int res=1;
	while(k)
	{
		if(k&1) res=res*a%mod;
		a=a*a%mod;
		k>>=1;
	}
	return res;
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	for(int i=1;i<=s.size();i++)
		r[i]=(qpow(10,i-1)*(s[s.size()-i]-'0')+r[i-1])%mod;
	for(int i=0;i<=s.size();i++)
		mp[r[i]]++;
	int ans=0;
	for(unordered_map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
		ans+=it->second*(it->second-1)/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5180
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    mod = 10**9+7
    a = [n,n*n%mod]
    sa = [0,0]
    for i in range(2,n):
        a.append((a[-1]+sa[-1]+(n-i+1)*n%mod)%mod)
        sa.append((sa[-1]+a[i-2]+n-1)%mod)

    print(a[-1])



    return

if __name__ == '__main__':
    main()


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

typedef long long ll;

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

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            char[] str = line.toCharArray();
            for (int i = 0; i < str.length / 2; i++) {
                char c;
                int u;
                c = str[i];
                u = str.length - 1 - i;
                str[i] = str[u];
                str[u] = c;
            }
            System.out.println(new String(str));
        }
    }
}

Measured memory_bytes: 17056
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();

		String A = sc.next();
		String B = sc.next();

		
		long tmp;
		long x=Math.max(N,M);
		long y=Math.min(N,M);
        while ((tmp = x % y) != 0) {
           	x = y;
           	y = tmp;
        }
        long gcd = y;

        long lcm = N*M/gcd;

        boolean f = true;
        for(long n=0,k=0;n<lcm;n+=(M/gcd)*(N/gcd),k++){
			if(A.charAt((int)(N/gcd*k)) != B.charAt((int)(M/gcd*k))){
        		f = false;
        		break;
        	}
        }
        
       	if(f) System.out.println(lcm);
       	else System.out.println(-1);
		
	}
}

Measured memory_bytes: 26324
from itertools import permutations
from math import factorial
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for d in permutations(list(range(n))):
    tmp = 0
    for i in range(n - 1):
        x, y = l[d[i]]
        a, b = l[d[i + 1]]
        tmp += ((x - a) ** 2 + (y - b) ** 2) ** .5
    ans += tmp
print(ans / factorial(n))

Measured memory_bytes: 42604
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = n - 1; i >= 0; --i)
#define INF 100000000
#define pb push_back
#define all(x) (x).begin(),(x).end()

typedef long long ll;

int main() {
	int N; cin >> N;
	int ans = 0;
	int m = 0;

	REP(i, N){
		int t; cin >> t;
		m = max(m, t);
		ans += t;
	}

	ans -= m / 2;
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const ll INF = 1LL << 60;
const ll divisors[3] = {2, 3, 5};

ll dfs(const vector<ll>& costs, map<ll, ll>& dp, ll val) {
    if (dp.count(val)) {
        return dp[val];
    }
    if (!val) {
        return 0;
    }
    if (val == 1) {
        return costs[3];
    }
    ll res = INF;
    rep(i, 0, 3) {
        ll d = divisors[i];
        if (val / d) {
            chmin(res, dfs(costs, dp, val / d) + (val % d) * costs[3] + costs[i]);
        }
        chmin(res, dfs(costs, dp, (val + d - 1) / d) + ((d - val % d) % d) * costs[3] + costs[i]);
    }
    if ((res + val - 1) / val >= costs[3]) {
        chmin(res, val * costs[3]);
    }
    return dp[val] = res;
}

void solve() {
    ll N;
    cin >> N;
    vector<ll> costs(4);
    for (auto& c : costs) {
        cin >> c;
    }
    map<ll, ll> dp;
    cout << dfs(costs, dp, N) << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    rep(_, 0, T) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4412
#define PI 3.14159265359
#define INF 2000000000
#define MAX 500000
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long ll;

ll merge(int A[],int n,int left,int mid,int right) {
	ll cnt=0;
	int n1 = mid - left;
	int n2 = right - mid;
	int L[MAX/2+2], R[MAX/2+2];
	//?????????2??????????????????????????¨??????????????§????????±??????
	for (int i = 0;i < n1;i++) L[i] = A[left + i];
	for (int i = 0;i < n2;i++)R[i] = A[mid + i];
	L[n1] = R[n2] = INF;
	int i =0, j = 0;
	for(int k=left;k<right;k++){
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
			cnt += (n1 - i);
		}
	}
	return cnt;
}

ll mergeSort(int A[],int n,int left, int right) {
	ll  v1, v2, v3;
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		v1 = mergeSort(A, n, left, mid);
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else return 0;
}

int main() {
	int n, A[MAX + 1];
	cin >> n;
	for (int i = 0;i < n;i++) cin >> A[i];
	
	ll inv = mergeSort(A, n, 0, n);

	cout << inv << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,x;
ll l[1000];
ll d;
ll ans;

int main(){
  cin >> n >> x;
  for(ll i = 0;i < n;i++) cin >> l[i];
  d = 0;
  ans = 1;
  for(ll i = 0;i < n;i++){
    d += l[i];
    if(d <= x) ans++;

  }
  cout << ans << endl;

}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(b < c or d < a)
        cout << 0;
    else{
        int start = max(a, c);
        int stop = min(b,d);
        cout << stop-start;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int h[n];
	for(int i=0;i<n;i++)
		cin >> h[i];
	int dp[n];
	for(int i=0;i<n;i++)
		dp[i] = 1000000001;
	dp[0] = 0;
	for(int i=0;i<n-1;i++) {
		dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
		if(i+2<n) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
	}
	cout << dp[n-1] << "\n";
	return 0;
}


Measured memory_bytes: 1024
import itertools
import math

def calc(xy1, xy2):
    return (math.sqrt((xy1[0]-xy2[0])**2 + (xy1[1]-xy2[1])**2))

N = int(input())

p_list = list(itertools.permutations(range(N)))

x_y = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i in p_list:
    for j in range(1, len(i)):
        ans += calc(x_y[i[j]], x_y[i[j-1]])

print(ans/math.factorial(N))


Measured memory_bytes: 7972
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int c = 0;
  if(s[0] == 'o') c++;
  if(s[1] == 'o') c++;
  if(s[2] == 'o') c++;
  cout << 700+c*100 << endl;
}

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

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

  int x,a,b;
  cin >> x >> a >> b;
  if(b - a > x){
    cout << "dangerous" << endl;
  }else if(b - a <= 0){
    cout << "delicious" << endl;
  }else{
    cout << "safe" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
v64 dp;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin >> n >> k;
    v64 a(n,0);
    forn(i,n) cin >> a[i];
    v64 dp(n,INF);
    dp[0]=0;
    forn(i,n){
    	forn(j,k){
    		if(i-j-1>=0) dp[i]=min(dp[i],dp[i-j-1]+abs(a[i-j-1]-a[i]));
    	}
    }
    cout << dp[n-1] << ln;
    return 0;
}

Measured memory_bytes: 1792
m,d = [i for i in input().split()]
ans = 0
for i in range(1,int(m)+1):
    for j in range(1,int(d)+1):
        if (j//10) < 2 or (j%10) < 2:
            pass
        elif i == ((j//10) * (j%10)):
            ans += 1
        else:
            pass
            
print(ans)

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

#define long long long

template<class T> inline void MIN(T &a, T b) { if (a > b) a = b; }
template<class T> inline void MAX(T &a, T b) { if (a < b) a = b; }

const int N = 1e5 + 5;
int n, amt[N];

int main() {

	scanf("%d", &n);

	long ans = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", amt + i);
	}

	for (int i = 0; i < n; i++) {
		ans += amt[i] / 2; amt[i] %= 2;
		int ch = min(amt[i], amt[i + 1]);
		amt[i] -= ch; amt[i + 1] -= ch; ans += ch;
	}

	printf("%lld\n", ans);

}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int i,n,ans=0,height=0;
	int h[n];
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%d",&h[i]);
	}
	for(i=0;i<n;i++){
		if(height <= h[i]){
			height = h[i];
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(void) {
	double x[100];
	double y[100];
	int n;
	
	while(cin >> n) {
		if(n == 0)   break;
		double steep = 100000;
		double min_cos = 1;
		double naiseki;
		double line1, line2;
		double cos;
		int start;
		int min_x1 = 0;
		int min_x2 = 0;
		int next;
		int remove = 1;
		for(int i = 0; i < n; ++i) {
			scanf("%lf,%lf", &x[i], &y[i]);
			if(x[i] < x[min_x1])   min_x1 = i;
			else if(x[i] == x[min_x1] && y[i] < y[min_x1])   min_x1 = i;
		}
		start = min_x1;
		
		for(int i = 0; i < n; ++i) {
			if(x[i] == x[min_x1])   continue;
			if((y[i] - y[min_x1]) / (x[i] - x[min_x1]) < steep) {
				steep = (y[i] - y[min_x1]) / (x[i] - x[min_x1]);
				min_x2 = i;
			}
		}
		
		while(next != start) {
			min_cos = 1;
			for(int i = 0; i < n; ++i) {
				if(i == min_x1 || i == min_x2)   continue;
				naiseki = (x[i] - x[min_x2]) * (x[min_x1] - x[min_x2]) + (y[i] - y[min_x2]) * (y[min_x1] - y[min_x2]);
				line1 = sqrt(pow(x[i] - x[min_x2], 2.0) + pow(y[i] - y[min_x2], 2.0));
				line2 = sqrt(pow(x[min_x1] - x[min_x2], 2.0) + pow(y[min_x1] - y[min_x2], 2.0));
				cos = naiseki / (line1 * line2);
				if(cos < min_cos) {
					min_cos = cos;
					next = i;
				}
			}
			min_x1 = min_x2;
			min_x2 = next;
			++remove;
		}
		
		cout << n - remove << endl;
	}
}


Measured memory_bytes: 3232
#include <stdio.h>

int main(){
	int S,y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	S=y*10000+m*100+d;
	if(S>20190430) printf("TBD");
	if(S<=20190430) printf("Heisei");
	return 0;
}


Measured memory_bytes: 128
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m, x = input_a
c = []
n.times do
  c.push(input_a)
end

# bit全探索
min = 10 ** 8
[0, 1].repeated_permutation(n) do |bits|
  # repeated_permutationで長さn(本の冊数)のbit列を作成(ex. n=3, [0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], ..., [1, 1, 1])
  # bit=1のとき購入とし、bit配列の値をindex付きで順次取り出し
  # アルゴリズムの個数m分の理解度を格納する配列performanceを用意
  cost = 0
  performances = Array.new(m, 0)
  bits.each_with_index do |buy, i|
    if buy == 1
      cost += c[i][0]
      c[i][1..m].each_with_index do |performance, j|
        performances[j] += performance
      end
    else
    end
  end
  ok = 1
  performances.each do |performance|
    if performance < x
      ok = 0
    end
  end
  if ok == 1
    if min > cost
      min = cost
    end
  end
end
if min == 10 ** 8
  puts -1
else
  puts min
end

Measured memory_bytes: 14360
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383



int main (){
    fast;

	
	string n;
	cin>>n;
	ll sum = 0;
	for(unsigned int i=0;i<n.length();i++){
		sum += (int)(n[i] - '0');
		//cout<<sum<<endl;
	}
//cout<<sum<<endl;
	if(sum%9 == 0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	
}











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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 200500;

string s;
int n, nxt[N], prv[N];

inline void del(int pos) {
	int NXT = nxt[pos];
	int PRV = prv[pos];
	nxt[PRV] = NXT;
	prv[NXT] = PRV;
}

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

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> s;
	n = sz(s);
	s = "!" + s;

	nxt[0] = 1;
	prv[n + 1] = n;

	for (int i = 1; i <= n; i++) {
		nxt[i] = i + 1;
		prv[i] = i - 1;
	}

	int i = 1, ans = n;

	while (nxt[i] <= n) {
		if (s[i] == 'S' && s[nxt[i]] == 'T') {
			ans -= 2;
			del(i);
			del(nxt[i]);
			i = prv[i];
		}
		else
			i = nxt[i];
	}

	cout << ans;
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 2128
#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 emplece_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 vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
int calc(int a, int b);
signed main()
{
    Int(n);

    vi pr;

    for (int i = 1; i * i <= n; i++) {
        if (!(n % i)) {
            pr.pb(i);
        }
    }

    int ans = calc(1, n);
    for (int i : pr) {
        ans = min(ans, calc(i, n/i));
    }
    cout << ans << endl;

    return 0;
}

int calc(int a, int b)
{
    int aa = 0, bb = 0;
    while (a) {
        aa++; a /=10;
    }
    while (b) {
        bb++; b /= 10;
    }
    return max(aa, bb);
}



Measured memory_bytes: 256
#abc099c

n=int(raw_input())
res=n
for i in xrange(n+1):
 s=0
 t=i
 while t>0:
  s+=t%6
  t/=6
 t=n-i
 while t>0:
  s+=t%9
  t/=9
 res=min(s,res)
print res


Measured memory_bytes: 32540