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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<pair<pair<int, int>, ll>> edges(M);
  int a, b, c;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %d", &a, &b, &c);
    edges[i] = make_pair(make_pair(a, b), c);
  }
  ll LLMIN = -1 * (ll)1e18;
  vector<ll> dist(N + 5, LLMIN);
  dist[1] = 0;
  vector<ll> ans(2);
  for (int t = 0; t < 2; ++t) {
    for (int i = 0; i < N - 1; ++i) {
      for (int j = 0; j < M; ++j) {
        int u = edges[j].first.first, v = edges[j].first.second;
        ll cost = edges[j].second;
        if (dist[u] != LLMIN and dist[v] < dist[u] + cost) {
          dist[v] = dist[u] + cost;
        }
      }
    }
    ans[t] = dist[N];
  }
  if (ans[0] != ans[1]) { printf("inf\n"); }
  else { printf("%lld\n", ans[0]); }
  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 __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
	int n,k;
	cin>>n>>k;
	int arr[n],ans[n];
	
	for(int i = 0;i<n;i++)
		cin>>arr[i];
	
	for(int i = n-1;i>=0;i--){
		if(i==n-1){
			ans[i] = 0;
		}else{
			ans[i] = inf;
			for(int j = 1;j<=k&&i+j<n;j++){
				ans[i] = min(ans[i],ans[i+j]+abs(arr[i]-arr[i+j]));
			}
		}
		//cout<<ans[i]<<endl;
	}
	
	cout<<ans[0];
	return 0;
}

