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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  cout<<(n-2)*180<<endl;


  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;
void insertsort(int A[],int n,int g){
	for(int i=g;i<n;i++){
		int v=A[i];
		int j=i-g;
		while(j>=0&&A[j]>v){
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
		A[j+g]=v;
	}
}
void shell(int A[],int n){
	for(int h=1; ; ){
		if(h>n){
			break;
		}
		G.push_back(h);
		h=3*h+1;
	}
	for(int i=G.size()-1;i>=0;i--){
		insertsort(A,n,G[i]);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
    cnt=0;
    shell(A,n);
    printf("%d\n",G.size());
    for(int i=G.size()-1;i>=0;i--){
    	printf("%d",G[i]);
    	if(i){
    		printf(" ");
	    }
	}
	printf("\n%d\n",cnt);
	for(int i=0;i<n;i++){
		printf("%d\n",A[i]);
	}
	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  vector<pair<int, int>> vs;
  for (int end = 0; end < N;) {
    int start = end;
    while (end < N && S[end] == S[start]) end++;
    vs.emplace_back(S[start] - '0', end - start);
  }

  int left = 0, right = 0, cnt = 0, curr = 0, ans = 0;
  while (left <= right) {
    if (right < vs.size() && vs[right].first == 0 && cnt < K) {
      cnt++;
      curr += vs[right++].second;
      ans = max(ans, curr);
    }
    else if (right < vs.size() && vs[right].first == 1) {
      curr += vs[right++].second;
      ans = max(ans, curr);
    }
    else if (cnt == K) {
      if (left < N && vs[left].first == 1) {
        curr -= vs[left++].second;
      }
      curr -= vs[left++].second;
      cnt--;
    }
    else {
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1528
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;



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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        ab: [(usize1, usize1); n-1],
        mut c: [usize; n],
    }
    c.sort();
    let mut g = vec![vec![]; n];
    let mut edge_cnt = vec![0; n];
    for &(a, b) in ab.iter() {
        g[a].push(b);
        g[b].push(a);
        edge_cnt[a] += 1;
        edge_cnt[b] += 1;
    }

    let mut queue = VecDeque::new();

    for i in 0..n {
        if edge_cnt[i] == 1 {
            queue.push_back(i)
        }
    }

    let mut d = vec![0; n];
    let mut pos = 0;
    let mut tot = 0;
    while let Some(v) = queue.pop_front() {
        d[v] = c[pos];
        if pos >= n - 1 {break};
        tot += d[v];
        pos += 1;

        for &w in &g[v] {
            edge_cnt[w] -= 1;
            if edge_cnt[w] == 1 {
                queue.push_back(w);
            }
        }
    }

    println!("{}", tot);
    for val in d {
        print!("{} ", val)
    }
    println!();

}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
int main()
{
  int x;
  cin >> x;

  int s = 0;
  re(i, x) {
    if (x - 105 * i <= 0) {
      s = i;
      break;
    }
  }

  if (100 * s <= x && x <= 105 * s) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}


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

typedef long long ll;

int main()
{
    int n;
    vector<int> d;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }

    sort(d.begin(), d.end());

    cout << d[n/2] - d[n/2 - 1] << endl;

}

Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            int iN = int.Parse(Console.ReadLine().Trim());

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iK = (int)Math.Sqrt(iN);
            int iO = (int)Math.Pow(iK, 2);

            // 出力
            Console.WriteLine("{0}", iO.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include	<bits/stdc++.h>
using	namespace	std;
typedef	long long ll;

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll H, W;
	cin >>H >>W;
	if ((1==H)||(1==W))
		cout <<1 <<endl;
	else 
		cout <<(H*W+1)/2 <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x;
    
    for(int i=1;;i++){
        cin>>x;
        if(x == 0){
            break;
        }
        
        cout<<"Case "<<i<<": "<<x<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3068
import math

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = int(0)
satis = int(0)

for i in range(N):
    satis += B[i]
    if i<N-1 and A[i]==A[i+1]-1:
        satis += C[A[i]-1]

ans = satis
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n){
		cin>>a[i];
	}
	ll ans=inf;
	FOR(i,-100000,100000){
		ll now=0;
		rep(j,n){
			now+=(a[j]-i)*(a[j]-i);
		}
		chmin(ans,now);
	}
	cout<<ans<<endl;
}

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

// see: https://qiita.com/drken/items/4a7869c5e304883f539b
int main() {
  int n;
  cin >> n;

  vector<int> order;
  int P[n], Q[n];
  for (int i = 1; i <= n; i++) {
    order.push_back(i);
  }

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

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

  int ordernum = 1;
  int pOrder = 0;
  int qOrder = 0;

  do {
    bool pMatched = true;
    bool qMatched = true;

    for (int i = 0; i < order.size(); i++) {
      int num = order[i];

      if (num != P[i]) pMatched = false;
      if (num != Q[i]) qMatched = false;
    }

    if (pMatched) pOrder = ordernum;
    if (qMatched) qOrder = ordernum;
    ordernum++;
  } while (next_permutation(order.begin(), order.end()));

  cout << (abs(pOrder - qOrder)) << endl;
}


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

int cmp(const void *a,const void *b)
{
  return *(int*)a-*(int*)b;
}

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int a[n];
  int i;
  int count=0;
  int ans=0;
  int tmp;
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  
  qsort(a,n,sizeof(int),cmp);
  
  int j=0,k=0;
 while(j<n)
 {
   tmp=a[j];
   while(tmp==a[j])
   {
    count++;
    j++;
   }
   ans+=count%2;
   count=0;
 }
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<queue>
#include<string.h>
#include<algorithm>
#include<stack>
#include<set>
#include<numeric>

using namespace std;

int N,M;
int ans=0;
int graph[8][8];

void dfs(int i,int visited[8]);

int main(){
  cin>>N>>M;
  for (int m = 0; m < M; m++) {
    int a;cin>>a;
    int b;cin>>b;
    graph[a-1][b-1]=graph[b-1][a-1]=1;
  }
  int visited[8];
  for(int n=0;n<8;n++){
    visited[n]=0;
  }
  visited[0]=1;
  dfs(0,visited);
  cout<<ans<<"\n";

}

void dfs(int i,int visited[8]){
  for (int j = 0; j < N; j++) {
    if(graph[i][j]==1&&visited[j]==0){
      if(accumulate(visited,visited+N,0)==N-1){
        ans++;
        return;
      }
      visited[j]=1;
      dfs(j,visited);
      visited[j]=0;

    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>
#include<set>

using namespace std;

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

int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string> p;
    for (int i = 0; i < s.size(); i++){
        string t = "";
        for (int j = 0; j < s.size() - i && j < 6; j++){
            t += s[i + j];
            p.insert(t);
        }
    }
    rep(i, k - 1){
        p.erase(p.begin());
    }
    string ans = *p.begin();
    cout << ans << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
  long long N,sw= 0,sw2 = 0;
  cin >> N >> sw2;
 long long count = 1;
  froop1(0,N){
    int a;
    cin >> a;
    if(a % 2 != 0){
      sw = 1;
    }
    count *= 2;
  }
  if(sw == 0){
    if(sw2 == 0){
    cout << count << endl;
    }else{
      cout << 0 << endl;
    }
  }else{
   cout << count / 2 << endl; 
  }
}

Measured memory_bytes: 3636
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> ba(m);
	for (int i = 0; i < m; i++) {
		cin >> ba[i].second >> ba[i].first;
	}
	sort(ba.begin(), ba.end());

	int ans = 0, pre = -INF;
	for (auto& x : ba) {
		if (x.second >= pre) {
			ans++;
			pre = x.first;
		}
	}

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


Measured memory_bytes: 3972
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    long long  n,m;
    cin>>n>>m;
    if(n%m==0)
        cout<<"-1"<<endl;
    else
    {
        cout<<n*m-n<<endl;
    }
    return 0;
}


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

int main() {

  int N;
  cin >> N;

  string answer = "No";

  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (i * j == N) {
        answer = "Yes";
        break;
      }
    }
    if (answer == "Yes") {
      break;
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
#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)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int>h(n);
  rep(i,n)cin>>h[i];
  for(int i=n-1;i>0;i--){
    if(h[i-1]==h[i]+1)h[i-1]--;
    else if(h[i-1]>h[i]+1){
      cout<<"No"<<endl;
      return(0);
    }
  }
  cout<<"Yes"<<endl;
  return(0);
}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
int main(void) {
    long double x1, y1, x2, y2, distance;
    scanf("%Lf %Lf %Lf %Lf", &x1, &y1, &x2, &y2);
    distance = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1);

    printf("%f", sqrt(distance));
    return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
	string S;
	cin >> S;
	int A = 0;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < i; j++) {
			if (S.at(j) == S.at(i)) {
				A++;
			}
			else {
				continue;
			}
		}
	}
	if (A == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
sum =0
min_time =10

for i in range (5):
    x = int(input()) 
    if x%10 > 0 :
        if x%10 < min_time :
            min_time = x%10;
        x = (int(x/10) +1)*10;
        sum = sum+x;
    else:
        sum = sum+x;
print (sum-(10-min_time));

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n(1 <= 100);
    cin >> n;
    int answer = n % 2;
    if (answer == 0){
        cout << n / 2 << endl;
    }
    else if (answer != 0){
        cout << n / 2 + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<cmath>
#include<cstdlib>
using namespace std;
using lli = long long int;

void deleteD(vector<char>& cv) {
    vector<char>::iterator p = cv.begin();
    char prev = 'a';
    while (p != cv.end()) {
        if (prev == *p) {
            p = cv.erase(p);
            prev = 'a';
        }
        else {
            prev = *p;
            p++;
        }
    }
}

int main() {
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    vector<char> kv;
    vector<vector<char>> allv(k, kv);
    for (int i = 0; i < n; i++) {
        allv[i % k].push_back(t[i]);
    }
    int res = 0;
    for (int i = 0; i < k; i++) {
        deleteD(allv[i]);
        for (int j = 0; j < allv[i].size(); j++) {
            switch (allv[i].at(j)) {
            case'r':
                res += p;
                break;
            case's':
                res += r;
                break;
            case'p':
                res += s;
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#define FOR(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
#define MAXN (2000)
double r[MAXN],p[MAXN];
int main (int argc, char *argv[])
{
	int n;
	while (scanf("%d",&n)!=EOF){

		double ans=0;
		FOR(i,1,n){
			scanf("%lf",&r[i]);

			p[i]=r[i];
			FOR(j,1,i-1){
				int dr=r[j]+r[i];
				int tr=r[j]-r[i];
				double nowp=sqrt(dr*dr-tr*tr)+p[j];
				p[i]=max(p[i],nowp);
			}

			ans=max(ans,p[i]+r[i]);
		}
		printf("%.8f\n",ans);


	}
	return 0;
}

Measured memory_bytes: 3228
s = list(input())
t = list(input())

if sorted(s) != sorted(t):
  print("No")
  exit(0)
else:
  for i in range(len(s)+1):
    if s == t:
      print("Yes")
      exit(0) 
    
    s.insert(0,s.pop())

print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  ll ans = 0;
  ll bcnt = 0;
  
  for(int i = s.size() - 1; i >= 0; i--) {
    if(s[i] == 'B') {
      ans += s.size() - 1 - i - bcnt;
      bcnt++;
    }
  }
  cout << ans << endl;
  

  return 0;

}


Measured memory_bytes: 720
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Wed Jan 16 16:19:53 2019
//
package main

import "fmt"

func main() {
	var X, A, B int
	fmt.Scan(&X, &A, &B)

	if B-A <= 0 {
		fmt.Println("delicious")
	} else if B-A <= X {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int n, k;
string s;
signed main() {
	cin >> n >> k;
	cin >> s;
	rep(i, min(k, (int)20)) {
		string memo = s;
		reverse(memo.begin(), memo.end());
		s += memo;
		string p = s;
		for (int j = 0; j <= p.size() - n; j++) {
			memo = min(memo, p.substr(j, n));
		}
		reverse(memo.begin(), memo.end());
		s = memo;
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	ggr
}


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

int a[100005];
int main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i ++) cin >> a[i];
	if(n == k){
		cout << 1 << '\n';
	}
	else {
		cout << 1 + (n - k - 1) / (k - 1) + 1 << '\n';
	}
	return 0;
}

Measured memory_bytes: 640
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
        mut s:Chars,
    }
    // 7moji ijo
    if s.len() < 7 {
        println!("NO");
        return;
    }

    let n = s.len();
    let rem = n - 7;
    let aaa = vec!['k', 'e', 'y', 'e', 'n', 'c', 'e'];
    for i in 0..n {
        // i文字目からremもじさくじょ
        let mut st = vec![];
        for j in 0..n {
            if (i..i + rem).contains(&j) {
                continue;
            }
            st.push(s[j]);
        }

        if aaa == st {
            println!("YES");
            return;
        }
    }
    println!("NO");
}


Measured memory_bytes: 2140
#include<iostream>
#include<math.h>
int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a + b + c >= 22) {
		std::cout << "bust" << std::endl;
	}
	else {
		std::cout << "win" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=(1LL<<31)-1;

class Segtree{
    public:
        ll N=1;
        ll dat[1000000];
        explicit Segtree(ll sz){
            while(N<sz) N*=2;
        }
    
        ll unit(){
            return INF;
        }
        ll calc(ll a,ll b){
            return min(a,b);
        }
        void update(ll k,ll a){
            k+=N-1;
            dat[k]=a;
            while(k>0){
                k=(k-1)/2;
                this->dat[k]=calc(dat[2*k+1],dat[2*k+2]);
            }
        }
        ll query(ll a,ll b,ll k,ll l,ll r){
            if(r<=a||b<=l)return unit();
            if(a<=l&&r<=b)return dat[k];
            ll m=(l+r)/2;
            ll u=query(a,b,2*k+1,l,m);
            ll v=query(a,b,2*k+2,m,r);
            return calc(u,v);
        }


        void m_init(){
            for(int i=0;i<N;i++)update(i,INF);
        }
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,q;
    cin>>n>>q;
    Segtree sgtree(n);
    sgtree.m_init();
    while(q--){
        ll c,x,y;
        cin>>c>>x>>y;
        if(c==0)sgtree.update(x,y);
        else cout<<sgtree.query(x,y+1,0,0,sgtree.N)<<'\n';
    }
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/


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

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


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

int main() {
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0){
        cout<<1<<endl;
    }else if(b==0){
        cout<<2<<endl;
    }else if(c==0){
        cout<<3<<endl;
    }else if(d==0){
        cout<<4<<endl;
    }else if(e==0){
        cout<<5<<endl;
    }
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//-------------------------------------------------------
int sum[186];
bool Map[185][185];
void Calc(){
	int H = rei();
	int W = rei();
	for(int i=0;i<H;i++){
		string S = res();
		for(int j=0;j<W;j++){
			Map[i][j] = S[j] == '#';
		}
	}
	vector<vector<vector<int>>> DPH(H,vector<vector<int>>(H,vector<int>(W)));
	vector<vector<vector<int>>> DPH2(H,vector<vector<int>>(H,vector<int>(W)));
	vector<vector<vector<int>>> DPW(W,vector<vector<int>>(W,vector<int>(H)));
	vector<vector<vector<int>>> DPW2(W,vector<vector<int>>(W,vector<int>(H)));
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			sum[j+1] = sum[j] + (Map[i][j] ? 1 : 0);
		}
		for(int j=0;j<W;j++){
			for(int k=j;k<W;k++){
				if(sum[k+1] - sum[j] == 0 || sum[k+1] - sum[j] == k-j+1){
					DPW[j][k][i] = i;
				}
				else{
					DPW[j][k][i] = i-1;
				}
			}
		}
	}
	for(int i=H-2;i>=0;i--){
		for(int j=0;j<W;j++){
			for(int k=j;k<W;k++){
				if(DPW[j][k][i] == i && Map[i][j] == Map[i+1][j]){
					DPW[j][k][i] = DPW[j][k][i+1];
				}
			}
		}
	}
	for(int i=0;i<W;i++){
		for(int j=0;j<H;j++){
			sum[j+1] = sum[j] + (Map[j][i] ? 1 : 0);
		}
		for(int j=0;j<H;j++){
			for(int k=j;k<H;k++){
				if(sum[k+1] - sum[j] == 0 || sum[k+1] - sum[j] == k-j+1){
					DPH[j][k][i] = i;
				}
				else{
					DPH[j][k][i] = i-1;
				}
			}
		}
	}
	for(int i=W-2;i>=0;i--){
		for(int j=0;j<H;j++){
			for(int k=j;k<H;k++){
				if(DPH[j][k][i] == i && Map[j][i] == Map[j][i+1]){
					DPH[j][k][i] = DPH[j][k][i+1];
				}
			}
		}
	}
	int c = 0;
	while(1){
		if(DPH[0][H-1][0] == W-1){
			cout << c << endl;
			return;
		}
		c++;
		for(int i=0;i<H;i++){
			for(int j=i;j<H;j++){
				for(int k=0;k<W;k++){
					DPH2[i][j][k] = DPH[i][j][min(DPH[i][j][k]+1,W-1)];
				}
			}
		}
		for(int i=0;i<W;i++){
			for(int j=i;j<W;j++){
				for(int k=0;k<H;k++){
					DPW2[i][j][k] = DPW[i][j][min(DPW[i][j][k]+1,H-1)];
				}
			}
		}
		for(int i=0;i<H;i++){
			for(int j=i;j<H;j++){
				int p = 0;
				for(int k=0;k<W;k++){
					p = max(p,k);
					while(p < W && DPW2[k][p][i] >= j){
						p++;
					}
					DPH2[i][j][k] = max(DPH2[i][j][k],p-1);
				}
			}
		}
		for(int i=0;i<W;i++){
			for(int j=i;j<W;j++){
				int p = 0;
				for(int k=0;k<H;k++){
					p = max(p,k);
					while(p < H && DPH2[k][p][i] >= j){
						p++;
					}
					DPW2[i][j][k] = max(DPW2[i][j][k],p-1);
				}
			}
		}
		swap(DPH,DPH2);
		swap(DPW,DPW2);
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 106240
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
 
}
 
Node treeSearch(Node u, int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key)
      u=u->left;
    else
      u=u->right;
  }
  return u;
   
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
   
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
   
  if(z->left==NIL ||z->right ==NIL)
    y=z;
  else
    y=treeSuccessor(z);
  if(y->left!=NIL)
    x=y->left;
  else
    x=y->right;
  if(x!=NIL)
    x->parent=y->parent;
  if(y->parent==NIL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else
    y->parent->right=x;
  if(y!=z)
    z->key=y->key;
   
   
}
 
  
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
  
    else
      x = x->right;
  }
    
  z->parent = y;
  
  if(y == NIL)
    root = z;
  
  else if(z->key < y->key)
    y->left = z;
  
  else
    y->right = z;
}
 
void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 19364
#include <stdio.h>
#include <math.h>

int main(int argc, char const *argv[])
{
  unsigned int A, B, C, D;
  scanf("%u %u %u %u", &A, &B, &C, &D);

  int takahashi_turn = (int)ceil((float)C / B);
  int aoki_turn = (int)ceil((float)A / D);
  if (takahashi_turn <= aoki_turn)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1676
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
//const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll dp[65][10000] = {0};
int main(void){
    ll n;
    cin >> n;
    map<ll,ll> mp;
    ll num = n;
    for(ll i = 2; i * i <= n; i++){
        while(num % i == 0){
            mp[i]++;
            num /= i;
        }
    }
    if(num != 1) mp[num] = 1;


    
    for(ll i = 1; i < 64; i++){
        for(ll j = 0; j < 10000; j++){
            if(j - i >= 0)dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - i] + 1);
            dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
        }
    }
    ll ans = 0;
    for(auto &i : mp){
        ans += dp[64][i.second];
    }
    cout << ans << endl;
}


Measured memory_bytes: 8556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='?') s[i]='D';
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a[5], k;
  rep(i,5) cin >> a[i];
  cin >> k;

  if (a[4] - a[0] > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}


