akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

pc_memo = defaultdict(int)
memo = defaultdict(int)


def to_next(x):
    if x not in pc_memo.keys():
        pc_memo[x] = x % "{:b}".format(x).count('1')
    return pc_memo[x]


def f(x):
    if x == 0:
        return 0
    if x not in memo.keys():
        memo[x] = f(to_next(x))+1
    return memo[x]


for i in range(2*10**5):
    f(i)

n = int(input())
x = input().rstrip()
one_cnt = x.count('1')

mod_minus = 0
mod_plus = 0
for i, a in enumerate(reversed(x)):
    if a == '1':
        if 0 < one_cnt-1:
            mod_minus += pow(2, i, one_cnt-1)
            mod_minus %= one_cnt-1
        mod_plus += pow(2, i, one_cnt+1)
        mod_plus %= one_cnt+1


for i in range(n):
    if x[i] == '0':
        nx = mod_plus+pow(2, n-i-1, one_cnt+1)
        nx %= one_cnt+1
        print(f(nx)+1)
    else:
        if 0 < one_cnt-1:
            nx = mod_minus-pow(2, n-i-1, one_cnt-1)
            nx %= one_cnt-1
            print(f(nx)+1)
        else:
            print(0)


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{

	double n, m, d;
	cin>>n>>m>>d;
	if (d==0) {
		cout << fixed << setprecision(10) << (m - 1) / n << endl;
	}
	else {
		cout << fixed << setprecision(10) << 2*(n-d)*(m - 1) / (n*n) << endl;
	}
    return 0;
}



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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 110;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);


int n;
char s[N];


void solve(int testCase){

    scanf("%d %s" , &n , s);

    if(n&1){
            printf("No\n");
            return;
    }

    for(int p1 = 0 , p2 = n/2 ; p2 < n ; p1 ++ , p2 ++){
            if(s[p1] != s[p2]){
                    printf("No\n");
                    return;
            }
    }

    printf("Yes\n");

}

