akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 20005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0, N, K, cur;
int nums[MAXN][2] = {};
vi A;

void print_table(){
    rep(i, N){
        cout << nums[i][0] << " " << nums[i][1] << endl;
    }
}

void solve(){

    rep(i, N){
        cur = A[i];
        rep(j,N){
            if(cur > A[j]){
                nums[i][0]++;
                if(i < j) nums[i][1]++;
            }
        }
    }

    rep(i,N){
        ans += K * nums[i][1];
        ans %= MOD;
        ans += nums[i][0]*((K*(K-1)/2)%MOD);
        ans %= MOD;
    }

    // print_table();

    cout << ans << endl;
}

int main(){
    cin >> N >> K;
    A.resize(N);

    rep(i, N) cin >> A[i];

    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string>
#include <vector>

using namespace std;

int n,m,a[10];

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

  char s[3];
  cin >> s;
  int ok = 0;
  for(int i = 0; i < 2; i++){
    if(s[i] != s[i + 1]){
      ok = 1;
      break;
    }
  }
  if(ok){
    cout << "Yes";
  }else{
    cout << "No";
  }


}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}


#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228

const int N = 100 * 1000 + 228;

namespace DSU
{
	int p[N], sz[N];

	void init(int n) {
		for (int i = 1; i <= n; ++i) {
			p[i] = i;
			sz[i] = 1;
		}
	}

	int getp(int v) {
		if (v == p[v]) return v;
		p[v] = getp(p[v]);
		return p[v];
	}

	bool join(int u, int v) {
		u = getp(u);
		v = getp(v);
		if (u == v) return 0;
		if (sz[u] < sz[v]) {
			p[u] = v;
			sz[v] += sz[u];
		} else {
			p[v] = u;
			sz[u] += sz[v];
		}
		return 1;
	}
};

vector<int> g[N];
vector< pair<int, int> > ans;
int deg[N];

void dfs(int v, int par = -1) {
	for (int to : g[v]) {
		if (to != par) dfs(to, v);
	}
	if (deg[v]) {
		ans.emplace_back(v, par);
	} else {
		if (par != -1) {
			ans.emplace_back(par, v);
			deg[par] ^= 1;
		}
	}
}

int a[100];

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n, m;
	cin >> n >> m;
	if (m & 1) {
		cout << -1 << '\n';
		return 0;
	}
	DSU::init(n);
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		if (DSU::join(u, v)) {
			g[u].push_back(v);
			g[v].push_back(u);
		} else {
			ans.emplace_back(u, v);
			deg[u] ^= 1;
		}
	}
	dfs(1);
	for (auto p : ans) cout << p.first << ' ' << p.second << '\n';
    return 0;
} // kek ;


Measured memory_bytes: 14960
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;

    // 全探索する。Sを切断する位置を全通り試して、この問題のスコアを数える。

    // Sを切断する位置。Yはs[i],...,s[n-1]
    for (int i = 0; i < n; i++) {
        bitset<'z' - 'a' + 1> f, b;
        for (int j = 0; j < n; j++) {
            if (j < i)
                f.set(s[j] - 'a');
            else
                b.set(s[j] - 'a');
        }
        f &= b;
        const int nowans = f.count();
        ans = max(nowans, ans);
    }

    cout << ans << endl;
}


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

using namespace std;

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

    vector<int> ab(N+1);

    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        ab[a]++;
        ab[b]++;
    }

    for(int i=1;i<=N;i++){
        cout<<ab[i]<<endl;
    }
}


Measured memory_bytes: 256
local mmi = math.min
local h, w = io.read("*n", "*n")
local map = {}
for i = 1, 100 do map[i] = io.read("*n") end

local tasks = {2}
local tasknum, done = 1, 0
local cost = {}
for i = 1, 10 do cost[i] = 10000 end
cost[2] = 0
while(done < tasknum) do
  done = done + 1
  local dst = tasks[done]
  for i = 1, 10 do
    if(i ~= 2 and i ~= dst) then
      local v = cost[dst] + map[dst + (i - 1) * 10]
      if v < cost[i] then
        cost[i] = v
        tasknum = tasknum + 1
        table.insert(tasks, i)
      end
    end
  end
end

local tot = 0
for i = 1, h * w do
  local a = io.read("*n")
  if 0 <= a then
    tot = tot + cost[a + 1]
  end
end
print(tot)


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int h,w,i;
	char c[101][101];

	scanf("%d%d",&h,&w);
	for(i=0;i<h;i++)
		scanf("%s",c[i]);

	i=0;
	while(2*h--){
		printf("%s\n%s\n",c[i],c[i]);
		i++;
	}
	return 0;
}

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

int main()
{
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  if(n<=k)
    cout<< x*n  <<endl;
  else
    cout<< x*k+y*(n-k) << endl;
}


Measured memory_bytes: 256
function Main(input) {
  let arr = parseInput(input)[0];
  console.log(Math.max(0, arr[0] - arr[1]*2));
}

