akhauriyash/Code-Regression huggingface dataset:
a=input()
if a=='SUN':
    print(7)
elif a=='MON':
    print(6)
elif a=='TUE':
    print(5)
elif a=='WED':
    print(4)
elif a=='THU':
    print(3)
elif a=='FRI':
    print(2)
else:
    print(1)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<5;i++) {
			int a = sc.nextInt();
			if(a == 0) {
				System.out.println(i+1);
			}
		}

	}

}


Measured memory_bytes: 35640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[1005];
int main()
{
   int n;
   scanf("%d%s",&n,s+1);
   int ans=0;
   for(int i=1;i<=n-2;i++)
   {
       if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')ans++;
   }
   printf("%d",ans);
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N)
{
    string res = NO;
    switch (N)
    {
    case 1:
        res = YES;
        break;

    default:
        if (N > 81)
        {
            break;
        }
        else
        {
            for (size_t i = 2; i <= 9; i++)
            {
                if (N % i == 0 && N / i <= 9)
                {
                    res = YES;
                    break;
                }
            }
        }
    }

    cout << res << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7, N = 300005;

ll h, w, a, b, ans, fac[N] = {1}, fi[N] = {1};

ll comb (ll A, ll B) {
	return fac[A] * fi[B] % mod * fi[A-B] % mod;
}

ll calc (ll A, ll B, ll C, ll D) {
	return comb(D - B + A - C, D - B);
}

ll Pow (ll A, ll B) {
	if(!B) return 1;
	ll R = Pow(A, B/2);
	R = R * R % mod;
	if(B&1) R = R * A % mod;
	return R;
}

int main()
{
	scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
	for(ll i=1;i<N;i++) {
		fac[i] = fac[i-1] * i % mod;
		fi[i] = Pow(fac[i], mod-2);
	}
	for(ll i=1;;i++) {
		ll X = a+i, Y = b+i;
		if(X > h || Y > w) break;
		ans = (ans + calc(h, 1, X, Y) * calc(X, Y, 1, w)) % mod;
	}
	printf("%lld\n",ans);
}


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

using namespace std;

int main() {
	string S;
	cin >> S;
	int Sc = 0, Tc = 0;
	int ans = 0;
	for( size_t i = 0; i < S.size(); i++ ) {
		if( S[i] == 'S' ) {
			Sc++;
		} else {
			if( Sc ) {
				Sc--;
				ans++;
			}
		}
	}
	cout << S.size() - (ans * 2) << endl;
}

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

int main() {
    vector<string> vstr;
    string str;
    vector<int> vint;
    vector<vector<int> > vvint;
    int i, j, m, h, n = 0;

    while(1) {
        cin >> str;
        if(str == "-") break;
        ++n;
        vstr.push_back(str);
        cin >> m;
        for(i=0; i<m; ++i) {
            cin >> h;
            vint.push_back(h);
        }
        vvint.push_back(vint);
        vint.clear();
    }

    for(i=0; i<n; ++i) {
        for(j=0; j<vvint[i].size(); ++j) {
            str = vstr[i].substr(0, vvint[i][j]);
            vstr[i].erase(0, vvint[i][j]);
            vstr[i].append(str);
        }
        cout << vstr[i] << endl;
    }

    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
//const int mod = 1000000007;
const ll mod = INF / 1000;


vector<pair<ll, int >> factorize(ll n) {
    vector<pair<ll, int >> res;

    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }

    if (n != 1) res.emplace_back(n, 1);
    return res;

}

ll comb(ll l, ll r) {
    vector<ll> factors(50);
    for (ll j = l; j > (l - r); j--) {
        auto fs = factorize(j);
        for (auto f : fs) {
            factors[f.first] += f.second;
        }
    }

    for (ll j = 1; j <= r; j++) {
        auto fs = factorize(j);
        for (auto f : fs) {
            factors[f.first] -= f.second;
        }
    }

    ll s = 1;

    for (int j = 1; j < 50; j++) {
        for (int k = 0; k < factors[j]; k++) {
            s *= j;
        }
    }

    return s;

}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    vector<ll> values(n);
    rep(i, n) cin >> values[i];

    sort(values.rbegin(), values.rend());

    {
        double sum = 0;
        for (int i = 0; i < a; i++) {
            sum += values[i];
        }
        printf("%.10f\n", sum / a);

    }


    ll min_element = values[a - 1];
    ll min_element_count = accumulate(values.begin(), values.end(), 0ll, [&](ll m, ll n) {
        if (n == min_element) return m + 1;
        return m;
    });

    ll large_element_count = accumulate(values.begin(), values.end(), 0ll, [&](ll m, ll n) {
        if (n > min_element) return m + 1;
        return m;
    });

    ll can_choose = [&] {
        return min(b - large_element_count, min_element_count);
    }();

    ll need_choose = [&] {
        return a - large_element_count;
    }();

    if (values[0] == min_element) {

        ll ans = 0;
        for (ll i = need_choose; i <= can_choose; i++) {
            ll now = comb(min_element_count, i);
            ans += now;
        }

        cout << ans << endl;
    } else {
        ll ans = comb(min_element_count, need_choose);
        cout << ans << endl;

    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

ll N, M, num[] = {0, 0};
vector<int> edge[100000];
int col[100000];
bool res = true;

void dfs(int now){
    int c = col[now];
    num[c]++;
    for(auto &e: edge[now]){
        if(col[e] == -1){
            col[e] = (c+1)%2;
            dfs(e);
        }
        elif(col[e] == c){
            res = false;
        }
    }
}

int main(){
    cin >> N >> M;
    rep(i, M){
        int u, v;
        cin >> u >> v;
        u--, v--;
        edge[u].pb(v), edge[v].pb(u);
    }
    fill_n(col, 100000, -1);
    col[0] = 0;
    dfs(0);
    if(!res){
        cout << N*(N-1)/2 - M << endl;
    }
    else{
        cout << num[0]*num[1]-M << endl;
    }
}

Measured memory_bytes: 6912
#include<iostream>
using namespace std;
int main()
{
    int n, p = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
           int k = 0;
        if(i % 2 == 1)
        {
            for(int j = 1; j <= i; j++)
            {
                if(i % j == 0)
                    k++;
            }
        }
        if(k == 8)
            p++;
    }
    cout << p;
    return 0;
}

Measured memory_bytes: 256
a,b,h,m = map(int,input().split())
t = 60 * h + m#経過時間
aa = t / 360
bb = t / 30
import math
if aa >= bb:
    θ = (aa - bb)
else:
    θ = (bb - aa)
theta1 = θ * math.pi
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(theta1))
print(c)


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

