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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	int n ;cin  >> n;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];

	int count = 0;
	ll ans = 0;
	ll m = abs(v[0]);
	rep(i,n){
		if(v[i]<0){
			count ++ ;
		}
		ans += abs(v[i]);
		chmin(m,abs(v[i]));
	}
	if(count %2 ==1 ){
		ans -= 2 * m;
	}
	cout << ans << endl;

}


Measured memory_bytes: 1024
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define print(a) cout << a << endl;
#define cin(x) cin >> x;

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int N=0, M=0;
    cin(N);cin(M);
    vector<int> X(M,0);
    REP(i,M){cin(X.at(i))};

    int count=0;
    if(N>=M){cout <<  0;};
    if(N<M){
      sort(X.begin(),X.end());
      vector<int> diff(M-1);
      count = X.at(M-1)-X.at(0);
      REP(i,M-1){
        diff.at(i) = X.at(i+1) - X.at(i);
      }
      sort(diff.begin(),diff.end());
      reverse(diff.begin(),diff.end());
      REP(i,N-1){
        count -= diff.at(i);
      }

      cout << count;
    }

  
  return 0;
}

Measured memory_bytes: 3888
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			String line = sc.next();
			String word = sc.next();
			System.out.println((line + line).indexOf(word) >= 0 ? "Yes" : "No");
		}
	}
}



Measured memory_bytes: 26184
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    VI a(1<<n);
    REP(i,1<<n) cin >> a[i];
    REP(x,n){
        VI b;
        REP(i,a.size()/2){
            int x = a[2*i], y = a[2*i+1];
            if (x != y) b.push_back(abs(x-y));
            else b.push_back(x);
        }
        a = b;
    }

    cout << a[0] << endl;

    return 0;
}

