akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    ll a,b,x;
    cin >> a >> b >> x;
    ll ans = b / x;
    if (a == 0) ans++;
    else ans -= (a-1) / x;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    l=[a[1] for i in 1:n]
    r=[a[n] for i in 1:n]
    for i in 2:n
        l[i]=gcd(l[i-1],a[i])
        r[i]=gcd(r[i-1],a[n-i+1])
    end
    ans=1
    for i in 1:n
        if i==1
            ans=max(ans,r[n-1])
        elseif i==n
            ans=max(ans,l[n-1])
        else
            ans=max(ans,gcd(r[i-1],l[n-i]))
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 122436
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] m = new int[N];
		for (int i = 0; i < N; i++) {
			m[i] = sc.nextInt();
		}
		
		int cnt = 0;
		int sum = 0;
		int min = X;
		for (int i = 0; i < N; i++) {
			sum += m[i];
			cnt++;
			if (m[i] < min)
				min = m[i];
		}
		
		X -= sum;
		while(X >= min) {
			X -= min;
			cnt++;
		}
		
		System.out.println(cnt);
		
		sc.close();

	}

}

Measured memory_bytes: 21844
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using ll = long long ;
using namespace std;
const ll maxn=1e5+5;
long double x,p;
int main(){
	ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0);
	cin>>x;
	p=3.141592;
	cout<<fixed<<setprecision(2);
	cout<<(2*x*p);
}



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

int main(void) {
int sx, sy, tx, ty;
std::cin >> sx >> sy >> tx >> ty;

const int dx = tx - sx, dy = ty - sy;

std::cout << string(dx, 'R') << string(dy, 'U');//path1

std::cout << string(dx, 'L') << string(dy, 'D') ;//path2

std::cout << string(1, 'L') << string(dy+1, 'U') << string(dx+1, 'R') << string(1, 'D');//path3

std::cout << string(1, 'R') << string(dy+1, 'D') << string(dx+1, 'L') << string(1, 'U') << '\n';//path4

return 0;
}


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

using namespace std;

int main(void) {
	
	int y,m,d;
	char sl1,sl2;
	cin >>y >>sl1 >>m >>sl2 >>d;
	
	if (m<=4) cout <<"Heisei" <<endl;
	if (m>=5) cout <<"TBD" <<endl;
	
	return 0;
}

Measured memory_bytes: 256
l = ['maerd', 'remaerd', 'esare', 'resare']
flag = False
S = input()
S = ''.join(list(reversed(S)))
j = 0
for i in range(len(S)+1):
    if S[j:i] in l:
        j=i
        flag = True
    else:
        flag = False
print("YES" if flag else "NO")

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

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

const ll MAX_N = 200010;
ll fact[MAX_N];
ll fact_inv[MAX_N];