Measured memory_bytes: 3600
#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n,k,p[200020],sm[200020],no[200020];
int main() {
	read(n);read(k);
	for(int i=0;i<n;i++){
		read(p[i]);
	}
	no[n-1] = 1e9;
	for(int i=n-2;i>=0;i--){
		if(p[i]>p[i+1]){
			no[i] = i;
		}else{
			no[i] = no[i+1];
		}
	}
	set<int> Q;
	for(int i=0;i<k;i++){
		Q.insert(p[i]);
	}
	int ans = n-k+1,ccn = 0,cnt = 0;
	if(no[0]>=k-1 && ccn == 0){
		ccn = 1;
		cnt++;
	}
	for(int i=0;i+k<n;i++){
		int cc = 0;
		if(p[i] == *Q.begin()){
			cc++;
		}
		Q.insert(p[i+k]);
		Q.erase(p[i]);
		if(p[i+k] == *Q.rbegin()){
			cc++;
		}
		if(cc == 2){
			ans--;
		}else{
			ccn = 0;
		}
		if(no[i+1]>=i+k && ccn == 0){
			ccn = 1;
			cnt++;
		}
	}
	//cout<<cnt<<endl;
	if(cnt>1)ans-=cnt-1;
	cout<<ans<<endl;
	return 0;
}


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