//Total solved problems:- 13


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin>>N>>A>>B;
  int s1,s2,s3,s4,s5,S;
  int Ans=0;
  for(int i=1;i<=N;i++){
    if(i<10000){
      s4=i/1000;
      s3=(i-s4*1000)/100;
      s2=(i-s4*1000-s3*100)/10;
      s1=i-s4*1000-s3*100-s2*10;
      S=s1+s2+s3+s4;
    }else{
      S=1;
    }
    if(A<=S&&S<=B){
        Ans+=i;
    }
  }
  cout<<Ans<<endl;
    
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, x, m] <- getIntList

  let getSeq a as s = let a' = a*a `mod` m
                      in if (a' `Set.member` s)
                         then (V.fromList (reverse as), a')
                         else getSeq a' (a':as) (a' `Set.insert` s)

      (as, a) = getSeq x [x] (Set.fromList [x])

      solve n | n <= V.length as = V.sum (V.take n as)
              | otherwise = let i = fromJust $ V.findIndex (== a) as
                                prefix = V.sum $ V.take i as
                                as' = V.drop i as
                                len = V.length as'
                                s = V.sum as'
                                n' = n - i
                                q = n' `div` len
                                r = n' `mod` len
                                s' = V.sum $ V.take r as'
                            in prefix + q * s + s'

  print $ solve n

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

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        vector<int> k(n);
        bool valid = false;
        int cnt1 = 0;
        for(int i=0; i<n; i++){
            cin>>k[i];
            if(1 < k[i]) valid = true;
            if(1 <= k[i]) cnt1++;
        }

        if(!valid){
            cout << "NA" << endl;
            continue;
        }

        cout << cnt1 + 1 << endl;
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	cin>>n>>m;
	bool B=0;
	for(int i=0;i<=n;i++){
		if(i*2+(n-i)*4==m) B=1;
	}
	cout<<(B?"Yes":"No")<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double ma;
    double ans;
    if(a * b / 2 * a < x) {
        ma = x / a  / a * 2 - b;
        ans = 90 - atan(a / (b - ma)) * 180 / M_PI;
    }
    else{
        ma = x / a * 2 / b;
        ans = 90 - atan(ma / b) * 180 / M_PI;
    }
    printf("%.10lf\n",ans) ;
}

Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    map<ll,ll> mp;
    ll ans=0;
    rep(j,n){
        ll sa=j+1-a[j];
        ans+=mp[sa];
        ll wa=j+1+a[j];
        mp[wa]++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 27448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define NIL -1

typedef struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
}Node;

Node* insert(Node*, Node *);
void find(Node*, int);
void print(Node *);
void inorderTreeWalk(Node *);
void preorderTreeWalk(Node *);

main(){
  int m, key, i;
  char string[10];
  Node *T, *node;

  T = NULL;

  scanf("%d", &m);
  for(i=0; i<m; i++){
    scanf("%s", string);
    if(strcmp(string, "insert")==0){
      scanf("%d", &key);
      node = malloc(sizeof(Node));
      node->key = key;
      node->left = NULL;
      node->right = NULL;

      T = insert(T, node);
    }
    else if(strcmp(string, "find")==0){
      scanf("%d", &key);
      find(T, key);
    }
    else print(T);
  }

  return 0;
}

Node* insert(Node *T, Node *z){
  Node *x, *y;
  
  y = NULL;  //xの親
  x = T;
  
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  
  if(y==NULL) T = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
  return T;
}

void find(Node *T, int key){
  while(T != NULL && T->key != key){
    if(key < T->key) T = T->left;
    else T = T->right;
  }
  if(T == NULL) printf("no\n");
  else printf("yes\n");
}

void print(Node *T){
  inorderTreeWalk(T);
  printf("\n");

  preorderTreeWalk(T);
  printf("\n");
}

void inorderTreeWalk(Node *T){
  if(T == NULL) return;

  inorderTreeWalk(T->left);
  printf(" %d", T->key);
  inorderTreeWalk(T->right);
}

void preorderTreeWalk(Node *T){
  if(T == NULL) return;
  printf(" %d", T->key);
  preorderTreeWalk(T->left);
  preorderTreeWalk(T->right);
}

Measured memory_bytes: 19364
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(); //価格
    int B = sc.nextInt(); //所持金
    int C = sc.nextInt(); //聞きたい回数
    
    if(B>A*C){
      System.out.println(C);
    }else{
      System.out.println(B/A);
    }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int N; 
	cin >> N;
    long long int a[N]; 
    	for(int i=0;i<N;i++){
    	cin >> a[i];
    	}
    long long b = a[0];
    long long c = a[0];
  	for(int i=1;i<N;i++){
    		if(b < a[i]){
			b = a[i];
			}
    		if(c > a[i]){
			c = a[i];
			}
    	}
		cout << b-c << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

var (
	n int
	m int
	p int
	judge string
)

func main() {
	fmt.Scanln(&n, &m);
	vis := make([]int, n);
	var cnt int
	var pen int
	for i := 0; i < m; i++ {
		fmt.Scanln(&p, &judge)
		p--;
		if judge[0] == 'A' {
			if(vis[p] != -1) {
				cnt++;
				pen += vis[p];
				vis[p] = -1;
			}
		} else {
			if(vis[p] != -1) {
				vis[p]++;
			}
		}
	}
	fmt.Printf("%d %d\n", cnt, pen)
}

Measured memory_bytes: 7168
object Main {
  def main(args: Array[String]) {
    val input = io.Source.stdin.getLines().mkString("\n")
    println(kagamiMochi(input).trim())
  }

  //  def solve(input: String): String = {
  //    Stream.iterate(input.split("^n")(1).split(" ").map(_.toInt))(_.map(_/2)).takeWhile(_.forall(_%2 ==0)).size.toString
  //  }

  def kagamiMochi(input: String) :String = {
    //先頭の要素を除外する
    //新しいコレクションを作る
    //index != 0という条件を加える

    //distinctしてsizeをとるだけでよい
    //ソート不要

    input.split("\n").tail.distinct.size.toString
  }
}

Measured memory_bytes: 27348
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int a, b, x;
	cin >> a >> b >> x;
	if (a == b)
		cout << (a % x == 0) << en;
	else if (a == 0)
		cout << b / x + 1 << en;
	else
		cout << b / x - (a - 1) / x << en;


	return 0;
}



Measured memory_bytes: 3548
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on
ll H, W;

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

  ll t = H * W;
  if (H == 1 || W == 1) {
    printf("1\n");
  } else if (t % 2 == 0) {
    printf("%lld\n", t / 2);
  } else {
    printf("%lld\n", t / 2 + 1);
  }

  return 0;
}


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

int min(int a,int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}