main(){

    int t = 1;
    //scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

struct edge {
    int s, t, w;
};

int main() {
    int l;
    cin >> l;
    int n = 1, t = 0;;
    for (; n <= l; n <<= 1, t++);
    n >>= 1, t--;
    if (n == l) {
        cout << t + 1 << " " << 2 * t << endl;
        for (int i = 1; i <= t; i++) {
            cout << i << " " << i + 1 << " " << 0 << endl;
            cout << i << " " << i + 1 << " " << (1 << (i - 1)) << endl;
        }
        return 0;
    }

    cout << t + 1 << " ";
    vector<edge> es;
    for (int i = 1; i <= t; i++) {
        es.push_back({i, i + 1, 0});
        es.push_back({i, i + 1, (1 << (i - 1))});
    }

    vi as;
    for (int i = 0; i < t; i++) {
        as.push_back(1 << i);
    }

    auto ikamax = [&](i64 a) {
        if (upper_bound(as.begin(), as.end(), a) - lower_bound(as.begin(), as.end(), a)) {
            return a;
        } else {
            int d = lower_bound(as.begin(), as.end(), a) - as.begin();
            return as[d - 1];
        }
    };

    auto get_beki = [&](i64 a) {
        int cnt = 0;
        while (a > 1) {
            a >>= 1;
            cnt++;
        }
        return cnt;
    };

    int made = n;
    while (made < l) {
        int k = ikamax(l - made);
        es.push_back({get_beki(k) + 1, t + 1, made});
        made += k;
    }

    cout << es.size() << endl;
    for (edge& e: es) {
        cout << e.s << " " << e.t << " " << e.w << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (ll)(1e9 + 7)
#define MAX (ll)(5e1 + 4)
#define INF (ll)(1e18)
using namespace std;
using ll =  long long;
using ld = long double;

int hi[MAX], pr[MAX], p[MAX];
vector<pair<int, int>> gr[MAX];

void dfs (int node, int par) {
	hi[node] = hi[par] + 1;
	p[node] =  par;
	for (auto x : gr[node]) {
		if (x.first != par) {
			pr[x.first] = x.second;
			dfs (x.first, node);
		}
	}
}

vector<int> path[22];

int main () {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		gr[u].push_back (make_pair (v, i + 1));
		gr[v].push_back (make_pair (u, i + 1));
	}
	hi[0] = 0;
	dfs (1, 0);
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		while (u != v) {
			if (hi[v] > hi[u]) {
				swap (v, u);
			}
			path[i].push_back (pr[u]);
			u = p[u];
		}
	}
	int aa[] = {1, -1};
	ll ans = (1LL << (n - 1));
	for (int i = 1; i < (1LL << m); i++) {
		int cou = 0;
		bool cn[n] = {}, ch = 0;
		for (int j = 0; j < m; j++) {
			if ((i >> j) & 1) {
				ch ^= 1;
				for (int x : path[j]) {
					if (!cn[x]) {
						cou++;
					}
					cn[x] = 1;
				}	
			}
		}
		assert (n - 1 >= cou);
		ans += aa[ch] * (1LL << (n - 1 - cou));
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (A, B, C, K) = Scanner.Scan<long, long, long, long>();
            var answer = Math.Min(A, K);
            K -= A;
            K -= Math.Min(B, K);
            answer -= K;
            Console.WriteLine(answer);

        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define _READ freopen("input.txt", "r", stdin);
#define _FAST                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
int32_t main()
{
    int n;
    cin >> n;
    vector<int> ar(n);
    for (auto &i : ar)
        cin >> i;
    sort(ar.rbegin(), ar.rend());
    int ans = ar[0];
    if (n % 2 == 0)
    {
        for (int i = 2,j=1; i < n; i += 2,j++)
        {
            ans+=ar[j]+ar[j];
        }
        cout<<ans;
    }
    else
    {
        for (int i = 2,j=1; i < n; i += 2,j++)
        {
            ans+=ar[j]+ar[j];
            if(i+2>=n)
            {
                ans-=ar[j];
                break;
            }
        }
        cout<<ans;
    }
    return 0;
}

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

int main() {
  int n,a;
  //string op;
  cin >> n >> a;

  if (n % 500 <= a) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  // ここにプログラムを追記
}

Measured memory_bytes: 3636
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public final class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int h = s.nextInt();
		int m = s.nextInt();
		double angle = Math.abs((double)(60*h - 11*m)/(double)2);
		angle = Math.toRadians(angle);
		// System.out.println((2*a*b*Math.cos(angle)));
		double ans = Math.sqrt(a*a + b*b - (2*a*b*Math.cos(angle)));
		System.out.println(ans);
	}
}

Measured memory_bytes: 35920
#include<stdio.h>
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	int n,m,i,j,f=0,b[101][101]={0};
	char a[101][101]={0};
	cin>>n>>m;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			cin>>a[i][j];
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			{
				if(a[i-1][j-1]=='#') f++;
				if(a[i-1][j]=='#') f++;
				if(a[i-1][j+1]=='#') f++;
				if(a[i][j-1]=='#') f++;
				if(a[i][j+1]=='#') f++;
				if(a[i+1][j-1]=='#') f++;
				if(a[i+1][j]=='#') f++;
				if(a[i+1][j+1]=='#') f++;
				b[i][j]=f;
				f=0;
			}
	for(i=1;i<=n;i++)
		{
			for(j=1;j<=m;j++)
				{
					if(a[i][j]=='#') cout<<"#";
					else cout<<b[i][j];
				}
			cout<<endl;
		}
	return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int q = Integer.parseInt(br.readLine());
		for(int i =0; i<q; i++){
			String[] input = br.readLine().split(" ");
			if(input[0].equals("replace")){
				char[] c = str.toCharArray();
				String rep = input[3];
				int index = 0;
				for(int k=Integer.parseInt(input[1]); k<=Integer.parseInt(input[2]); k++){
					c[k] = rep.charAt(index);
					index++;
				}
				str = String.valueOf(c);
			}else if(input[0].equals("print")){
				System.out.println(str.substring(Integer.parseInt(input[1]),Integer.parseInt(input[2]) + 1));
			}else{
				char[] c = str.toCharArray();
				char[] cc = str.toCharArray();
				int index = Integer.parseInt(input[2]);
				for(int k=Integer.parseInt(input[1]); k<=Integer.parseInt(input[2]); k++){
					c[k] = cc[index];
					index--;
				}
				str = String.valueOf(c);
			}
		}

	}
}

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