Measured memory_bytes: 2044
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = A.copy()
    for i in reversed(range(1, N // 2 + 1)):
        tag = i * 2
        tmp = 0
        while tag <= N:
            tmp += ans[tag - 1]
            tag += i
        ans[i - 1] = 1 if tmp % 2 != ans[i - 1] else 0

    print(sum(ans))
    s = ''
    for i, a in enumerate(ans, 1):
        if a == 1:
            s += str(i) + ' '
    if s != '':
        print(s.strip())


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9916
# coding-utf8 #

n = int(input())
num_list = list(map(int, input().split()))

alice_sum = 0
bob_sum = 0

num_list.sort(reverse=True)

for i in range(n):
  if i % 2 == 0:
    alice_sum += num_list[i]
  else:
    bob_sum += num_list[i]

print(alice_sum - bob_sum)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,lst,fac[30];
int main()
{
	fac[0]=1;
	for(int i=1;i<=13;i++)fac[i]=fac[i-1]*26;
	cin>>n;
	ll m=26,n2=n;
	while(n2>0)
	{
		n2-=m;
		m*=26;
		lst++;
	}
	for(int i=lst-1;i>=1;i--)n-=fac[i];
	for(int i=lst;i>=1;i--)
	{
		char c='a';
		while(n>fac[i-1])
		{
			n-=fac[i-1];
			c++;
		}
		cout<<c;
	}
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int h, w;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  int c = 0;
  FOR(i, 0, h){
    cin >> s;
    FOR(j, 0, w)if(s[j] == '#') c++;
  }
  cout << ((c == h+w-1) ? "Possible" : "Impossible") << endl;
  return 0;
}

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

int main() {
	string S;
	cin >> S;
	int len = (int)S.size(), mid = len / 2;
	string s1 = S.substr(0, mid), s2 = S.substr(mid + 1);
	int flag = 0;
	for (int i = 0; i < mid / 2; i++) {
		if (s1.at(i) != s1.at((int)s1.size() - i - 1) || s2.at(i) != s2.at((int)s1.size() - i - 1)) {
			flag = 1;
		}
	}
	if (s1 != s2) {
		flag = 1;
	}

	if (flag == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

/*
問題文


*/

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

        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();

    int ans = 0;
    
    ans += s / 500 * 1000;
    ans += (s % 500)/ 5 * 5;
        System.out.println(ans);
    }
}

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

int main(){
  int s;
  cin>>s;
  int a=s;
  int m=2;
  vector<bool> seen(2000000,false);
  seen.at(a)=true;
  while(1){
    if(a%2==0){
      a/=2;
    }else{
      a=3*a+1;
    }
    if(seen.at(a)){
      cout<<m<<endl;
      break;
    }
    seen.at(a)=true;
    m++;
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>

using namespace std;

int main() {
  
  int N;
  cin >> N;
  
  int currentHeight = 0;
  int lastHeight = 0;
  int step = 0;
  int maxStep = 0;
  
  for (int i = 0; i < N; i++) {
  	cin >> currentHeight;
    if (currentHeight <= lastHeight) {
      step++;
      maxStep = max(step, maxStep);
    } else {
      step = 0;
    }
    lastHeight = currentHeight;
  }  
  cout << maxStep;
 return 0; 
}

Measured memory_bytes: 256
# coding: utf-8

h, w = map(int, raw_input().split())

pic = [["#" for _j in xrange(w+2)] for _i in xrange(h+2)]

for i in xrange(h):
    aij = raw_input()

    for j in xrange(len(aij)):
        pic[i+1][j+1] = aij[j]

for p in pic:
    print "".join(p)


Measured memory_bytes: 2692
#include<stdio.h>
#define M 20
int n,i,x,res,A[M];

int solve(int i, int x){
  if(x == 0)return 1;
  else if(i>=n)return 0;
  res = solve(i+1, x)|| solve(i+1, x-A[i]);
 return res;
  
}

int main(){
  int m;
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
   scanf("%d", &m);
  for(i=0; i<m; i++){
    scanf("%d", &x);
    if(solve(0,x)== 1)printf("yes\n");
    else if(solve(0,x)== 0)printf("no\n");
  }


  return 0; 
  
}



Measured memory_bytes: 2048
# 初期入力
from itertools import product
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
num_suitch =[-1]*M
switch =[[]for i in range(M)]
for i in range(M):
    k,*s = (int(i) for i in input().split())
    num_suitch[i] =k
    switch[i] =s
p = list(map(int, input().split()))

#スイッチのON、OFFを全探索。スイッチの組み合わせで全ての電球がつけばカウント
count =0
for on in product([0,1],repeat=N): #N個の スイッチ
    light =[0]*M
    index_on =[i+1 for i, x in enumerate(on) if x == 1] 
    for j in range(M):                      # M 個の電球       
        l =set(index_on) & set(switch[j])
        if len(l) %2 ==p[j]:
            light[j] =1
    if sum(light) ==M:
        count +=1
print(count)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define ll unsigned long long

ll gcd(ll a, ll b) {
    if(a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

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

int main() {
    string s,t;
    cin >> s>> t;
    cout << t << s << endl;
}


Measured memory_bytes: 256
// Made by Luis Miguel Baez
// es.luismiguelbaez@gmail.com
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define precise(n,k) fixed << setprecision(k) << n
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
 
#define uint  unsigned int
#define ll    long long
#define ull   unsigned long long
#define ld    long double
 
#define pii   pair<int, int>
#define piii  pair<int, pair<int, int>>
#define pll   pair<ll, ll>
 
#define F  first
#define S  second
#define PB push_back
#define MP make_pair
 
#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
string to_string(string s) {
    return '"' + s + '"';
}
 
string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename T>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const T &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string((T)x);
    }
    res += "}";
    return res;
}
 
// add templates here
 
template<class T>
void println(const vector<T> &data) {
    cout << to_string<vector<T>, T>(data) <<endl;
}
 
template<class T>
void println(const T &data) {
    cout << to_string((T)data) << endl;
}
 
const int MOD = int(1e9+7);
const int oo  = int(1e9 + 20);
const ll lloo  = (ll)(1e18 + 10);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, m;
    cin >> n >> m;
    if(n < m) {
        cout << "0" << endl;
    } else {
        cout << "10" << endl;
    }
    // your code goes here
 
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    vi T(N+1);
    rep(i, N) cin >> T[i];
    T[N] = 0;
    SORT(T);

    int res = INF;
    int lp=0, rp=0;
    FOR(i, 1, N+1) {
        if(i%2) {
            res = min(res, T[i]-lp);
            lp = T[i];
        } else {
            res = min(res, T[i]-rp);
            rp = T[i];
        }
        res = min(res, (12-lp)+(12-rp));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e;
	scanf("%d",&a);
	for(b=1;b<=a;b++){
		scanf("%d%d%d",&c,&d,&e);
		if(c<d+e){
			printf("No");
			return 0;
		}
		if(c%2!=(d+e)%2){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
using System;

namespace PrintTestCases
{
	class MainClass
	{
		public static void Main (string[] args)
		{   
			int i=0;

			while(true)
			{
				string input = Console.ReadLine();
				int x = int.Parse (input);
				i++;
				if(x==0)
				break;
				Console.WriteLine ("Case"+" " + i + ":"+" "+ x);
			}
		}
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n; cin >> n;
  string s; cin >> s;
  int cnt = 0;
  for(int i=0;i<n-2;++i) {
    if(s.substr(i, 3) == "ABC") cnt++;
  }
  cout << cnt << endl;

}


Measured memory_bytes: 384
MOD = 10**9 + 7

N, M, K = map(int, input().split())

invs = [1] * (K-1)
for x in range(2, K-1):
    invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD

C = 1
for x in range(N*M-K+1, N*M-1):
    C *= x
    C %= MOD
for x in range(1, K-1):
    C *= invs[x]
    C %= MOD

ans1 = 0
for d in range(1, N):
    ans1 += (N-d) * d
    ans1 %= MOD
ans1 *= M**2
ans1 %= MOD

ans2 = 0
for d in range(1, M):
    ans2 += (M-d) * d
    ans2 %= MOD
ans2 *= N**2
ans2 %= MOD

print((ans1+ans2) * C % MOD)


Measured memory_bytes: 10868
package main

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

type Node struct {
	value int
	left *Node
	right *Node
}


/****************************************************************
*関数insert():													*
*	 挿入される二分探索木のrootノードを表すポインタrootと				*
*	 挿入したいノードのvalueを引数に、適切な葉に新たなノードを挿入して、	*
*	 挿入された二分探索木のルートノードのポインタを返す関数				*
*****************************************************************/
func insert(root *Node, val int) *Node {

	// 二分探索木がまだ構築されていないときはここが呼び出される
	if root == nil {
		return &Node{val, nil,nil}
	}

	// すでにある二分探索木に対するノード（value: val）を挿入する
	// ここを抜けるとparentに挿入されるノードの親へのポインタが入っている
	// 変数nodeは、挿入すべき場所を探すための一時的なポインタ変数
	var parent *Node
	node := root
	for node != nil {
		parent = node
		if node.value > val {
			node = node.left
		} else {
			node = node.right
		}
	}

	// 新たなノードの挿入を実行
	if parent.value > val {
		parent.left = &Node{val, nil,nil}
	} else {
		parent.right = &Node{val, nil, nil}
	}

	// 二分探索木の根は変わらないのでそのまま返す
	return root
}

func printNodes(nodes []int) {
	// 木の走査によって得られたint型スライスを引数に、
	// 指定されたフォーマットに出力する関数
	writer := bufio.NewWriter(os.Stdout)
	for _, v := range nodes{
		writer.Write([]byte(fmt.Sprintf(" %d", v)))
	}
	writer.Write([]byte("\n"))
	writer.Flush()
}

func preorder(root *Node, memo []int) []int {
	// 引数rootが根となっている二分探索木に対して先行巡回によって
	// 各ノードをを舐めて、引数memoで与えられる空のスライスに書き込み、
	// 書き込まれた後のスライスを返す関数
	if root != nil {
		memo = append(memo, root.value)
		memo = preorder(root.left, memo)
		memo = preorder(root.right, memo)
	}
	return memo
}

func inorder(root *Node, memo []int) []int {
	// 引数rootが根となっている二分探索木に対して中間巡回によって
	// 各ノードをを舐めて、引数memoで与えられる空のスライスに書き込み、
	// 書き込まれた後のスライスを返す関数
	if root != nil {
		memo = inorder(root.left, memo)
		memo = append(memo, root.value)
		memo = inorder(root.right, memo)
	}
	return memo
}

func main() {
	var n int
	var root *Node
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _  = strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		operation := scanner.Text()
		switch operation {
		case "insert":
			scanner.Scan()
			value, _ := strconv.Atoi(scanner.Text())
			root = insert(root, value)
		case "print":
			printNodes(inorder(root, []int{}))
			printNodes(preorder(root, []int{}))
		}
	}
}


Measured memory_bytes: 51832
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S, T;

int main()
{
	in >> S >> T;

	if (S.length() < T.length())
	{
		out << "UNRESTORABLE" << std::endl;
		return 0;
	}
	for (int i = S.length() - T.length(); i >= 0; --i)
	{
		bool ok = true;
		for (int j = i; (j - i) < T.length(); ++j)
		{
			if (S[j] != '?'&&S[j] != T[j - i])
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			rep(j, i)
			{
				if (S[j] == '?') { S[j] = 'a'; }
				out << S[j];
			}
			out << T;
			for (int j = i + T.length(); j < S.length(); ++j)
			{
				if (S[j] == '?') { S[j] = 'a'; }
				out << S[j];
			}
			out << std::endl;
			return 0;
		}
	}
	out << "UNRESTORABLE" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


//////////////////////////////////////////////////////////////////////////////////////

int main(){
    string s;
    cin >> s;
    long long sum = 0;
    for (char x : s){
        sum += x - '0';
    }

    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



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

using namespace std; 

typedef long long ll;

int main(){
	// freopen("test.txt","r",stdin);
	cin.sync_with_stdio(0); cin.tie(0);
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	if (K%2 == 0){
		cout << A - B;
	}
	else{
		cout << B - A;
	}

	return 0;	
}

Measured memory_bytes: 256
s=input()
t=""
w=["dreameraser","dreamerase","dreamer","dream","eraser","erase"]
for i in range(10**5):
    for j in range(6):
        temp=t
        temp+=w[j]
        if temp[len(t):len(temp)]==s[len(t):len(temp)]:
                t+=w[j]
                break
    if s==t:
        print("YES")
        exit()
print("NO")
exit()
        

Measured memory_bytes: 9236
h,m,M=60;P(s){printf("0%d:%02d:%02d\n",s/M/M,s/M%M,s%M);}main(s){for(;scanf("%d%d%d",&h,&m,&s)+h*3;P(s*3))P(s=7200-h*M*M-m*M-s);}///////////

Measured memory_bytes: 612
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    int ans = 0;
    for (int i = 0; i < N - 2; i++) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld n,i,j,p,k;char ch;cin>>ch;
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
    	cout<<"vowel";
    else
    	cout<<"consonant";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if ((A == B and A != C)
      or (A == C and A != B)
      or (B == C and B != A)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	int N;
	int a[200010];

	int cnt = 0;
	int cur = 1;

	cin >> N;
	rep(i, N)
	{
		cin >> a[i];

		if (a[i] == cur)
			cur++;
		else
			cnt++;
	}

	if (cur == 1 && cnt == N)
		cout << -1;
	else
		cout << cnt;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define vll vector<pair<ll, ll> >
#define vl vector<ll>
#define vi vector<int>
#define vii vector<pair<int, int> >
const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
using namespace std;

ll power_mod(ll x, ll y, ll p)
{
	ll ans = 1;
	x = x%p;
	if(x==0)
	return p;

	while(y>0)
	{
		if(y&1)
		{
			ans = (ans*x)%p;
		}
		y = y>>1;
		x = (x*x)%p;
	}
	return ans;
} 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll i,j,k,l,m,n;
	cin>>n;
	vi a(n, 0);
	bool ok = false;
	for(i=0;i<n;i++)
	{
	    cin>>a[i];
	    if(a[i]==1)
	    ok = true;
	}
	if(!ok)
	{
	    cout<<"-1";
	}
	else
	{
	    ll count= 1, sum=0;
	    for(i=0;i<n;i++)
	    {
	        if(a[i]==count)
	        {
	            count++;
	        }
	        else
	        {
	            sum++;
	        }
	    }
	    cout<<sum;
	}
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
int a,b,c,k,x,y,z,ans;
int main() 
{
  cin>>a>>b>>c>>k;
  x=a+b;
  y=k-x;
  if(k<=a)
  {
      cout<<k;
      return 0;
  }
  else
  {
      if(k<=x)
      {
          cout<<a;
          return 0;
      }
      else
      {
          cout<<a-y;
          return 0;
      }
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
ll dp[maxn], arr[maxn], n, k;

int main() {
    cin>>n>>k;;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
    }
    dp[1] = 0LL;
    dp[2] = abs(arr[2] - arr[1]);
    for(int i=3;i<=n;i++) {
        dp[i] = LLONG_MAX;
        for(int j=i-1;j>=max(1LL, i-k);j--) {
            dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
        }
    }
    cout<<dp[n]<<"\n";
    return 0;
}


Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(1,n-1):
    if p[i-1]<=p[i]<=p[i+1] or p[i+1]<=p[i]<=p[i-1]:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(final String... args) {
        final String mode = "b";

        if (mode.equals("a")) {
            A.solve();
        } else if (mode.equals("b")) {
            B.solve();
        } else if (mode.contentEquals("c")) {
            C.solve();
        }
    }
}

class B {
    static void solve() {
        final Scanner sc = new Scanner(System.in);
        final String str = sc.nextLine();
        final char[] s = str.toCharArray();
        final boolean res = calc(s);
        if (res) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static boolean calc(final char[] s) {
        if (cond1(s) && cond2(s)) {
            return true;
        }
        return false;
    }

    private static boolean cond1(final char[] s) {
        for (int i = 0; i < s.length; i += 2) {
            if (s[i] == 'L') {
                return false;
            }
        }
        return true;
    }

    private static boolean cond2(final char[] s) {
        for (int i = 1; i < s.length; i += 2) {
            if (s[i] == 'R') {
                return false;
            }
        }
        return true;
    }
}

class C {

    static void solve() {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int k = sc.nextInt();
        final int q = sc.nextInt();
        final int[] a = new int[q];
        for (int i = 0; i < q; i++) {
            a[i] = sc.nextInt();
        }
        final int[] res = calc(n, k, q, a);
        for (final int p : res) {
            if (q - p < k) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

    static int[] calc(final int n, final int k, final int q, final int[] correctors) {
        final int[] points = new int[n];
        for (final int col : correctors) {
            points[col - 1]++;
        }
        return points;
    }
}

class A {
    static void solve() {
        final Scanner sc = new Scanner(System.in);
        final int r = sc.nextInt();
        final int res = calc(r);
        System.out.println(res);
    }

    static int calc(final int r) {
        return 3 * r * r;
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  int n;cin>>n;
  long long sum=0;
  multiset<int> s{};
  REP(i,n){
    int tmp; cin>>tmp;
    s.insert(tmp);
    sum+=tmp;
  }
  cout<<*(s.begin())<<" "<<*(s.rbegin())<<" "<<sum<<endl;
}

Measured memory_bytes: 1672
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll K;
  cin >> K;
  vector<ll> A(K);
  for (ll i = 0; i < K; ++i)
  {
    cin >> A.at(i);
  }
  if (A.at(K - 1) != 2)
  {
    cout << -1 << endl;
    return 0;
  }
  ll l = 2, r = 2;
  for (ll i = K - 1; i >= 0; --i)
  {
    l = (l + A.at(i) - 1) / A.at(i) * A.at(i);
    r = r / A.at(i) * A.at(i) + A.at(i) - 1;
    if (r < l)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << ' ' << r << endl;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(200000)

n = int(input())
edge = [[] for _ in range(n)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    edge[u].append((v, w))
    edge[v].append((u, w))


visited = [0] * n
ans = [0] * n
def dfs(u, d):
    for i in range(len(edge[u])):
        v, w = edge[u][i]
        if visited[v] == 0:
            ans[v] = (d + w) % 2
            visited[v] = 1
            dfs(v, d + w)


visited[0] = 1
dfs(0, 0)
for a in ans:
    print(a)



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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	ll a , b , k ;
	cin >>  a >> b >> k ;
	ll c = a; 
	a -= min(a,k);
	if(a==0){
		b -= min(b, k - c);
	}
	cout << a << " " << b << endl;
}


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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    string s;
    cin>>s;
    int ans = 0;
    int i = 0; 
    int j = n - 1;
    while(i < j){
        while(i < n && s[i] != 'W'){
            i++;
        }
        while(j >= 0 && s[j] != 'R'){
            j--;
        }
        if(i < j && s[i] == 'W' && s[j] == 'R'){
            ans++;
            i++;
            j--;
        }
    }
    cout<<ans;    
}

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

int N, M;
int cnt[100100];

signed main() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        ++cnt[a];
        ++cnt[b];
    }
    rep(i, N) {
        if (cnt[i] % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    int k; cin>>k;
    string s; cin>>s;
    if(s.size()<=k){
        cout<<s<<endl;
    }else {
        string ss=s.substr(0,k);
        ss+="...";
        cout<<ss<<endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = n / (a+b) * a + min(a, (n - n / (a+b) * (a+b)));
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  int count = 0;
  rep(i, n-2) {
    if((vec.at(i+1)>vec.at(i) && vec.at(i+1)<vec.at(i+2)) ||(vec.at(i+1)<vec.at(i) && vec.at(i+1)>vec.at(i+2))) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long N;
	cin >> N;
	long long ans = 0;
	for (int i = 357; i <= N; ) {
		int cnt = 1;
		bool e = false;
		set<int> A = {};
		long long x = i;
		while (x > 0) {
			
			int n = x % 10;
			
			if (n != 7) {
				if (n != 3) {
					if (n != 5) {
						e = true;
						i += cnt;
						break;
					}
				}
			}
			x /= 10;
			cnt *= 10;
			A.insert(n);
		}
		if (!e) {
			if (A.size() == 3) {
				ans++;
			}
			i++;
		}
		
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  string s;
  cin>>s;
  string t;
  rrep(i,n-1){
    if(s==t){
      Yes(true);
      return 0;
    }
    t=s[i]+t;
    s.erase(s.size()-1);
    //xout<<s<<' '<<t<<endl;
  }

  Yes(false);

}

Measured memory_bytes: 256
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')


def inpl(): return list(map(int, input().split()))


# 整数(x, y)最大公約数を求める
def gcd(x, y):
    if x % y == 0:
        return y
    else:
        x, y = y, x % y
        return gcd(x, y)


# 整数(x, y)最小公倍数を求める
def lcm(x, y):
    return x * y // gcd(x, y)


def solve(N, M, S, T):
    L = lcm(N, M)
    ln, lm = L // N, L // M

    # 文字列Xのk * lcm(L/N, L/M) (k = 0 ~ gcd(N, M) - 1)番目の文字は
    # S[k * lcm(L/N, L/M) / (L/N)]と
    # T[k * lcm(L/N, L/M) / (L/M)]で使われる
    D = lcm(ln, lm)
    A = D // ln
    B = D // lm
    for i in range(gcd(N, M)):
        if S[A * i] != T[B * i]:
            break
    else:
        return L
    return -1


N, M = inpl()
S = input()
T = input()
print(solve(N, M, S, T))


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

int main() {

    long long int n,m;

    cin >> n >> m;

    long long int ans = 0;

    if(n > 2 && m > 2){
        ans = n*m - 2*n - 2*m + 4;
    }
    else if(n == 2 || m == 2){
        ans = 0;
    }
    else if((n == 1 && m != 1)||(m == 1 && n !=1 )){
        ans = max(n,m) - 2;
    }
    else if(n == 1 && m == 1){
        ans = 1;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            long[] nk = ILongs();
            long n = nk[0];
            long k = nk[1];

            List<long[]> hens = new List<long[]>();
            for(long i=1;i<n;i++){
                hens.Add(new long[2]{i,n});
            }
            long count = (n-2)*(n-1) /2;
            if(k>count){
                Console.WriteLine(-1);
                return;
            }else if(k==count){
                Console.WriteLine(n-1);
                foreach(long[] hen in hens){
                    Console.WriteLine(hen[0].ToString() + " " + hen[1].ToString());
                }
                return;
            }

            for(long i=1;i<n-1;i++){
                for(long j=i+1;j<n;j++){
                    hens.Add(new long[2]{i,j});
                    count --;
                    if(count==k){
                        Console.WriteLine(hens.Count);
                        foreach(long[] hen in hens){
                            Console.WriteLine(hen[0].ToString() + " " + hen[1].ToString());
                        }
                        return;
                    }
                }
            }
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = Console.ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return Console.ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return Console.ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = Console.ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = Console.ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;


bool same_side(double x1, double y1, double x2, double y2, double x, double y, double x0, double y0) {
  return ((y1 - y2) * (x - x2) - (x1 - x2) * (y - y2)) * ((y1 - y2) * (x0 - x2) - (x1 - x2) * (y0 - y2)) >= 0;
}

int main() {
  // ifstream cin("../test.txt");
  double x1, y1, x2, y2, x3, y3, xp, yp;
  while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
    if (same_side(x1,y1,x2,y2,xp,yp,x3,y3) && same_side(x2,y2,x3,y3,xp,yp,x1,y1) && same_side(x3,y3,x1,y1,xp,yp,x2,y2)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1216
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

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

  ll n;
  std::cin>>n;

  std::vector<ll> d(n);
  rep(i,0,n)std::cin>>d[i];

  ll ans=0;
  rep(i,0,n-1){
    rep(j,i+1,n){
      ans+=d[i]*d[j];
    }
  }

  std::cout<<ans;
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int num[105];
int n;
#define negtive() return puts("Impossible"),0
int main(){
	scanf("%d",&n);
	int mx=0;
	for(int i=1,t;i<=n;i++) scanf("%d",&t),num[t]++,mx=max(mx,t);
	int mn=(mx+1)/2;
	for(int i=1;i<mn;i++) if(num[i]!=0) negtive();
	if(!(mx&1)) {if(num[mn]!=1) negtive();num[mn]++;}
	else if(num[mn]!=2) negtive();
	for(int i=mn;i<=mx;i++) if(num[i]<2) negtive();
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		long K = Long.parseLong(scan.next());
		int maxDigit = 40;
		String binK = toBinaryString(K, maxDigit);
		long[] A = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = Long.parseLong(scan.next());
		}
		String[] binA = new String[N];
		for (int i = 0; i < N; i++) {
			binA[i] = toBinaryString(A[i], maxDigit);
		}
		String binAns;
		int numOfOne;
		int numOfZero;
		long result = Long.MIN_VALUE;
		for (int i = 0; i < maxDigit; i++) {
			binAns = "";
			for (int l = 0; l <= i; l++) {
				if (l != maxDigit - 1 && l == i) {
					binAns += '0';
				} else {
					binAns += binK.charAt(l);
				}
			}

			for (int k = i + 1; k < maxDigit; k++) {
				numOfOne = 0;
				numOfZero = 0;
				for (int j = 0; j < N; j++) {
					if (binA[j].charAt(k) == '1') {
						numOfOne++;
					} else {
						numOfZero++;
					}
				}
				if (numOfZero >= numOfOne) {
					binAns += "1";
				} else {
					binAns += "0";
				}
			}
			if (K >= Long.parseLong(binAns, 2)) {
				result = Math.max(result, function(Long.parseLong(binAns, 2), A));
			}
		}
		System.out.println(result);

	}

	public static long function(long X, long[] A) {
		long sum = 0;
		for (int i = 0; i < A.length; i++) {
			sum += X ^ A[i];
		}
		return sum;
	}

	public static String toBinaryString(long a, int digit) {
		String binString = String.format("%40s", Long.toBinaryString(a));
		binString = binString.replace(' ', '0');
		return binString;
	}
}


Measured memory_bytes: 105316
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	string S;
	cin >> S;
	int N = S.length();

	int rnum, bnum;
	rnum = bnum = 0;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == '0')
			rnum++;
		else if (S[i] == '1')
			bnum++;
	} 

	cout << min(rnum, bnum) * 2 << endl;

	return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  int amax=a[n-1]+1;
  bool dp[a[n-1]+1];
  for(int i=0;i<amax;i++) dp[i]=true;
  int i=0;
  int now=0;
  while(i<n){
    if(now!=a[i]){
      now=a[i];
      int bound=a[n-1]/now;
      for(int j=2;j<=bound;j++){
        dp[now*j]=false;
      }
    }
    else{
      dp[now]=false;
    }
    i++;
  }
  int ans=0;
  for(int i=1;i<=a[n-1];i++){
    if(dp[i] && binary_search(a.begin(),a.end(),i)) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  int N;
  cin >> N;
  vector<ll>A(N),B(N),C(N);
  ll ans=0;
  rep(i,N)cin >> A[i];
  rep(i,N){cin >> B[i];ans+=B[i];}
  rep(i,N-1)cin >> C[i];
  rep(i,N-1){
    if(A[i]+1==A[i+1])ans+=C[A[i]-1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256