int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    printf("%d\n",min(a,b) + min(c,d));
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define rvp(i,x,y) for(int i=y;i>=x;i--)
#define sc scanf
#define pr printf
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int a[110],b[110];
int main()
{
	int n;
	ios;
	while(cin>>n)
	{
		for(int i=1;i<=n;i++) 
		{
			cin>>a[i];
			b[i]=a[i];
		}
		sort(b+1,b+n+1);
		int cnt=0;
		for(int i=1;i<=n;i++) if(a[i]!=b[i]) cnt++;
		if(cnt==0)
		cout<<"YES"<<endl;
		else if(cnt>2) cout<<"NO"<<endl;
		else {
			cout<<"YES"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
// #include <map>
#include <iomanip>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
const int inf = 1e9 + 7; 
const int maxn = 1e5 + 5;
LL d[111][maxn], s[111][maxn], a[111];

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	for(int i = 0; i <= a[1]; ++i){
		d[1][i] = 1;
		s[1][i] = i + 1;
	}
	for(int i = a[1] + 1; i <= k; ++i){
		s[1][i] = a[1] + 1;
	}
	for(int i = 2; i <= n; ++i){
		s[i][0] = 1;
		d[i][0] = 1;
		for(int j = 1; j <= k; ++j){
			LL t = 0;
			if(j > a[i]){
				 t = s[i - 1][j - a[i] - 1];
			}
			d[i][j] = (s[i - 1][j] - t + inf) % inf;
			s[i][j] = (s[i][j - 1] + d[i][j]) % inf;
		}
	}
	cout << d[n][k] << endl;
	return 0;
}

Measured memory_bytes: 159232
import java.util.*

fun main(args: Array<String>) = abc157e()

fun abc157e() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val q = readLine()!!.toInt()
    val queries = (1..q).map {
        readLine()!!.split(' ').map { it }
            .let { Query(if (it[0].toInt() == 1) QueryType.UPDATE else QueryType.GET, it[1].toInt(), it[2]) }
    }

    val arr = LongArray(n)
    s.forEachIndexed { index, c -> arr[index] = charToBit(c) }

    val st = SegmentTree(arr, Long::or)
    val answer = StringBuilder()

    for ((type, x, y) in queries) {
        when (type) {
            QueryType.UPDATE -> st[x - 1] = y[0]
            else -> answer.appendln(st[x - 1..y.toInt() - 1])
        }
    }

    print(answer)
}

private fun charToBit(char: Char) = Math.pow(2.0, (char - 'a').toDouble()).toLong()

private data class Query(val type: QueryType, val x: Int, val y: String)
private enum class QueryType { UPDATE, GET }

private class SegmentTree(init: LongArray, val monad: (Long, Long) -> Long) {
    val indices: Int
    val nodes: LongArray

    init {
        var indices = 1
        while (indices < init.size) indices = indices shl 1
        val nodes = LongArray(2 * indices - 1)
        for (i in init.indices) nodes[i + indices - 1] = init[i]
        for (i in indices - 2 downTo 0) nodes[i] = monad(nodes[2 * i + 1], nodes[2 * i + 2])
        this.indices = indices
        this.nodes = nodes
    }

    operator fun set(x: Int, value: Char) {
        var index = x + indices - 1
        nodes[index] = charToBit(value)
        while (index > 0) {
            index = (index - 1) / 2
            nodes[index] = monad(nodes[2 * index + 1], nodes[2 * index + 2])
        }
    }

    operator fun get(range: IntRange): Int =
        BitSet.valueOf(longArrayOf(get(range.first, range.last + 1).toLong())).cardinality()

    fun get(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = indices): Long {
        if (r <= a || b <= l) return 0
        if (a <= l && r <= b) return nodes[k]
        return monad(
            get(a, b, 2 * k + 1, l, (l + r) / 2),
            get(a, b, 2 * k + 2, (l + r) / 2, r)
        )
    }
}


Measured memory_bytes: 93252
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i,n)for(int i=0; i<(int)(n); i++)
#define bitrep(tmp, N)for (int tmp=0; tmp < (1<<N);tmp++)
#define all(v) v.begin(), end.bigin()
//int INF = 10e9;
using P = pair<int,int>;