#define  __  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  int  long long
#define  endl  '\n'
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________


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

  string s;

  unordered_map<string, int> cnt;

  for(int i = 0; i < n; i++)
  {
    cin >> s;
    sort(s.begin(), s.end());
    cnt[s]++;
  }
  int ans = 0;
  for(auto it : cnt)
  {
    ans += it.second * (it.second - 1) / 2;
  }

  cout << ans;

 return 0;
}

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

using Vertex = int;
struct Edge {Vertex from, to;};
using Graph = std::vector<std::vector<Edge>>;

std::vector<Vertex> postorder(const Graph& G) {
  std::vector<bool> used(G.size());
  std::vector<Vertex> order;
  std::function<void(Vertex)> dfs = [&](Vertex v) {
    used[v] = true;
    for(const auto& e: G[v]) if(!used[e.to]) dfs(e.to);
    order.emplace_back(v);
  };
  for(Vertex v = 0; v < G.size(); ++v) if(!used[v]) dfs(v);
  std::reverse(std::begin(order), std::end(order));
  return order;
}

using namespace std;

int N, P;
Graph G;
vector<int> ORDER;
vector<vector<int>> T1, T2;

int solve(Vertex u, Vertex v, bool behind) {
  if(ORDER[u] > ORDER[v]) swap(u, v);

  static vector<vector<vector<int>>> memo(N, vector<vector<int>>(N, vector<int>(2, -1)));
  if(~memo[u][v][behind]) return memo[u][v][behind];
  if(u == N-1 && v == N-1) return 0;

  int res = 1e9;

  for(auto e: G[u]) {
    if(behind) {
      if(e.to == v) res = min(res, solve(e.to, v, false) + T2[u][e.to]);
      else          res = min(res, solve(e.to, v, false) + T1[u][e.to]);
    } else {
      res = min(res, solve(e.to, v, u == v) + T1[u][e.to]);
    }
  }

  return memo[u][v][behind] = res;
}

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

  T1 = T2 = vector<vector<int>>(N, vector<int>(N));

  G.resize(N);
  for(auto i = 0; i < P; ++i) {
    int s, e, t1, t2;
    cin >> s >> e >> t1 >> t2;
    --s; --e;
    G[s].push_back({s, e});
    T1[s][e] = t1;
    T2[s][e] = t2;
  }

  auto v = postorder(G);
  ORDER.resize(N);
  for(auto i = 0; i < N; ++i) ORDER[v[i]] = i;

  cout << solve(0, 0, false) << endl;
}

