akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc130/tasks/abc130_b
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, x: i32,
        l: [i32; n]
    };

    let mut p = 0;
    let mut cnt = 0;
    for i in 0..n+1 {
        if p <= x {
            cnt += 1;
        }
        if i == n {
            break;
        }
        p += l[i];
    }
    println!("{}", cnt);
}


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

int main(){
  int n,m=0,i=0,sum=0;
  scanf("%d",&n);
  int a[n], b[n],c[n-1];
  while(m!=n){
    scanf("%d",&a[i++]);    
    m++;
  }
  
  i=0;m=0;
  while(m!=n){
    scanf("%d",&b[i++]);
    m++;
  }

   
  i=0;m=0;
  while(m!=n-1){
    scanf("%d",&c[i++]);
    m++;
  }
  
  i=0;m=0;
  int next = 0;
  while(i!=n){
    if(next == a[i]){
      sum+=c[a[i-1]-1];
    }
    sum += b[a[i++]-1];
    next = a[i-1]+1;
  }
  printf("%d\n",sum);
  
  return 0;
}


Measured memory_bytes: 128
// C - Flip,Flip, and Flip......
#include <bits/stdc++.h>
// C - Flip,Flip, and Flip......
using namespace std;
using ll = long long;

int main(){
	ll N,M; cin>>N>>M;
	ll ans = 0;
	if(N == 1 && M == 1) ans = 1;
	else if(N == 1) ans = M - 2;
	else if(M == 1) ans = N - 2;
	else ans = (N-2) * (M-2);
	cout<< ans <<endl;
}

Measured memory_bytes: 256
n,c = map(int,input().split())
imos = [0 for i in range(10**5+1)]
stcl = []
for _ in range(n):
    s,t,c = map(int,input().split())
    stcl.append((s,t,c))
    imos[s-1] += 1
    imos[t] -= 1

stcl = sorted(stcl, key=lambda x: (x[2], x[1]))

new = []
s,t,c = stcl[0]
for i in range(1,n):
    if c == stcl[i][2] and t == stcl[i][0]:
        t = stcl[i][1]
    else:
        new.append((s, t, c))
        s, t ,c = stcl[i]
else:
    new.append((s, t, c))

imos = [0 for i in range(10**5+1)]
for s,t,c in new:
    imos[s-1] += 1
    imos[t] -= 1
import itertools
imos_ac = list(itertools.accumulate(imos))
print(max(imos_ac))


Measured memory_bytes: 84256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2 << "\n";

	return 0;
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N,X,Y;
	cin>>N>>X>>Y;
    vector<ll> ans(N);
    vector<ll> ans_ab(N);
    ll a,b,c;
    a = X-1;
    b = N-Y;
    c = Y-X+1;
    ll max_c = c/2;
    if(c%2==0){
        ans[max_c]+=max_c;
    }else{
        ans[max_c]+=c;
    }
    rep(i,max_c-1){
        ans[i+1]+=c;
    }
    
    rep(i,a){
        ans_ab[i+1]+=a-i;
        rep(j,max_c-1){
            ans_ab[i+1+j+1] += 2;
        }
        if(c%2==0){
            ans_ab[i+1+max_c] += 1;
        }else{
            ans_ab[i+1+max_c] += 2;
        }
    }


    rep(i,b){
        ans_ab[i+1]+=b-i;
        rep(j,max_c-1){
            ans_ab[i+1+j+1] += 2;
        }
        if(c%2==0){
            ans_ab[i+1+max_c] += 1;
        }else{
            ans_ab[i+1+max_c] += 2;
        }
    }

    rep(i,a){
        rep(j,b){
            ans_ab[i+1+1+j+1]+=1;
        }
    }

    rep(i,N-1){
        cout<<(ans[i+1]+ans_ab[i+1])<<"\n";
    }


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string alphabet;
  alphabet = "abcdefghijklmnopqrstuvwxyz";
  char c;
  cin >> c;
  for(int i = 0; i < 25; i++){
    if(c == alphabet[i]){
      cout << alphabet[i+1];
    }
  }
}