int main(){
  int N;
  cin >>N;
  vector<P> red(N);
  rep(i, N){
    int a, b;
    cin >> a >> b;
    red[i] = make_pair(a,b);
  }
  sort(red.begin(), red.end());
  vector<P> blue(N);
  rep(i, N){
    int c, d;
    cin >> c >> d;
    blue[i] = make_pair(c,d);
  }
  sort(blue.begin(), blue.end());
  int cnt = 0;
  vector<int> removed;
  rep(i,N){
    int m=-1;
    int pos=-1;
    rep(j,N){
      if(red[j].first<=blue[i].first && red[j].second<=blue[i].second && (!count(removed.begin(),removed.end(), j))){
        if(m<red[j].second){
          m = red[j].second;
          pos = j;
        }
      }
    }
    if(pos!=-1){
      cnt++;
      removed.push_back(pos);
    }
  }
  cout << cnt <<endl;
}

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


int x1, y1_, x2, y2_;


void input() {
    cin >> x1 >> y1_ >> x2 >> y2_;
}


int main() {
    input();
    int x3 = x2 - (y2_ - y1_);
    int y3_ = y2_ + x2 - x1;
    int x4 = x1 - (y2_ - y1_);
    int y4_ = y1_ + x2 - x1;
    printf("%d %d %d %d\n", x3, y3_, x4, y4_);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
const int maxn = 101;
char grid[maxn][maxn];
int h = 100, w = 100;
void solve(int white, int black){
    for(int e = 1; e <= h; e++) for(int f = 1; f <= w; f++) grid[e][f] = '.';
    int line = 0;
    for(int e = 1; e <= h; e += 2) for(int f = 1; f <= w; f += 2){
        if(black){
            grid[e][f] = '#';
            black--;
            line = e + 1;
        }
    }
    grid[line][1] = '#';
    for(int f = 1; f <= w - 10; f++) grid[line + 1][f] = '#';
    white--;
    for(int e = line + 1; e <= h; e += 2) for(int f = 1; f <= w - 10; f += 2){
        if(white){
            grid[e+1][f+1] = '#';
            grid[e+2][f] = '#';
            grid[e+2][f+1] = '#';
            white--;
        }
    }
}
int p[maxn * maxn];
void init(){
    for(int e = 1; e <= maxn * maxn; e++) p[e] = e;
}
int find(int x){
    if(x == p[x]) return x;
    return p[x] = find(p[x]);
}
int mh(int a, int b){
    return find(a * w + b);
}
int sum[maxn][maxn];
int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        solve(b, a);
        for(int e = 1; e <= h; e++) for(int f = 1; f <= w; f++)
            if(grid[e][f] == '#') grid[e][f] = '.';
            else grid[e][f] = '#';
    } else {
        solve(a, b);
    }
    init();
    for(int e = 1; e <= h; e++) for(int f = 1; f <= w; f++){
        if(grid[e-1][f] == grid[e][f]) p[mh(e - 1, f)] = mh(e, f);
        if(grid[e+1][f] == grid[e][f]) p[mh(e + 1, f)] = mh(e, f);
        if(grid[e][f-1] == grid[e][f]) p[mh(e, f - 1)] = mh(e, f);
        if(grid[e][f+1] == grid[e][f]) p[mh(e, f + 1)] = mh(e, f);
    }
    int whi = 0, bla = 0;
    for(int e = 1; e <= h; e++) for(int f = 1; f <= w; f++){
        if(e * w + f == mh(e, f)) {
            if(grid[e][f] == '.') whi++;
            else bla++;
        }
    }
    // cerr << whi << " " << bla << endl;
    // assert(whi == a);
    // assert(bla == b);
    cout << h << " " << w << endl;
    for(int e = 1; e <= h; e++, cout << endl) for(int f = 1; f <= w; f++) cout << grid[e][f];
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long ll;
ll n;
ll s = 100;
ll res = 0;