Measured memory_bytes: 65808
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

distance (x,y) (x',y') = abs (x-x') + abs (y-y')

movable (t,p) (t',p') = dist<=time && even dist == even time
  where
    dist = distance p p'
    time = t' - t



main = do
    n <- getInt
    ds <- ((0,(0,0)):) . map (fmap (apply2 (,)) . unconsU) <$> replicateM n getInts
    putStrLn $ cond "Yes" "No" $ and$ binMap movable ds

Measured memory_bytes: 81276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PRINT(s) cout << s << endl;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR((i), 0, (n))

int main() {
    vector<int> x(5);
    REP(i, 5) {
        cin >> x[i];
    }

    REP(i, 5) {
        if (x[i] == 0) PRINT(i + 1);
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
const int N = 100000 + 10;
using namespace std;

int n;
struct node
{
  int v;
  int p;
};
struct node a[N];
inline bool cmp(node a,node b)
{
  if(a.v==b.v) return a.p<b.p;
  return a.v<b.v;
}
namespace solver
{
  void solve()
  {
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
	{
	  scanf("%d",&a[i].v);
	  a[i].p=i;
	} 
    sort(a+1,a+n+1,cmp);
	
	int ta=0, tb=0;
	for(int i=1; i<=n; ++i)
	{
	  if((a[i].p&1) && !(i&1)) ta ++;
	  if(!(a[i].p&1) && (i&1)) tb ++;
	}
	ta = min(ta, tb);
	printf("%d\n",ta);
  }
}

int main()
{
  solver :: solve();
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
    char s[100000000],t[100000000];
    int i,c=0,len=0;
    scanf("%s",&s);
    scanf("%s",&t);
    len=strlen(s);
    for(i=0;i<len;i++){
        if(s[i]!=t[i])
        c++;
    }
    printf("%d\n",c);
    return 0;
}

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

int n,a[100005];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(a[n]-a[1]>=2) {puts("No");return 0;}
	else {
		int cnt1=0,cnt2=0;
		for(int i=1;i<=n;i++){
			if(a[i]==a[1]) cnt1++;
			else cnt2++;
		}
		if(cnt2==0){
			if(a[1]<=n/2||a[1]==n-1) {printf("Yes\n");return 0;}
			else printf("No\n");
		}
		else{
			if(cnt1<=a[1]&&(cnt1+cnt2/2)>=a[n]) {printf("Yes\n");return 0;}
			else printf("No\n");
		}
	}
	return 0;
}

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

using namespace std;

int main(){
    int h,w;
    char c;
    cin >> h >> w;

    vector<vector<int>>v(h+1,vector<int>(w+1));

    for(int i = 0;i < h;i++){
        int count = 0;
        for(int j = 0;j < w;j++){
            cin >> c;
            if(c == '.')
                v[i+1][j+1] = 0;
            else{
                v[i+1][j+1] = 1;
                v[i+1][0]++;
                v[0][j+1]++;
            }
        }
    }


    for(int i = 0;i < h;i++){
        bool flag = false;
        for(int j = 0;j < w;j++){
            if(v[i+1][0] == 0){
                flag = true;
                break;
            }
            else if(v[0][j+1] != 0)
                if(v[i+1][j+1] == 0)
                    cout << '.';
                else 
                    cout << '#';
        }
        if(!flag)cout << endl;
    }


    return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int32_t N = s.size();

	for (int32_t i = 1; i < N; i++) {
		if (s[i - 1] == s[i]) {
			cout << i << " " << i + 1 << endl;
			return 0;
		}
		if (i > 1 && s[i - 2] == s[i]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
	}

	cout << "-1 -1" << endl;
	return 0;
}

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

int main() {
	int n, p;
	while(cin >> n >> p, n || p) {
		int pp = p;
		int cnt[60] = {};
		int i = 0;
		while(1) {
			if(pp == 0) {
				pp = cnt[i];
				cnt[i] = 0;
			}
			else {
				pp -= 1;
				cnt[i]++;
				if(cnt[i] == p) {
					cout << i << endl;
					break;
				}
			}
//			cout << "@" << cnt[i] << endl;
			i++;
			i %= n;
		}
	}
}

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

long long max(long long x,long long y){
    if(x>y)return x;
    return y;
}

int main(){
  long long n,now,tmp;
  long long ans=0;
  long long nowans=0;
  std::cin >> n;
  std::cin >> tmp;
  for (int i = 1; i < n; i++) {
    std::cin >> now;
    if(now<=tmp){nowans++;}
    else {ans=max(ans,nowans);nowans=0;}
    tmp=now;
  }

  std::cout << max(ans,nowans)<< '\n';

return 0;
}


Measured memory_bytes: 256