Measured memory_bytes: 256
#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() {
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<vector<int>> a(2,vector<int>(n));
	for(int i=0;i<2;++i)
		for(int& x:a[i]) cin>>x;
	int res=0;
	for(int i=0;i<n;++i)
		res=max(res,accumulate(a[0].begin(),a[0].begin()+i,0)+accumulate(a[1].begin()+i+1,a[1].end(),0)+a[0][i]+a[1][i]);
	cout<<res<<'\n';
}



Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n; cin >> n;
  vector<bool> isSafe(n, true);
  vi ans(n+5, 0);
  int m; cin >> m;
  rep(i,m) {
    int a; cin >> a;
    isSafe[a] = false;
  }
  ans[0] = 1;
  rep(i,n) {
    if (isSafe[i+1]) {
      ans[i+1] += ans[i];
      ans[i+1] %= MOD;
    }
    if (isSafe[i+2]) {
      ans[i+2] += ans[i];
      ans[i+2] %= MOD;
    }
  }
  cout << ans[n] << endl;
  return 0;
}


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

const int N = 200005;
const int INF = 2e9;

int n, a[N];
vector <int> z;
pair<int,int> T[N << 2];
int lz[N << 2]; // the amount of adding

#define mid ((l + r) >> 1)

void build(int v, int l, int r) {
	if (l == r) { T[v] = {z[l - 1], l}; return; }
	build(v << 1, l, mid);
	build(v << 1 | 1, mid + 1, r);
	T[v] = min(T[v << 1], T[v << 1 | 1]);
}

void push(int v, int l, int r) {
	if (lz[v] == 0) return;
	if (l < r) lz[v << 1] += lz[v], lz[v << 1 | 1] += lz[v];
	T[v].first += lz[v];
	lz[v] = 0;
}

void upd(int v, int l, int r, int L, int R, int val) {
	push(v, l, r);
	if (R < l || L > r) return;
	if (L <= l && r <= R) {
		lz[v] = val; push(v, l, r); return;
	}
	upd(v << 1, l, mid, L, R, val);
	upd(v << 1 | 1, mid + 1, r, L, R, val);
	T[v] = min(T[v << 1], T[v << 1 | 1]);
}

pair<int,int> get(int v, int l, int r, int L, int R) {
	push(v, l, r);
	if (R < l || L > r) return {INF, 0};
	if (L <= l && r <= R) return T[v];
	return min(get(v << 1, l, mid, L, R), get(v << 1 | 1, mid + 1, r, L, R));
}

#undef mid

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		z.push_back(a[i]);
	}
	sort(z.begin(), z.end());
	z.erase(unique(z.begin(), z.end()), z.end());

	build(1, 1, z.size());

	long long res = 0; // result
	for (int i = 1; i <= n; ++i) {
		int p = lower_bound(z.begin(), z.end(), a[i]) - z.begin() + 1;
		pair<int, int> w = get(1, 1, z.size(), p, z.size()); // get min cost

		int wcost = w.first;
		int	wpos = w.second;

		res += wcost - a[i];

		upd(1, 1, z.size(), 1, wpos - 1, +1);
	}

	cout << res << endl;
}

Measured memory_bytes: 10100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    auto f = [](ll x, ll y) { return (x + y - 1) / y;};
    ll ans = 4 + max({f(n, a), f(n, b), f(n, c), f(n, d), f(n, e)});
    cout << ans << endl;
}


Measured memory_bytes: 3560
#include <stdio.h>

int gcd(int,int);

int main(){
  int a,b;

  scanf("%d%d" ,&a ,&b);
  printf("%d\n" ,gcd(a,b));

  return 0;
}

int gcd(int a,int b){
  if(b == 0){
    return a;
  }
  return gcd(b , a % b);
}

Measured memory_bytes: 592
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x *= i;
    return x;
}

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b)
{
   return a / gcd(a, b) * b;
}

