akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	string s,t;
	cin>>s>>t;

	bool ans=false;
	rep(i,s.length()){
		bool flag=true; 
		rep(j,s.length()){
			if(s[(j+i)%s.length()] != t[j])flag=false;
		}
		if(flag)ans=true;
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

long long dp[1000][2];

int main()
{
    int n, p, x, par(0), impar(0);
    cin >> n >> p;
    while (n--) {
        cin >> x;
        if (x & 1)
            impar++;
        else
            par++;
    }

    dp[0][0] = 1;
    for (int i(1); i <= 100; i++)
        dp[i][0] = dp[i - 1][0] + dp[i - 1][1], dp[i][1] = dp[i - 1][1] + dp[i - 1][0];

    cout << (1ll << par) * dp[impar][p];

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int total;
  int price;
  int i;

  while(1){
    scanf("%d", &total);
    if(total == 0) break;
    for(i = 0; i < 9; i++){
      scanf("%d", &price);
      total = total - price;
    }

    printf("%d\n", total);
  }

  return 0;
}

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

int solve();

int main()
{
	printf("%d\n", solve());

	return 0;
}

int solve()
{
	int N;
	scanf("%d", &N);
	std::vector<int> a(N);
	for (auto& e: a) scanf("%d", &e);
	int nim{};
	for (auto& e: a) nim ^= e;
	std::vector<int> bucket(31);
	for (auto& e: a)
	{
		int digit{};
		while (~e >> digit & 1) digit++;
		bucket[digit]++;
	}

	int ans{};
	for (int i{30}; i >= 0; i--)
	{
		if (((nim >> i & 1) ^ (nim >> (i + 1) & 1)))
		{
			if (bucket[i] == 0) return -1;
			ans++;
		}
	}
	return ans;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string s1,s2;
  cin >> s1 >> s2;
  if(s1[0]==s2[2]&&s2[1]==s1[1]&&s1[2]==s2[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
 
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);
 
 
ll n, m, x, k;
 
void solve()
{
   string s;
   cin >>k >>  s;
   ll n = s.size();
   if(n <= k) cout << s << endl;
   else{ cout << s.substr(0,k);
   for(int i = k ; i < k+3 ; i ++)
   cout <<'.';
   cout << endl;
   }
}
 
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int n, k;
  while(cin >> n >> k, n || k) {
    int a[n]; FOR(i,0,n) cin >> a[i];
    int sum = 0;
    FOR(i,0,k) sum += a[i];
    int mx = sum;
    FOR(i,k,n) {
      sum += a[i];
      sum -= a[i-k];
      mx = max(mx, sum);
    }
    cout << mx << '\n';
  }
  return 0;
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

struct Combination {
	vector<int64_t> _fact, _rfact, _inv;
	int64_t MOD;

	Combination(size_t sz, int64_t mod) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1), MOD(mod) {
		_fact[0] = _rfact[sz] = _inv[0] = 1;
		for (int i = 1; i <= sz; ++i) {
			_fact[i] = _fact[i - 1] * i % MOD;
		}
		_rfact[sz] = inverse(_fact[sz]);
		for (int i = sz - 1; i >= 0; --i) {
			_rfact[i] = _rfact[i + 1] * (i + 1) % MOD;
		}
		for (int i = 1; i <= sz; ++i) {
			_inv[i] = _rfact[i] * _fact[i - 1] % MOD;
		}
	}

	inline int64_t fact(int k) const { return _fact[k]; }
	inline int64_t rfact(int k) const { return _rfact[k]; }
	inline int64_t inv(int k) const { return _inv[k]; }

	int64_t inverse(int64_t x) const { return pow(x, MOD - 2); }
	int64_t pow(int64_t x, int64_t n) const {
		int64_t ret = 1;
		while (n > 0) {
			if (n & 1) { (ret *= x) %= MOD; }
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;
	}

	int64_t P(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(n - r) % MOD;
	}
	int64_t C(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(r) % MOD * rfact(n - r) % MOD;
	}
	int64_t H(int n, int r) const {
		if (n < 0 || r < 0) { return 0; }
		return r == 0 ? 1 : C(n + r - 1, r);
	}
};

int main() {
	constexpr Int MOD = 1e9 + 7;
	int K;
	string s;
	cin >> K >> s;

	int n = s.size();
	int L = n + K;
	Combination cb(L, MOD);
	Int ans = 0;
	for (int i = n - 1; i < L; ++i) {
		(ans += cb.C(i, n - 1) * cb.pow(25, i - n + 1) % MOD * cb.pow(26, L - i - 1)) %= MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 51148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=200005;
vi v[N];
int d[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,x,y,m;
  cin>>n>>m;
  rep(i,1,m+1)
    {
      cin>>x>>y;
      v[x].pb(y); v[y].pb(x);
    }
  rep(i,1,n+1) d[i]=n+100;
  queue<int> q;
  q.push(1); d[1]=0;
  while(!q.empty())
    {
      int u=q.front();
      q.pop();
      for(int v1:v[u])
	{
	  if(d[v1]==n+100)
	    {
	      q.push(v1);
	      d[v1]=d[u]+1;
	    }
	}
    }
  cout<<((d[n]==2)?"POSSIBLE":"IMPOSSIBLE")<<endl;
  return 0 ;
}


Measured memory_bytes: 13168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            int N = int.Parse(line);

            Console.WriteLine((int)((N+1)/2));
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> mypair;
int d(int a,int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
int main(void){
int n;
cin>>n;
vector<int> a(n+2);
a[0]=a[n+1]=0;
mypair ans=mypair(0,0);
for(int i=1;i<n+1;i++){
	cin>>a[i];
	
			ans.first+=d(a[i],ans.second);
			ans.second=a[i];
		
	
}
ans.first+=d(a[n+1],ans.second);
for(int i=0;i<n;i++){
	cout<<ans.first-d(a[i],a[i+1])-d(a[i+1],a[i+2])+d(a[i],a[i+2])<<endl;
}
	return 0;
}

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

int main() {
	int n;
	long long d;
	cin >> n >> d;
	int c=0;
	for(int i=0;i<n;i++)
	{
		long long x,y,dd=d*d;
		cin >> x >> y;
		x=x*x;
		y=y*y;
		if(x+y<=dd)
		{
			c++;
		}
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vi = vector<int>;
using vl = vector<i64>;
using vd = vector<double>;
using pi = pair<int, int>;
using pl = pair<i64, i64>;
using pd = pair<double, double>;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

void dfs(vector<vector<pl>> &edges, vi &color) {
  auto cnt = 0;
  queue<i64> q;
  q.push(0);
  while (!q.empty()) {
    auto i = q.front();
    q.pop();
    for (auto &&p : edges[i]) {
      auto v = p.first;
      auto w = p.second;
      if (color[v] != -1) continue;
      if (w == 0) {
        color[v] = color[i];
      } else {
        color[v] = 1 - color[i];
      }
      q.push(v);
    }
  }
}

int main() {
  int n;
  cin >> n;
  vector<vector<pl>> edges(n);
  vi color(n, -1);
  color[0] = 0;
  REP(i, n) {
    i64 ui, vi, wi;
    cin >> ui >> vi >> wi;
    edges[ui - 1].push_back(make_pair(vi - 1, wi % 2));
    edges[vi - 1].push_back(make_pair(ui - 1, wi % 2));
  }
  dfs(edges, color);

  REP(i, n) cout << color[i] << endl;
}


Measured memory_bytes: 8320
/// hi_im_manh :D
#include <bits/stdc++.h>
#define reset(a,n) memset(a,0,(n+1)*sizeof(int))
#define endl "\n"
#define llmin LLONG_MIN
#define llmax LLONG_MAX
#define intmax INT_MAX
#define intmin INT_MIN
#define ll long long
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define duckman "TASK"

#define input freopen(duckman".inp", "r", stdin);
#define output freopen(duckman".out", "w", stdout);

#define nmax 22000
using namespace std;


int main()
{
    fast;
//    input;
//    output;

    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; i++) {
        dp[i] = intmax;
        for (int j = i-1; j >= i-2; j--) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n-1];
    return 0;
}
/*

*/


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int num = sc.nextInt();
		long[] n = new long[num];
		for(int i = 0; i < num; i++) {
			n[i] = sc.nextLong() - (long)(i+1);
		}
		Arrays.sort(n);
		long tmp;
		if(num % 2 == 0) {
			tmp = (n[num/2-1]+n[num/2])/2;
		} else {
			tmp = n[num/2];
		}
		long ans = 0;
		for(int i = 0; i < num; i++) {
			ans += Math.abs(n[i]-tmp);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 66272
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,s=0;
	cin>>n;
	while(n>0)
	{
		if(n%3!=0&&n%5!=0)
		s=s+n;
		n--;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int N,K;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N >> K;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    map<int,int> m;
    int l = 0, r = 0, cnt = 0, ans = N+1;
    for(;;){
        while(r < N && cnt != K){
            if(a[r] <= K){
                if(m[a[r]]++==0) ++cnt;
            }
            ++r;
        }
        if(cnt!=K) break;
        chmin(ans,r-l);
        if(l==r) ++r;
        if(--m[a[l++]] == 0) --cnt;
    }
    cout << (ans==N+1 ? 0 : ans) << '\n';
    return 0;
}


Measured memory_bytes: 7868
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line().split_whitespace().map(|s| s.to_string()).collect()
    }

    pub struct Reader {
        buf: VecDeque<String>
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader {buf: VecDeque::new()}
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T where T: FromStr, T::Err: Debug {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn nextN<T>(&mut self, n: usize) -> Vec<T> where T: FromStr, T::Err: Debug {
            let mut vec: Vec<T> = Vec::with_capacity(n);
            for i in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

fn f(x: i32) -> i32 {
    match x {
        2 => 0,
        4 | 6 | 9 | 11 => 1,
        _ => 2,
    }
}

fn main() {
    let mut reader = reader::Reader::new();

    let x: i32 = reader.next();
    let y: i32 = reader.next();

    println!("{}", if f(x) == f(y) {"Yes"} else {"No"});
}
 

Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int M;
    cin >> M;
    cout << 24 + (24 - M) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(void)
{
	int x, t;
	scanf("%d %d\n", &x, &t);
	x -= t;
	if(x < 0)
		x = 0;
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;

typedef long double ld;
using namespace std;


int main() {
    ll a;
    cin>>a;
    string s;
    cin>>s;

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

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

int main() {
	string s;
	int K;
	cin >> s >> K;
	vector<string> ans;
	for (int i = 0; i < K; ++i) {
		for (int j = 0; j < s.size() - i; ++j) ans.push_back(s.substr(j, i + 1));
	}
	sort(ans.begin(), ans.end());
	ans.erase(unique(ans.begin(), ans.end()), ans.end());
	cout << ans[K - 1];
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
#define X first
#define Y second

constexpr int MAXN = 300005;

int row[MAXN];
int col[MAXN];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m, q;
    cin >> n >> m >> q;
    vector<pii> arr(q);
    loop(q) {
        cin >> arr[i].X >> arr[i].Y;
        ++row[arr[i].X];
        ++col[arr[i].Y];
    }
    sort(all(arr));
    auto Has = [&arr](pii x) {
        return binary_search(all(arr), x);
    };
    vector<pii> kr, kc;
    for (int i = 1; i <= max(n, m); ++i) {
        if (row[i] > 0) {
            kr.emplace_back(row[i], i);
        }
        if (col[i] > 0) {
            kc.emplace_back(col[i], i);
        }
    }
    sort(all(kr), greater<>());
    sort(all(kc), greater<>());
    int ans = kr[0].first + kc[0].first - 1;
    for (int i = 0; i < sz(kr) && kr[i].first == kr[0].first; ++i) {
        for (int j = 0; j < sz(kc) && kc[0].first == kc[j].first; ++j) {
            if (!Has({kr[i].second, kc[j].second})) {
                RET(ans + 1);
            }
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 14264
n = int(input())
c = input()

R = 0
W = 0


for i in range(n):
    if c[i] == "R":
        R += 1
W = n - R
RR = 0
WW = 0
i = 0
while i<R:
    if c[i] == "W":
        WW +=1 
    i += 1
print(WW)




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

int main(){
    int x,y; cin >> x >> y;
    for(int i = 0; i <= x; i++) {
        if(y==2*i+4*(x-i)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {

	static int n;
	static int[] S;
	static int q;
	static int[] T;
	static int ans;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		S = new int[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		q = sc.nextInt();
		T = new int[q];
		for (int i = 0; i < q; i++) {
			T[i] = sc.nextInt();
		}
		sc.close();

		ans = 0;
		for (int i = 0; i < q; i++) {
			binarySearch(T[i]);
		}
		System.out.println(ans);
	}

	private static void binarySearch(int num) {
		int left = 0;
		int right = n;

		while (left < right) {
			int mid = (left + right) / 2;
			if (S[mid] == num) {
				ans++;
				return;
			} else if (S[mid] > num) {
				right = mid;
			} else if (S[mid] < num) {
				left = mid + 1;
			}
		}
	}
}

Measured memory_bytes: 69408
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define maxn 1005
#define ll long long 
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
int n,x,y;
int main()
{ cin>>n>>x>>y;
  cout<<min(x,y)<<' ';
  if(x+y<=n) cout<<0;
  else       cout<<(x+y-n);
	
	
return 0;	
}

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




    int main(){
        int n;
        std::cin >> n;
        std::vector<int> w(n);
        rep(i, n) std::cin >> w[i];
        int ans = 1e9;
        for (int i = 1; i < n; ++i)
        {
            int l = 0, r = 0;
            for(int j = 0; j < i; j++) l += w[j];
            for (int j = i; j < n; j++) r += w[j];
            ans = min(ans, abs(l-r));
        }
        std::cout << ans << "\n";
        return 0;
    }


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	Ki := 0
	for i := 0; i < N; i++ {
		if Ki+1 == nextInt() {
			Ki++
		}
	}
	if Ki == 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(N - Ki)
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int Maxn = 100005;
const int Maxm = 11;

int n, m;
vector <int> neigh[Maxn];
int dist[Maxn][Maxm];
int q;
int qv[Maxn], qd[Maxn], qc[Maxn];
priority_queue <iii> Q;

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b; scanf("%d %d", &a, &b);
        neigh[a].push_back(b);
        neigh[b].push_back(a);
    }
    scanf("%d", &q);
    for (int i = 1; i <= q; i++) {
        scanf("%d %d %d", &qv[i], &qd[i], &qc[i]);
        if (i > dist[qv[i]][qd[i]]) {
            dist[qv[i]][qd[i]] = i;
            Q.push(iii(i, ii(qv[i], qd[i])));
        }
    }
    while (!Q.empty()) {
        ii v = Q.top().second;
        int d = Q.top().first; Q.pop();
        if (dist[v.first][v.second] != d) continue;
        v.second--;
        if (v.second >= 0) {
            ii u = ii(v.first, v.second);
            if (d > dist[u.first][u.second]) {
                dist[u.first][u.second] = d;
                Q.push(iii(d, u));
            }
            for (int i = 0; i < neigh[v.first].size(); i++) {
                u = ii(neigh[v.first][i], v.second);
                if (d > dist[u.first][u.second]) {
                    dist[u.first][u.second] = d;
                    Q.push(iii(d, u));
                }
            }
        }
    }
    for (int i = 1; i <= n; i++)
        printf("%d\n", qc[dist[i][0]]);
    return 0;
}


Measured memory_bytes: 25576
#N = int(input())
#S = str(input())
N, A, B = map(int, input().split())
#C = list(map(int, input().split()))

def su(n):
  n = str(n)
  aa = 0
  for i in range(len(n)):
    aa += int(n[i])
  return aa
  

ans = 0
for i in range(1, N + 1):
  now = su(i)
  if A <= now <= B:
    ans += i
print(ans)
  
  


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int n; cin >> n;
    int ret = 0;
    REP(i, n){
        int num = i+1;
        if ((num/1 && !(num/10)) or (num/100 && !(num/1000)) or (num/10000 && !(num/100000))) {
            ret++;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



const int MAX = 301000;
bool Isprime[MAX];

int main() {   
    memset(Isprime, 0, sizeof(Isprime));
    for (int i = 2; i < MAX; ++i) {
        if (i % 7 != 1 && i % 7 != 6) continue;
        bool isprime = true;
        for (int j = 2; j*j <= i; ++j) {
            if (i % j == 0 && (j % 7 == 1 || j % 7 == 6)) isprime = false;
        }
        Isprime[i] = isprime;
    }
    
    int n;
    while (cin >> n) {
        if (n == 1) break;
        vint res;
        for (int i = 1; i*i <= n; ++i) {
            if (n%i == 0LL) {
                res.push_back(i);
                long long temp = n/i;
                if (i != temp) res.push_back(temp);
            }
        }
        sort(ALL(res));
        
        cout << n << ":";
        for (int i = 0; i < res.size(); ++i) {
            if (Isprime[res[i]]) cout << " " << res[i];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1516
import qualified Data.Vector.Unboxed.Mutable as UM

main = do
    n <- readLn
    as <- UM.replicateM n readLn
    solve 0 as 1 >>= print

solve ac as i = do
    x <- UM.read as (i-1)
    UM.write as (i-1) (-1)
    case x of
        -1 -> return (-1)
        2 -> return (ac+1)
        _ -> solve (ac+1) as x

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

int main()
{
    int N, M;
    cin >> N >> M;
    int R = N;
    int L = 0;

    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        L = max(L, x);
        R = min(R, y);
    }
    cout << (R - L >= 0 ? R - L + 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != 'A' 
            && s.charAt(i) != 'C'
            && s.charAt(i) != 'G'
            && s.charAt(i) != 'T') {
                continue;
            }
            if (s.substring(i).matches("[ACGT]*")) {
                len = Math.max(len, s.substring(i).length());
            }
            for (int j = i + 1; j < s.length(); j++) {
                if (s.substring(i, j).matches("[ACGT]*")) {
                    len = Math.max(len, s.substring(i, j).length());
                }
            }
        }
        System.out.println(len);
        sc.close();
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        int[][] a = new int[2][];
        a[0] = ReadIntArray();
        a[1] = ReadIntArray();

        int ct = a[0].Sum() + a[1][n-1];
        int ans = ct;
        for (int i = n-1; i >= 1; i--)
        {
            ct = ct - a[0][i] + a[1][i-1];
            ans = Math.Max(ans, ct);
        }

        WriteLine(ans);
    }
}

Measured memory_bytes: 13524
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
int d[1000000];
int main()
{
	int n,i;
  cin>>n;
  for(i=0;i<n;i++)
  {
  	cin>>d[i];
  }
  int s=0,k=0;
  for(i=1;i<n;i++)
  {
  	if(d[i]<=d[i-1])
  	s++;
  	else
  	s=0;
  	k=max(s,k);
  }
  cout<<k<<endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vector<pii> r(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> r[i].first >> r[i].second;
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i].first >> b[i].second;
    }
    sort(r.begin(), r.end(), [&](pii le, pii ri) { return le.second > ri.second; });
    sort(b.begin(), b.end());
    int ret = 0;
    vector<bool> used(n, false);
    for (int i = 0; i < n; ++i) {
        auto p = b[i];
        for (int j = 0; j < n; ++j) {
            if (!used[j] && r[j].first < p.first && r[j].second < p.second) {
                used[j] = true;
                ret++;
                break;
            }
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
scores = []
for i in range(n):
  scores.append(int(input()))

m = 0

if sum(scores) % 10 != 0:
  m = sum(scores)
else:
  scores.sort()
  for i in range(n):
    if scores[i] % 10 != 0:
      m = sum(scores) - scores[i]
      break
  
print(m)

Measured memory_bytes: 2940
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,a[205];
    while(scanf("%d",&n)!=EOF)
    {
        int ans=0;
        for(int i=0;i<2*n;i++)scanf("%d",&a[i]);
        sort(a,a+(2*n));
        for(int i=2*n-2;i>=0;i-=2) ans+=a[i];
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int N;

    cin>>N;

    vector<int>A(N);

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

    vector<int>rev(N);

    for(int i=0; i<N; i++)
    {
        rev[A[i]-1]=i+1;
       // cout<<rev[A[i]-1]<<" = "<<i+1<<endl;
    }


    for(int i=0; i<N; i++)cout<<rev[i]<<endl;
    return 0;

}

Measured memory_bytes: 3992
#include <iostream>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W));
  rep(i, H) rep(j, W) cin >> A[i][j];

  int N = 0;
  vector<tuple<int, int, int, int>> STEP;
  rep(i, H) {
    rep(j, W) {
      if (A[i][j] % 2) {
        int ni = i + 1;
        int nj = j + 1;
        if (nj < W && A[i][nj] % 2) {
          STEP.emplace_back(i, j, i, nj);
          A[i][nj]++;
          A[i][j]--;
          N++;
        } else if (ni < H && A[ni][j] % 2) {
          STEP.emplace_back(i, j, ni, j);
          A[ni][j]++;
          A[i][j]--;
          N++;
        } else if (nj < W) {
          STEP.emplace_back(i, j, i, nj);
          A[i][nj]++;
          A[i][j]--;
          N++;
        } else if (ni < H) {
          STEP.emplace_back(i, j, ni, j);
          A[ni][j]++;
          A[i][j]--;
          N++;
        }
      }
    }
  }

  cout << N << endl;
  rep(i, N) {
    int y, x, ny, nx;
    tie(y, x, ny, nx) = STEP[i];
    cout << y + 1 << " " << x + 1 << " " << ny + 1 << " " << nx + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 5232
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int M=2e5+5;
void Rd(int &res){
	res=0;char p;
	while(p=getchar(),p<'0');
	do{
		res=(res*10)+(p^48);
	}while(p=getchar(),p>='0');
}
void Ps(int x){
	if(x==0)return;
	Ps(x/10);putchar(x%10^48);
}
void Pt(int x){
	if(x==0)putchar('0');
	else Ps(x);putchar('\n');
}
int cnt[M],a[M],n,m,mk[M*2];
int ans;
void Add(int x){
	cnt[x]++;
	if(x-cnt[x]>=0&&mk[x-cnt[x]+n]++==0)ans++;
}
void Del(int x){
	if(x-cnt[x]>=0&&mk[x-cnt[x]+n]--==1)ans--;
	cnt[x]--;
}
int main(){
	Rd(n),Rd(m);
	for(int i=0;i<n;i++)Rd(a[i]),Add(a[i]);
	for(int i=1,x,y;i<=m;i++){
		Rd(x),Rd(y);x--;
		Del(a[x]);
		Add(y);
		a[x]=y;
		Pt(n-ans);
	}
	return 0;
}

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

int main()
{
  string s;cin>>s;int a=-1,z;
  for(int i=0;i<s.size();i++)
  {
    if(a==-1&&s[i]=='A')a=i;
    if(s[i]=='Z')z=i;
  }
  printf("%d",z-a+1);
}

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

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

    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));

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

    for (int i = 0; i < D; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            cin >> s.at(i).at(j);
        }
    }

    vector<int> T(D);
    for (int i = 0; i < D; i++)
    {
        cin >> T.at(i);
    }

    int M;
    cin >> M;

    vector<int> d(M);
    vector<int> q(M);

    for (int i = 0; i < M; i++)
    {
        cin >> d.at(i) >> q.at(i);
    }

    for (int k = 0; k < M; k++)
    {
        T.at(d.at(k) - 1) = q.at(k);

        int point = 0;
        int t;
        vector<int> last(26);
        for (int i = 0; i < D; i++)
        {
            t = T.at(i);
            last.at(t - 1) = i + 1;
            for (int j = 0; j < 26; j++)
            {
                point -= c.at(j) * (i + 1 - last.at(j));
            }

            point += s.at(i).at(t - 1);
        }
        cout << point << endl;
    }

    return 0;
}

Measured memory_bytes: 3948
h, w = map(int, input().split())
amap = ['.' * (w + 2)]
for _ in range(h):
  amap.append('.' + input().strip() + '.')
amap.append('.' * (w + 2))

x, y = 1, 1
is_one = True
while x != w or y != h:
  if x == 1 and y == 1 and amap[y][x] != '#':
    break
  c = 0
  if amap[y][x+1] == '#':
    c += 1
  if amap[y][x-1] == '#':
    c += 1
  if amap[y+1][x] == '#':
    c += 1
  if amap[y-1][x] == '#':
    c += 1

  if c != 1:
    break
  else:
    amap[y] = amap[y][:x] + '.' + amap[y][x+1:]
    if amap[y][x+1] == '#':
      x += 1
    elif amap[y+1][x] == '#':
      y += 1
    elif amap[y][x-1] == '#':
      break
    elif amap[y-1][x] == '#':
      break

if x == w or y == h:
  c = 0
  for a in amap:
    c += a.count('#')
  if c == 1:
    print('Possible')
  else:
    print('Impossible')
else:
  print('Impossible')


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5;
int n,m,u,v,fa[maxn];
long long a[maxn],b[maxn],c[maxn],f[maxn],sum[maxn],id[maxn];
bool vis[maxn];
vector <int> to[maxn];
bool cmp(int x,int y){return c[x]<c[y];}
int get_fa(int now){return fa[now]=((fa[now]==now)?now:get_fa(fa[now]));}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
		c[i]=max(a[i]-b[i],0ll);
		id[i]=i;fa[i]=i;sum[i]=b[i];f[i]=c[i];
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		to[u].push_back(v);
		to[v].push_back(u);
	}
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++){
		int now=id[i],siz;
		vis[now]=true;siz=to[now].size();
		for(int j=0;j<siz;j++){
			int t=to[now][j];
			if(!vis[t]) continue;
			t=get_fa(t);
			if(t==now) continue;
			fa[t]=now;
			sum[now]+=sum[t];
			f[now]=min(f[now],max(f[t],c[now]-sum[t]));
		}
	}
	printf("%lld\n",f[id[n]]+sum[id[n]]);
	return 0;
}

Measured memory_bytes: 18172
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long linf = 4523372036854775807;
const int inf = 1500000000;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s, h = "CODEFESTIVAL2016";
	cin >> s;
	int sum = 0;
	for (int i = 0; i < 16; i++)
		if (s[i] != h[i])
			sum++;
	cout << sum << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
const ll mod=1e9+7;

bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}


void solve(){

    ll n;
    cin>>n;
    intarr(a,n);

    map<ll,ll> m;
    for(ll i=0;i<n;i++)
        m[a[i]]++;


    ll sum=0;
    for(auto i=m.begin();i!=m.end();i++){
        sum+= (i->ss)*(i->ss -1)/2;
    }

    for(ll i=0;i<n; i++){
        cout<< sum - m[a[i]] +1<<endl;
    }

    return;
}
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
 
    return 0;
}       

Measured memory_bytes: 11136
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string key = "keyence";
string s;
int main(){
    INIT;
    cin >> s;
    if(s.substr(0, 7) == "keyence"){
        cout << "YES" << endl;
        return 0;
    }
    if(s == key){
        cout << "YES" << endl;
        return 0;
    }
    REP(i, (int)s.size() - ((int)s.size() - 7)){
        string ss = "";
        REP(j, (int)s.size()){
            if(i <= j && j < i + (int)s.size() - 7)continue;
            ss = ss + s[j];
        }
        //cout << ss << endl;
        if(ss == key){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
import heapq

def solve(n, a):
    a = sorted(a, reverse=True)
    ans = a[0]
    que = [(-a[1], -a[0]), (-a[1], -a[0])]
    heapq.heapify(que)
    for i in range(2, n):
        x, y = heapq.heappop(que)
        ans += min(-x, -y)
        heapq.heappush(que, (-a[i], x))
        heapq.heappush(que, (-a[i], y))
    return ans

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))


Measured memory_bytes: 47292
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='+') ans++;
        else ans--;
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N;
string S;

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

	char cur = '_';
	long long num = 0;

	rep(i, N) {
		char ch = S[i];
		if(ch != cur) {
			num++;
			cur = ch;
		}
	}
	cout << num << endl;

}

Measured memory_bytes: 3760
#include<stdio.h>

int main(void)
{
        int n, i, res = 0;
        int c[50], v[50], r[50];

        scanf("%d", &n);

        for(i = 0; i < n; i++) {
                scanf("%d", &v[i]);
        }
        for(i = 0; i < n; i++) {
                scanf("%d", &c[i]);
        }

        for(i = 0; i < n; i++) {
                r[i] = v[i] - c[i];
                if(r[i] > 0) {
                        res += r[i];
                }
        }

        printf("%d",res);
        return 0;
}


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

int N;
vector<int> a, b;

int main(){
  cin >> N;
  long long sum = 0;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    b.push_back(tmp);
  }
  for(int i = 0; i < N; i++){
    int dif = a[i]-b[i];
    if(dif > 0) sum -= dif;
    else sum -= dif/2;
  }
  if(sum>=0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

void solve(){
    int N; cin>>N;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        int h; cin>>h;
        H[i] = h;
    }
    int count =0;
    for(int i=0;i<N-1;i++){
        //condition
        int temp =0;
        while(H[i] >= H[i+1] && i < N-1){
            temp++;
            i++;
        }
        count = max(count,temp);
    }   

    cout << count << endl;

    

}


int main(){
   solve();
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static long MOD = (long)Math.pow(10, 9) + 7;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long ans = func(2, n);
    ans = (ans + MOD - 1) % MOD;
    long[] kai = new long[1000001];
    kai[0] = 1;
    for(int i = 1; i <= 1000000; i++) {
      kai[i] = (kai[i - 1] * (long)i) % MOD;
    }
    long t1 = 1;
    for(long i = n; i > n - a; i--) {
      t1 = (t1 * i) % MOD;
    }
    long t2 = 1;
    for(long i = n; i > n - b; i--) {
      t2 = (t2 * i) % MOD;
    }
    long aa = func(kai[(int)a], MOD - 2);
    long bb = func(kai[(int)b], MOD - 2);
    t1 = (t1 * aa) % MOD;
    t2 = (t2 * bb) % MOD;
    ans = (ans + MOD - t1) % MOD;
    ans = (ans + MOD - t2) % MOD;
    System.out.println(ans);
  }

  public static long func(long a, long x) {
    if(x == 0) return 1;
    long t = func(a, x / 2);
    if((x % 2) == 0) {
      return (t * t) % MOD;
    } else {
      return (a * func(a, x - 1)) % MOD;
    }
  }
}

Measured memory_bytes: 29908
import sys, fractions
input = sys.stdin.readline
N,M = map(int,input().split())
aa = list(map(int, input().split()))

lcm = 1
i = 1

for a in aa:
    lcm = a*lcm//fractions.gcd(a,lcm)

ans = 0
ch = True
for a in aa:
	if(0 != ((lcm // 2) - a // 2) % a):
		ch = False
if(ch):
	ans += (M // lcm)
	if (M % lcm) >= (lcm//2):
		ans += 1
	print(ans)
else:
	print(0)


Measured memory_bytes: 16272
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	while(getline(cin,str))
	{
		bool flag=false;
		for(int k=0;k<26;k++)
		{
			int i=0;
			for(i=0;i<str.size();i++)
			{
				if(str[i]-'a'<0 || str[i]-'z'>0) continue;
				else { str[i]++; if(str[i]-'z'>0) str[i]-=26; }
			};
			string ptr,qtr;
			for(i=0;i<str.size();i++)
			{
				if(i+4<str.size()) ptr=str.substr(i,4);
				if(i+3<str.size()) qtr=str.substr(i,3);
				if(ptr=="this" || ptr=="that" || qtr=="the") {flag=true; break;}
			};
			if(flag==true) break;
		};
		cout << str << endl ;
	}
}

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

int main()
{
  string s;
  cin >> s;
  bool found = false;
	if (s.find("AB") != string::npos)
  {
    found = true;
  }
  if (s.find("BA") != string::npos)
  {
    found = true;
  }
  cout << (found ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628