int main() {
	cin >> n;

	while (s < n) {
		s += s / 100;
		res++;
	}

	cout << res << endl;

	return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  ll a[5] = {};
  for(int i = 0; i < n; ++i){
    string s; cin >> s;
    switch(s.front()){
    case 'M':a[0]++;break;
    case 'A':a[1]++;break;
    case 'R':a[2]++;break;
    case 'C':a[3]++;break;
    case 'H':a[4]++;break;
    }
  }
  ll ans = 0;
  for(int i = 0; i < 5; ++i){
    for(int j = i+1; j < 5; ++j){
      for(int k = j+1; k < 5; ++k){
	ans += a[i] * a[j] * a[k];
      }	
    }
  }
  cout << ans << endl;
}



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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    unordered_map<int, vector<int>> edges;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<int> comeFrom(N + 1, 0);
    int access = 0;
    int step = 0;
    queue<int> q;
    q.push(1);
    vector<bool> seen(N + 1, false);
    seen[1] = true;
    while (!q.empty()) {
        int s = q.size();
        for (int i = 0; i < s; ++i) {
            int current = q.front();
            q.pop();
            ++access;
            for (int neighbor : edges[current]) {
                if (!seen[neighbor]) {
                    q.push(neighbor);
                    seen[neighbor] = true;
                    comeFrom[neighbor] = current;
                }
            }
        }
        ++step;
    }
    if (access != N) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int i = 2; i <= N; ++i) {
            cout << comeFrom[i] << endl;
        }
    }
    return 0;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; i++)
	{
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}

	vector<long long> ans(M);
	ans[M - 1] = (long long)N * (N - 1) / 2;

	UnionFind Uni(N);

	for (int i = M - 1; i >= 1; i--)
	{
		ans[i - 1] = ans[i];

		//繋がってなかったのが繋がった時
		if (Uni.root(A[i]) != Uni.root(B[i])) {
			ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
			Uni.connect(A[i], B[i]);
		}
	}

	for (int i = 0; i < M; i++)
	{
		cout << ans[i] << endl;
	}
}



Measured memory_bytes: 3328
#include <iostream>
 
using namespace std;
 
int x,y;
 