int main(){
    long double l;
    cin>>l;
    long double a=l/3;
    cout<<fixed<<setprecision(10)<<a*a*a<<endl;
    return 0;
}


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

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

    int YYMM = 0;
    int MMYY = 0;
    string s;

    cin >> s;

    int x = stoi(s.substr(0,2));
    int y = stoi(s.substr(2,2));

    if(x>=1 && x<=12)
    {
        MMYY = 1;
    }
    if(y>=1 && y<=12)
    {
        YYMM = 1;
    }

    int val = 2*MMYY + YYMM;
    if(val==3)
    {
        cout << "AMBIGUOUS" << '\n';
    }
    else if(val==0)
    {
        cout << "NA" << '\n';
    }
    else if(val==2)
    {
        cout << "MMYY" << '\n';
    }
    else
    {
        cout << "YYMM" << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,i,j,ans = 1;scanf("%d%d",&n,&m);
  for(i=1;i*i<=m;i++){
    if(m%i==0){
      j = m/i;
      if(i<n && j<n) continue;
      if(i>=n) ans = max(ans,j);
      else if(j>=n) ans = max(ans,i);
      else ans = max({ans,i,j});
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

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

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vi l, r; vi vec; vector<int> tmp;
	int n; cin >> n;
	for(int i = 0; i < n; i++)
	{
		int x; cin >> x;
		tmp.pb(x);
		vec.pb(x);
	}
	sort(tmp.begin(), tmp.end());
	for(int i = 0; i < n; i++)
	{
		vec[i] = lower_bound(tmp.begin(), tmp.end(), vec[i]) - tmp.begin();
	}
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(i%2 != vec[i]%2) ans++;
	}
	ans>>=1;
	cout << ans;
}


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

public class Main
{

	public static void main(String[] args) throws IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int i = Integer.parseInt(str);
		System.out.println(i * i * i);
	}

}



Measured memory_bytes: 24340
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    A = NLI()
    
    sum_A = sum(A)
    ans = 0
    
    for n in range(N):
        sum_A -= A[n] 
        ans += (A[n] * sum_A)%MOD
        ans = ans % MOD
    print(ans)
        



if __name__ == '__main__':
    main()

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

void solve(){
    while(true){
        int n,m,cap;
        cin >> n >> m >> cap;
        if(!n and !m and !cap) return;

        string str_src,str_dest;
        map<string,int> mp;
        vector<tuple<int,int,int>> edges;
        cin >> str_src >> str_dest;
        mp[str_src]=0;
        mp[str_dest]=1;
        int size=2;
        rep(i,0,n){
            string c1,c2;
            int d;
            cin >> c1 >> c2 >> d;
            if(!mp.count(c1)){
                mp[c1]=size;
                ++size;
            }
            if(!mp.count(c2)){
                mp[c2]=size;
                ++size;
            }
            edges.emplace_back(make_tuple(mp[c1],mp[c2],d));
        }
        vector<vector<pii>> graph(size);
        vector<bool> is_station(size,false);
        rep(i,0,m){
            string name;
            cin >> name;
            is_station[mp[name]]=true;
        }
        for(const auto &e:edges){
            graph[get<0>(e)].emplace_back(make_pair(get<1>(e),get<2>(e)*10));
            graph[get<1>(e)].emplace_back(make_pair(get<0>(e),get<2>(e)*10));
        }

        vector<vector<int>> dist(size,vector<int>(cap*10+1,inf));
        priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>> que;
        dist[0][cap*10]=0;
        que.push(make_tuple(0,0,cap*10));
        while(!que.empty()){
            const auto tup=que.top();
            que.pop();
            const int d=get<0>(tup),u=get<1>(tup),c=get<2>(tup);
            if(d>dist[u][c]) continue;
            if(is_station[u] and d<dist[u][cap*10]){
                dist[u][cap*10]=d;
                que.push(make_tuple(d,u,cap*10));
            }
            for(const auto &e:graph[u]){
                const int v=e.first,tmp_d=d+e.second,remain=c-e.second/10;
                if(remain<0 or tmp_d>=dist[v][remain]) continue;
                dist[v][remain]=tmp_d;
                que.push(make_tuple(tmp_d,v,remain));
            }
        }

        int ans=inf;
        rep(i,0,cap*10+1) ans=min(ans,dist[1][i]);
        if(ans==inf) cout << -1 << endl;
        else cout << ans/10 << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Measured memory_bytes: 51664
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - .. (Double Dots)
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int ds[MAX_N], ps[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    nbrs[x].push_back(y);
    nbrs[y].push_back(x);
  }

  fill(ds, ds + n, INF);
  ds[0] = 0;
  ps[0] = -1;
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int up = ps[u], vd = ds[u] + 1;
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int v = *vit;
      if (v != up && ds[v] > vd) {
	ds[v] = vd;
	ps[v] = u;
	q.push(v);
      }
    }
  }

  puts("Yes");
  for (int u = 1; u < n; u++) printf("%d\n", ps[u] + 1);
  return 0;
}


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

const double pi=acos(-1);
typedef long long ll;
const int maxn=1e6+10;
ll f[200050];
int main()
{
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++)
        cin >> f[i];
    sort(f,f+n);
    ll ans=0;
    for(int i=n-k-1;i>=0;i--)
        ans+=f[i];
    cout << ans;

    return 0;
}



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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define int long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 7;
const double P = 3.141592653589793238462643;