using namespace std;

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


int main()
{
  int a, b;
  cin >> a >> b;
  if (a == b) {
    cout << "Draw" << endl;
  }else if(a == 1){
    cout << "Alice" << endl;
  }else if(b == 1){
    cout << "Bob" << endl;
  }else if (a > b){
    cout << "Alice" << endl;
  }else if (a < b) {
    cout << "Bob" << endl;
  }
  return 0;
}


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

int main(){
   ll a[5];
   for(int i=0;i<5;i++)
   cin>>a[i];
   for(int i=0;i<5;i++)
   {
       if(a[i]==0)
       {
           cout<<i+1<<endl;
           break;
       }
   }
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int n;

int main()
{
  fastio;
  cin >> n;
  bool Check = true;
  for (int i = 1; i <= n; i++){
    int x; cin >> x;
    if (x % 2) continue;
    if ((x % 3 == 0) || (x % 5 == 0)) continue;
    Check = false;
  }
  cout << (Check ? "APPROVED" : "DENIED");
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn rle(s: Vec<char>) -> Vec<(char, u64)> {
    let mut res: Vec<(char, u64)> = Vec::new();
    let mut pre = ' ';
    let mut chain = 1;

    for c in s.into_iter() {
        if c == pre {
            chain += 1;
        } else {
            if pre != ' ' {
                res.push((pre, chain));
            }
            pre = c;
            chain = 1;
        }
    }
    res.push((pre, chain));
    res
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let rle = rle(s);
    let mut ans = 0;
    //println!("{:?}", rle);

    //先端の処理
    if rle[0].0 == '>' {
        ans += (rle[0].1 * (rle[0].1 + 1)) / 2;
    }
    let mid_ans: u64 = rle[..]
        .windows(2)
        .map(|v| {
            let mut res = 0;
            if v[0].0 == '<' && v[1].0 == '>' {
                if v[0].1 >= v[1].1 {
                    res += (v[0].1 * (v[0].1 + 1)) / 2;
                    res += (v[1].1 * (v[1].1 - 1)) / 2;
                }else{
                    res += (v[0].1 * (v[0].1 - 1)) / 2;
                    res += (v[1].1 * (v[1].1 + 1)) / 2;
                }
            }
            res
        })
        .sum();
    //println!("{}", mid_ans);
    ans += mid_ans;
    //終端の処理
    if let Some(v) = rle.last() {
        if v.0 == '<' {
            ans += (v.1 * (v.1 + 1)) / 2;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 8376
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
ll ji,ou;
ll n;
ll x;
int main()
{
	n=read();
	for(rg int i=1;i<=n;++i)
	{
		x=read();
		if(x%2==0)
		{
			ou++;
		}	
		else if(x%2!=0)
		{
			ji++;
		}	
	}
	while(1)
	{
		if(ji<=1&&ou<= 1)
		{
			break;
		}
		if(ji>=2)
		{
			ji-=2;
			ou+=1;
		}
		if(ou>=2)
		{
			ou--;
		}
	}
	if(ji+ou==1)
	{
		cout<<"YES";
		return 0;
	}
	else
	{
		cout<<"NO";
		return 0;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>

#define rep(i,p,n) for(int i=p;i<n;i++)
#define lli long long int
#define vi vector<int> 

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}


int main() {
	string s;
	cin >> s;
	string ss = "CODEFESTIVAL2016";

	int count = 0;
	rep(i, 0, s.length()) {
		if (s[i] != ss[i])count++;
	}

	p(count);



	return 0;
}

Measured memory_bytes: 256
using System;

namespace Abc087
{
    class Program
    {
        static void Main(string[] args)
        {
            uint A = uint.Parse(Console.ReadLine());
            uint B = uint.Parse(Console.ReadLine());
            uint C = uint.Parse(Console.ReadLine());
            uint X = uint.Parse(Console.ReadLine());

            int Count = 0;

            for (int i = 0; i <= A; i++)
            {
                for (int j = 0; j <= B; j++)
                {
                    for (int k = 0; k <= C; k++)
                    {
                        if ((500 * i + 100 * j + 50 * k) == X)
                        {
                            Count++;
                        }
                    }
                }
            }

            Console.WriteLine(Count);
        }
    }
}


Measured memory_bytes: 27560
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
    }

    match n {
        25 => println!("Christmas"),
        24 => println!("Christmas Eve"),
        23 => println!("Christmas Eve Eve"),
        _  => println!("Christmas Eve Eve Eve"),
    }
}

Measured memory_bytes: 4352
n, m = map(int, input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    if s[i:i + 2] == "AC":
        t[i + 1] = t[i] + 1
    else:
        t[i + 1] = t[i]
for i in range(m):
    a, b = map(int, input().split())
    print(t[b-1] - t[a-1])

Measured memory_bytes: 6188
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

def bit_search(bit_num)
  for x in [*0...2**bit_num]
    # true, falseの配列がyieldされる
    yield x.to_s(2).rjust(bit_num, '0').split('').map { |s| s == '1' }
  end
end

N, M = get_ints
K = []
S = Array.new(M) { [] }
M.times do |i|
  line = get_ints_minus_one
  K[i] = line[0]
  S[i] = line[1..]
end
P = get_ints

ans = 0
bit_search(N) do |n_arr|
  count = 0
  S.each.with_index do |s_arr, p_index|
    on_count = s_arr.each.count { |s| n_arr[s] }
    count += 1 if on_count % 2 == P[p_index]
  end
  ans += 1 if count == M
end

puts ans


Measured memory_bytes: 14372
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve()
{
  int N, M; cin >> N >> M;
  LL ans = 0;
  vector<pair<LL, int>> shops; shops.reserve(N);
  REP0(i, N)
  {
      LL A; int B; cin >> A >> B;
      pair<LL, int> shop = make_pair(A, B);
      shops.push_back(shop);
  }

  auto sort_func = [](pair<LL, int> A, pair<LL, int> B){
      return A.first < B.first;
  };

  sort(shops.begin(), shops.end(), sort_func);

  for (auto shop : shops)
  {
     if (M == 0) break;
     if (M >= shop.second) {
         M -= shop.second;
         ans += shop.second * shop.first;
     } else {
         ans += M * shop.first;
         M = 0;
     }
  }
  cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << std::setprecision(12) << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	int aa,bb,h,m;
	std::cin >> aa >> bb >> h >> m;
	m+=h*60;
	long double a=aa,b=bb;
	long double pi = std::atan((long double)1)*4;
	long double c = std::sqrt(a*a+b*b-2*a*b*std::cos((long double)(11)/360.0*pi*m));
	print(c);
	return 0;
}


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

using namespace std;

const int MAXN = 1E5;
int setNum[MAXN + 1];
int pos[MAXN + 1];
vector<int> sets[MAXN + 1];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        setNum[i] = i;
        sets[i].push_back(i);
    }
    bool valid = true;
    for (int i = 0; valid && i < m; i++)
    {
        int l, r, d;
        cin >> l >> r >> d;
        if (setNum[l] == setNum[r])
        {
            if (pos[r] - pos[l] != d)
                valid = false;
        }
        else
        {
            int a = l;
            int b = r;
            int offset = pos[b] - d - pos[a];
            if ((int) sets[setNum[a]].size() > (int) sets[setNum[b]].size())
            {
                offset = pos[a] + d - pos[b];
                swap(a, b);
            }
            for (int x : sets[setNum[a]])
            {
                pos[x] += offset;
                setNum[x] = setNum[b];
                sets[setNum[b]].push_back(x);
            }
        }
    }
    if (valid)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 10236
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main() {
	int a[5];
	for (int i = 0; i < 5; ++i) {
		cin >> a[i];
	}

	for (int i = 0; i < 5; ++i) {
		if (a[i] == 0) {
			cout << i + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3164
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  struct Edge {
    int to, cost;
  };
  vector<deque<Edge>> g(N);
  for (int i = 0; i < N - 1; ++i) {
    int a, b, c;
    cin >> a >> b >> c, --a, --b;
    g[a].push_back(Edge{b, c});
    g[b].push_back(Edge{a, c});
  }
  int Q, K;
  cin >> Q >> K, --K;
  using ll = long long;
  using P = pair<ll, int>;
  constexpr ll kInf = numeric_limits<ll>::max();
  vector<ll> rec(N, kInf);
  priority_queue<P, vector<P>, greater<P>> pq;
  rec[K] = 0;
  pq.emplace(0, K);
  while (!pq.empty()) {
    ll cost_sum;
    int v;
    tie(cost_sum, v) = pq.top();
    pq.pop();
    for (const auto& e : g[v]) {
      if (rec[e.to] <= cost_sum + e.cost) continue;
      rec[e.to] = cost_sum + e.cost;
      pq.emplace(rec[e.to], e.to);
    }
  }
  for (int i = 0; i < Q; ++i) {
    int x, y;
    cin >> x >> y, --x, --y;
    cout << (rec[x] + rec[y]) << '\n';
  }
}


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

int main()
{
	int n;
	int ans = 100000;
	std::cin >> n;
	
	while( n-- ){
		ans *= 1.05;
		int temp = ans % 1000;
		if( temp ){
		 	ans -= temp;
			ans += 1000;
		}
	}
	
	std::cout << ans << std::endl;

	return 0;
}

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

using namespace std;

int main()
{
  	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	
  	int a, b;
  	
  	cin >> a >> b;
  
  	if(a <= 0 && 0 <= b) cout << "Zero" << endl;
  	else if(max(-a, 0) - max(-b + 1, 0) & 1) cout << "Negative" << endl;
  	else cout << "Positive" << endl;
  
  	return 0;
}

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

int main()
{
  int H, W, K;

  cin >> H >> W >> K;

  vector<vector<char>> c(H, vector<char>(W));

  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> c.at(i).at(j);
    }
  }

  int ans = 0;

  for (int i = 0; i < (1 << H); i++)
  {
    for (int j = 0; j < (1 << W); j++)
    {
      int cnt = 0;
      for (int k = 0; k < H; k++)
      {
        for (int l = 0; l < W; l++)
        {
          if ((i & (1 << k)) || (j & (1 << l)))
          {
            continue;
          }
          if (c.at(k).at(l) == '#')
          {
            cnt++;
          }
        }
      }
      if (K == cnt)
      {
        ans++;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
vector<int64_t>data(N+1);
  data.at(0)=2;
  data.at(1)=1;
for(int i=2;i<N+1;i++){
	data.at(i)=data.at(i-1)+data.at(i-2);
}  
 cout<<data.at(N)<<endl; 
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
	char a[55][55];
int main()
{
	int n, m; cin >> n >> m; 
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			cin >> a[i][j];
		}
	}
	
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (a[i][j] == '#')cout << "#";
			else
			{
				int sum = 0;
				if (a[i - 1][j - 1] == '#')sum++;
				if (a[i][j - 1] == '#')sum++;
				if (a[i - 1][j] == '#')sum++;
				if (a[i][j + 1] == '#')sum++;
				if (a[i - 1][j + 1] == '#')sum++;
				if (a[i + 1][j] == '#')sum++;
				if (a[i + 1][j + 1] == '#')sum++;
				if (a[i + 1][j - 1] == '#')sum++;
				cout << sum;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

VL solve(int N, VI X, VI Y, VI P){
    int mul = 1;
    REP(i,N) mul *= 3;
    VVI xsel(1<<N, VI(N));
    VVI ysel(1<<N, VI(N));
    REP(i,(1<<N)){
        REP(j,N){
            xsel[i][j] = abs(X[j]);
            ysel[i][j] = abs(Y[j]);
            REP(k,N){
                if((i >> k)&1){
                    chmin(xsel[i][j], abs(X[j] - X[k]));
                    chmin(ysel[i][j], abs(Y[j] - Y[k]));

                }
            }
        }
    }

    VL ans(N+1, LINF);
    REP(i,(1<<N)){
        int cnt = 0;
        REP(j,N){
            if((i >> j) & 1) cnt++;
        }
        for(int j = i; j >= 0; j--){
            j &= i;
            LL cost = 0;
            REP(k,N){
                //if(!((i >> k) & 1)){
                    cost += 1LL * min(xsel[j][k], ysel[i-j][k]) * P[k];
                //}
            }
            chmin(ans[cnt], cost);
        }
    }
    return ans;

}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    VI X(N),Y(N),P(N);
    REP(i,N) cin >> X[i] >> Y[i] >> P[i];
    VL ans = solve(N,X,Y,P);
    for(LL a : ans) cout << a << endl;
}

Measured memory_bytes: 9804
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

char s[10003];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	scanf("%s", s + 1); int len = strlen(s + 1), ans = 0;
	for (int i = 1; i <= len / 2; i+=1)
	{
		if (s[i] != s[len - i + 1]) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().parse::<usize>().unwrap();

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut an = vec![0];
    let iter = buf.trim().split_whitespace();
    for it in iter {
        an.push(it.parse::<i32>().unwrap());
    }
    let mut sum = 0;
    for i in 0..n {
        sum += (an[i+1] - an[i]).abs();
    }
    sum += an[n].abs();
    for i in 0..n-1 {
        println!("{}", sum - (an[i+1] - an[i]).abs() - (an[i+2] - an[i+1]).abs() + (an[i+2] - an[i]).abs());
    }
    println!("{}", sum - (an[n] - an[n-1]).abs() - an[n].abs() + an[n-1].abs());
}


Measured memory_bytes: 5244
/** author: __nishad__ **/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int n;
    cin>>n;

    n = n%10;

    if(n==2 || n==4 || n==5 || n==7 || n==9)
        cout<<"hon";
    else if(n==3)
        cout<<"bon";
    else
        cout<<"pon";



}




Measured memory_bytes: 3592
import sys
import numpy as np
read = sys.stdin.readline


def main(n, k, a):
    for i in np.arange(n, 100000):
        ok = True
        for j in str(i):
            ok &= j not in a
        if ok:
            print(i)
            break


if __name__ == '__main__':
    n, k = np.fromstring(read(), dtype=np.int32, sep=' ')
    a = set(read().split())
    main(n, k, a)


Measured memory_bytes: 27384
/*
 © 2020-07-05 06:57:04 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli h, w, k; cin >> h >> w >> k;
  vector<string> m(h);
  fore(i, 0, h){
    cin >> m[i];
  }
  lli ans = 0;
  fore(x, 0, 1ll << h){
    fore(y, 0, 1ll << w){
      lli aux = 0;
      fore(i, 0, h){
        fore(j, 0, w){
          if((x & (1ll << i)) and (y & (1ll << j))){
            if(m[i][j] == '#') aux++;
          }
        }
      }
      if(aux == k) ans++;
    }
  }
  cout << ans << ENDL;
  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

#define DICE 6
#define CMD 128

typedef struct {
  int side[DICE];
  int tmp;
  char command[CMD];
} dice_t;

int main(void){
  int i;
  dice_t d;

  for (i = 0; i < DICE; i++)
    scanf("%d", &d.side[i]);
  scanf("%s", d.command);

  for (i = 0; d.command[i] != '\0'; i++) {
    switch (d.command[i]) {
    case 'N':
      d.tmp = d.side[0];
      d.side[0] = d.side[1];
      d.side[1] = d.side[5];
      d.side[5] = d.side[4];
      d.side[4] = d.tmp;
      break;
    case 'S':
      d.tmp = d.side[0];
      d.side[0] = d.side[4];
      d.side[4] = d.side[5];
      d.side[5] = d.side[1];
      d.side[1] = d.tmp;
      break;
    case 'W':
      d.tmp = d.side[0];
      d.side[0] = d.side[2];
      d.side[2] = d.side[5];
      d.side[5] = d.side[3];
      d.side[3] = d.tmp;
      break;
    default: //case 'E':
      d.tmp = d.side[0];
      d.side[0] = d.side[3];
      d.side[3] = d.side[5];
      d.side[5] = d.side[2];
      d.side[2] = d.tmp;
      break;
    }
  }
  printf("%d\n", d.side[0]);
  return 0;
}

Measured memory_bytes: 596
(let* ((lst (list (read) (read) (read)))
       (lst2 (remove-duplicates
               (loop for i in lst
                     collect (cons i (count i lst)))
               :test #'equal)))

  (format t "~A~%"
          (if
            (or (equal lst2 '((5 . 2) (7 . 1)))
                (equal lst2 '((7 . 1) (5 . 2))))
            'yes 'no)))



Measured memory_bytes: 23376
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	long ans = long.max;
	long i;
	while (i^^2 <= N)
	{
		++i;
		if (N % i != 0) continue;

		auto x = max(N / i, i);
		//stderr.writeln(i, " ", x);
		long cnt;
		while (x != 0)
		{
			++cnt;
			x /= 10;
		}
		ans = min(ans, cnt);
	}
	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 256
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,m = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに
sc =[]
for i in range(m):
    l = list(map(int, stdin.readline().rstrip().split()))
    sc.append(l)

ans = 0

if n == 1:
    mini = 0
    max = 9
elif n == 2:
    mini = 10
    max = 99
else:
    mini =100
    max = 999


for num in range(mini,max+1):
    a = 1
    for i in range(m):
        s,c = sc[i]
        try:
            if str(num)[s-1]==str(c):
                pass
            else:
                a = 0
        except:
            a = 0

    if a == 1:
        print(num)
        exit()

print(-1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int ord(int n){
    int ret=0;
    while(n){
        n/=10;
        ret++;
    }
    return ret;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,b,t;
    long long ans=0;
    cin>>n;
    int d[10][10];
    memset(d,0,sizeof(d));
    for(int i=1;i<=n;i++){
        b=i%10;
        t=i/((int)pow(10,ord(i)-1));
        d[t][b]++;
    }
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            ans+=d[i][j]*d[j][i];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
import sys
import time
def input():
    return sys.stdin.readline()
 
def main():
    a = time.time()
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    l = [0] * N
    ans = 0
    count = 0
    check = [False] * N
    tmpl = []
    next = False
 
    while(count < N):
        check = [False] * N
        for i in range(N):
            if l[i] < N - 1:
                to = A[i][l[i]] - 1
                if (not check[to]) and (not check[i]):
                    if A[to][l[to]] - 1 == i:
                        l[i] += 1
                        l[to] += 1
                        check[to] = True
                        check[i] = True
                        next = True
                    if l[i] == N - 1:
                        count += 1
                    if l[to] == N - 1:
                        count += 1
        ans += 1
        if not next:
            print(-1)
            exit()
        next = False

        b = time.time()
        if b - a >= 1.7:
            print(N*(N - 1)//2)
            exit()
        # print(l, ans)
 
    print(ans)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 35112
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll cnt4 = 0;
  ll cnt2 = 0;
  ll cnt1 = 0;
  for (int i = 0; i < N; i++) {
    a[i] %= 4;
    if (a[i] == 0) {
      cnt4++;
    } else if (a[i] == 2) {
      cnt2++;
    } else {
      cnt1++;
    }
  }

  bool OK;

  if (cnt4 == 0 && cnt1 == 0) {
    OK = true;
  } else {
    if (cnt4 == 0) {
      OK = false;
    } else {
      if (cnt2 != 0) {
        cnt1++;
      }
      if (cnt4 + 1 < cnt1) {
        OK = false;
      } else {
        OK = true;
      }
    }
  }

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

Measured memory_bytes: 4384
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

m,n,k = map(int,readline().split())

def comb(n, r, mod):
    r = min(r, n-r)
    mol = 1
    deno = 1
    for i in range(1, r+1):
        mol = mol * (n-r+i) % mod
        deno = deno * i % mod
    ret = mol * pow(deno, mod-2, mod) % mod
    return ret

def f1(x,y,a,b):
    return (a+b-x-y)*(a-x+1)*(b-y+1)//2

def f2(x,a):
    return (a-x)*(a-x+1)//2

ans = 0

for x in range(1,n+1):
    for y in range(1,m+1):
        ans += f1(x,y,n,m)+f1(1,1,x,y)+f1(1,y,x,m)+f1(x,1,n,y)
        ans -= f2(x,n) + f2(1,x) + f2(1,y) + f2(y,m)
        ans %= mod

ans = (ans * comb(m*n-2,k-2,mod))%mod
ans = ans*pow(2,mod-2,mod)%mod

print(ans)


Measured memory_bytes: 9432
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	int N;
	cin>>N;
	vector<long long> A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.push_back(a);
	}
	sort(A.begin(),A.end());
	long long sum = 0;
	int ans = 0;
	for (int i = 0;i < N - 1 ;i++){
		ans ++;
		sum += A[i];
		if (2*sum < A[i+1]) ans = 0;
	}
	ans++;
	cout<<ans<<endl;
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] list = str.split(" ");
		String answer = "";
		for(int i=0; i<3; i++){
			answer = answer +  list[i].substring(0, 1).toUpperCase();
		}
		System.out.println(answer);

	}

}


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

using namespace std;

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


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

int main(){
	int n, x;
	int count;

	while(1){
		count = 0;
		cin >> n >> x;
		if( n == 0 && x == 0) break;
		for(int i = 1 ; i <= n - 2; i++){
			for(int j = i+1; j <= n - 1; j++){
				for(int k = j+1; k <= n; k++){
					if((i + j + k) == x){
						count++;
						//cout << i << '+' << j << '+' << k << endl;
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;

int main(){
  string s;
  cin >> s;
  int alph[26] = { 0 };
  
  rep(i,s.length()){
    alph[ (int)(s[i]-'a') ]++;
  }
  
  int out=0;
  while(alph[out] != 0){
    out++;
    if(out == 26) break;
  }
  
  if(out == 26) cout << "None" << endl;
  else cout << (char)('a' + out) << endl;
  
  return 0;
}

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

int main(){
    vector<int> vec(101);
    int i,j;
    int t;
   // int min;
    int N;
    cin >> N;
    for(i=0;i<N;i++){
        cin >> vec.at(i);
    }
 //   min=vec.at(0);
    for(i=N-1;i>=0;i--){
        for(j=0;j<i;j++){
            if(vec.at(j)>vec.at(j+1)){
              t=vec.at(j);
              vec.at(j)=vec.at(j+1);
              vec.at(j+1)=t;  
              //min=vec.at(j+1);
            }
        }
    }
  /*  for(i=0;i<N;i++){
    cout << vec.at(i) <<" ";
    }
    cout << endl;*/
   int count=0;
   for(i=0;i<N;i++){
       if(vec.at(i)==vec.at(i+1)){
           count++;
       }
   }
   //cout << count <<endl;
   cout << N-count << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		int [] ni = new int[n];
		int difference = 0;
		List<Integer> heights = new ArrayList<Integer>();
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ni[i] = sc.nextInt();
		}
		for(int i = 0; i < n-1; i++) {
			if(ni[i] < ni[i+1]) {
				heights.add(difference);
				difference = 0;
			}else {
				difference++;
				if(i == n-2) {
					heights.add(difference);
				}
			}
		}
		for(int i = 0; i < heights.size(); i++) {
			if(ans <= heights.get(i)) {
				ans = heights.get(i);
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 50292
n = int(input())
l = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]: continue
            if l[i] >= l[j] + l[k]: continue
            if l[j] >= l[i] + l[k]: continue
            if l[k] >= l[i] + l[j]: continue
            ans += 1
print(ans)

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

using CP = complex<long double>;
#define X real()
#define Y imag()
const long double PI = acos(-1);
const long double EPS = 1e-10;
// conj(x) : complex conjugate,(0,1)->(0,-1)
// abs(x) : dist between(0,0) and x
// norm(x) : abs(x) * abs(x)
// arg(x) : argment
long double dot(CP a, CP b) { return (a * conj(b)).X; }
long double cross(CP a, CP b) { return (a * conj(b)).Y; }
long double corner(CP a, CP b) {
    //[0,pi]
    return acos(dot(a, b) / (abs(a) * abs(b)));
}

CP intersection(CP a, CP b, CP c, CP d) {
    return a + (b - a) * (cross(d - c, c - a) /
                          cross(d - c, b - a));
}

long long n;
vector<CP> points;
CP ans(0,0);

void solve();

int main() {
    cout << fixed << setprecision(10);
  cin >> n;
  for(int i = 0;i < n;++i){
      long double x,y;
      cin >> x >> y;
      points.push_back(CP(x,y));
  }
  solve();
  if(ans == CP(-1,-1))cout <<"NA" << endl;
  else cout << ans.X << " " << ans.Y << endl;
  return 0;
}


void solve(){
    if(n % 2){
        ans = CP(-1,-1);
        return;
    }
    ans = (points[0] + points[n/2]);
    ans /= 2;
    for(int i = 0;i < n/2;++i){
        CP now = (points[i] + (points[n/2+i]));
        now /= 2;
        if(abs(ans - now) > EPS){
            ans = CP(-1,-1);
            return;
        }
    }
}


Measured memory_bytes: 3340
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll f(ll n) {
	return n*(n+1)/2;
}

int main() {
	int	n;
	ll	ans = 0;
	cin >> n;
	rep(i,n){
		ll r = n/i;
		ans += i * f(r);
	}
	cout << ans <<endl;
}

Measured memory_bytes: 3548
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define INF (1<<29)
#define EPS (1e-10)
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;

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

int main(){
	int N, K;
	cin >> N >> K;
	vii dp(N+1, vi(3, 1));
	for (int k=0; k<K; k++) {
		int A, B;
		cin >> A >> B;
		for (int b=0; b<3; b++) {
			if (b == B-1) continue;
			dp[A][b] = 0;
		}
	}

	for (int d=2; d<=N; d++) {
		for (int i=0; i<3; i++) {
			if (dp[d][i] == 0) continue;
			int sum = 0;
			for (int j=0; j<3; j++) {
				if (dp[d-1][j] == 0) continue;
				if (j == i && d != 2) {
					for (int k=0; k<3; k++) {
						if (k == j) continue;
						sum += dp[d-2][k];
					}
				} else {
					sum += dp[d-1][j];
				}
			}
			dp[d][i] = sum%MOD;
		}
	}
	int ans = dp[N][0]+dp[N][1]+dp[N][2];
	cout << ans%MOD << endl;
}

Measured memory_bytes: 1216
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)
#print("x = ", x)
#print("a = ", a)
#print("b = ", b)

if x < a:
  distance_xa = a - x
else:
  distance_xa = x - a
#print("distance_xa = ", distance_xa)

if x < b:
  distance_xb = b - x
else:
  distance_xb = x - b
#print("distance_xb = ", distance_xb)

if distance_xa < distance_xb:
  print("A")
else:
  print("B")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 998244353
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll a[200009],f[200009];
ll h[200009];
ll n;
void fill(ll x)
{
	for(ll i=0;i<n;i++)
	{
		h[i]=x/f[i];
	}
}
ll check()
{
	ll res=0;
	for(ll i=0;i<n;i++)
	{
		res+=max((ll)0,a[i]-h[i]);
	}
	return res;
}
void solve()
{
	ll k;
	cin>>n>>k;;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(ll i=0;i<n;i++)
	{
		cin>>f[i];
	}
	sort(a,a+n);
	sort(f,f+n,greater<ll>());
	ll l=0,u=1e18,mid;
	ll ans=inf;
	while(l<=u)
	{
		mid=(l+u)/2;
		fill(mid);
		ll z=check();
		if(z>k)
		{
			l=mid+1;
		}
		else
		{
			ans=mid;
			u=mid-1;
		}
	}
	cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  deque<char>d[3];
  rep(i,0,3){
    string s;cin>>s;
    rep(j,0,s.size())d[i].push_back(s[j]);
  }
  char p[]={'A','B','C'};
  int n=0,k=0;
  while(1){
    n=k;
    if(d[n].size()==0){out(p[n]);return 0;}
    char c=d[n].front();
    k=c-'a';
    d[n].pop_front();
  }

  return 0;
}


Measured memory_bytes: 256