int main () {
	cin >> x >>y;
if (x==1 || x==3 || x==5||x==7||x==8||x==10||x==12) {
	if (y==1 || y==3 || y==5||y==7||y==8||y==10||y==12) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
} else if(x==2) {
	if (y==2) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
} else {
	if (y==4||y==6||y==9||y==11) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n,m;cin>>n>>m;
  int a,b;
  vector<P> v(m);
  rep(i,m){
    cin>>a>>b;
    if(a<b){
      v[i]=P(b,a);
    }
    else{
      v[i]=P(a,b);
    }
  }
  
  sort(all(v));
  int now=v[0].fi;
  int ans=1;
  rep(i,m){
    if(v[i].fi!=now&&now<=v[i].se){
      ans++;
      //cout<<now<<endl;
      now=v[i].fi;
      
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#define NDEBUG
NDEBUG


#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <random>

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


using namespace std;

/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    /// caide keep
    template<int N>
    struct bytetype {
        
    };

    /// caide keep
    template<>
    struct bytetype<4> {
        
    };

    /// caide keep
    template<>
    struct bytetype<3> {
        
    };

    /// caide keep
    template<>
    struct bytetype<2> {
        
    };

    /// caide keep
    template<>
    struct bytetype<1> {
        
    };

    /// caide keep
    template<>
    struct bytetype<0> {
        
    };

    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vector(istream& in, size_t n) {
    vector<T> ret(n);
    for (size_t i = 0; i < n; ++i) {
        ret[i] = next<T>(in);
    }
    return ret;
}


void solve(istream& in, ostream& out) {
    int n = next<int>(in);
    int L = next<int>(in);
    vector<int> v = next_vector<int>(in, n);
    int last_knot = -1;
    FOR(i, v.size()-1) {
        if (v[i] + v[i + 1] >= L) {
            last_knot = i;
            break;
        }
    }
    if (last_knot == -1) {
        out << "Impossible\n";
        return;
    }
    out << "Possible\n";
    FOR(i, last_knot) {
        out << i + 1 << endl;
    }
    for (int i = n-2; i > last_knot; --i) {
        out << i + 1 << endl;
    }
    out << last_knot + 1 << endl;
}


int main() {
    solve(cin, cout);
    return 0;
}



Measured memory_bytes: 1280
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, X, T;

signed main(){
    cin >> N >> X >> T;
    cout << (N+X-1)/X * T << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>

using namespace std;

#define N 10


int main(void){
	
	int W[N];
	int K[N];
	
	int w_total, k_total;
	
	
	w_total = k_total = 0; 
	
	for(int i = 0;i < N;i++){
		
		cin >> W[i];
		
	}
	
	for(int i = 0;i < N;i++){
		
		cin >> K[i];
		
	}
	
	sort(W,W+N,greater<int>());
	
	sort(K,K+N,greater<int>());
	
	for(int i = 0;i < 3;i++){
	
	w_total += W[i];
	k_total += K[i];
	
	}
	
	cout << w_total << " " << k_total << endl;
	
	return 0;
	
}


Measured memory_bytes: 3168
// パスカルの三角形
package main

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

const (
	m = 1000000007
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	defer flush()

	N := readInt()
	K := readInt()

	n := max(K, N-K+1)
	c := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		c[i] = make([]int, n+1)
	}
	c[0][0] = 1
	for i := 0; i < n+1; i++ {
		c[i][0] = 1
		for j := 1; j < i+1; j++ {
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) % m
		}
	}

	for i := 1; i <= K; i++ {
		println(c[K-1][i-1] * c[N-K+1][i] % m)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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

using namespace std;

int digit(long long val){
	int digit=1;
  
  	while(val >= 10){
      digit++;
      val /= 10;
    }
	return digit;
}

int main()
{
	long long n;
  	cin >> n;
  
  	int vmin=INT_MAX;
  
  	long long sq_n = max((long long)sqrt(n), (long long)1);
    //cout << sq_n << endl;
  	for(long long a=1; a <= sq_n; a++){
      long long b = n / a;
      //printf("%lld %lld\n", a,b);
      if(a * b == n){
        int dig_a = digit(a);
        int dig_b = digit(b);
        vmin = min(vmin, max(dig_a, dig_b));
      }
    } 
      
  	cout << vmin << endl;
          
	return 0;
}  

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()
t = 0 # 入れ替え回数
if N == 1:
  print(0)
else:
  for i in range(N-1):
    if S[i] != S[i+1]:
      t += 1
  h = (N-1)-t # 元々の「幸福」
  h = min(h+2*K, N-1)
  print(h)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<stack>
#include<cstring>
#include<unordered_map>
#include<cmath>
#include<climits>
using namespace std;

template<typename T>
istream& operator>>(istream& in, vector<T> &a) {for(auto &i : a) {in >> i; } return in; } 
template<typename T>
ostream& operator<<(ostream& out, vector<T> &a) {for(auto &i : a) {out << i << ' '; } out << '\n'; return out; }

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



bool isVowel(char c)
{
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
	{
		return true;
	}
	return false;
}
int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input/input.txt", "r", stdin);
		freopen("input/output.txt", "w", stdout);
	#endif
	string s;
	cin >> s;
	int len = s.size()-1;
	if(s[len] == 's')
	{
		s += "es";
	}
	else
	{
		s += "s";
	}
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 3628
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 回数 - 取得
int
fGetCnt(
	int piLtl					// <I> 値(小)
	, int piBig					// <I> 値(大)
)
{
	int liCnt = piBig - piLtl;

	if (piLtl < 0 && piBig > 0) {
		if (-piLtl <= piBig) {
			liCnt = 1 + piBig + piLtl;
		}
		else {
			liCnt = -piLtl - piBig + 1;
		}
	}

	return liCnt;
}

// 実行メイン
int
fMain(
)
{
	char lc1Buf[1024];

	// X, Y - 取得
	int liX, liY;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liX, &liY);

	// 回数 - 取得
	int liCnt;
	if (liX < liY) {
		liCnt = fGetCnt(liX, liY);
	}
	else {
		if (-liX <= liY) {
			liCnt = 1 + fGetCnt(-liX, liY);
		}
		else {
			if (liX >= 0) {
				liCnt = -liY - liX + 1;
			}
			else {
				liCnt = 1 - liY + liX + 1;
			}
		}
	}

	return liCnt;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// １行出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 384
n = int(input())
s = []
for i in range(n):
    ss = ''.join(sorted(input()))
    s.append(ss)

from collections import Counter
d = Counter(s)

count = 0
for s in d.values():
    if s > 1:
        count += s/2*(s-1) 


print(int(count))

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



int main(){
    ll N ,T ,A;
    cin >> N >> T >> A;
    vector<pair<long double, int> > temper(N);

    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        temper[i] = make_pair(abs(T - 0.006 * tmp - A) , i);
        
    }
    sort(temper.begin(), temper.end());

    cout << temper[0].second + 1  << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
c=0;d={}
for _ in[0]*n:
 a,b=map(int,input().split())
 if not a in d.keys():
  d[a]=0
 d[a]+=b
for k in sorted(d.keys()):
 if d[k] < m:
  c+=k*d[k]
  m-=d[k]
 else:
  c+=k*m
  m=0
 if m == 0:break
print(c)

Measured memory_bytes: 18648
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> X(N);
  rep(i, N) { cin >> X[i]; }
  int ans = INT_MAX;
  for(int p=1; p<=100; ++p) {
    int tmp = 0;
    for(int i:X) {
      tmp += (p-i)*(p-i);
    }
    chmin(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import bisect

N,K = map(int,input().split())
V = list(map(int,input().split()))

ans = 0

if N < K :
    pp = K
    K = N
else :
    pp = K
for a in range(1,K+1) :
    for i in range(a+1) :
        G = []
        G.extend(V[:i])
        G.extend(V[len(V)-(a-i):])
        G.append(0)
        G = sorted(G)
        #bi = bisect.bisect(G,0)
        #G = G[min(bi-1,K-a):]

        cnt = 0
        calc = 0
        for i in range(len(G)) :
            if G[i] < 0 :
                if cnt < pp-a :
                    cnt += 1
                else :
                    calc += G[i]
            else :
                calc += G[i]


        ans = max(ans,calc)

print(ans)


Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int D, Q, x[131072], ls, rs, es; vector<int> seg[262144];
int query1(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return 999999999;
	if (a <= l && r <= b) return seg[k].size() ? seg[k][0] : 999999999;
	int lc = query1(a, b, 2 * k, l, (l + r) / 2);
	int rc = query1(a, b, 2 * k + 1, (l + r) / 2, r);
	return min(lc, rc);
}
int query2(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return -999999999;
	if (a <= l && r <= b) return seg[k].size() ? seg[k][seg[k].size() - 1] : -999999999;
	int lc = query2(a, b, 2 * k, l, (l + r) / 2);
	int rc = query2(a, b, 2 * k + 1, (l + r) / 2, r);
	return max(lc, rc);
}
int query3(int a, int b, int x1, int x2, int k, int l, int r) {
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b) return lower_bound(seg[k].begin(), seg[k].end(), x2) - lower_bound(seg[k].begin(), seg[k].end(), x1);
	int lc = query3(a, b, x1, x2, 2 * k, l, (l + r) / 2);
	int rc = query3(a, b, x1, x2, 2 * k + 1, (l + r) / 2, r);
	return lc + rc;
}
int main() {
	scanf("%d", &D);
	for (int i = 0; i < D; i++) {
		scanf("%d", &x[i]);
		int t = i + 131072;
		while (t > 0) {
			seg[t].push_back(x[i]);
			t >>= 1;
		}
	}
	for (int i = 1; i < 262144; i++) {
		if (seg[i].size() > 1) {
			sort(seg[i].begin(), seg[i].end());
		}
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d%d", &ls, &rs, &es);
		int a = min(x[ls - 1], x[rs - 1]);// query1(ls - 1, rs, 1, 0, 131072);
		int b = max(x[ls - 1], x[rs - 1]);// query2(ls - 1, rs, 1, 0, 131072);
		printf("%d\n", rs - ls + 1 - query3(ls - 1, rs, a - es, b + es + 1, 1, 0, 131072));
	}
	return 0;
}

Measured memory_bytes: 21224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

struct UnionFind {
    int n, cnt;
    vector<int> par, rank, sz;

    UnionFind(int n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) { iota(par.begin(), par.end(), 0); }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return sz[find(x)]; }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};

VVP E(101010);
vector<bool> iseven(101010, 1);
vector<bool> tome(101010);
int a[101010], b[101010];
VI ans(101010, -1);

void dfs(int cu, int pa = -1) {
    // v[cu]=0;
    for (P to : E[cu]) {
        if (to.fi != pa) {
            //
            dfs(to.fi, cu);
            if (tome[to.fi]) {
                iseven[cu] = !iseven[cu];
                if (a[to.se] == cu)
                    ans[to.se] = 1;
                else
                    ans[to.se] = 0;
            } else {
                if (a[to.se] == cu)
                    ans[to.se] = 0;
                else
                    ans[to.se] = 1;
            }
        }
    }
    tome[cu] = iseven[cu];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        if (uf.same(a[i], b[i])) {
            ans[i] = 1;
            iseven[a[i]] = !iseven[a[i]];
        } else {
            E[a[i]].pb(P(b[i], i));
            E[b[i]].pb(P(a[i], i));
            uf.unite(a[i], b[i]);
        }
    }
    if (m % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }
    dfs(0);
    for (i = 0; i < m; i++) {
        if (ans[i] == 1)
            cout << a[i] + 1 << " " << b[i] + 1 << endl;
        else
            cout << b[i] + 1 << " " << a[i] + 1 << endl;
    }
}

Measured memory_bytes: 20828
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, int> cnt;
    for (int i = 2; i <= N; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }

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


Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main (){
  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  rep(i,N) cin>>A[i];
  rep(i,N-K){
    if(A[i+K]>A[i]){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 4044
N = int(input())
H = [int(x) for x in input().split()]

ans = 0
while sum(H) != 0:
    l = 0
    while l < N and H[l] == 0: l += 1
    r = l
    while r < N and H[r] >= 1: r += 1
    for i in range(l, r):
        H[i] -= 1
    ans += 1

print(ans)


Measured memory_bytes: 3064
N = int(input())
S1 = input()
S2 = input()


state = 0
now = 0
ans = 1

while now < N:

    if state == 0 and S1[now] == S2[now]:
        ans *= 3
        now += 1
        state = 1

    elif state == 0 and S1[now] != S2[now]:
        ans *= 6
        now += 2
        state = 2

    elif state == 1 and S1[now] == S2[now]:
        ans *= 2
        now += 1
        state = 1

    elif state == 1 and S1[now] != S2[now]:
        ans *= 2
        now += 2
        state = 2

    elif state == 2 and S1[now] == S2[now]:
        ans *= 1
        now += 1
        state = 1

    elif state == 2 and S1[now] != S2[now]:
        ans *= 3
        now += 2
        state = 2

    ans %= (10 ** 9 + 7)

print (ans)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;

struct edge{
	int to;
	double cost;

	edge(int to, double cost){
		this->to = to;
		this->cost = cost;
	}
};

int main(){
	int xs, ys, xt, yt, n;
	cin >> xs >> ys >> xt >> yt >> n;
	double x[n], y[n], r[n];
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i];
	vector<vector<edge>> v(n + 2);
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			double dist = max(0.0, hypot(x[i] - x[j], y[i] - y[j]) - r[i] - r[j]);
			v[i].emplace_back(edge(j, dist));
			v[j].emplace_back(edge(i, dist));
		}
	}
	for(int i = 0; i < n; i++){
		double dist = max(0.0, hypot(xs - x[i], ys - y[i]) - r[i]);
		v[n].emplace_back(edge(i, dist));
	}
	for(int i = 0; i < n; i++){
		double dist = max(0.0, hypot(xt - x[i], yt - y[i]) - r[i]);
		v[i].emplace_back(edge(n + 1, dist));
	}
	{
		double dist = hypot(xs - xt, ys - yt);
		v[n].emplace_back(edge(n + 1, dist));
	}
	vector<double> dist(n + 2, 1e20);
	dist[n] = 0;
	priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> pq;
	pq.emplace(make_pair(dist[n], n));
	while(!pq.empty()){
		pair<double, int> p = pq.top();
		pq.pop();
		int now = p.second;
		for(edge &e:v[now]){
			if(dist[now] + e.cost < dist[e.to]){
				dist[e.to] = dist[now] + e.cost;
				pq.emplace(make_pair(dist[e.to], e.to));
			}
		}
	}
	cout << fixed << setprecision(10) << dist[n + 1] << endl;
}

Measured memory_bytes: 22532