int a[N], c[N], cnt, mx = -inf, cnt2, u[N];

main()
{
    int n;
    cin >> n;
    for( int i = 1; i <= n; i++ )
    {
        cin >> a[i];
    }
    for( int i = 1; i <= n; i++ )
    {
        if( a[i] == i )
        {
            if( a[i + 1] == i + 1 && u[i] == 0 )
            {
                cnt++;
                u[i + 1] = 1;
                continue;
            }
            if( u[i] == 0 )
                cnt2 ++;
//            cout << a[i + 1] << "  "<< i + 1 << endl;
        }
    }
    cout << cnt + cnt2;
}


Measured memory_bytes: 1792
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	int totalDist;
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjWeight[i][j] = in.nextInt();
				if (adjWeight[i][j] != -1) {
					adjMatrix[i][j] = 1;
				}
			}
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int minimum(int s) {
		int[] dist = new int[totalVertex];
		LinkedList<Integer> unsettled = new LinkedList<Integer>();
		for(int i = 0; i < totalVertex; i++) {
			unsettled.add(i);
			dist[i] = Integer.MAX_VALUE;
			ifSettled[i] = false;
		}
		dist[0] = 0;
		
		while(!unsettled.isEmpty()) {
			Integer shortestNeighbor = getUnsettledNearest(dist);
			
			ifSettled[shortestNeighbor] = true;
			unsettled.remove(shortestNeighbor); 
			
			LinkedList<Integer> neigh = getUnsettledNeighbors(shortestNeighbor);
			Iterator<Integer> iter = neigh.iterator();
			
			while(iter.hasNext()){
				int current = iter.next();
				if(dist[current] > adjWeight[shortestNeighbor][current]) {
					dist[current] = adjWeight[shortestNeighbor][current];
				}
			}
			
		}
		for(int i = 0; i < dist.length; i++) {
			totalDist += dist[i];
		}
		
		return totalDist;
	}
}


public class Main{
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int dist = g.minimum(0);
		System.out.println(dist);
	}
}



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

typedef long long ll;

int main() {
    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    if (x / d < k) {
        if ((k - x / d) % 2 == 0) {
            cout << x % d << endl;
            return 0;
        } else {
            cout << d - x % d << endl;
            return 0;
        }
    } else {
        cout << x - k * d << endl;
        return 0;
    }
}


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