function parseInput(input) {
  const lines = input.trim().split('\n');
  return lines.map(line => line.split(' '));
}

Main(require('fs').readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
fun main(args: Array<String>) {
    var (n, k)= readLine()!!.split(' ').map { it.toInt() }
    var pList = readLine()!!.split(' ').map { (it.toDouble() +1)/2}
    var count=0
    var tmp:Double=0.0
    var max:Double= 0.0
    for(p in pList){
        if(count>=k){
            tmp=tmp-pList[count-k]
        }
        tmp=tmp+p
        if(max<tmp) {
            max = tmp
        }
        if(count==pList.size-1){
            break
        }
        count++
    }
    println(max)
}


Measured memory_bytes: 79356
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}
vector<string> v;
lli dp[1010][1010];

void solve(){
	lli n,m;
	cin>>n>>m;	
	v.resize(n);
	fr(i,n){
		cin>>v[i];
	}
	fr(i,n){
		fr(j,m){
			if(v[i][j]=='.'){
				dp[i][j]=0;
				if(i)dp[i][j]+=dp[i-1][j];
				if(j)dp[i][j]+=dp[i][j-1];
				dp[i][j]%=MOD;
			}
			if(i==0&&j==0)dp[i][j]=1;
		}
	}
	cout<<dp[n-1][m-1]<<endl;
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	pre();lli t=1;//cin>>t;
	for(lli i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int MAX = 2e5+4;
ll dp[MAX];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,w;
	cin >> n >> w;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin >> a >> b;
		for(int j=w;j>=a;j--)
		{
			dp[j]=max(dp[j],dp[j-a]+b);
		}
	}
	ll ans=0;
	for(int i=1;i<=w;i++)
	{
		ans=max(ans,dp[i]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,wei;
	cin>>n>>wei;
	ll w[n],v[n];
	for(ll i=0;i<n;i++)
    {
       cin>>w[i]>>v[i];
	}
	ll dp[n+1][wei+1];
    for(ll i=0;i<=n;i++)
    {
    	for(ll j=0;j<=wei;j++)
    	{
    		if(i==0 || j==0)
    		dp[i][j] = 0;
    		else if(w[i-1]<=j)
    		{
    			dp[i][j] = max(v[i-1] + dp[i-1][j-w[i-1]], dp[i-1][j]);
			}
			else
			    dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[n][wei];
}

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

const double rasian = M_PI*60.0/180.0;
  
typedef struct
{
  double x;
  double y;
}K;

void print(K plot)
{
  printf("%lf %lf\n",plot.x,plot.y);
}

void KochCurve(int n, K p1, K p2)
{
  if(n == 0) return;
  K s,t,u;
  
  s.x = (2.0*p1.x+1.0*p2.x)/3.0;
  s.y = (2.0*p1.y+1.0*p2.y)/3.0;

  t.x = (1.0*p1.x+2.0*p2.x)/3.0;
  t.y = (1.0*p1.y+2.0*p2.y)/3.0;

  u.x = (t.x-s.x)*cos(rasian)-(t.y-s.y)*sin(rasian)+s.x;
  u.y = (t.x-s.x)*sin(rasian)+(t.y-s.y)*cos(rasian)+s.y;
  
  KochCurve(n-1, p1, s);
  print(s);
  KochCurve(n-1, s, u);
  print(u);
  KochCurve(n-1, u, t);
  print(t);
  KochCurve(n-1, t, p2);
}

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

  K plot1={0,0};
  K plot2={100,0};

  print(plot1);
  KochCurve(n,plot1,plot2);
  print(plot2);
  
  return 0;
}


Measured memory_bytes: 3236
N=int(input())
F=[int(input().replace(' ',''),2) for i in range(N)]
P=[list(map(int,input().split())) for i in range(N)]
print(max(sum([p[bin(f&i).count('1')] for f,p in zip(F,P)]) for i in range(1,2**10)))

Measured memory_bytes: 3188
input()
As = [int(n) for n in input().split()]
# print(As)
count = {}
sum = 0
for A in As:
    pre = count.get(A, 0)
    count[A] = pre + 1
    sum += A
# print(count)
# print(sum)

Q = int(input())
for i in range(Q):
    B, C = (int(n) for n in input().split())
    B_count = count.pop(B, 0)
    sum += (C - B) * B_count
    count[C] = count.get(C, 0) + B_count
    print(sum)

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

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= b; i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

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

int main() {
  ll x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	
	long a = 100000;
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		a = a*1.05;
		if(a%1000){
			a -= a%1000;
			a += 1000;
		}
	}
	cout<< a;
	cout<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1160
IDENTIFICATION DIVISION.
      PROGRAM-ID. 043A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 N   PIC 9(3).
      01 ANS PIC 9(4).
      01 ANSS PIC Z(4).
      
      PROCEDURE DIVISION.
      ACCEPT N .
      COMPUTE ANS = N * (N + 1) / 2.
      MOVE ANS TO ANSS.
      DISPLAY ANSS.
      STOP RUN.

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, a[100010]={};
    cin >> n;

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


    int tmp=a[1], button=0;
    for(i=0; i<n; i++){
        button=tmp;
        tmp=a[button];
        if(button==2)break;
    }
    cout << (i==n ? -1 : i+1) << endl;

    return 0;
}


Measured memory_bytes: 768
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      
      	if(n %k == 0){
        	System.out.println(0);
        }else{
        	System.out.println(1);
        }
    }
}

