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

typedef long long ll;

ll single(ll X){
  if(X&1){
    return ((X+1)>>1)&1;
  }
  else{
    return ((X>>1)&1)^X;
  }
}

int main(){
  ll A, B;cin>>A>>B;
  if (A==0){
    ll ans=single(B);
    cout << ans<< endl;
  }
  else{
    ll ans=single(B)^single(A-1);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
bool check(string &str)
{
    ll l = str.size();
    ll i,j;
    for(i = 0; i<l; i++)
    {
        if(str[i] != str[l-i-1])
        {
            return false;
            break;
        }
    }
    return true;
}
int main()
{
    string str;
    getline(cin,str);
    ll l = str.size();
    ll i,j;
    ll n = (l - 1)/2;
    ll k = (l+3)/2;
    string a = "",b="";
    for(i = 0; i<n; i++)
        a+= str[i];
    for(i = k-1; i<l; i++)
        b+= str[i];
    if(l % 2 != 0)
    {
        if(check(str) && check(a) == true && check(b) == true)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
        cout << "No" << endl;

    return 0;
}


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

int main() {
    int n;
    cin>>n;
    vector<int> tako(n);
    for(int i=0; i<n; i++) {
        cin>>tako.at(i);
    }

    int ans = 0;
    for(int i=0; i<n-1; i++) {
        for(int j=i+1; j<n; j++) {
            ans += tako.at(i)*tako.at(j);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define RO 1
#define SI 2
#define PA 3

int main(){
    int n,k;cin>>n>>k;;
    int R,S,P;cin>>R>>S>>P;
    string T;cin>>T;
    
    vector<int> J(n+k,0);
    int score=0;
    rep(i,0,n){
        if(T[i]=='r'&&J[i]!=PA){
            score+=P;
            J[i+k]=PA;
        }    
        if(T[i]=='s'&&J[i]!=RO){
            score+=R;
            J[i+k]=RO;
        }    
        if(T[i]=='p'&&J[i]!=SI){
            score+=S;
            J[i+k]=SI;
        }        
    }        
    cout<<score<<endl;
}    



Measured memory_bytes: 1216
#include<iostream><string>
using namespace std;
int main(){

  int N;
  cin>>N;
  string S;
  cin>>S;
  int count=0;
  int max=0;
  for(int i=0;i<=N-1;i++){
  
    if(S[i]=='I')count++;
    else if(S[i]=='D')count--;
    if(count>max)max=count;
  }
  cout<<max;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/


void solve(){
  int test;
  //cin>>test;
  test=1;
     
  while(test--){
        int n,r;
        cin>>n>>r;
        if(n>=10){
            cout<<r;
        }else{
            cout<<r+(100*(10-n));
        }
    }         
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 100005;
int n, v, u, c = 2;
vector<int> G[MX], a;
int dfs1(int u, int p){
	int c = u != v, ret = u;
	for(int nx: G[u]) if(nx != p && G[nx].size() > 1){
		if(c++ > 1){
			puts("-1");
			exit(0);
		}
		ret = dfs1(nx,u);
	}
	return ret;
}
void dfs2(int u, int p){
	a.push_back((int)G[u].size());
	for(int nx: G[u]) if(nx != p && G[nx].size() > 1) dfs2(nx,u);
}
int main(){
	scanf("%d", &n);
	rep(i,n-1){
		scanf("%d%d", &v, &u);
		v--; u--;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	if(G[v].size() == 1) v = G[v][0];
	v = dfs1(v,-1);
	dfs2(v,-1);
	u = (int)a.size();
	rep(i,u) if(a[i] != a[u-1-i]){
		if(a[i] > a[u-1-i]) reverse(a.begin(), a.end());
		break;
	}
	printf("1 ");
	rep(i,u){
		int t = c++;
		rep(j,a[i]-2) printf("%d ", c++);
		printf("%d ", t);
		if(i == u-1) printf("%d\n", c++);
	}
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, M, ans = 1;
	cin >> N >> M;
	for (int i = (int)(sqrt(M) + 1e-9); i > 0; i--) {
		if (M%i == 0) {
			if (M / i >= N) {
				ans = max(ans, i);
			}
			if (i >= N) {
				ans = max(ans, M / i);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

string encode(int p,int n){
  string ret="";
  ret += to_string(p);
  ret.insert(0,"000000", 6-ret.size());
  ret += to_string(n);
  ret.insert(6,"000000", 12-ret.size());
  return ret;
}

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,P>> a;
  rep(i,m){
    int p,y; cin>>p>>y;
    a.push_back({y,{p,i}});
  }
  sort(a.begin(),a.end());
  vector<string> ans(m);
  map<int,int> mp;
  rep(i,m){
    mp[a[i].S.F]++;
    ans[a[i].S.S]=encode(a[i].S.F,mp[a[i].S.F]);
  }
  rep(i,m){
    cout << ans[i] << endl;
  }

  return 0;
}


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



Measured memory_bytes: 2048
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define re(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second


ll binpow(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return binpow(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n,i,f=0,j,ans=0,k,x,r,l,t;
    string s;
    cin >> n ;
    vector<ll> a(n);
    rep(i,n) cin >> a[i] ;
    ll mx=a[0];
    for(i=1;i<n;++i)
    {
          ans+=max((ll)0,mx-a[i]);
          //cout << ans << endl ;
          mx=max(a[i],mx);
    }
    cout << ans ;
    
    return 0;
}

Measured memory_bytes: 4780
N,K = map(int,input().split())
mod = 10**9+7
sum_min = 0
sum_max = 0
diff = 0
while K != N+2:
    sum_min = 1/2*K*(K-1)
    sum_max = 1/2*K*(2*N-K+1)
    diff += sum_max - sum_min+1
    K+= 1
diff = diff % mod
print(int(diff))

Measured memory_bytes: 9184
def main():
    num = list(map(int, input().split()))
    num.sort()
    answer = 0
    a = num[2] - num[0]
    b = num[2] - num[1]
    if a % 2 == b % 2:
        answer = a // 2 + b // 2 + a % 2
    elif a % 2 != b % 2:
        answer = a // 2 + b // 2 + 2
    print(answer)


if __name__ == '__main__':
    main()



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

using namespace std;

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

    vector<long long int> a(n+2,0);
    for(int i=0;i<n;i++)cin>>a[i];

    sort(a.begin(),a.end(),greater<long long int>());
    long long int value = 0;
    for(int i=0;i<n;i++){
        if(a[i]==a[i+1]&&value==0){
            value=a[i];
            i++;
        }else if(a[i]==a[i+1]){
            cout<<a[i]*value;
            return 0;
        }
    }
    cout<<"0"<<endl;
}


Measured memory_bytes: 1024
n,t = map(int,input().split())
a = list(map(int,input().split()))
p = 0
m = 10**9+7
ans = 0
for i in range(n):
    m = min(m,a[i])
    if p < a[i]-m:
        p = a[i]-m
        ans = 1
    elif p == a[i]-m:
        ans += 1
print(ans)


Measured memory_bytes: 14252
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> a = new ArrayList<Integer>();
		while(sc.hasNextInt()){
			a.add(sc.nextInt());
			if(a.get(a.size()-1) == 0){
				a.remove(a.size()-1);
				System.out.println(a.get(a.size()-1));
			    a.remove(a.size()-1);
			}
		}
	}
}

Measured memory_bytes: 17216
#include <iostream>

using namespace std;

int main()
{
	int n;
	char a;
	int b;
	int card[4][13] = { 0 };
	int i, j;

	while (1)
	{
		cin >> n;

		if (n <= 52 && n >= 0)
			break;
	}

	for (i = 0; i < n; i++)
	{
		while (1)
		{
			cin >> a >> b;
			if (a == 'S' || a == 'H' || a == 'C' || a == 'D')
			{
				if (b <= 13 && b > 0)
					break;
			}
		}

		if (a == 'S')
			card[0][b-1] = 1;
		else if (a == 'H')
			card[1][b-1] = 1;
		else if (a == 'C')
			card[2][b-1] = 1;
		else
			card[3][b-1] = 1;
	}

	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 13; j++)
		{
			if (card[i][j] != 1)
			{
				if (i == 0)
					cout << "S " << j+1 << endl;
				else if (i == 1)
					cout << "H " << j+1 << endl;
				else if (i == 2)
					cout << "C " << j+1 << endl;
				else
					cout << "D " << j+1 << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

use std::fmt::Display;
pub fn print_vec<T: Display>(v: &Vec<T>, prefix: &str, suffix: &str) {
    if v.is_empty() {
        println!("[]");
        return;
    }
    print!("{}", prefix);
    print!("{}", v[0]);
    for i in 1..v.len() {
        print!(" {}", v[i]);
    }
    println!("{}", suffix);
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, k) = input!(usize, u64);
    let a = invec!(u16);
    let m = 1_000_000_007;

    let mut inv = vec![0_u64; n];
    let mut inv_first = vec![0_u64; n];

    for i in 0..n {
        for v2 in &a {
            if a[i] > *v2 {
                inv[i] += 1;
            }
        }
    }

    for i in 0..n {
        for j in (i+1)..n {
            if a[i] > a[j] {
                inv_first[i] += 1;
            }
        }
    }

    let mut count = 0;
    let total = ((k as u64 - 1) * (k as u64) / 2) % m;
    for i in 0..n {
        if inv[i] == 0 {
            continue;
        }
        count += (total * inv[i]) % m;
    }

    for i in 0..(n - 1) {
        count += (inv_first[i] * k) % m;
    }

    println!("{}", count % m);
}

fn main() {
    solve();
}


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

int INF = 99000000;
int n;
std::vector<int> vec;
std::vector<int> dp;

int main() {
    std::cin >> n;
    vec.assign(n, 0);
    dp.assign(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> vec[i];
    }
    dp[0] = 0;
    dp[1] = std::abs(vec[0] - vec[1]);
    for (int i = 2; i < n; i++) {
        int diff1 = dp[i-1] + std::abs(vec[i-1] - vec[i]);
        int diff2 = dp[i-2] + std::abs(vec[i-2] - vec[i]);
        if (diff1 < diff2) {
            dp[i] = diff1;
        }
        else {
            dp[i] = diff2;
        }
    }
    std::cout << dp[n-1] << std::endl;
}


Measured memory_bytes: 1024
N = int(input())
numlist = list(map(int,input().split()))
temp = 9999999999999
for i in numlist:
	sum = 0
	if i % 2 != 0:
		temp =0
		break
	else:
		while i % 2 ==0:
			i //= 2
			sum += 1
		if temp > sum :
			temp = sum
			
print(temp)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long N,M,i,l=1;
int main(){
  cin>>N>>M;
  vector<long>A(N);
  for(i=0;i<N;i++)cin>>A[i];
  for(auto a:A)l=l/__gcd(a/2,l)*a/2;
  for(auto a:A){
    if((l/(a/2))%2)continue;
    cout<<0<<endl;
    return 0;
  }
  cout<<(M/l+1)/2<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>

int main()
{
    while ( true )
    {
        int x, y;
        std::cin >> x >> y;

        if ( x == 0 && y == 0 ) { break; }

        if ( x > y ) { std::swap( x, y ); }
        std::cout
            << x << " " << y
            << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cctype>
#include <utility>
#include <climits>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	pair<int, int> m = {0, INT_MIN}, t;
	for (int n = in(); n; n--) {
		int a = -in();
		t = {in(), a};
		m = max(m, t);
	}
	outl(-m.second, ' ', m.first);
}


Measured memory_bytes: 2544
N = int(input())
As = list(map(int,input().split()))
zoka = 0
before = As[0]
c = 1
for i in range(1,N):
    if before == As[i]:
        continue
    elif before < As[i]:
        if zoka == 0 or zoka == 1:
            before = As[i]
            zoka = 1
        else:
            c+=1
            zoka = 0
            before = As[i]
    else:
        if zoka == 0 or zoka == 2:
            before = As[i]
            zoka = 2
        else:
            c+=1
            zoka = 0
            before = As[i]
print(c)

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

int main(){
    int n; cin>>n;
    int minp; cin>>minp;
    int ans=1;
    rep(i,0,n-1){
        int p; cin>>p;
        if(p<=minp){
            minp=p;
            ans++;
        }
    }
    cout<<ans<<"\n";
}

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

int main(int argc, char const *argv[]) {
  /* code */
  string input;
  cin >> input;

  string strA = "A";
  string strZ = "Z";

  int posA = input.find_first_of(strA);
  int posZ = input.find_last_of(strZ);

  cout << (posZ - posA + 1) << endl;

  return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var N, M int
	fmt.Scan(&N, &M)

	votes := make([]int, M)

	for i := 0; i < N; i++ {
		row, _ := reader.ReadString('\n')
		// ex. "1 4 2 9"
		row = strings.TrimSuffix(row, "\n")
		// ex. {"1" "4" "2" "9"}
		splitted := strings.Split(row, " ")

		for i, char := range splitted {
			if i == 0 {
				continue
			}
			num, _ := strconv.Atoi(char)
			votes[num-1]++
		}
	}

	answer := 0
	for i := 0; i < M; i++ {
		if votes[i] == N {
			answer++
		}
	}

	fmt.Println(answer)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int w,a,b;
    cin >> w >> a >> b;
    if(b+w < a){
        cout << a-b-w << endl;
    }else if(a+w < b){
        cout << b-a-w << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll mu(ll a) {
    return a * a * a * a * a;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    ll x;
    cin >> x;
    FOR(i,-1000,1000)
        FOR(j,-1000,1000)
            if (mu(i) - mu(j) == x) {
                cout << i << ' ' << j;
                return 0;
            }
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    VL dp(n+1,inf);
    dp[0]=0;
    VL arr;
    arr.pb(1);
    ll op=1;
    while(power(6,op)<=n)
    {
        arr.pb(power(6,op));
        op++;
    }
    op=1;
    while(power(9,op)<=n)
    {
        arr.pb(power(9,op));
        op++;
    }
    sort(ALL(arr));
    fr(i,1,n+1)
    {
        fr(j,0,SZ(arr))
        {
            if(i-arr[j]>=0)
            {
                dp[i]=min(dp[i],1+dp[i-arr[j]]);
            }
        }
    }

    cout<<dp[n]<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
    int a,b;
    cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
}

Measured memory_bytes: 256
"use strict";

function main(input) {
  input = input.split("\n");
  if (input[0].length + 1 == input[1].length) {
    const str1 = input[0].split("");
    const str2 = input[1].split("");
    for (let i = 0; i < str1.length; i++) {
      if (str1[i] !== str2[i]) {
        console.log("No");
        return;
      }
    }
  }
  console.log("Yes");
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes";break;
		}
		a-=d;
		if(a<=0){
			cout<<"No";break;
		}
	}
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

int main()
{
	int c[3][3];
	rep(i, 3)
	{
		rep(j, 3)
		{
			cin >> c[i][j];
		}
	}

	bool ans = true;
	//h
	int diff;
	rep(i, 2)
	{

		if (c[0][i] - c[0][i + 1] != c[1][i] - c[1][i + 1])
		{
			ans = false;
		}
		if (c[1][i] - c[1][i + 1] != c[2][i] - c[2][i + 1])
		{
			ans = false;
		}
	}
	
	rep(i, 2)
	{

		if (c[i][0] - c[i + 1][0] != c[i][1] - c[i + 1][1])
		{
			ans = false;
		}
		if (c[i][1] - c[i + 1][1] != c[i][2] - c[i + 1][2])
		{
			ans = false;
		}
	}

	if (ans)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  int n,flag=0;
  int a,b;
  scanf("%d",&n);
  int count=0;
  for(int i=0;i<n;i++)
  {
    scanf("%d %d",&a,&b);
    if(a==b)
    {
      count++;
      if(count>2)
      {
        printf("Yes");
        flag=1;
        break;
      }
    }else{
      count=0;
    }
    
  }
  if(flag==0)
  {
    if(count>2)
    {
      printf("Yes");
    }else{
      printf("No");
    }
  }
	return 0;
}

Measured memory_bytes: 3220
#include<stdio.h>
 
int main(){
    int a, b ,c ,max,min,middle;
     
    scanf("%d %d %d", &a, &b, &c);
    
    max = a; 
    if (b >= max) {
      middle = a;
      max = b;
    } else {
       middle = b;
    }

    if (c >= max) {
       min = middle;
       middle = max;
       max = c;
    } else if (c >= middle) {
       min = middle;
       middle = c;
    } else {
       min = c;
    }

    printf("%d %d %d\n", min, middle, max);
     
    return 0;
}
	

Measured memory_bytes: 1848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

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

using namespace std;

int main()
{
    int n,q;
    while(cin >> n >> q)
    {
        if(n == 0 && q == 0) break;

        int cnt[105];
        memset(cnt,0,sizeof(cnt));
        rep(i,n) {
            int m;
            cin >> m;

            rep(j,m) {
                int date;
                cin >> date;
                
                cnt[date]++;
            }
        }
        
        int vmax = 0;
        rep(i,105) vmax = max(vmax,cnt[i]);

        if(vmax < q) cout << 0 << endl;
        else {
            rep(i,105) {
                if(cnt[i] == vmax) {
                    cout << i << endl;
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1160
n = gets.to_i

def check(ax, ay, bx, by, cx, cy, dx, dy)
    ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
    tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
    tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
    td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
    return (tc * td <= 0 && ta * tb <= 0) ? 1 : 0
end

n.times do
    x1,y1,x2,y2,x3,y3,xk,yk,xs,ys=gets.chomp.split(" ").map(&:to_i)
    if (check(x1,y1,x2,y2,xk,yk,xs,ys) + check(x2,y2,x3,y3,xk,yk,xs,ys) + check(x3,y3,x1,y1,xk,yk,xs,ys)).odd?
        puts "OK"
    else
        puts "NG"
    end
end



Measured memory_bytes: 6960
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>

#define ll long long

using namespace std;

int main()
{
    int a, b; cin >> a >> b;
    string ans;
    if ((a*b) % 2 != 0) {
        ans = "Yes";
    }
    else {
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}


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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


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

    if(n<=3) {
        cout << "No" << endl;
        return 0;
    }
    else {
        int cnt4=0;
        while(4*cnt4<=n) {
            if((n-4*cnt4)%7==0) {
                cout << "Yes" << endl;
                return 0;
            }
            cnt4++;
        }
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, k;
	while (cin >> n >> k) {
		if (n == 0 && k == 0) {
			break;
		}

		vector<ll> a(n);
		for (auto &v : a) {
			cin >> v;
		}

		vector<ll> memo(n + 1);
		for (int i = 1; i <= n; i++) {
			memo[i] = memo[i - 1] + a[i - 1];
		}

		ll ans = INT_MIN;
		for (int i = 0; i < n - k; i++) {
			ll score = memo[i + k] - memo[i];
			ans = max(ans, score);
		}

		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const int INF = 1LL << 30;
int n,m,k;
vector<int> to[100100];
vector<int> brock[100100];
bool used[100100];
map<int,int> mp; //person to group
vector<int> grp_n; //number of people in each group

void bfs(int sv, int g){
    queue<int> q;
    q.push(sv);
    used[sv] = true;
    int n = 0;
    while(!q.empty()){
        int v = q.front(); q.pop();
        n++;
        mp[v] = g;
        for(auto tv : to[v]){
            if(used[tv]) continue;
            used[tv] = true;
            q.push(tv);
        }
    }
    grp_n.push_back(n);
}
int main(){
    cin >> n >> m >> k;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,k){
        int c,d;
        cin >> c >> d;
        c--; d--;
        brock[c].push_back(d);
        brock[d].push_back(c);
    }
    int grp = 0;
    rep(i,n){
        if(used[i]==false){
            bfs(i, grp);
            grp++;
        }
    }
    rep(i,n){
        int ans = grp_n[mp[i]]-1;
        for(auto tv : to[i]){
            if(mp[i]==mp[tv]) ans--;
        }
        for(auto bv : brock[i]){
            if(mp[i]==mp[bv]) ans--;
        }
        cout << ans << endl;
    }
    return 0;
}

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

string s,t;

int main(){
	while(cin >> s >> t){
		for(int i=0;i<s.size()-1;i++){
			for(int j=i+1;j<s.size();j++)
				if(s[i]>s[j]){
					char s0 = s[i];
					s[i] = s[j];
					s[j] = s0;
				}			
		}
		for(int i=0;i<t.size()-1;i++){
			for(int j=i+1;j<t.size();j++)
				if(t[i]<t[j]){
					char t0 = t[i];
					t[i] = t[j];
					t[j] = t0;
				}				
		}
		if(s<t) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

#define MAXN 1001

struct Node
{
    string name;
    int a, b;
}node[MAXN];


int n, m;

void input()
{
    int a, b;

    while (cin >> n >> m)
    {
        if (!n && !m)
        {
            break;
        }

        for (int i = 0; i < n; i++)
        {
            cin >> node[i].name;
            cin >> a >> b;
            node[i].a = b - a + 1;
            node[i].b = b;
        }

        for (int i = 0; i < m; i++)
        {
            cin >> a;
            bool flag = false;

            for (int i = 0; i < n; i++)
            {
                if (node[i].a <= a && a <= node[i].b)
                {
                    cout << node[i].name << ' ' << a - node[i].a + 1<< endl;
                    flag = true;
                    break;
                }
            }

            if (!flag)
            {
                cout << "Unknown" << endl;
            }
        }
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    input();
    return 0;
}

Measured memory_bytes: 1328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll n,t;
  cin>>n>>t;

  ll a[111111];
  ll mi=MOD,ma=0;
  ll ans=1;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mi=min(mi,a[i]);
    if(a[i]-mi==ma){
	 ans++;
    }else if(a[i]-mi>ma){
	 ans=1;
	 ma=a[i]-mi;
    }
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	float tak = ceil(c/(float)b);
	int aok = ceil(a/(float)d);
	//cout<<tak<<' '<<aok<<'\n';
	if(tak<=aok){
		cout<<"Yes"<<'\n';
	}
	else{
		cout<<"No"<<'\n';
	}
	return 0;
}// c/b     a/d

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>

main(){

  int i,j;
  int C[37][2];
  int Bub[37][2];
  int Sel[37][2];
  int N;
  int tmpi;
  char tmpc;
  char str[3];
  int mini,isStable;

  scanf("%d",&N);

  for(i=1; i<=N;i++){
    scanf("%s",str);
    C[i][0] = Bub[i][0] = Sel[i][0] = atoi(&str[1]);
    C[i][1] = Bub[i][1] = Sel[i][1] = str[0];
  }

  // bubble
  for (i=1; i<=N; i++){

    for (j=N; j>=i+1; j--){

      if(Bub[j][0] < Bub[j-1][0]){
	
	tmpi = Bub[j][0];
	tmpc = Bub[j][1];
	Bub[j][0] = Bub[j-1][0];
	Bub[j][1] = Bub[j-1][1];
	Bub[j-1][0] = tmpi;
	Bub[j-1][1] = tmpc;

      }

    }

  }

  // selection
  for (i=1; i<=N; i++){
    mini = i;
    for (j=i; j<=N; j++){
      if(Sel[j][0] < Sel[mini][0]){
	mini = j;
      }
    }
    if(i != mini){
      
      tmpi = Sel[i][0];
      tmpc = Sel[i][1];
      Sel[i][0] = Sel[mini][0];
      Sel[i][1] = Sel[mini][1];
      Sel[mini][0] = tmpi;
      Sel[mini][1] = tmpc;
      
    }

  }

  isStable = 1;

  // DISPLAY
  for (i=1; i<=N; i++){
    printf("%c%d",Bub[i][1],Bub[i][0]);

    // SAME NUMBER
    if(isStable==1 && i>1 && Bub[i][0] == Bub[i-1][0]){
      for(j=1; j<=N; j++){
	if(C[j][0]==Bub[i][0] && C[j][1]==Bub[i][1]){
	  isStable = 0;
	  break;
	}
	if(C[j][0]==Bub[i-1][0] && C[j][1]==Bub[i-1][1]){
	  break;
	}
      }
    }

    if(i!=N){
      printf(" ");
    }
  }

  printf("\n");
  if(isStable==1){
    printf("Stable");
  }else{
    printf("Not stable");
  }
  printf("\n");

  isStable = 1;

  for (i=1; i<=N; i++){
    printf("%c%d",Sel[i][1],Sel[i][0]);

    // SAME NUMBER
    if(isStable==1 && i>1 && Sel[i][0] == Sel[i-1][0]){
      for(j=1; j<=N; j++){
	if(C[j][0]==Sel[i][0] && C[j][1]==Sel[i][1]){
	  isStable = 0;
	  break;
	}
	if(C[j][0]==Sel[i-1][0] && C[j][1]==Sel[i-1][1]){
	  break;
	}
      }
    }

    if(i!=N){
      printf(" ");
    }
  }

  printf("\n");
  if(isStable==1){
    printf("Stable");
  }else{
    printf("Not stable");
  }
  printf("\n");

return 0;

}

Measured memory_bytes: 0
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    li x;
    cin>>x;
    cout<<((x<1200)?"ABC":"ARC")<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def solve(N: int, K: int):
    ans = 0
    while N >= K:
        N //= K
        ans += 1

    
    print(ans+1)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)



if __name__ == "__main__":
    main()


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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e3 + 5;
bool isPrime[MAXN];
void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}
ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}
//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}


int main() {
    FAST
int n,m;
    cin>>n>>m;
    ll arr[n];
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
   
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(4*arr[i]*m>=sum)
            c++;
    }
    if(c>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  set<int> ans;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(ans.find(a)!=ans.end()){
      ans.erase(a);
    }else{
      ans.insert(a);
    }
  }
  cout<<ans.size()<<endl;
  return 0;
}


Measured memory_bytes: 4864
using System;
using System.Linq;

namespace A_Point_in_Triangle
{
    class Vector 
    {
        public double X { get; set; }
        public double Y { get; set; }
    }
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string str = Console.ReadLine();
                if (string.IsNullOrEmpty(str))
                {
                    break;
                }

                var inputCordinate = str.Split().Select(double.Parse).ToList();
                Vector a = new Vector() { X = inputCordinate[0], Y = inputCordinate[1] };
                Vector b = new Vector() { X = inputCordinate[2], Y = inputCordinate[3] };
                Vector c = new Vector() { X = inputCordinate[4], Y = inputCordinate[5] };
                Vector p = new Vector() { X = inputCordinate[6], Y = inputCordinate[7] };

                var answer = (IsInTriangle(a, b, c, p)) ? "YES" : "NO";
                Console.WriteLine(answer);
                              
            }




        }

        static Vector SubVector(Vector a, Vector b)
        {
            Vector result = new Vector()
            {
                X = a.X - b.X,
                Y = a.Y - b.Y
            };
            return result;
        }

        static bool IsInTriangle(Vector a, Vector b, Vector c, Vector p) 
        {
            Vector ab = SubVector(b, a);
            Vector bp = SubVector(p, b);

            Vector bc = SubVector(c, b);
            Vector cp = SubVector(p, c);

            Vector ca = SubVector(a, c);
            Vector ap = SubVector(p, a);

            double c1 = ab.X * bp.Y - ab.Y * bp.X;
            double c2 = bc.X * cp.Y - bc.Y * cp.X;
            double c3 = ca.X * ap.Y - ca.Y * ap.X;

            if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0))
            {
                return true;
            }
            return false;
        }

    }
}



Measured memory_bytes: 16300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    double N, K;
    cin >> N >> K;
    vector<double> sum(N + 1);
    sum[0] = 0;
    for (int i = 1; i <= N; i++) {
        double a;
        cin >> a;
        sum[i] = (1 + a) / 2;
        sum[i] += sum[i - 1];
    }

    double ans = 0;
    for (int i = 0; i + K <= N; i++) {
        ans = max(ans, sum[i + K] - sum[i]);
    }

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;


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

	int A[3][110];
	for(int i=0;i<N;++i)cin>>A[0][i];
	for(int i=0;i<N;++i)cin>>A[1][i];


	int asw=0;

	for(int i=0;i<N;++i){

		int count=A[1][i];

		for(int j=0;j<N;++j){
			if(j<=i)count+=A[0][j];
			else count+=A[1][j];
		}
		asw=max(asw,count);
	}

	cout<<asw<<endl;
	return 0;
}


Measured memory_bytes: 256
s = input()
l = len(s)


def is_kaibun(s):
    ans = True
    n = len(s)
    for i in range(n):
        if s[i] != s[n-1-i]:
            ans = False
    return ans

if is_kaibun(s) and is_kaibun(s[0:(l-1)//2]) and is_kaibun(s[(l+1)//2:]):
    print('Yes')
else:
    print('No')


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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	vector<int> cnt(10);
	for (int i = 0; i < 3; i++) {
		int s;
		cin >> s;
		cnt[s]++;
	}
    if (cnt[5] == 2 && cnt[7] == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 200005;
int n;
int32_t main()
{
    cin >> n;
    LL ans = 0;
    for(int i = 1;i < n;i++){
        int u , v;
        cin >> u >> v;
        if(u > v)swap(u,v);
        LL l = u;
        LL r = (n - v + 1);
        ans += (l * r);
    }
    LL ret = 0;
    for(LL i = 1;i <= n;i++){
        ret += (i * (n - i + 1));
    }
    cout << ret - ans << "\n";

}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

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

    int first = n%10;
    
    switch(first){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 3:
        cout << "bon" << endl;
        break;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 
#define ll long long
#include<fstream>
int main()
{
	ll n;cin>>n;string s;cin>>s;
	ll pre[n];ll red=0;ll white=0;
	if(s[0]=='R'){
	red++;
	pre[0]=1;}
	else{
	white++;
	pre[0]=0;}
	for(ll i=1;i<n;i++)
	{
		if(s[i]=='R'){
		red++;
		pre[i]=pre[i-1]+1;}
		else{
		white++;
		pre[i]=pre[i-1]+0;}
	}
	ll mi=min(white,red);
	for(ll i=0;i<n;i++)
	{
		ll right_red=pre[n-1]-pre[i];
		ll left_white=i+1-pre[i];
		mi=min(mi,max(right_red,left_white));
		
	}
	cout<<mi<<endl;
	return 0;
}
		

Measured memory_bytes: 5312
def resolve():
    D = int(input())
    cost = list(map(int, input().split()))
    sat = [list((map(int, input().split()))) for _ in range(D)]
    last = [0]*26

    for i in range(D):
        maxcost = 0
        ans = 0
        for j in range(26):
            if maxcost <= sat[i][j]:
                ans = j+1
                maxcost = sat[i][j]
        print(ans)
resolve()

Measured memory_bytes: 68484
#include <stdio.h>
#include <math.h>
#define Mx 10000
#define Mk 9

int N, K;
int D[Mk];

int check(int a){
    int i, j, n, m;
n=a;
while(n!=0){
        m = n%10;
        for (j=0; j<K; j++)
            if (m==D[j]) return 1;
            n/=10;
}
    return 0;
}

int main(){
    int i;
    scanf("%d%d", &N, &K);
    for (i=0; i<K; i++)
        scanf("%d", &D[i]);

    i=N;
    while (1)
    {
        if(check(i)==0)break;
        else
        {
            i++;
        }
    }

    printf("%d\n", i);

    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll dp[100010][2];
// i : 調べている桁
// smaller : 対象の数字未満であることが確定しているならば1、そうでなければ0

int main()
{
    cout << fixed << setprecision(15);
    string L;
    cin >> L;

    ll l = L.size();  //Lの長さ
    
    ll ans = 1;
    ll pow3 = 1;

    reverse(L.begin(), L.end());
    for(ll i=0; i<l; i++){
        if(L[i] == '1'){
            ans = ((ans*2)%MOD + pow3) % MOD;
        }
        pow3 = (3*pow3) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512