int main() {
	int K, N;
	cin >> K >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	int max_dist = A.at(0) + (K - A.at(N - 1));
	for (int i = 1; i < N; i++) {
		int tmp = A.at(i) - A.at(i - 1);
		max_dist = max(max_dist, tmp);
	}
	cout << K - max_dist << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int n;
  scanf("%d", &n);
  char s[MAX];
  scanf("%s", s);

  int ans = 1;
  rep(i, n - 1)
  {
    if (s[i] == s[i + 1])
      continue;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
H = [int(x) for x in input().split(' ')]

max_cnt=0
cnt =0

for i in range(n-1):
  if H[i]>=H[i+1]:
    cnt+=1
  else:
    if cnt>max_cnt:
      max_cnt=cnt
    cnt=0
  #print(cnt,max_cnt)
if cnt>max_cnt:
      max_cnt=cnt
print(max_cnt)

Measured memory_bytes: 14252
#include<stdio.h>
int main(void){
	
	int n,i,x;
	scanf("%d",&n);
	
	for(i=3;i<=n;i++){
		x=i;
		if(x%3==0){
			printf(" %d",i);
		}else{
			while(x){
				if(x%10==3){
					printf(" %d",i);
					break;
				}
				x/=10;
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
#define lowbit(x) ((x) & (-(x)))
using namespace std;

const int N = 2e5 + 10;
typedef long long ll;
ll n, num[26], C[N << 2], lst[26], ans;
bool vis[N];
char s[N];
vector<int> pos[26];

void add(int x, int val) {
	for (; x <= n; x += lowbit(x)) C[x] += val;
}

ll query(int x) {
	ll ret = 0;
	for (; x; x -= lowbit(x)) ret += C[x];
	return ret;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	rep(i, 1, n) pos[s[i] - 'a'].push_back(i);
	
	int chk = 0;
	rep(i, 0, 25) {
		if ((pos[i].size()) & 1) chk++;
		lst[i] = (pos[i].size()) - 1;
	}
	if (chk > 1) { puts("-1"); return 0; }
	
	rep(i, 1, n) add(i, 1);
	rep(l, 1, n) if (!vis[l]) {
		int c = s[l] - 'a', r = pos[c][lst[c]];
		if (l == r) ans += (query(n) - query(l)) >> 1;
		else ans += query(n) - query(r);
		vis[l] = vis[r] = 1;
		add(l, -1), add(r, -1);
		lst[c]--;
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int main ()
{
  int n, i;
  i = 0;
  cin >> n;
  vector<int> str(n);
  while(i < n)
  {
  	cin >> str[i];
   	i++;
  }
  i = 0;
  while(i < n)
  {
    if(str[i] % 2 == 0)
    {
      if((str[i] % 3 == 0) || (str[i] % 5 == 0))
      {
      }
      else
      {
        cout << "DENIED" << endl;
        return 0;
      }
    }
    i++;
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,a=0,b=0,c=0,d=0;
    cin>>n;
    string s;

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

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;

  int w,l;
  cin >> w;
  l = s.length();

  for(int i=0;i<l;i+=w){
    cout << s[i];
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner stdin=new Scanner(System.in);
		int a=stdin.nextInt();
		int b=stdin.nextInt();

		if((a*b)%2==1)
			System.out.println("Odd");
		else if((a*b)%2==0)
			System.out.println("Even");
	}
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    cin >> N;
    cout << fixed << setprecision(12) << ceil(N / 2.0) / N << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

int ans = 0;
 if(N %2 == 0) {
ans = N / 2;
 }else if(N < 2){
     ans = N;
 }else{
ans = (N + 1)/2;
 }
 cout << ans << endl;
 return 0;

}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
#define fr first
#define sc second

const int maxn=2e5+5;

pii node[maxn];
int n,rt,tot,cnt;
int f[20][maxn][2];
int a[maxn],now[maxn],pre[maxn],son[maxn];

int read() {
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return x*f;
}

void add(int a,int b) {
	if(!b)return;
	pre[++tot]=now[a];
	now[a]=tot,son[tot]=b;
}

int cmp(int pos1,int pos2) {
	if(a[pos1]<a[pos2])return pos1;
	return pos2;
}

void make_st() {
	for(int i=1;i<20;i++)
		for(int j=1;j+(1<<i)-1<=n;j++)
			for(int k=0;k<2;k++)
				f[i][j][k]=cmp(f[i-1][j][k],f[i-1][j+(1<<(i-1))][k]);
}

int solve(int l,int r,int opt) {
	if(r<l)return 0;
	if(l+1==r) {
		node[++cnt]=make_pair(a[l],a[r]);
		return cnt;
	}
	int x=log2(r-l+1);
	int pos=cmp(f[x][l][opt],f[x][r-(1<<x)+1][opt]);
	x=log2(r-pos+1);
	int tmp=cmp(f[x][pos][opt^1],f[x][r-(1<<x)+1][opt^1]);
	node[++cnt]=make_pair(a[pos],a[tmp]);x=cnt;
	add(x,solve(l,pos-1,opt));
	add(x,solve(pos+1,tmp-1,opt^1));
	add(x,solve(tmp+1,r,opt));
	return x;
}

struct Heap {
	int len;
	int tree[maxn];

	void ins(int u) {
		tree[++len]=u;
		int pos=len;
		while(pos>1) {
			if(node[tree[pos]]<node[tree[pos>>1]])
				swap(tree[pos],tree[pos>>1]),pos>>=1;
			else break;
		}
	}

	int pop() {
		int res=tree[1];
		tree[1]=tree[len--];
		int pos=1,son=2;
		while(son<=len) {
			if(son<len&&node[tree[son|1]]<node[tree[son]])son|=1;
			if(node[tree[son]]<node[tree[pos]])
				swap(tree[pos],tree[son]),pos=son,son=pos<<1;
			else break;
		}
		return res;
	}
}H;

void make_ans() {
	H.ins(rt);
	while(H.len) {
		int u=H.pop();printf("%d %d ",node[u].fr,node[u].sc);
		for(int p=now[u];p;p=pre[p])
		    H.ins(son[p]);
	}
}

int main() {
	n=read();a[0]=2e9;
	for(int i=1;i<=n;i++)
		a[i]=read(),f[0][i][i&1]=i;
	make_st();
	rt=solve(1,n,1);
	make_ans();
	return 0;
}


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

typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 3;
const int MOD = 1e9 + 7;

int ans, n, k, x;

int main() {
	ans = 0;
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &x);
		ans += min(x, abs(k - x));
	}
	printf("%d\n", ans << 1);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;
typedef vector<vi> mat;

inline ll read(){
	ll Hashimoto=0,Kanna=1;
	char I_Love=getchar();
	while(I_Love<'0'||I_Love>'9'){
		if(I_Love=='-')Kanna=-1;
		I_Love=getchar();
	}
	while(I_Love>='0'&&I_Love<='9'){
		Hashimoto=Hashimoto*10+I_Love-'0';
		I_Love=getchar();
	}
	return Hashimoto*Kanna;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<Kanna;I_Love++)cout<<Hashimoto[I_Love]<<(I_Love==Kanna-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<Kanna;I_Love++)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n,m;
vpii g[111111];
int cnt[111111];
vi vert[1111111];
int col[1111111];
queue<int>q;
vi ng[311111];
int dp[311111];

int I_Love_Hashimoto_Kanna() {
  fastio;
  n=read();m=read();
  FOR(i,0,m){
  	int a=read()-1,b=read()-1,c=read();
  	g[a].push_back({c,b});
  	g[b].push_back({c,a});
  	vert[c].push_back(a);
  	vert[c].push_back(b);
	}
	FOR(i,0,n){
		SORT(g[i]);
	}
	int nn=n; 
	FOR(c,0,1000001){
		if(!vert[c].size())continue;
		FOR(tot,0,vert[c].size()){
			if(col[vert[c][tot]]==c)continue;
			q.push(vert[c][tot]);
			col[vert[c][tot]]=c;
			ng[nn].push_back(vert[c][tot]);
			ng[vert[c][tot]].push_back(nn);
			
			while(!q.empty()){
				int x=q.front();q.pop();
				while(cnt[x]<g[x].size()&&g[x][cnt[x]].first==c){
					int to=g[x][cnt[x]++].second;
					col[to]=c;
					q.push(to);
					ng[nn].push_back(to);
					ng[to].push_back(nn);
				}
			}
			nn++;
		}
	}
	FOR(i,0,nn)dp[i]=-2;
	dp[0]=0;
	q.push(0);
	while(!q.empty()){
		int x=q.front();q.pop();
		FOR(i,0,ng[x].size()){
			int to=ng[x][i];
			if(dp[to]==-2){
				dp[to]=dp[x]+1;
				q.push(to);
			}
		}
	}
	Tone(dp[n-1]/2)
  
  
  
  
  return 0;
}


Measured memory_bytes: 62720
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1e+15;


void solve(istream &cin) {
    string s;
    cin >> s;
    if(!cin) return;

    ll ans = 2 * min(count(s.begin(), s.end(), '0'), count(s.begin(), s.end(), '1'));
    cout << ans  << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
    int n, i, j, t, a[100][100];
    int u, min, d[100], p[100], v[100];
    scanf("%d", &n);
    for(i = 0; i < n; i++) for(j = 0; j < n; j++) {
        scanf("%d", &t);
        a[i][j] = (t==-1)?1000000000:t;
    }
    for(i = 0; i < n; i++) {
        d[i] = 1000000000;
        p[i] = -1;
        v[i] = 0;
    }
    d[0] = 0;
    while(1) {
        min = 1000000000;
        u = -1;
        for(i = 0; i < n; i++) {
            if(min > d[i] && v[i] != 2) {
                u = i;
                min = d[i];
            }
        }
        if(u == -1) break;
        v[u] = 2;
        for(j = 0; j < n; j++) {
            if(v[j] != 2 && a[i][j] != 1000000000){
                if(d[j] > a[u][j]) {
                    d[j] = a[u][j];
                    p[j] = u;
                    v[j] = 1;
                }
            }
        }
        t = 0;
        for(i = 0; i < n; i++) {
            if(p[i] != -1) t+=a[i][p[i]];
        }
    }
    printf("%d\n", t);
    return 0;
}



Measured memory_bytes: 2656
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
  int N; cin>>N;
  vector<int> h(N); for(int i=0;i<N;i++) cin>>h[i];

  vector<int> dp(N);

  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);

  for(int i=2;i<N;i++){
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
  }

  cout<<dp[N-1]<<endl;

  return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int m, n, c = 0;
	int a, b;
	int i, max;
	
	scanf("%d %d", &n, &m);
	max = m;
	
	for (i = 0; i < n; i++){
		
		scanf("%d %d", &a, &b);
		
		m += a - b;
		
		if (max < m){
			max = m;
		}
		
		if (m < 0){
			c = 1;
		}
	}
	if (c == 0){
		printf("%d\n", max);
	}
	else {
		printf("0\n");
	}
	
	return (0);
}

Measured memory_bytes: 596
module String = struct
  include String
  let to_list s =
    let rec loop acc = function
      | 0 -> acc
      | n -> loop (s.[n - 1] :: acc) (n - 1) in
    loop [] (String.length s)
end

let rec tabulate n f = 
  let rec loop acc m =
    if m < n then loop (f m :: acc) (m + 1)
    else List.rev acc in
  loop [] 0

let () =
  read_line ()
    |> String.to_list
    |> List.fold_left (fun (prev, n) c ->
        (c, if prev = c then n else n + 1)) ('X', 0)
    |> (fun (_, n) -> n - 1)
    |> Printf.printf "%d\n"


Measured memory_bytes: 4864
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    cin>>A>>S;
    if(A>=3200){
        cout<<S<<endl;
    }else{
        cout<<"red"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  //vector<ll>to[1000005];
  // ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  double a,c=1,ans=0;cin>>a;
  vector<pair<double,double>>b(a);
  vector<ll>d(a);
  rep(i,a){
    c*=i+1;
    d[i]=i;
    cin>>b[i].first>>b[i].second;
  }
  do{
    rep(i,a-1)ans+=sqrt((b[d[i]].first-b[d[i+1]].first)*(b[d[i]].first-b[d[i+1]].first)+(b[d[i]].second-b[d[i+1]].second)*(b[d[i]].second-b[d[i+1]].second));
  }while(next_permutation(d.begin(),d.end()));
  cout<<fixed<<setprecision(12)<<ans/c;
}



Measured memory_bytes: 3780
#include<stdio.h>
 
int main(){
 
  int i, left, right, mid, n, q, cnt = 0, s[100000], t[50000] ;

 
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &s[i]);
 }
 
  scanf("%d", &q);
  for(i = 0;i < q;i++){
    scanf("%d", &t[i]);
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right) / 2;
      if(t[i] == s[mid]){
        cnt++;
        break;
      }
      if(t[i] > s[mid]){
        left = mid + 1;
      }
      else if(t[i] < s[mid]){
        right = mid;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int a, b;
	cin >> a >> b;
	vector<int> data = { 2,3,4,5,6,7,8,9,10,11,12,13,1 };
	ff(i, 0, 13) {
		if (data.at(i) == a && data.at(i) == b) {
			cout << "Draw" << endl;
			return 0;
		}
		if (data.at(i) == a) {
			cout << "Bob" << endl;
			return 0;
		}
		if (data.at(i) == b) {
			cout << "Alice" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*ab = map(int, read().split())

    A, B = [], []
    for a, b in zip(*[iter(ab)]*2):
        A.append(a)
        B.append(b)

    A.sort()
    B.sort()

    if N % 2 == 0:
        a1, a2 = A[N // 2 - 1], A[N // 2]
        b1, b2 = B[N // 2 - 1], B[N // 2]

        ans = b1 + b2 - (a1 + a2) + 1
    
    else:
        a = A[N // 2]
        b = B[N // 2]
        
        ans = b - a + 1
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 54572
from math import atan2, pi

N = int(input())
dxy = []
for _ in range(N) :
    x, y = map(int, input().split())
    dxy.append((atan2(y, x), x, y))

dxy.sort()
for i in range(N) :
    dxy.append((dxy[i][0] + 2 * pi, dxy[i][1], dxy[i][2]))

M = 0
E = 1e-6
for i in range(N) :
    d, x, y = dxy[i][0], 0, 0
    for j in range(i, 2 * N) :
        if dxy[j][0] - d > pi + E :
            break
        x += dxy[j][1]
        y += dxy[j][2]
        M = max(M, x * x + y * y)
print(M ** 0.5)

Measured memory_bytes: 39280
#include <bits/stdc++.h>
#define Rint register int
#define C(n,m) (n<m?0:1ll*fac[n]*invfac[n-m]%mod*invfac[m]%mod)
using namespace std;
int T,n,m,p,k,head[100010],o=0,sz,ed,cnt[3],c[100010];
bool can,vis[100010];
struct edge{
	int to,link,w;
}e[200010];
void add_edge(int u,int v){
	e[++o].to=v,e[o].link=head[u],head[u]=o,e[o].w=1;
	e[++o].to=u,e[o].link=head[v],head[v]=o,e[o].w=2;
}
void dfs(int u,int col){
	cnt[col]++;vis[u]=true;c[u]=col,sz++;
	for(int i=head[u];i;i=e[i].link){
		if(e[i].w==1) ed++;
		if(vis[e[i].to]){
			if(c[e[i].to]!=(col+e[i].w)%3) can=false;
			continue;
		}
		dfs(e[i].to,(col+e[i].w)%3);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++) scanf("%d%d",&u,&v),add_edge(u,v);
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(vis[i]) continue;
		sz=ed=cnt[0]=cnt[1]=cnt[2]=0;can=true;
		dfs(i,0);
		if(!can) ans+=1ll*sz*sz;
		else{
			if(!min(min(cnt[0],cnt[1]),cnt[2])) ans+=ed;
			else ans+=1ll*cnt[0]*cnt[2]+1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2];
		}
	}
	printf("%lld\n",ans); 
}


Measured memory_bytes: 11732
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int s = sc.nextInt();
    
    int s1 = s / 100;
    int s2 = (s - (s1 * 100)) / 10;
    int s3 = (s - (s1 * 100) - (s2 * 10));
    
    System.out.println(s1 + s2 + s3);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int n, k; cin >> n >> k;
    int ans=0;
    for(int i=0; i<n; ++i){
        int h; cin >> h;
        if(h>=k) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdint>

using namespace std;

using elem_t = pair<int_least32_t, int_least32_t>;

int main()
{
	int_least32_t n;
	int_least64_t k;
	cin >> n >> k;

	vector<elem_t> v( n );
	for(auto& x : v) {
		cin >> x.first >> x.second;
	}

	sort(v.begin(), v.end(), [](elem_t x, elem_t y){ return x.first < y.first; } );

	int_least32_t result;
	int_least64_t count = 0;
	for(auto i = 0; count < k; ++i) {
		result = v[i].first;
		count += v[i].second;
	}

	cout << result << endl;
}


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

using namespace std;

int main(){
    int n,k;
    cin >> n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=1; i<=n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    int ans[n+1][3];
    ans[0][0] = ans[0][1] = ans[0][2] = 0;
    for(int i=1; i<=n; i++){
        ans[i][0] = max(ans[i-1][1],ans[i-1][2]) + a[i];
        ans[i][1] = max(ans[i-1][0],ans[i-1][2]) + b[i];
        ans[i][2] = max(ans[i-1][0],ans[i-1][1]) + c[i];
    }
    cout << max(ans[n][0], max(ans[n][1],ans[n][2]));
    return 0;
}

Measured memory_bytes: 5944
N = int(input())
T = [int(x) for x in input().split()]
total = sum(T)
M = int(input())
D = [None]*M
for i in range(M):
  D[i] = [int(x) for x in input().split()]
  D[i][0]-=1
  
for p, x in D:
  print(total - (T[p] - x))
  

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

using std::string;
using std::cin;
using std::cout;

int main( )
{
	string str;
	cin >> str;
	int ans1 = -1, ans2 = 1;
	for( string::iterator c = str.begin( ); c != str.end( ); ++c )
	{
		if( c == str.begin( ) )
			continue;
		if( *c == *( c - 1 ) )
		{
			ans1 = c - str.begin( );
			ans2 = 2;
			break;
		}
		if( c > str.begin( ) + 1 && *c == *( c - 2 ) )
		{
			ans1 = c - str.begin( ) - 1;
			ans2 = 3;
		}
	}
	cout << ans1 << " " << ans2 + ans1 - 1;
	return 0;
} 

Measured memory_bytes: 3708
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

long int N;

long int f(string s){
    long int l=stol(s),ans=0;
    int a=0,b=0,c=0;
    if (l>N) return 0;
    for (int i=0;i<s.size();i++){
        if (s[i]=='3') a=1;
        else if(s[i]=='5') b=1;
        else if (s[i]=='7') c=1; 
    }    
    if (a*b*c) ans=1;
    ans+=f(s+"3")+f(s+"5")+f(s+"7");
    return ans;
}


int main(){
    cin>>N;
    cout<<f("0")<<endl;

    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter

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

a.sort(key=itemgetter(1))

p = 0

for i in range(n):
    p+=a[i][0]
    if p>a[i][1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 89688