#define llint long long
const int N_D = 10000001;

class Room{
public:
	int n;
	int mark;
	vector<int>* pathes = new vector<int>();
	bool entered = false;

	Room(int n): n(n){
	}

	void nextRoom(queue<Room*>* roomQ, vector<Room*>* rooms){
		for(int i = 0; i < pathes->size(); i++){
			auto* room = rooms->at(pathes->at(i));
			if(!room->entered && room->n != 0 && room->n != this->mark){
				room->mark = this->n;
				room->entered = true;
				roomQ->push(room);
			}
		}
	}
};

signed main() {
	int n ,m;
	cin >> n >> m;
	vector<Room*> rooms;
	rooms.push_back(new Room(0));
	for(int i = 1; i < n; i++){
		rooms.push_back(new Room(i));
	}
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		rooms[a]->pathes->push_back(b);
		rooms[b]->pathes->push_back(a);
	}
	queue<Room*> roomQ;
	roomQ.push(rooms[0]);
	while(!roomQ.empty()){
		auto* room = roomQ.front();
		roomQ.pop();
		room->nextRoom(&roomQ, &rooms);
	}

	cout << "Yes" << endl;
	for(int i = 1; i < rooms.size(); i++){
		cout << rooms[i]->mark + 1 << endl;
	}
}


Measured memory_bytes: 14688
//https://atcoder.jp/contests/agc033/tasks/agc033_c
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

template< typename T >
struct edge {
	int src, to;
	T cost;
	edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {}
	edge(int _src, int _to, T _cost) : src(_src), to(_to), cost(_cost) {}
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T>
struct node {
	vector<edge<T>> edges;
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< node< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

//木の直径,aoj_grl_5_a
template< typename T >
pair< T, int > tree_dfs(const WeightedGraph< T > &g, int idx, int par) {
    pair< T, int > ret(0, idx);
    for(auto &e : g[idx].edges) {
        if(e.to == par) continue;
        auto cost = tree_dfs(g, e.to, idx);
        cost.first += e.cost;
        ret = max(ret, cost);
    } 
    return ret;
}

//st_idx探索開始のidx
template< typename T >
T tree_diameter(const WeightedGraph< T > &g, int st_idx) {
    auto p = tree_dfs(g, st_idx, -1); //st_idxから最遠頂点
    auto q = tree_dfs(g, p.second, -1); //上記の最遠頂点からの最遠頂点
    return (q.first);
}

int main() {
    ll N; cin>>N;
    WeightedGraph<ll> graph(N+1);
    REP(n,N-1){
        ll a,b; cin>>a>>b;
        graph.at(a).edges.emplace_back(a,b,1);
        graph.at(b).edges.emplace_back(b,a,1);
    }    

    ll ans=tree_diameter(graph,1);
    dump(ans);
    //0(1個) 先win
    //1(2個) 先lose
    //2(3個) 先win
    //3(4個) 先win
    //4(5個) 先lose
    //5(6個) 先win
    //6(7個) 先win
    //7(8個) 先lose ... dp?
    cout<<(ans%3==1?"Second":"First")<<endl;
    return 0;
}

Measured memory_bytes: 29952
use std::io::*;

enum Op { Add, Sub, Mul, Div }

fn main() {
  let input = {
    let mut buf = vec![];
    stdin().read_to_end(&mut buf);
    unsafe { String::from_utf8_unchecked(buf) }
  };
  let mut lines = input.split('\n');

  let mut ans = 0;
  let mut op = Op::Add;

  loop {
    use Op::*;

    let n: i32 = lines.next().unwrap().parse().unwrap();
    ans = match op {
      Add => ans + n,
      Sub => ans - n,
      Mul => ans * n,
      Div => ans / n
    };

    op = match lines.next().unwrap() {
      "+" => Add,
      "-" => Sub,
      "*" => Mul,
      "/" => Div,
      _   => {
        println!("{}", ans);
        return
      }
    };
  }
}



Measured memory_bytes: 5020
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

const int MOD = 1000000007;
const int MAX = 5000000;
ll fac[MAX], finv[MAX], inv[MAX];

ll N, M;

vector<int> cnt_yakusu;

void decompose(ll M) {
	ll tar = 2;
	while (M >= 2) {
		cnt_yakusu.push_back(0);
		while (M%tar == 0) {
			*(cnt_yakusu.end() - 1)+=1;
			M /= tar;
		}
		tar++;
	}
	return;
}


void COMInit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