ll pow_mod(ll x, ll y, ll m = MOD) { //x^y mod m
    if (x == 0) return 0;
    ll prod = 1;
    while (y > 0) {
        if (y % 2 == 1) prod = (prod * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return prod % m;
}

inline ll inv(ll a) {
    return pow_mod(a, MOD - 2);
}

void init_fact() {
    fact[0] = fact_inv[0] = 1;

    REP(i, 1, MAX_N) {
        fact[i] = (fact[i - 1] * i) % MOD;
        fact_inv[i] = inv(fact[i]);
    }
}

ll C_mod(ll n, ll r) {
    if (n < r) return 0;
    else return ((fact[n] * fact_inv[n - r]) % MOD * fact_inv[r]) % MOD;
}

inline ll H_mod(ll n, ll r) {
    return C_mod(n + r - 1, r);
}

inline ll P_mod(ll n, ll r) {
    return C_mod(n, r) * fact[r];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, k;
    cin >> n >> m >> k;
    init_fact();

    ll E_x = 0, E_y = 0;
    for (ll i = 1; i < n; ++i) {
        E_x += m * m % MOD * (n - i) % MOD * i;
        E_x %= MOD;
    }
    E_x *= inv(C_mod(n * m, 2));
    E_x %= MOD;
    for (ll i = 1; i < m; ++i) {
        E_y += n * n % MOD * (m - i) % MOD * i;
        E_y %= MOD;
    }
    E_y *= inv(C_mod(n * m, 2));
    E_y %= MOD;

    ll E = (E_x + E_y) % MOD; //2つ駒を置いたときのコストの期待値
    E *= C_mod(k, 2);
    E %= MOD;
    ll ans = E * C_mod(n * m, k) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
# set
n,m = gets.chomp.split(" ").map(&:to_i)
days_arr = Array.new
days_arr = gets.chomp.split(" ").map(&:to_i)
require_days = 0
0.upto(m - 1) do |i|
  require_days += days_arr[i]
end

# main
answer = n - require_days
answer = -1 if require_days > n
print ("#{answer}\n")

Measured memory_bytes: 14744
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<climits>
#include<cmath>
#include<iomanip>

using namespace std;

int main(void){
    int L;
    cin >> L;
    vector<long long> A(L);
    for(int i = 0; i < L; i++) cin >> A[i];

    vector<long long> LO(L + 1), LR(L + 1), RO(L + 1), RR(L + 1), S(L + 1);
    
    LO[0] = 0;
    LR[0] = 0;
    S[0] = 0;
    for(int i = 1; i <= L; i++){
        long long a = A[i - 1];
        S[i] = S[i - 1] + a;
        LO[i] = min((a + 1) % 2 + LO[i - 1], (a == 0 ? 1 : 0) + LR[i - 1]);
        if(a == 0){
            LR[i] = min(S[i], 2 + LR[i - 1]);
        }else{
            LR[i] = a % 2 + LR[i - 1];
        }
    }

    RO[L] = 0;
    RR[L] = 0;
    S[L] = 0;
    for(int i = L - 1; i >= 0; i--){
        S[i] = S[i + 1] + A[i];
        RO[i] = min((A[i] + 1) % 2 + RO[i + 1], (A[i] == 0 ? 1 : 0) + RR[i + 1]);
        if(A[i] == 0){
            RR[i] = min(S[i], 2 + RR[i + 1]);
        }else{
            RR[i] = A[i] % 2 + RR[i + 1];
        }
    }

    long long ans = LLONG_MAX;
    for(int i = 0; i <= L; i++) ans = min(ans, min(LO[i] + RR[i], LR[i] + RO[i]));
    cout << ans << endl;
    return 0;
}

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

ll mincost=INT_MAX;
void func(int idx, vector<ll> &c, vector<vector<ll>> &a, vector<ll> cost_ar, ll cost, ll n, ll m, ll x){
	if(idx==n){
		bool flag=true;
		for(auto a:cost_ar){
			if(a<x){
				flag=false;
				break;
			} 
		}
		if(flag) {
			mincost=min(mincost, cost);
			return;
		}
		return;
	}
	//Not choose
	func(idx+1, c, a, cost_ar, cost, n, m, x);
	
	//Choose
	cost+=c[idx];
	for(ll i=0;i<m;i++){
		cost_ar[i]+=a[idx][i];
	}
	func(idx+1, c, a, cost_ar, cost, n, m, x);
}

int main() {
	// your code goes here
	ll n, m, x;
	cin>>n>>m>>x;
	vector<ll> c(n);
	vector<vector<ll>> a(n,vector<ll>(m));
	for(ll i=0;i<n;i++){
		cin>>c[i];
		for(ll j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	vector<ll> cost_ar(m, 0);
	func(0, c, a, cost_ar, 0, n, m, x);
	if(mincost==INT_MAX) mincost=-1;
	cout<<mincost<<endl;
	
	return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x,a,b; cin>>x>>a>>b;
	cout << (x-a)%b << endl;
	return 0;
}


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

int main() {
    string Sentence1, Sentence2, Sentence3;
    cin >> Sentence1 >>Sentence2 >>Sentence3;
    string AXC = "AXC";
    AXC.at(1) = Sentence2.at(0);
    cout << AXC << endl;
}

Measured memory_bytes: 256
a,b=map(int, input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
 
x10 = a
c = Base_10_to_n(a,b )
print( len(c) )

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int N=200005;
ll a[N];
int main()
{
	int n;
	cin>>n;
	int maxn=0;
	for(int i=1;i<=n;i++) 
	{
		cin>>a[i];
		a[i]-=i;
	}
	sort(a+1,a+n+1);
	int mid;
	ll t;
	if(n%2!=0) mid=(n+1)/2,t=a[mid];
	else mid=n/2,t=(a[mid]+a[mid+1])/2;
	ll ans=0;
	for(int i=1;i<=n;i++) ans+=abs(t-a[i]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
 
int main(void) {
    int a,b;
    while(scanf("%d%d", &a, &b)){
        if(a == 0 && b == 0) break;
        if(a < b) printf("%d %d\n", a,b);
        else printf("%d %d\n", b,a);
    }
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define x first
#define d second
using namespace std;
using ll = long long;

const int N = 200005;
const int mod = 998244353;
int add(int a, int b) {
	return a + b < mod ? a + b : a + b - mod;
}

int n;
pair<int, int> p[N];
int rig[N];
int dp[N];

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d %d", &p[i].x, &p[i].d);

	sort(p, p + n);

	dp[n] = 1;
	for(int i = n - 1; i >= 0; i--) {
		rig[i] = i;
		while(rig[i] < n - 1 and p[i].x + p[i].d > p[ rig[i] + 1 ].x) {
			rig[i] = rig[ rig[i] + 1 ];
		}
		dp[i] = add(dp[i + 1], dp[rig[i] + 1]);
	}
	printf("%d\n", dp[0]);
}


Measured memory_bytes: 6984
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [n, x] = li()
    l_list = li()

    bound = 0
    bound_x = 0
    index = 0
    bound = bound + 1
    while bound_x + l_list[index] <= x:
        bound = bound + 1
        bound_x = bound_x + l_list[index]
        index = index + 1
        if index >= len(l_list):
            break

    print(bound)


Measured memory_bytes: 38256
S = input()


def find_edge(arr):
    edge = [0] * len(arr)
    for i in range(len(arr)):
        if arr[i] == 'L':
            if arr[i-1] == 'R':
                edge[i] = i
            else:
                edge[i] = edge[i-1]
    for i in range(len(arr))[::-1]:
        if arr[i] == 'R':
            if arr[i+1] == 'L':
                edge[i] = i
            else:
                edge[i] = edge[i+1]
    return edge


def find_child(arr, edge):
    child = [0] * len(arr)

    for i in range(len(arr)):
        if (edge[i] - i) % 2 == 0:
            child[i] = edge[i]
        else:
            if arr[edge[i]] == 'R':
                child[i] = edge[i] + 1
            else:
                child[i] = edge[i] - 1
    return child

edge = find_edge(S)
child = find_child(S, edge)
result = [0] * len(S)

for c in child:
    result[c] += 1
print(" ".join(map(str, result)))


Measured memory_bytes: 15220
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define flush fflush(stdout)
#define debug printf("Hello\n")
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, x, y, sum, cnt, ans;
int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	cout<<3*n*n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define LL long long
const int mod = 1e9 + 7;
const int N = 4e5 + 11;
int n;
LL c[N], mi[N];
inline int M(int x, int y){
    return 1LL * x * y % mod;
}
inline int A(int x, int y){
    return x + y - (x + y >= mod ? mod : 0);
}
int main(){
    cin>>n;
    mi[0] = 1;
    for(int i = 1;i <= n; i++){
        scanf("%lld", &c[i]);
        mi[i] = M(mi[i-1], 2);
    }
    for(int i = n + 1;i <= 2 * n; i++)mi[i] = M(2, mi[i-1]);
    sort(c + 1, c + 1 + n);
    int ans = 0;
    for(int i = 1;i <= n; i++){
        ans = A(ans, M(M(mi[n+i-1], c[i]), A(M(n - i, mi[n-i-1]), mi[n-i])));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6016
n, a, b = map(int, input().split(' '))

total = 0
for num in range(1, n + 1):
    digit_5 = num // 10000 % 10
    digit_4 = num // 1000 % 10
    digit_3 = num // 100 % 10
    digit_2 = num // 10 % 10
    digit_1 = num % 10
    digits = (digit_5, digit_4, digit_3, digit_2, digit_1)

    if a <= sum(digits) <= b:
        total += num

print(total)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
string N;

void solve(){
    if(N.at(0) == '7' || N.at(1) == '7' || N.at(2) == '7'){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

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

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

void toE(int a[])
{
    int tmp = a[0];
    a[0] = a[3];
    a[3] = a[5];
    a[5] = a[2];
    a[2] = tmp;
}

void toW(int a[])
{
    int tmp = a[0];
    a[0] = a[2];
    a[2] = a[5];
    a[5] = a[3];
    a[3] = tmp;
}

void toS(int a[])
{
    int tmp = a[0];
    a[0] = a[4];
    a[4] = a[5];
    a[5] = a[1];
    a[1] = tmp;
}

void toN(int a[])
{
    int tmp = a[0];
    a[0] = a[1];
    a[1] = a[5];
    a[5] = a[4];
    a[4] = tmp;
}

int detectRight(int f, int a[])
{
    int ans;
    if (f == a[1])
    {
        ans = a[2];
    }
    else if (f == a[2])
    {
        ans = a[4];
    }
    else if (f == a[4])
    {
        ans = a[3];
    }
    else
    {
        ans = a[1];
    }
    return ans;
}

void copyArray(int a[], int b[])
{
    for (int i = 0; i < 6; i++)
    {
        b[i] = a[i];
    }
}

int main()
{
    int a[6], b[6];
    int q, u, f;
    for (int i = 0; i < 6; i++)
    {
        cin >> a[i];
    }
    copyArray(a, b);
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> u >> f;

        if (u == a[1])
        {
            toN(a);
        }
        else if (u == a[2])
        {
            toW(a);
        }
        else if (u == a[3])
        {
            toE(a);
        }
        else if (u == a[4])
        {
            toS(a);
        }
        else if (u == a[5])
        {
            toN(a);
            toN(a);
        }

        cout << detectRight(f, a) << endl;
    }

    return 0;
}



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

using namespace std;

int main(){
    int n; // たこ焼きの個数
    cin >> n;
    vector<int> d(n,0); // たこ焼きのおいしさ

    for(int i=0;i<n;++i){
        cin >> d[i];
    }
    int recoveryAmount = 0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            recoveryAmount += d[i]*d[j];
        }
    }
    cout << recoveryAmount << endl;
    return 0;
}

Measured memory_bytes: 256
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}

class UnionFind {
private:
	Vec< int > data;
	int num_of_g;
	
public:
	UnionFind(int n) : data(n, -1), num_of_g(n) {}
	
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		
		if (x == y) return 0;
		
		if (data[y] < data[x]) swap(x, y);
		data[x] += data[y]; data[y] = x;
		--num_of_g;
		
		return 1;
	}
	
	bool sameSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
	int getNumOfG() { return num_of_g; }
};

int N, M;

int main() {
	cin >> N >> M;
	
	UnionFind uf(M);
	set< int > all_L;
	
	for_(i,0,N) {
		int K; cin >> K;
		int prev; cin >> prev; --prev;
		all_L.insert(prev);
		
		--K;
		for_(j,0,K) {
			int L; cin >> L; --L;
			all_L.insert(L);
			uf.unionSet(prev, L);
			prev = L;
		}
	}
	
	set< int > roots;
	for (int x : all_L) roots.insert(uf.root(x));
	cout << (roots.size() == 1 ? "YES": "NO") << endl;
}






Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
int main(){
  char w[3][7]={"Sunny","Cloudy","Rainy"};
  char t[7];

  scanf("%s",t);
  for(int i=0;i<3;i++){
    if(strncmp(t,w[i],1)==0){
      printf("%s\n",w[(i+1)%3]);
      break;
    }
  }
  return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  int u, v, w;
  vector<vector<P> > a(N);
  vector<int> seen(N, 2);
  queue<int> que;
  rep(i, N-1) {
    cin >> u >> v >> w;
    u--;
    v--;
    a[u].pb(make_pair(v, w));
    a[v].pb(make_pair(u, w));
  }
  int s = 0;
  que.push(s);
  seen[s] = 0;
  while (!que.empty()) {
    s = que.front();
    que.pop();
    rep(i, a[s].size()) {
      if (seen[a[s][i]._1] == 2) {
        if ((seen[s] == 1 && a[s][i]._2%2==0) || (seen[s] == 0 && a[s][i]._2%2)) {
          seen[a[s][i]._1] = 1;
          que.push(a[s][i]._1);
        }
        else {
          seen[a[s][i]._1] = 0;
          que.push(a[s][i]._1);
        }
      }
    }
  }
  rep(i, N) {
    cout << seen[i] << endl;
  }
}


Measured memory_bytes: 6784
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int a;
    cin>>a;
    vector<int> g;
    for(int i=1;;++i){
        g.push_back(pow(2,i));
        if(g[i-1]>a){
            break;
        }
    }
    cout<<g[g.size()-2]<<endl;
}


Measured memory_bytes: 3336
N = int(input())
A = list(map(int, input().split()))
S = [0]
for i in range(N):
    S.append(S[i] + A[i])

ans = float('inf')
for i in range(1,N):
    sunke = S[i] - S[0]
    araiguma = S[-1] - S[i]
    ans = min(ans, abs(sunke - araiguma))

print(ans)

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >>s;
  sort(s.begin(),s.end());
  if(s.at(0)==s.at(1)&&s.at(1)!=s.at(2)&&s.at(2)==s.at(3)){ 
    cout << "Yes" <<endl;
  }else cout << "No" << endl;
                                                           
  
  
}


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

using namespace std;

#define LCM(a,b)                (a / __gcd(a,b) ) *b
#define GCD(a,b)                __gcd(a,b)
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define fRead(x)                freopen(x,"r",stdin)
#define fWrite(x)               freopen (x,"w",stdout)
#define LL                      long long
#define ULL                     unsigned long long
#define pb                      push_back
#define tcase                   cout<<"Case "<<C++<<": ";
#define all(a)                  a.begin(),a.end()
#define Unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end
#define ABS(x)                  ((x)<0?-(x):(x))
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(a,min(b,min(c,d)))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(a,max(b,max(c,d)))
#define PI                      acos(-1.0)
#define ff                      first
#define ss                      second
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define FastRead                ios_base::sync_with_stdio(0);cin.tie(NULL);
#define FOR(x, l, r)            for (LL x = l; x<=r; ++x)
#define REP(x,r)               for (LL x = 0; x <r; ++x)
#define NN                      cout<<"\n";
#define NNN                     cout<<"\n------------------------------\n";

//***********************************************************************//
//                      SHAHED AHMED, CSE'15, IUT                        //
//***********************************************************************//

LL n;
string s;

map<string , LL> mp;

void func(LL pos)
{
        if(pos==n)
        {
                string t;
                for(LL i=0;i<n;i++)
                {
                        if(s[i]>='a'&&s[i]<='z') t+=s[i];
                }
                for(LL i=0;i<n;i++)
                {
                        if(s[i]>='A'&&s[i]<='Z') t+=s[i];
                }

                mp[t]++;

                return;
        }

        func(pos+1);
        s[pos] += 'A' - 'a';
        func(pos+1);
        s[pos] -= 'A' -'a';

}


LL ans;

void func2(LL pos)
{
        if(pos==n)
        {

                string t;
                for(LL i=0;i<n;i++)
                {
                        if(s[i]>='a'&&s[i]<='z') t+=s[i];
                }
                for(LL i=0;i<n;i++)
                {
                        if(s[i]>='A'&&s[i]<='Z') t+=s[i];
                }

                ans+=mp[t];



                return;
        }

        func2(pos+1);
        s[pos] += 'A' - 'a';
        func2(pos+1);
        s[pos] -= 'A' -'a';

}


int main()
{

        cin>>n;
        cin>>s;

        func(0);
        reverse(all(s));

        func2(0);

        cout<<ans;

        //cout<<s;

}


Measured memory_bytes: 73984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int N;
    cin >> N;
    ll sum = 0;
    rep1(i,N+1){
        if(i % 3 == 0 || i % 5 == 0)continue;
        sum += i;
    }
    cout << sum << endl;
}

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

int main(){
  string S;
  cin >> S;
  int i=0;
  bool flag=true;
  while(i<S.size()){
    if(i%2==0){
      if(S[i]=='h');
      else{
        flag = false;
        break;
      }
    }
    else{
      if(S[i]=='i');
      else{
        flag = false;
        break;
      }
    }
    i++;
  }
  if(S.size()%2!=0) flag = false;
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
m, d = map(int,input().split())

count = 0

for day in range (2,d+1):
    for month in range(2,m+1):
        d_1 = day%10
        d_10 = day//10
        if ((d_1 * d_10) == month) and (d_1 >= 2) and(d_10 >= 2):
            count += 1

print(count)


Measured memory_bytes: 38768
#include<bits/stdc++.h>
  using namespace std;
const int N=100000;
int a[N+1],L,n;
inline void into(){
  scanf("%d%d",&n,&L);
  for (int i=1;i<=n;i++)
    scanf("%d",&a[i]);
}
inline void work(){
}
inline void outo(){
  for (int i=1;i<n;i++)
    if (a[i]+a[i+1]>=L) {
	  printf("Possible\n");
	  for (int j=1;j<i;j++)
	    printf("%d\n",j);
	  for (int j=n-1;j>i;j--)
	    printf("%d\n",j);
	  printf("%d\n",i);
      return;
	}
  printf("Impossible\n");
}
int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 1152
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    odd = a[0::2]
    even = a[1::2]

    if n % 2 == 0:
        res = even[::-1] + odd
        print(*res)
    else:
        res = odd[::-1] + even
        print(*res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 89812
N, M = map(int, input().split())

left = 1
right = N

for _ in range(M):
    l, r = map(int, input().split())

    if left < l:
        left = l
    if right > r:
        right = r

ans = right - left

print(ans + 1 if ans >= 0 else 0)


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

int main(){
    string a,b;
    cin >> a >> b;

    int c=stoi(a+b);
    int rc=(int)sqrt(c);
    if(c==rc*rc){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    string S[3];
    for (int i = 0; i < 3; ++i) cin >> S[i];

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        set<char> s;
        for (int j = 0; j < 3; ++j) s.insert(S[j][i]);
        ans += s.size() - 1;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  int max_hats[100005] = {};
  int mid_hats[100005] = {};
  int min_hats[100005] = {};
  ll ans = 3;
  int data[100005] = {};

  REP(i, n) { cin >> data[i]; }
  max_hats[0] = 1;

  FOR(i, 1, n) {
    if (data[i] >= max_hats[i - 1]) {
      max_hats[i]++;
    } else if (data[i] >= mid_hats[i - 1]) {
      mid_hats[i]++;
    } else {
      min_hats[i]++;
    }
    max_hats[i] += max_hats[i - 1];
    mid_hats[i] += mid_hats[i - 1];
    min_hats[i] += min_hats[i - 1];
  }

  FOR(i, 1, n) {
    int cnt = (data[i] == max_hats[i - 1]) + (data[i] == mid_hats[i - 1]) +
              (data[i] == min_hats[i - 1]);
    ans *= cnt;
    ans %= MOD;
  }
  if (data[0] != 0) ans = 0;
  cout << ans << endl;
}

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

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

using namespace std;

typedef pair<int,int> pii;

int main (int argc, char const* argv[])
{
	int n;
	scanf("%d",&n);
	
	int d1 = n/10;
	int d2 = n%10;
	
	if (d1 == 9 || d2 == 9)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll h,n;
    cin >> h >> n;
    vector<int>A(n);
    int sum= 0;
    REP(i,n){
        cin >> A[i];
        sum+= A[i];
    }
    cout << ((sum>=h)?"Yes":"No") << endl;
}


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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

int x[MAX];
ll dp[MAX];
int n,k;

ll solve(int i){
      if(i==n-1){
         return 0;
      }


      ll &res=dp[i];
      if(res!=-1){
        return res;
      }

      res=INFINF;
      for(int j=i+1;j<=i+k&&j<n;j++){
           res=min(res,  solve(j)+abs(x[j]-x[i])  );
      }


      return res;
}



int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);





    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }

    mem(dp,-1);
    cout<<solve(0);





     return 0;

}


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

#define M 1046527
#define NIL (-1)
#define L 14
typedef long long ll;

int hash1( ll key );
int hash2( ll key );

ll getKey( char str[] );
int getChar( char ch );
bool find( char str[] );
bool insert( char str[] );

char T[M][L];

int main()
{
    int n;
    char command[8];
    char str[L];

    for ( int i = 0; i < M; i++ ) T[i][0] = '\0';

    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) {
	scanf("%s", command);
	scanf("%s", str);
	if ( !strcmp( command, "insert" ) ) {
	    insert( str );
	}
	else if ( !strcmp( command, "find" ) ) {
	    bool result = find( str );
	    if ( result ) {
		printf("yes\n");
	    }
	    else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


int hash1( ll key )
{
    return ( key % M );
}


int hash2( ll key )
{
    return 1 + ( key % ( M - 1 ) );
}


ll getKey( char str[] )
{
    ll key = 0;
    for ( int i = 0; i < strlen( str ); i++ ) {
	key *= 5;
	key += getChar( str[i] );
    }

    return key;
}


int getChar( char ch )
{
    int ret = 0;
    switch( ch ) {
    case 'A':
	ret = 1;
	break;
    case 'T':
	ret = 2;
	break;
    case 'G':
	ret = 3;
	break;
    case 'C':
	ret = 4;
	break;
    }

    return ret;
}


bool find( char str[] )
{
    ll key = getKey(str);
    ll i, h;
    for ( i = 0; ; i++ ) {
	h = ( hash1( key ) + i * hash2( key ) ) % M;
	if ( !strcmp( T[h], str ) ) return true;
	else if ( strlen( T[h] ) == 0 ) return false;
    }

    return false;
}


bool insert( char str[] )
{
    ll key = getKey( str );
    ll i, h;
    for ( i = 0; ; i++ ) {
	h = ( hash1( key ) + i * hash2( key ) ) % M;
	if ( !strcmp( T[h], str ) ) return false;
	else if ( strlen( T[h] ) == 0 ) {
	    strcpy( T[h], str );
	    return true;
	}
    }
    return false;
}

Measured memory_bytes: 15344
def get_num(n, x):
    ans = 0
    for n3 in xrange(min(n, x - 2), (x + 2) / 3, -1):
        for n2 in xrange(min(n3 - 1, x - n3 - 1), (x - n3 + 1) / 2 - 1, -1):
            for n1 in xrange(min(n2 - 1, x - n3 - n2), 0, -1):
                if n3 == x - n1 - n2:
                    ans += 1
                    break
    return ans


while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    if x < 3:
        print(0)
    else:
        print(get_num(n, x))

Measured memory_bytes: 6416
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

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

   V<P<int,int>> ans;
   if (n % 2 == 1) {
      for (int i = 1; i <= n; i++) {
         for (int j = i+1; j <= n; j++) {
            if (i + j == n) {
               continue;
            }
            ans.push_back({ i, j });
         }
      }
   } else {
      for (int i = 1; i <= n; i++) {
         for (int j = i+1; j <= n; j++) {
            if (i + j == n+1) {
               continue;
            }
            ans.push_back({ i, j });
         }
      }
   }
   cout << ans.size() << endl;
   for (int i = 0; i < ans.size(); i++) {
      cout << ans[i].first << " " << ans[i].second << endl;
   }

   return 0;
}


Measured memory_bytes: 512
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


vector<vector<pll>> edge; //to,rev
vector<vector<ll>> node;
vector<bool> color;
vector<bool> used;

stack<ll> S;

string solve(){
    for(int i=0;i<edge.size();i++){
        vector<ll> a(2,0);
        for(int t=0;t<edge[i].size();t++){
            ll to=edge[i][t].F;
            a[color[to]]++;
        }
        if(a[0]==0 || a[1]==0){S.push(i);}
        node[i]=a;
    }
    while(!S.empty()){
        ll w=S.top();
        S.pop();
        if(used[w]){continue;}
        used[w]=true;
        for(int i=0;i<edge[w].size();i++){
            ll to=edge[w][i].F;
            node[to][color[w]]--;
            if(node[to][color[w]]==0){S.push(to);}
        }
    }
    ll a[2]={};
    for(int i=0;i<used.size();i++){
        if(!used[i]){a[color[i]]++;}
    }
    if(a[0] && a[1]){return "Yes";}
    return "No";
}





int main(){
    ll n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    edge.resize(n);
    node.resize(n);
    color.resize(n);
    for(int i=0;i<n;i++){color[i]=s[i]=='A';}
    used.resize(n,false);
    for(int i=0;i<m;i++){
        ll u,v;
        cin>>u>>v;
        u--; v--;
        edge[u].push_back({v,-1});
        edge[v].push_back({u,-1});
    }
    cout<<solve()<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 25732
import std.string;
import std.conv;
import std.algorithm;
import std.stdio;
 
void main() {
  int hp = readln.chomp.split(" ")[0].to!int;  

  foreach (e;readln.chomp.split(" ").map!(to!int)) {
    hp -= e;
    if (hp <= 0) {
      writeln("Yes");
      return;
    }
  }

  writeln("No");
}


Measured memory_bytes: 3888
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


int main() {
	
	int n;
	cin >> n;
	vector<string> list(n);
	rep(i, n) {
		cin >> list[i];
	}
	SORT(list);

	int ans = 0;
	rep(i, n) {
		if (i == 0 || list[i] != list[i - 1]) {
			ans++;
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 9664
def findnumberofTriangles(arr): 
  
    n = len(arr) 
    arr.sort() 
    count = 0
  
    for i in range(0,n-2): 
   
        k = i + 2
  
        for j in range(i+1,n): 
  
            while (k < n and arr[i] + arr[j] > arr[k]): 
                k += 1
            if(k>j): 
                count += k - j - 1
  
    return count 

N = int(input())
L = list(map(int, input().split()))

print(findnumberofTriangles(L))

Measured memory_bytes: 3188
from collections import deque

N,X,Y = map(int,input().split())
X -= 1
Y -= 1

d = {i:set() for i in range(N)}
for i in range(0,N):
  if i-1>=0:
    d[i-1].add(i)
  if i+1<=N-1:
    d[i+1].add(i)
  if i==X:
    d[Y].add(X)
    d[X].add(Y)

ans = {i+1:0 for i in range(N-1)}

for i in range(0,N):
  dist = [-1]*N
  q = deque([i])
  dist[i] = 0
  while q:
    v = q.popleft()
    for j in d[v]:
      if  dist[j] == -1:
        dist[j] = dist[v] + 1
        ans[dist[j]] += 1
        q.appendleft(j)
      elif dist[v] + 1 < dist[j]:
        ans[dist[j]] -= 1
        dist[j] = dist[v] + 1
        ans[dist[j]] += 1
        q.appendleft(j)

for l in ans.values():
  print(l//2)
  

Measured memory_bytes: 52188
#include <iostream>
#include <string>
#include <cmath>

#define PI 3.14159265358979323846

using namespace std;
int main() {
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    
//    double theta = M_PI*h/6.0;
//    double beta = M_PI*m/30.0;
    double theta = PI*((double)h+(double)m/60)/6.0;
    double beta = PI*(double)m/30.0;
    
    double angu = theta-beta;
    if(abs(angu)>PI)
        angu = 2*PI-angu;
    
    
    double ans = sqrt((double)a*(double)a+(double)b*(double)b-2*(double)a*(double)b* cos(angu));
    
    printf("%.9f",ans);
    
    return 0;
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int INF = 1e9 + 7;
int dp[MAXN][3];
int cost[MAXN][3];
int N;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> cost[i][0] >> cost[i][1] >> cost[i][2];
	}
	dp[0][0] = cost[0][0], dp[0][1] = cost[0][1], dp[0][2] = cost[0][2];
	for (int i = 1; i < N; ++i) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + cost[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + cost[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + cost[i][2];
	}
	cout << max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2])) << '\n';
	return 0;
}

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

int main()
{
  int n, count = 0;
  cin >> n;
  vector<int> v(n, 0);

  for (int i = 0; i < n; i++)
    cin >> v[i]; 

  for (int i = 0; i < n; i++)
  {
    if (v[i] % 2 != 0)
      count++;
  }

  if (count % 2 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

}


Measured memory_bytes: 640
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn fact(n: usize) -> usize {
    if n == 0 {
        1
    } else {
        n * fact(n - 1)
    }
}

fn encode(v: &Vec<u8>) -> usize {
    let n: usize = v.len();
    if n == 1 {
        return 0;
    }
    let mut c = 0;
    for i in 0..n {
        if v[i] < v[0] {
            c += 1;
        }
    }
    let mut nv = vec![];
    for i in 1..n {
        nv.push(v[i]);
    }
    c * fact(n - 1) + encode(&nv)
}

use std::collections::VecDeque;

fn next(v: &Vec<u8>, check: &mut Vec<bool>) -> Vec<Vec<u8>> {
    let mut i = 0;
    for j in 0..9 {
        if v[j] == 0 {
            i = j;
            break;
        }
    }
    let mut ret = vec![];
    if i % 3 != 0 {
        let mut n = v.clone();
        let tmp = n[i];
        n[i] = n[i - 1];
        n[i - 1] = tmp;
        let c = encode(&n);
        if !check[c] {
            check[c] = true;
            ret.push(n);
        }
    }
    if i % 3 != 2 {
        let mut n = v.clone();
        let tmp = n[i];
        n[i] = n[i + 1];
        n[i + 1] = tmp;
        let c = encode(&n);
        if !check[c] {
            check[c] = true;
            ret.push(n);
        }
    }
    if i > 2 {
        let mut n = v.clone();
        let tmp = n[i];
        n[i] = n[i - 3];
        n[i - 3] = tmp;
        let c = encode(&n);
        if !check[c] {
            check[c] = true;
            ret.push(n);
        }
    }
    if i < 6 {
        let mut n = v.clone();
        let tmp = n[i];
        n[i] = n[i + 3];
        n[i + 3] = tmp;
        let c = encode(&n);
        if !check[c] {
            check[c] = true;
            ret.push(n);
        }
    }
    ret
}

fn main() {
    let mut v: Vec<u8> = vec![];
    let t: Vec<u8> = read_vec();
    for a in t {
        v.push(a);
    }
    let t: Vec<u8> = read_vec();
    for a in t {
        v.push(a);
    }
    let t: Vec<u8> = read_vec();
    for a in t {
        v.push(a);
    }

    let goal = encode(&vec![1, 2, 3, 4, 5, 6, 7, 8, 0]);

    let mut check: Vec<bool> = vec![false; 362880];
    let mut vd = VecDeque::new();
    check[encode(&v)] = true;
    vd.push_back((v, 0));

    loop {
        let (v, d) = vd.pop_front().unwrap();
        if encode(&v) == goal {
            println!("{}", d);
            break;
        }
        for n in next(&v, &mut check) {
            vd.push_back((n, d + 1));
        }
    }
}



Measured memory_bytes: 7096
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
  int n,l;cin>>n>>l;
  string res="",s[100];rep(i,n)cin>>s[i];
  sort(s,s+n);
  rep(i,n){
    res+=s[i];
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n,d;
  cin >> n>>d;
  vector<ll> x(n), y(n);
  int cnt = 0;
  for (int i = 0; i < n;i++){
    cin >> x[i] >> y[i];
    if(d*d>=x[i]*x[i]+y[i]*y[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 6424