Measured memory_bytes: 35672
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn gcd(a: i32, b: i32) -> i32 {
    fn gcd1(m: i32, n: i32) -> i32 {
        if n == 0 {
            m
        } else {
            gcd1(n, m % n)
        }
    }
    if a > b {
        gcd1(a, b)
    } else {
        gcd1(b, a)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0i32; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut lv = vec![0i32; n];
    lv[0] = av[0];
    for i in 1..n {
        lv[i] = gcd(lv[i - 1], av[i]);
    }

    let mut rv = vec![0i32; n];
    rv[n - 1] = av[n - 1];
    for i in 1..n {
        let j = n - i - 1;
        rv[j] = gcd(rv[j + 1], av[j]);
    }

    let mut ans = max(lv[n - 2], rv[1]);
    for i in 1..n - 1 {
        ans = max(ans, gcd(lv[i - 1], rv[i + 1]));
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
//-fexec-charset=CP932
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 100
#define THOU 1000
#define FIVEMAX 100000
#define NINEMAX 1000000000
#define TWEMAX 1000000000000
#define rep(i,n) for (int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define darep(i,a,n) for(int i=n,i>=a;i--)
 
 
 
int main(){
 cin.tie(0);
 ios::sync_with_stdio(false);
 string s,t;
 vector<int>v;
 map<string,int>m;
 pair<int,int>p;
 
 
 cin>>s>>t;
 
 int sizes=s.length();
 int sizet=t.length();
 int ans=1e9;
 rep(i,sizes){
     int cnt=0;
     if(i+sizet>sizes)break;
     rep(j,sizet){
       if(s[i+j]!=t[j])cnt++;
     }
     ans=min(ans,cnt);
 }
 
 
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
int main(void){
    int n, v[20], c[20], i, sum=0;
    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++){
        if(v[i]>c[i])
            sum+=(v[i]-c[i]);
    }
    printf("%d", sum);
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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

	ll N, K;
	cin >> N >> K;

	ll A[60][50][50] = {};
	rep(i, N) rep(j, N) cin >> A[0][i][j];

	const ll mod = 1e9 + 7;
	rep(i, 59) {
		rep(j, N) {
			rep(x, N) {
				rep(k, N) {
					A[i + 1][j][k] += A[i][j][x] * A[i][x][k];
					A[i + 1][j][k] %= mod;
				}
			}
		}
	}

	ll B[50];
	rep(i, N) B[i] = 1;
	rep(i, 60) {
		if (K >> i & 1) {
			ll C[50] = {};
			rep(j, N) {
				rep(k, N) {
					C[j] += A[i][j][k] * B[k];
					C[j] %= mod;
				}
			}
			rep(j, N) B[j] = C[j];
		}
	}

	ll kotae = 0;
	rep(i, N) kotae = (kotae + B[i]) % mod;
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

int main(){
	int n,i;
	cin >> n;
	vector<int> a(100000);
	vector<int> b(100001);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = 0;
	}
	int ans = 0;
	int m = 0;
	for (i = 0; i*2 < n; i++) {
		m = a[i*2];
		b[m]++;
	}
	vector<int>::iterator even = max_element(b.begin(), b.end());
	size_t e1 = distance(b.begin(), even);
	int even3 = b[e1];
	b[e1] = 0;
	vector<int>::iterator even2 = max_element(b.begin(), b.end());
	size_t e2 = distance(b.begin(), even2);
	int even4 = b[e2];
	for (i = 0; i < 100001; i++) {
		b[i] = 0;
	}
	for (i = 0; i * 2 + 1 < n; i++) {
		m = a[i * 2 + 1];
		b[m]++;
	}
	vector<int>::iterator odd = max_element(b.begin(), b.end());
	size_t o1 = distance(b.begin(), odd);
	int odd3 = b[o1];
	b[o1] = 0;
	vector<int>::iterator odd2 = max_element(b.begin(), b.end());
	size_t o2 = distance(b.begin(), odd2);
	int odd4 = b[o2];
	if (e1 == o1) {
		ans = n - max(even3 + odd4, even4 + odd3);
	}
	else {
		ans = n - even3 - odd3;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
const main = (input) => {
  var inputs = input.trim().split("\n")[1].split(" ");
  var base = inputs[0]-0;
  var ans = 0;
  for(var i=0;i<inputs.length;i++){
    var b = inputs[i]-0;
    if(base <= b){
      ans++;
      base = b;
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 21064
// 3/06/2018
#include<bits/stdc++.h>

using namespace std;
//  return sum of digits of a  number
int sum_digits(int number){
  int sum = 0;
  char nb;
while(number>0){
  sum += number % 10;
  number /= 10;
}
  return sum;
}
int main(){
  int N,a,b,digits,res;
  cin >> N;
  b = 1;
  N -= 1;
  res = sum_digits(N) + sum_digits(b);
  while(N > 1){
    b++;
    N--;
    digits = sum_digits(N) + sum_digits(b);
    res = min(digits,res);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <time.h>
#define mp(a,b)   make_pair(a,b)
#define ll        long long
#define mp(a,b)   make_pair(a,b)
#define si(n)     scanf("%d",&n)
#define sl(n)     scanf("%lld",&n)
#define pi(n)     printf("%d\n",n)
#define pl(n)     printf("%lld\n",n)
#define           newline cout << endl;
#define           ff first
#define           ss second
using namespace std;

int main(){
  //clock_t tStart = clock();
  int a,b,c;
  cin >> a >> b >> c;
  int ans1 = min((abs(b-a)+abs(c-b)), (abs(c-a)+abs(b-c)));
  int ans2 = min((abs(b-a)+abs(c-a)), (abs(c-a)+abs(b-c)));
  int ans3 = min((abs(c-a)+abs(b-a)), (abs(c-b)+abs(b-a)));
  int ans = min(ans1, min(ans2, ans3));
  cout << ans << endl;
  //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();//?????°
		String result1,result2;
		int sum1,sum2;
		sum1 = 0;//?????????
		sum2 = 0;//?????????
		
		//?????°??????????????????
		for(int count=0;count<x;count++){
			result1 = scan.next();
			result2 = scan.next();
			if(result1.compareTo(result2) > 0){//result1?????????
				sum1 = sum1 + 3;
			}else if(result1.compareTo(result2) == 0){//????????????
				sum1++;
				sum2++;
			}else{//result1?????????
				sum2 = sum2 + 3;
			}
		}
		System.out.println(Integer.toString(sum1) + " " + Integer.toString(sum2));
	}
}

Measured memory_bytes: 29384
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
typedef long long ll;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	long long int n, x, sum = 0, cmp = 0, ans = LINF;
	cin >> n;
	vector<long long> vec;
	for (int i = 0; i < n; i++) {
		cin >> x;
		vec.push_back(x);
		sum += x;
	}
	for (int i = 0; i < n - 1; i++) {
		cmp += vec[i];
		ans = min(ans, abs(cmp - (sum - cmp)));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  string s,t;
  cin>>s;
  for(int i=0;i<s.size();i++){
    t[i]=s[i];
  }
  reverse(s.begin(),s.end());
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cnt++;
    }
  }
  cout<<cnt/2<<endl;
  return 0;
}


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

long long MOD = 1000000007LL;

int n;
char s[5050];
long long power[5050];
long long dp[5050][5050];
int lens = 0;

long long rek(int step, int len) {
	if(step >= n) {
		if(len == lens) {
			return 1LL;
		} else {
			return 0LL;
		}
	}

	if(dp[step][len] != -1) {
		return dp[step][len] % MOD;
	}

	long long rek1 = (long long) ((rek(step + 1, len + 1) % MOD * 2) % MOD);
	long long rek2 = (long long) (rek(step + 1, max(0, len-1)) % MOD);

	return dp[step][len] = (long long)((rek1 + rek2) % MOD);
}

long long pangkat(long long a, int b) {
	if(b == 0) return 1;
	if(b == 1) return a;

	long long aa = pangkat(a, b/2);
	if(b % 2 == 0) {
		return (aa * aa) % MOD;
	} else {
		return (((aa * aa) % MOD) * a) % MOD;
	}
}

int main() {
	power[0] = 1;
	for(int i = 1; i < 5005; i++) {
		power[i] = (power[i-1] * 2) % MOD;
	}

	memset(dp, -1LL, sizeof dp);
	scanf("%d", &n);
	scanf("%s", &s);

	lens = strlen(s);
	long long ans = rek(0, 0);
	long long inv = pangkat(power[lens], MOD - 2);

	printf("%lld\n", ((long long)(ans * inv)) % MOD);
	return 0;
}


Measured memory_bytes: 199808
#!/usr/bin/env python3

import math
from functools import lru_cache


def ncr(n, r):
    r = min(r, n - r)
    # 桁が小さいときは直接 math.factorial を使ったほうが早い
    if n + r < 4000:
        return math.factorial(n) // math.factorial(n-r) // math.factorial(r)
    if r == 0:
        return 1
    if r == 1:
        return n
    numerator = list(range(n - r + 1, n + 1))
    denominator = list(range(1, r+1))
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] //= pivot
                denominator[k] //= pivot
    result = 1
    for k in range(r):
        result *= numerator[k]
    return result


# 穴なしで n step 離れている場合の組み合わせ
def no_hole(n):
    count = 0
    m = n // 2
    for i in range(0, m+1):
        count += ncr(n-i, i)
    return count


# 穴なしで n step 離れている場合の組み合わせ(高速化版)
@lru_cache(maxsize=8192)
def no_hole2(n):
    if n <= 5:
        return (1, 1, 2, 3, 5, 8)[n]
    if n % 2:
        h = (n-1) // 2
        m1 = no_hole2(h-1)
        m0 = no_hole2(h)
        return 2 * m1 * m0 + m0 * m0
    else:
        h = n // 2
        m2 = no_hole2(h-2)
        m1 = no_hole2(h-1)
        m0 = no_hole2(h)
        return m1 * m1 + m2 * m0 + m1 * m0


def solv(n, m, a):
    ans = 1
    current_pos = 0
    for pos in a:
        dist = pos - 1 - current_pos
        if dist < 0:
            return 0
        ans *= no_hole2(dist)
        current_pos = pos + 1
    dist = n - current_pos
    ans *= no_hole2(dist)
    return ans


if __name__ == '__main__':

    n, m = map(int, input().split())
    a = [int(input()) for _ in range(m)]

    ans = solv(n, m, a)

    P_NUM = 1000000007
    print(ans % P_NUM)


Measured memory_bytes: 7668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i <n; i++)
#define NMAX 107
#define WMAX 100007

using namespace std;

struct Item{
    long long weight,value;
};

int N,W;
Item items[NMAX];
long long C[NMAX][WMAX];

long long compute(){
    for(int i=0;i<=N;i++){
        C[i][0] = 0;
    }

    for(int w=0;w<=W;w++){
        C[0][w] =0;
    }

    for(int i=1;i<=N;i++){
        for(int w=1;w<=W;w++){
            C[i][w] = C[i-1][w];
            if(items[i].weight > w) continue;
            if(items[i].value + C[i-1][w-items[i].weight] > C[i-1][w]){
                C[i][w] = C[i-1][w-items[i].weight] + items[i].value;
            }
        }
    }

    return C[N][W];
}


int main() {
  cin >> N >> W;
  for(int i=1;i<=N;i++){
      cin >> items[i].weight >> items[i].value;
  }

  long long ans = compute();

  cout << ans << endl;

}

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

int main(){
  int N;
  cin >> N;
  map<int,int> card;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    card[a]++;
  }
  int round=0;
  int remain=0;
  for(auto a:card){
    if(a.second>1){
      round+=(a.second-1)/2;
      if(a.second%2==0){
        remain++;
      }
    }
  }
  cout << N-2*(round+(remain+1)/2) << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define MOD 1000000007
#define line "\n"
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector < int >
# define vs vector < string >
# define vb vector < bool >
#define vll vector<ll>
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
#define vpii vector<pair<int,int>>
#define vpsi vector<pair<string,int>>
#define mii map<int ,int>
#define mis map<int,string>
#define all(v) v.begin(),v.end()
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
using namespace std;
const int row[]={0,0,1,1,-1,1,-1,-1};
const int col[]={1,-1,-1,1,1,0,0,-1};




void solve()
{ 
double d,t,s;
cin>>d>>t>>s;
double ans=0;
ans=d/s;
if(ans<=t)cout<<"Yes"<<line;
else cout<<"No"<<line;
}
int main()
{fast
{
solve();
}

}



Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    // cout<<pi<<"\n";
    ll a,b,h,m;cin>>a>>b>>h>>m;
    ld mdeg=m*6;
    ld hdeg=h*30+mdeg/12;
    ld angle=abs(hdeg-mdeg);
    ld c=sqrt(a*a+b*b-2*a*b*cos(angle*(pi/180)));
    cout<<fixed<<setprecision(20)<<c;
    return 0;  
} 





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

int main(){
  int p,q,r;
  int a,b,c,ans;
  cin >> p >> q >> r;
  a=p+q;
  b=q+r;
  c=r+p;
  ans=min(a,b);
  ans=min(ans,c);
  cout << ans << endl;
  return 0;
}
 

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

int main(){
ll n;
cin >> n;
int a=0;
int b = 0;
int c =0;
int d =0;
for(int i = 0; i < n; i++){
string s;
cin >> s;
int m;
if(s=="AC")  a++;
if(s=="WA")  b++;
if(s=="TLE")  c++;
if(s=="RE")  d++;
}
cout << "AC x " <<  a <<endl;
cout << "WA x " <<  b <<endl;
cout << "TLE x " <<  c <<endl;
cout << "RE x " <<  d <<endl;
return 0;
 }    

Measured memory_bytes: 3624
# Implementation by unihernandez22 || Idea by Vicfred
# https://atcoder.jp/contests/abc171/tasks/abc171_e
# bitwise

input()
a = list(map(int, input().split()))

xor = a[0]
for i in a[1:]:
    xor ^= i

for i in a:
    print(xor ^ i, end=' ')
print()


Measured memory_bytes: 31640
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  	var one = nextIntArray();
	var N = one[0];
	var M = one[1];
	var Q = one[2];
	var list = new Array(Q);
	for(var i = 0; i < Q; i++){
		list[i] = nextIntArray();
	}
	var output = 0;
	dfs(1,[]);
	myout(output);
	function dfs(parent, used){
		if(used.length == N){
			var tmp = 0;
			for(var i = 0; i < Q; i++){
				if(used[list[i][1] - 1] - used[list[i][0] - 1] == list[i][2]){
					tmp += list[i][3];
				}
			}
			output = Math.max(tmp, output);
			return;
		}
		for(var i = parent; i <= M; i++){
			var tmpList = JSON.parse(JSON.stringify(used));
			tmpList.push(i);
			dfs(i, tmpList);
		}
	}
}

Measured memory_bytes: 35816
#include <iostream>
#include <cstring>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

char s[101];

void solve() {

	REP(i, 0, strlen(s)) {
		if ( ((i+1) % 2 != 0 && s[i] == 'L') || ((i+1) % 2 == 0 && s[i] == 'R')) {
			puts("No");
			return;
		}
	}
	puts("Yes");

}

int main(void) {
    scanf("%s", s);

    solve();
	return 0;
}


Measured memory_bytes: 256
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    ll n,m;
    int a;
    cin >> n >> m;
    rep(i,m){
        cin >> a;
        n=n-a;
    }
    if(n<0) cout << "-1" << endl;
    else cout << n << endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
d = []
for i in range(1,n):
    if i == 1:
        d.append(sum(a[0:i])-sum(a[i:n]))
    else:
        d.append(d[-1]+2*a[i-1])
for i in range(len(d)):
    d[i] = abs(d[i])
print(min(d))

Measured memory_bytes: 88272
#include <bits/stdc++.h>
using namespace std;
int main() {
    long R,G,B,N;
    cin>>R>>G>>B>>N;
    long ans=0;
    for(int i=0;i<=N/R;i++){
        for(int j=0;j<=(N-R*i)/G;j++){
            if((N-R*i-G*j)%B==0) ans++;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main()
{
    while(true){
        int N;cin>>N;
        if(!N)break;
        int nx=0,ny=0;
        vector<pair<int,int>>squs;
        squs.emplace_back(0,0);
        for(int i=0;i<N-1;++i){
            int n,d;cin>>n>>d;
            auto from=squs[n];
            from.first+=dx[d];
            from.second+=dy[d];
            squs.push_back(from);
        }
        int minx=0,miny=0,maxx=0,maxy=0;
        for(int i=0;i<N;++i){
            auto squ(squs[i]);
            minx=min(minx,squ.first);
            miny=min(miny,squ.second);
            maxx=max(maxx,squ.first);
            maxy=max(maxy,squ.second);

        }
        int H=maxy-miny+1;
        int W=maxx-minx+1;
        cout<<W<<" "<<H<<endl;
    }
    return 0;
}

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

int s;

int f(int n) {
    if (n % 2 == 0) return n / 2;
    
    return n * 3 + 1;
}

int main() {
    cin >> s;

    vector<int> v = {s};
    // cout << v.back();
    set<int> st = {s};
    int ans;
    for (int i = 1; i <= 1000000; i++) {
        int tmp = f(v.back());
        v.push_back(tmp);
        st.insert(tmp);

        if (st.size() < i + 1) {
            ans = i + 1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;
struct union_find{
    vector<int> par; 
    map<int,int> size;
    //1からnまで初期化:par[i] = i(1<=i<=n)
    union_find(int n){
        par.push_back(0);
        for(int i = 1;i<=n;i++){
            par.push_back(i);
            size[i] = 1;
        }
    }
    int root(int a){
        if (par[a] == a) return a;
        par[a] = root(par[a]);
        return root(par[a]);
    }
    void unite(int a,int b){
        if (root(a) == root(b)) return;
        size[root(b)]+=size[root(a)];
        par[root(a)] = root(b);
    }
    bool same(int a,int b){
        return (root(a) == root(b));
    }
    //頂点aが含まれる木の大きさ(頂点数)
    int treesize(int a){
        return size[root(a)];
    }
};
int main(){
    int n,m;
    cin >> n >> m;
    map<int,int> mp;
    int a,b;
    union_find tree(n);
    for(int i = 0;i<n;i++){
        cin >> a;
        mp[a] = i+1;
    }
    for(int i = 0;i<m;i++){
        cin >> a >> b;
        tree.unite(a,b);
    }
    map<int,set<int>> mp2;
    set<int> st;
    for(int i = 1;i<=n;i++){
        st.insert(tree.root(i));
        mp2[tree.root(i)].insert(i);
    }
    int ans = 0;
    for(auto itr = st.begin();itr!=st.end();itr++){
        for(auto itrr = mp2[*itr].begin();itrr!=mp2[*itr].end();itrr++){
            ans+=mp2[*itr].count(mp[*itrr]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 28792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

ul N, M, T, H, W;
ul A, B;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  cin >> A >> B;
  vector<ul> P(N, 0);
  vector<ul> prob(3, 0);
  ul easy = 0;
  ul mid = 0;
  ul hard = 0;
  REP(ii, N) {
    cin >> P[ii];
    if (P[ii] > B) {
      ++prob[0];
    } else if (P[ii] > A) {
      ++prob[1];
    } else {
      ++prob[2];
    }
  }
  sort(prob.begin(), prob.end());
  cout <<prob[0]<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
#include<numeric>
#include <list>
#define fo(a, b, c) for (register int a = b; a <= c; ++a)
 
namespace IO
{
//    inline char gc()
//    {
//        static char s[1<<20|1]={0},*p1=s,*p2=s;
//        return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
//    }
	inline char gc() { return getchar(); }
	inline long long read()
	{
		long long ret=0;bool flag=0;char c=gc();
		while ((c<'0')|(c>'9')) flag ^= !(c^'-'),c=gc();
		while ((c>='0')&(c<='9')) ret=(ret<<1)+(ret<<3)+(c^'0'),c=gc();
		return flag?-ret:ret;
 	}
 	char OutputAns[1<<20|1],*OutputCur = OutputAns;
 	inline void output()
 	{
 		OutputCur -= fwrite(OutputAns,1,OutputCur - OutputAns,stdout);
	}
	inline void print(long long ans)
	{
		char s[20]={0};
		if (OutputCur - OutputAns + sprintf(s,"I64d",ans) >> 20) output();
		OutputCur += sprintf(OutputCur,"%I64d",ans);
	}
	inline void printc(char c)
	{
		if (OutputCur - OutputAns + 1 >> 20) output();
		*(OutputCur++) = c;
	}
}
 
using IO::read;
using IO::print;
using IO::printc;
using IO::output;
 
using namespace std;
 
typedef long long int64;
 
const int M = 2e3 + 11;
 
int lim, n, q, ans = 2e9;

int A[M], R[M], Ok[M], C[M];

inline void Input()
{
	n = read(), lim = read(), q = read();
	for (int i = 1;i <= n; ++i)
		A[i] = R[i] = read();
	std::sort(R + 1, R + 1 + n);
}

inline void Solve(int Min)
{
	Ok[0] = 0;
	int l = 1, r = 1;
	while (l <= n)
	{
		C[0] = 0;
		while (A[l] < Min && l <= n) ++l;
		r = l;
		while (A[r] >= Min && r <= n) ++r;
		if (r - l < lim) goto end;
		for (int i = l;i < r; ++i)
			C[++C[0]] = A[i];
		std::sort(C + 1, C + 1 + C[0]);
		for (int i = 1;i <= C[0] - lim + 1; ++i)
			Ok[++Ok[0]] = C[i];
		end:; l = r;
	}
	if (Ok[0] < q) return ;
	std::sort(Ok + 1, Ok + 1 + Ok[0]);
	ans = std::min(ans, Ok[q] - Ok[1]);
}

int main(void)
{
	Input();
	for (int i = 1;i <= n - lim + 1; ++i)
		Solve(R[i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * n; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

class UnionFind {
	typedef size_t U;
	vector<int32_t> v;
public:
	UnionFind(U n) : v(n, -1) {}
	U find(U x) { return v[x] < 0 ? x : (v[x] = find((U)v[x])); }
	bool same(U x, U y) { return find(x) == find(y); }
	U size(U x) { return (U)-v[find(x)]; }
	void unite(U x, U y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (-v[x] < -v[y]) swap(x, y);
			v[x] += v[y];
			v[y] = x;
		}
	}
};

struct Edge{ uint32_t to, id; };
typedef vector<vector<Edge>> Graph;

template<class T> struct Kruskal{
	typedef uint32_t U;
	template<class V> Kruskal(U n, const V & u, const V & v, const vector<T> & w) : g(n) {
		vector<U> es(w.size());
		iota(es.begin(), es.end(), 0);
		sort(es.begin(), es.end(), [&](U i, U j) { return w[i] < w[j]; });
		UnionFind uf(n);
		for (U i : es) {
			if (!uf.same(u[i], v[i])) {
				uf.unite(u[i], v[i]); cost += w[i];
				g[u[i]].push_back({ (U)v[i], i }); g[v[i]].push_back({ (U)u[i], i });
			}
		}
	}
	Graph g; T cost = 0;
};

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

	ll n; cin >> n;
	vl u, v, w;
	REP(i, n) REP(j, n) {
		ll x; cin >> x;
		if (x != -1) {
			u.push_back(i);
			v.push_back(j);
			w.push_back(x);
		}
	}
	Kruskal<ll> mst(n, u, v, w);
	cout << mst.cost << endl;
}

Measured memory_bytes: 3256
#include <stdio.h>
  
int  main(void)
{
	int h,w,i,j;
	
	while(1){
		scanf("%d%d",&h,&w);

		if(h==0 && w==0)
		break;

		for(i=1; i<=h; i++){
		for(j=1; j<=w; j++){
		if((i+j)%2 == 0) printf("#");
		else printf(".");

		}
			printf("\n");
		}
			printf("\n");		
		}
return 0;
}


Measured memory_bytes: 2044
A, B, C, X, Y = map(int, input().split())
ans = 0
if A + B <= 2 * C:
    ans = A * X + B * Y
else:
    a = min(X, Y)
    ans += a * 2 * C
    X -= a
    Y -= a
    ans += X * min(A, 2*C)
    ans += Y * min(B, 2*C)

print(ans)


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

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll i, j;
	ll ret;
	char s[4];
	
	cin >> s;
	
	if (s[1] == 'B') {
		cout << "ARC" <<endl;
	}
	else {
		cout << "ABC" <<endl;
	}
	

	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define lli long long int
#define all(v) (v.begin(),v.end())
#define fr first
#define sc second
#define mp make_pair
using namespace std;
int a[100];

int main()
{
    int n,i;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];int dp[n+1];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),
                  dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4412
H,W = map(int,input().split())
a = []
tmp = []
ttt = []
ans = []
annn = []
for i in range(H):
    aa = input()
    aa = list(aa)
    a.append(aa)
for i in range(H):
    for j in range(W):
        if '#' == a[i][j]:
            tmp.append(a[i])
            break
H = len(tmp)
for i in range(W):
    t = []
    for j in range(H):
        t.append(tmp[j][i])
    ttt.append(t)
for i in range(W):
    for j in range(H):
        if '#' == ttt[i][j]:
            ans.append(ttt[i])
            break
W = len(ans)
for i in range(H):
    t = []
    for j in range(W):
        t.append(ans[j][i])
    annn.append(t)
for i in range(H):
    print(''.join(annn[i]))

Measured memory_bytes: 3316
///ShzFahad
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    ll ac=0,wa=0,re=0,tl=0;
    while(t--)
    {
        string s;
        cin >> s;
        if(s=="AC")
            ac++;
        else if(s=="TLE")
            tl++;
        else if(s=="WA")
            wa++;
        else
            re++;

    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tl << endl;
    cout << "RE x " << re << endl;

}



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

int main(){

    string s;
    cin>> s;

    string t=s.substr(0,2);
    string tt=s.substr(2,2);
    int te=stoi(t);
    int tee=stoi(tt);

    bool f=false,g=false;
    if(te>0&&te<=12){
        f=true;
    }
    if(tee>0&&tee<=12){
        g=true;
    }

    if(f&&g){
        cout << "AMBIGUOUS" << endl;
    }else if(f){
        cout << "MMYY" << endl;
    }else if(g){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }

    return 0;
}

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

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


    int temp;
    vector<int> v(n);
    n--;

    while(n--) {
        cin>>temp;
        v[temp-1]++;
    }

    for(int i=0;i<v.size();i++) {
        cout<<v[i]<<"\n";
    }

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

int main() {

    int n,r;cin>>n>>r;
    if (n>=10) {
        cout<<r<<endl;
    }
    else {
        cout<<r+1000-100*n<<endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5])
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

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

int main() {
    string s, v;
    cin >> s;
    for(int i=0; i<s.size(); i+=2) v += s.substr(i, 1);
    cout << v << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int N;

signed main()
{
    cin >> N;
    vector<int> A;
    map<int, int> mp;
    rep(i, N)
    {
        int a;
        cin >> a;
        A.push_back(a);
        mp[a]++;
    }
    int kinds = mp.size(), cnt = 0;
    bool isOdd;
    for (auto& a : A) {
        if (mp[a] > 1) {
            cnt++;
            mp[a]--;
        }
    }
    if (cnt % 2) {
        isOdd = true;
    } else {
        isOdd = false;
    }
    if (isOdd) {
        cout << N - (cnt + 1) << endl;
    } else {
        cout << N - cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;
 
  if (op == "+") {
    cout << A + B << endl;
  }
  else if (op == "-") {
    cout << A - B << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stdio.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int *arr1=new int[n];
    int *arr2= new int[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr1[i];
        if(i!=0)arr1[i]+=arr1[i-1];
    }
    for(int i=0;i<n;i++)
        cin>>arr2[i];
    for(int i=n-2;i>=0;i--)
        arr2[i]+=arr2[i+1];
    int Max=0;
    for(int i=0;i<n;i++)
    {
        Max=max(arr1[i]+arr2[i],Max);
    }
    cout<<Max;
    return 0;
}


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


int main() {
  int n;
  string str;

  /*  while(cin >> str) {
    n = str.size();
    for(int i=0;i<n;i++) {
      if((str[i] <= 122) && (str[i] >= 97)) {
        str[i] -= 32;
      }
    }
    if(str[n-1] == 46)
      cout << str;
    else
      cout << str << " ";
  }
}
  */
  getline(cin,str);
  n = str.size();
  for(int i=0;i<n;i++) {
    if((str[i] <= 'z') && (str[i] >= 'a')) {
      str[i] -= 32;
    }
  }
  cout << str << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> x(n),y(n);
    rep(i,n) cin >> x[i] >> y[i];
    double sum=0;
    rep(i,n) {
        repr(j,i+1,n) {
            sum+=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
        }
    }
    cout << fixed << setprecision(15) << 2.0*sum/n << endl; 
    return 0;
}

Measured memory_bytes: 256