	ll ans=1;
	COMInit();
	for (int i = 0; i < cnt_yakusu.size(); i++) {
		if (cnt_yakusu[i] == 0)continue;
		int p = cnt_yakusu[i];
		//distribute p in N
		ans = (ans * COM(p + N - 1, p)) % MOD;
	}
	print(ans);






	return 0;
}


Measured memory_bytes: 264532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  //木の根なら-(size of tree) それ以外は木の根のindexが入っている。            
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) cin >> a[i];
  vector<ll> g[n];
  ll x[m],y[m];
  UnionFind s(n);
  rep(i,m){
    cin >> x[i] >> y[i];
    s.unite(x[i],y[i]);
    g[x[i]].pb(y[i]);
    g[y[i]].pb(x[i]);
  }
  
  if(((n-1-m)*2)>n){
    cout <<"Impossible" << endl;
    return 0;
  }
  else if(m==n-1){
    cout << 0<< endl;
    return 0;
  }
  
  set<int> set;
  rep(i,n){
    set.insert(s.root(i));
  }
  int ntree=set.size();
  //  cout << ntree <<" trees" << endl;
  //  priority_que<ll> pque[s.size()];
  vector<int> tree[ntree];
  int vs[n];//root num->pque index
  int ind=0;
  rep(i,n){
    if(s.data[i]<0){
      vs[s.root(i)]=ind;
      ind++;
    }  
  }
  
  rep(i,n){
    tree[vs[s.root(i)]].pb(a[i]);
  }
  ll ans=0;
  vector<ll> all;
  rep(i,ntree) sort(tree[i].begin(),tree[i].end());
  rep(i,ntree){
    //    cout <<i <<endl;
    ans+=tree[i][0];
    if(tree[i].size()>1){
      rep1(j,tree[i].size()-1){
	all.pb(tree[i][j]);
      }
    }
    //    cout <<i <<endl;
  }
  //  cout << ""<<endl;
  sort(all.begin(),all.end());
  rep(i,(n-1-m)*2-ntree){
    //    cout << ans << endl;
    ans+=all[i];
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 12924
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, ar[N], pos[N], ans = INT_MAX;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	if(n == 1) {
		cout << 0;
		return 0;
	}
	for(int i = 1; i <= n; i++) {
		cin >> ar[i];
		pos[ar[i]] = i;
	}
	int tot = 1;
	for(int i = 1; i < n; i++) {
		if(pos[i] < pos[i + 1])
			tot++;
		else
			tot = 1;
		ans = min(ans, n - tot);
	}
	cout << ans;
}

Measured memory_bytes: 5120
n,C = map(int,input().split())
ch = [[0]*(200001) for _ in range(C)]
m = 0
for _ in range(n):
    s,t,c = map(int,input().split())
    s = s*2-1
    t *= 2
    c -= 1
    ch[c][s] += 1
    ch[c][t] -= 1
    m = max(m,t)

cnt = [0]*(m+1)
for c in range(C):
    for i in range(1,m+1):
        ch[c][i] += ch[c][i-1]
        if ch[c][i-1] == 0 and ch[c][i] > 0: cnt[i] += 1
        if ch[c][i-1] > 0 and ch[c][i] == 0: cnt[i] -= 1

for i in range(1,m+1): cnt[i] += cnt[i-1]
print(max(cnt))

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

typedef long long ll;
int main()
{
	vector<int>v(3);
  cin>>v[0]>>v[1]>>v[2];
  sort(v.begin(),v.end());
  cout<<v[0]+v[1]<<endl;
  return 0;
  
}

Measured memory_bytes: 256
H, W = map(int, input().split())
L = []
brank = "." * W
ban = []
for _ in range(H):
  s = input()
  if brank == s:
    continue
  L.append(list(map(str, s)))
  
for i in range(W):
  for l in L:
    if l[i] != ".":
      break
  else:
    ban.append(i)
    continue

for l in L:
  ans = ""
  for i in range(W):
    if i in ban:
      continue
    ans += l[i]
  print(ans)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
#define int long long
//#pragma gcc optimize("Ofast, unroll-loops")
//#pragma gcc target("sse, sse2, sse3, ssse3, sse4, popcnt, abm, mmx, avx, avx2, tune = native")

using namespace std;

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

    int n, k, t;
    vector<double> v = {0};
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> t, v.push_back((double)t * (t + 1) / 2.0 / t);
    for (int i = 1; i <= n; i++)
        v[i] += v[i - 1];

    double ans = 0;
    for (int i = k; i <= n; i++)
        ans = max(ans, v[i] - v[i - k]);
    cout << fixed << setprecision(16) << ans << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 2420
#include <stdio.h>
int main(){
    int n,x[99],uhen,i,j;
    long dp[99][21];
    scanf("%d",&n);
    for (i=0; i<n-1; i++) {
        scanf("%d",&x[i]);
    }
    scanf("%d",&uhen);
    for (i=0; i<21; i++) {
        dp[0][i]=0;
    }
    dp[0][x[0]]=1;
    for (i=1; i<n-1; i++) {
        for (j=0; j<21; j++) {
            dp[i][j]=(j-x[i]>=0)*dp[i-1][j-x[i]]+(j+x[i]<=20)*dp[i-1][j+x[i]];
        }
    }
    printf("%ld\n",dp[n-2][uhen]);
    return 0;
}

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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}

int a[N], b[N];

void Solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	LL add = 0;
	for (int i = n; i >= 1; i--) {
		LL t = add + a[i];
		add += (b[i] - t % b[i]) % b[i];
	}
	cout << add << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<list>
#include<string.h>

class item{
 public:
  int pr;
  char name[101];
  std::list<int> ren;
};
item its[100];
int solve(int n){
  int sum;
  std::list<int>::iterator it;
  if(its[n].ren.empty()){
    return its[n].pr;
  }
  for(sum=0,it=its[n].ren.begin();it!=its[n].ren.end();it++){
    sum+=solve(*it);
    if(its[n].pr<sum) return its[n].pr;
  }
  return sum;
}
int main(){
  int i,j,n,m,k,l,o;
  char buf[400];
  using namespace std;
  list<int>::iterator it;
  do{
    scanf("%d",&n);
    if(!n) break;
    for(i=0;i<n;i++) scanf("%s %d",its[i].name,&(its[i].pr));
    scanf("%d",&m);
    for(i=0;i<m;i++){
      scanf("%s ",buf);
      for(j=0;j<n;j++) if(!strcmp(buf,its[j].name)) break;
      scanf("%d ",&k);
      for(l=0;l<k-1;l++){
	scanf("%s ",buf);
	for(o=0;o<n;o++) if(!strcmp(its[o].name,buf)) break;
	its[j].ren.push_back(o);
      }
      scanf("%s",buf);
      for(o=0;o<n;o++) if(!strcmp(its[o].name,buf)) break;
      its[j].ren.push_back(o);
    }
    scanf("%s",buf);
    for(i=0;i<n;i++) if(!strcmp(buf,its[i].name)) break;
    printf("%d\n",solve(i));
    for(i=0;i<n;i++) its[i].ren.clear();
  }while(1);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define str       string
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n,m;
	cin>>n>>m;
	ll x=abs(n-m);
	if(n<=x){cout<<n;}
	else{
		ll x=n%m;
		n=x;
		x=abs(n-m);
		cout<<min(n,x);
	}
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3648
from collections import Counter
from bisect import bisect_left

N = int(input())
A = list(map(int, input().split()))

rate = [399, 799, 1199, 1599, 1999, 2399, 2799, 3199]

color = Counter()
for a in A:
    i = bisect_left(rate, a)
    color[i] += 1

# print(color) 399 799 1199 1599 1999 2399 2799 3199
L = len(list(color.keys()))
if color[8] > 0:
    print(max(L - 1, 1), L - 1 + color[8])
else:
    print(L, L)


Measured memory_bytes: 3316
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	int N;
	int count = 0;
	string s;

	cin >> N;
	cin >> s;

	for (int i = 0; i < N; i++) {
		if (s[i] == 'R') {
			count++;
		}
	}

	if (count > N / 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

int main()
{
    int N;
    cin >> N;
    int k = N % 1000 == 0 ? N / 1000 : N / 1000 + 1;
    cout << 1000 * k - N << endl;
    return 0;
}

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

 using namespace std;
 
 int main(){
     int n,m; //都市の数nと道路の数m本
     cin >> n >> m;
     
     int a,b; //都市の番号
     
     vector<int> ans(n,0);
     
     for(int i = 0;i < m;i++){
         cin >> a >> b;
         ans.at(a - 1)++;
         ans.at(b - 1)++;
     }
     
     for(int i = 0;i < n;i++){
         cout << ans.at(i) << endl;
     }
 }


Measured memory_bytes: 3620
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int a[200005];
	int n;
	scanf("%d",&n);
	int min;
	int flag=1;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(i<1)
			min=a[0];
		else
		{
			if(a[i]<=min)
			{
				min=a[i];
				flag++;
			}
		}
	}
	cout<<flag<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main() {
	while (true) {
		string str;
		cin >> str;
		if (str == "-") return 0;

		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			int h;
			cin >> h;
			str = str.substr(h, str.size() - h) + str.substr(0, h);
		}
		cout << str << endl;
	}
	return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100100;
ll a[maxn];

int main() {
    #ifdef LOCAL
    assert(freopen("b.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    ll sum = 0;
    forn (i, n) {
        cin >> a[i];
        sum += a[i];
    }
    ll k = 0;
    forn (i, n + 1)
        k += i;
    if (sum % k) {
        cout << "NO\n";
        return 0;
    }
    sum /= k;

    forn (i, n) {
        a[i] -= sum * i;
        //cerr << a[i] << ' ';
    }
    //cerr << '\n';
    
    forn (i, n - 1) {
        ll x = a[i];
        ll y = a[i + 1];
        if (x < y || (x - y) % n != 0) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s[3];
  cin >> s[0] >> s[1] >> s[2];

  int dis = 'A' - 'a';

  cout << (char)(s[0][0] + dis) << (char)(s[1][0] + dis) << (char)(s[2][0] + dis) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	
	long long int n;
	cin >> n;
	long long int nn = pow(n, 0.5) + 1;
	long long int res = 0;
	for (long long int i = 1; i <= 2 * nn + 1; i++) {
		if (n % i == 0) {
			if (i < n / i - 1)
				res += n / i - 1;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
	string ans="";
	char c;
	
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			cin>>c;
			if(i==j){
				ans+=c;
			}
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
nums = [[int(i),1] for i in input().split()]

for i in range(m):
    b,c = map(int,input().split())
    nums.append([c,b])

nums.sort(reverse=True)

sum = 0
for i in nums:
    if i[1] > n:
        sum += i[0]*n
        break
    else:
        sum += i[0]*i[1]
        n -= i[1]

print(sum)


Measured memory_bytes: 33784
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
		
		int[] l=new int[m];
  		int[] r=new int[m];
		for(int c=0;c<m;c++){
    		l[c]=sc.nextInt();
          	r[c]=sc.nextInt();
    	}
  		int max=r[0];
  		int min=l[0];
    for(int a=0;a<m-1;a++){
 	if(max<l[a+1]){
      		max=-1; 
      		min=0;
    		break;
    	}else if(r[a+1]<min){
      		max=-1;
      		min=0;
     		break;
   	 }
      max=Math.min(r[a+1],max);
      min=Math.max(l[a+1],min);
    }

    	System.out.println(max-min+1);
    }
}


Measured memory_bytes: 85836
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long n;
long long dp(long long x){
    if (x==1) return 1;
    return dp(x/2)*2+1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    cout<<dp(n);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String s = sc.nextLine();
			s = s.replace("apple", "johnnyhibiki");
			s = s.replace("peach", "apple");
			s = s.replace("johnnyhibiki", "peach");
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 17132
k = int(input())
l = []

def lunlun(i):
    b = i[-1:]
    if int(i) <= 3234566667:
        if int(b)-1 >= 0 and int(b)-1 <= 9:
            l.append(int(i)*10+int(b)-1)
            lunlun(str(int(i)*10+int(b)-1))
        l.append(int(i)*10+int(b))
        lunlun(str(int(i)*10+int(b)))
        if int(b)+1 >= 0 and int(b)+1 <= 9:
            l.append(int(i)*10+int(b)+1)
            lunlun(str(int(i)*10+int(b)+1))
    

for i in range(1,10):
    l.append(i)
    lunlun(str(i))

l.sort()
#15print(l)
print(l[k-1])

Measured memory_bytes: 71768
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll a, b, k;

	FOR(i, a, min(a + k, b + 1))
	{
		OUT(i);
	}
	FOR(i, max(a + k, b - k + 1), b + 1)
	{
		OUT(i);
	}
}


Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define re register
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(x) putchar(x)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%lld",x)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
using namespace std;
il int ci(){
	re char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	re int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}
int nxt[30023][10];
char s[30023];
int main(){
	int n=ci();
	scanf("%s",s+1);
	rev_rep(i,n,1){
		memcpy(nxt[i],nxt[i+1],sizeof(nxt[i]));
		nxt[i][s[i]-'0']= i;
	}
	int ans= 0;
	rep(i,0,9){
		int posi= nxt[1][i];
		if( posi==0 ) continue;
		rep(j,0,9){
			int posj= nxt[posi+1][j];
			if( posj==0 ) continue;
			rep(k,0,9){
				if( nxt[posj+1][k] ) ans++;
				//printf("%d %d %d\n",i,j,k);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#define lop(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	string s[n];
	int c = 0, c1 = 0, c2 = 0, c3 = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> s[i];
	}
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == "AC") c++;
		else if (s[i] == "TLE") c1++;
		else if (s[i] == "WA") c2++;
		else if (s[i] == "RE") c3++;


	}
	cout << "AC x " << c << "\n" << "WA x " << c2 << "\n" << "TLE x " << c1 << "\n" << "RE x " << c3 << "\n";
}

Measured memory_bytes: 6732
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i,s,n) for(ll i = s;i<n;i++)
#define repe(i,s,n) for(ll i = s;i<=n;i++)


int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;

    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int ScanningData(int&, vector<int>&);
double CalculateArea(vector<int>);

int main(){
  int i, m, n;
  vector<int> degree1, degree2;
  double result1, result2;

  while(1){
    if(ScanningData(m, degree1) == 0) break;
    if(ScanningData(n, degree2) == 0) break;

    result1 = CalculateArea(degree1);
    result2 = CalculateArea(degree2);

    if(result1 == result2)
      cout << "0" << endl;
    else if(result1 > result2)
      cout << "1" << endl;
    else
      cout << "2" << endl;

    degree1.clear();
    degree2.clear();
  }

  return 0;
}

int ScanningData(int& n, vector<int>& data){
  int i, x, sum=0;

  cin >> n;
  if(n == 0) return 0;

  for(i=0; i<n-1; ++i){
    cin >> x;
    sum += x;
    data.push_back(x);
  }

  data.push_back(360-sum);
  return 1;
}

double CalculateArea(vector<int> data){
  int i;
  double radian, s, sum=0;

  for(i=0; i<data.size(); ++i){
    radian = data[i] * M_PI / 180;
    s = sin(radian)/2;
    sum += s;
  }

  return sum;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int ans = 0;
    for (int i = 1; i < N; i++)
    {
        if (A[i - 1] == A[i])
        {
            ans++;
            A[i] = -A[i];
        }
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long lint;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n, y;
    cin >> n >> y;
    int ans1 = -1, ans2 = -1, ans3 = -1;
    rep(i, n+1){
        bool flag = false;
        rep(j, n-i+1){
            int k = n - (i + j);
            if(i * 10000 + j * 5000 + k * 1000 == y){
                ans1 = i;
                ans2 = j;
                ans3 = k;
                flag = true;
                break;
            }
        }
        if(flag){
            break;
        }
    }
    printf("%d %d %d\n", ans1, ans2, ans3);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int N,k;
    cin >> N>>k;
    vector<int>h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    vector<int> a(N-1);//0~n-2まで
    for(int i=0;i<N-1;i++)
        a[i]=h[i+1]-h[i];
    int sum=0;
    for(int i=0;i<=k-2;i++)
        sum+=a[i];
   
    int min=sum;
    for(int i=0;i<=N-k-1;i++){
        sum-=a[i];
        sum+=a[i+k-1];
        
        if(sum<min)
            min=sum;
        
    }
    cout<<min<<endl;
}



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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    string s; int n, k;
    cin >> n >> k >> s;
    s[k-1] = s[k-1] - 'A' + 'a';
    cout << s << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
	}

	ans := 0
	min := p[0]
	for i := 0; i < n; i++ {
		if p[i] <= min {
			ans++
			min = p[i]
		}
	}

	fmt.Println(ans)
}


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

int main(){
  int n; cin >> n;
  int h[100010];
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  int ans = 0;
  int step[100010]; step[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--){
    if (h[i] >= h[i + 1]){
      step[i] = step[i + 1] + 1;
    }else step[i] = 0;
    ans = max(ans, step[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int i,N,L[100],max=0,sum=0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&L[i]);
        if(max<L[i]){
            max=L[i];
        }
        sum+=L[i];
    }
    if(sum>2*max){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0; 
}

Measured memory_bytes: 128
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
	ARIJIT SUR 
	@duke_knight
	@surcode
    @comeback
	IIT ISM 
 */
#include<bits/stdc++.h>
#define SIZE (ll)(1e6)
#define mod (ll)(1e9+7)
#define vi vector<int>
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) ((a)>0?(a):-(a))
#define sc(a) scanf("%d\n",&a);
#define all(a) a.begin(),a.end()
#define maxelem(a) *max_element(all(a))
#define minelem(a) *min_element(all(a))
#define pb push_back
#define pi pair<int,int>
#define pqq priority_queue
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i1=0;i1<a.size();i1++) cin>>a[i1];}
#define display(a) {for(int i1=0;i1<a.size();i1++) cout<<a[i1]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned ll
using namespace std;
void solve(){
	ll a,b,c,d; cin>>a>>b>>c>>d;
	cout<<max(a*c, max(a*d, max(b*c,b*d)))<<endl;
}
int main()
{
    IOS
    //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3652
N = int(input())
A = map(int, input().split())
B = map(int, input().split())
D = [0] * N

minus = 0
cnt = 0
for i, j in enumerate(zip(A, B)):
    d = j[0] - j[1]
    D[i] = d
    if d < 0:
        minus += d
        cnt += 1

if minus >= 0:
    print(0)
    exit()

D.sort(reverse=True)
for idx, d in enumerate(D):
    if d > 0:
        minus = minus + d
        if minus >= 0:
            print(idx + 1 + cnt)
            exit()
    else:
        break

print(-1)


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T> inline T LCM(T a, T b) { return (a + (b - 1)) / b; }

int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	ll n = 0, s = 0;
	rep(i, m) {
		ll a, b;
		cin >> a >> b;

		s += a * b, n += b;
	}

	cout << (n - 1) + (s - 1) / 9 << endl;
}

Measured memory_bytes: 256