akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n - 1);
    rep(i, n)cin >> a.at(i);
    rep(i, n)cin >> b.at(i);
    rep(i, n - 1)cin >> c.at(i);
    rep(i, n)ans += b.at(i);
    rep(i, n - 1)if (a.at(i) == a.at(i + 1) - 1) {
        ans += c.at(a.at(i)-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

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

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, T& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

class modint_t {
public:
    modint_t() = default;
    modint_t(int64_t value):value(value % MOD){}

    bool operator<(const modint_t rhs) const { return value < rhs.value; }
    bool operator<=(const modint_t rhs) const { return value <= rhs.value; }
    bool operator>(const modint_t rhs) const { return value > rhs.value; }
    bool operator>=(const modint_t rhs) const { return value >= rhs.value; }

    modint_t operator+(const modint_t rhs) const { return modint_t(value + rhs.value); }
    modint_t operator+=(const modint_t rhs) { return value = (value + rhs.value) % MOD; }
    modint_t operator-(const modint_t rhs) const { return modint_t(MOD + value - rhs.value); }
    modint_t operator-=(const modint_t rhs) { return value = (MOD + value - rhs.value) % MOD; }

    modint_t operator*(const modint_t rhs) const { return modint_t(value * rhs.value); }
    modint_t operator*=(const modint_t rhs) { return value = value * rhs.value % MOD; }
    modint_t operator/(const modint_t rhs) const { return *this * rhs.invert(); }
    modint_t operator/=(const modint_t rhs) { return *this *= rhs.invert(); }

    modint_t square() const { return *this * *this; }
    modint_t power(int64_t y) const
    {
        if(y == 0) return 1;
        else if(y == 1) return *this;
        else if(y % 2 == 0) return this->power(y/2).square();
        else return *this * this->power(y-1);
    }

    modint_t invert() const
    {
        return power(MOD-2);
    }

    operator int64_t() const
    {
        return value;
    }
private:
    static const int MOD = 1000000007;
    int64_t value = 0;
};

modint_t combination(int64_t n, int64_t r)
{
    if(r * 2 > n) r = n - r;
    modint_t x = 1;
    modint_t y = 1;
    for(int64_t i = 1; i <= r; ++i)
    {
        x *= n - i + 1;
        y *= i;
    }
    return x / y;
}

void solution()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << (modint_t{2}.power(n) - modint_t{1} - combination(n, a) - combination(n, b)) << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<String>();
    let s = v[0].chars().collect::<Vec<_>>();
    let t = v[1].chars().collect::<Vec<_>>();
    for i in 0..n {
        print!("{}", s[i]);
        print!("{}", t[i]);
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>

using namespace std;

#define THR 200
#define OTH 195

int main(void)
{
  int n;
  cin >> n;
  int y[n], m[n], d[n];
  for (int i = 0; i < n; i++)
    cin >> y[i] >> m[i] >> d[i];


  for (int i = 0; i < n; i++) {
    int date;
    int ninet = 0;
    int twe = 0;
    
    //d??????
    //y???3??§?????????
    if (y[i]%3 == 0) {
      date = 21 - d[i];
      twe = 10 - m[i];
    }
    //y???3??§????????????
    else {
      //m???2??§?????????
      if (m[i]%2 == 0) {
	date = 20 - d[i];
	int tmp = (10-m[i])/2;
	twe = tmp;
	ninet = tmp;
      }
      //m???2??§????????????
      else {
	date = 20 - d[i];
	int tmp = (10-m[i])/2;
	twe = 10-m[i]-tmp;
	ninet = tmp;
      }
    }
    twe *= 20;
    ninet *= 19;
    
    int year = 0;
    //?¬????y
    for (int j = y[i]+1; j < 1000; j++) {
      if (j%3 == 0)
	year += THR;
      else
	year += OTH;
    }
    cout << year+twe+ninet+date << endl;
  }
  
  return 0;	
}

Measured memory_bytes: 3024
require 'pp'

def gets_nums
  $stdin.gets.chomp.split(" ").map(&:to_i)
end

class Array
  def sum
    self.inject(0) {|x, accum| x + accum}
  end
end

loop do
  n, m = gets_nums
  break if (n == 0 && m == 0)
  table = n.times.map {gets_nums}.transpose.each_with_index.map {|line, i|
    {:i => i + 1, :line => line}
  }
  puts table.sort_by {|item| [item[:line].sum, -item[:i]]}.reverse.map {|item| item[:i]}.join(" ")
end

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

int main() {
  int n, a, b;

  cin >> n >> a >> b;

  int x, y, ans = 0;
  for (int i = 1; i <= n; i++) {
    x = i;
    y = 0;
    while (true) {
      y += x % 10;
      x /= 10;
      if (x == 0) break;
    }

    if (y >= a && y <= b) ans += i;
  }

  cout << ans << endl;


  return 0;

}

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

int main(void)
{
    vector<int> num(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> num[i];
    }
    int K;
    cin >> K;

    sort(num.begin(), num.end(), greater<int>());
    for (int i = 0; i < K; i++)
    {
        num[0] *= 2;
    }
    int sum = num[0] + num[1] + num[2];
    cout << sum << endl;
    return (0);
}

Measured memory_bytes: 256
moji = str(input())
cnt = 0
while len(moji)!=0:
  lst = list(moji)
  del lst[-1]
  cnt += 1
  moji = ''.join(lst)
  if len(moji)%2==0:
    centre = int(len(moji)/2)
    if lst[0:centre] == lst[centre:len(lst)+1]:
      print(len(lst))
      break;

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007
#define BOX 200000

typedef long long ll;

#define rep(i, s, e) for(unsigned int i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define uni(a) a.erase(unique(begin(a), end(a)), end(a))
#define sum(a) accumulate(begin(a), end(a), 0)


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

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll Tcnt = (C % B == 0) ? C / B : C / B + 1;
	ll Acnt = (A % D == 0) ? A / D : A / D + 1;

	if (Tcnt <= Acnt) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
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();
        long ans = 0;
        long cnt = 0;
        List<Pair> pairs = new ArrayList<Pair>();
        for (int i = 0; i < n; i++) {
            pairs.add(new Pair(sc.nextInt(), sc.nextInt()));
        }
        Collections.sort(pairs);
        for (int i = 0; i < n; i++) {
            long num = pairs.get(i).to;
            long value = pairs.get(i).from;
            if (m >= cnt + num) {
                ans += value * num;
                cnt += num;
            } else {
                ans += value * (m - cnt);
                break;
            }
            if (m == cnt) {
                break;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

class Pair implements Comparable {
    int from;
    int to;

    Pair(int from, int to) {
        this.from = from;
        this.to = to;
    }

    @Override
    public int compareTo(Object other) {
        Pair otherPair = (Pair) other;
        return this.from - otherPair.from;
    }
}

Measured memory_bytes: 85332
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll ans[222222];

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

	ll n;cin >> n;
	REP(i, n-1){
		ll a;cin >> a;
		a--;
		ans[a]++;
	}

	REP(i, n)cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 4716
#include<stdio.h>

#include<string.h>

int a[13],vis[13],flag;

void dfs(int x,int l,int r)

{

    int i;

    if(x==11)return; 

    if(flag)return ;

    if(a[x]>l)dfs(x+1,a[x],r);

    else  if(a[x]>r)dfs(x+1,l,a[x]);

    else  {flag=1;return;}

  

}

int main()

{

int T,i,j,k;

scanf("%d",&T);

while(T--)

{

flag=0;

for(i=1;i<=10;i++)

scanf("%d",&a[i]);

memset(vis,0,sizeof(vis));

dfs(1,0,0);

if(flag)printf("NO\n");

else printf("YES\n");

}

return 0;

}

Measured memory_bytes: 2520
N, T = map(int, input().split())
is_inT = False
min_c = 1000
for i in range(N):
    ct_i = [int(i) for i in input().split()]
    if ct_i[1] <= T:
        is_inT = True
        min_c = min(min_c, ct_i[0])
if is_inT:
    print(min_c)
else:
    print("TLE")


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

using namespace std;

bool pal(string s){
    int n = s.size();
    for(int i = 0 ; i < n / 2; ++i){
        if(s[i]!=s[n - i -1])return false;
    }
    return true;
}

int main() {
    string s; 
    cin>>s;
    int n  = s.size();
    string s1 = s.substr(0 , (n - 1)/2);
    string s2 = s.substr(((n + 3)/2) - 1, n);
    if(pal(s)&&pal(s1)&&pal(s2)){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    
    
}

Measured memory_bytes: 256
use std::io;
use std::collections::HashMap;
use std::str::FromStr;

fn main() {
    let n: i32 = {
        let mut n = String::new();
        io::stdin().read_line(&mut n).unwrap();
        n.trim_right().to_owned().trim().parse().unwrap()
    };

    let mut v: Vec<(String, i32, i32)> = vec![];
    for i in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.split_whitespace().map(|s| s.to_owned());
        v.push((it.next().unwrap(), 0 - i32::from_str(&it.next().unwrap()).unwrap(), i));
    }
    v.sort();
    for o in v {
        println!("{}", o.2 + 1);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
void judge(bool ans){
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int main(){
  int n;
  cin >> n;
  vector<string> da(n);
  for(int i=0;i<n;i++){
    cin >> da[i];
  }
  bool ans=true;
  for(int i=0;i<n-1;i++){
    int x=da[i].size();
    if(da[i+1][0]!=da[i][x-1])
      ans =false;
    //judge(ans);
  }
  for(int i=1;i<n;i++){
    for(int j=0;j<i;j++){
      if(da[i]==da[j]){
        ans=false;
      }
    }
  }
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
  int s;
  int a,b;
  cin >> s;
  a = s / 100;
  b = s % 100;
  if(a == 0 && b > 12 || a > 12 && b == 0 || a > 12 && b > 12 || a == 0 && b == 0){
    cout  << "NA" << endl;
  }
  else if(a > 12 && b <= 12 || a == 0 && b <= 12){
    cout << "YYMM" << endl;
  }
  else if(a <= 12 && b > 12 || a <= 12 && b == 0){
    cout << "MMYY" << endl;
  }
  else {
    cout << "AMBIGUOUS" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  int a[10];
  int b[11];
  int c[11];
  int k;
  int k2;
  int out=0;
  cin>>n;
  b[0]=0;
  c[0]=0;
  for(int i=0;i<n;i++){
    out=0;
    k=0;
    k2=0;
    b[1]=0;
    c[1]=0;
    for(int j=0;j<10;j++){
      cin>>a[j];
      if(b[k]<a[j]){
	b[k+1]=a[j];
	k++;
      }
      else if(c[k2]<a[j]){
	c[k2+1]=a[j];
	k2++;
      }
      else{
	out=1;
      }
    }
    if(out==0) cout << "YES" << endl;    
    else if(out==1) cout << "NO" <<endl;
  }
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    ll A,B,K;
    cin>>A>>B>>K;
    ll k=min(A,K);
    A-=k;
    K-=k;
    k=min(B,K);
    B-=k;
    cout<<A<<" "<<B<<endl;
}

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	main() {
	int N, C, K;
	cin >>N >>C >>K;
	vector<int> T(N, 0);
	for (int i=0; i<N; i++)
		cin >>T.at(i);
	sort(T.begin(), T.end());
	int S=1;
	int tk=T.at(0)+K;
	int c=1;
	for (int i=1; i<N; i++){
		if (T.at(i)>tk) {
			c=1;
			S++;
			tk=T.at(i)+K;
		} else {
			c++;
			if (c>C) {
				c=1;
				S++;
				tk=T.at(i)+K;
			}
		}
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define Rep(i,a,b) for(int i=a;i<=b;++i)
#define Rrep(i,a,b) for(int i=a;i>b;--i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define sq(a) (a)*(a)
#define nitro std::ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
#define pb push_back
#define pv(x) for(auto y:x)    cout<<y<<" ";    cout<<'\n';
#define fr first
#define sc second
#define ppb pop_back
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define int ll
#define tr(c,it) for(typeof(c.begin()) it= c.begin();it != c.end();it++)
#define ri(X) scanf("%lld", &(X))
#define rii(X, Y) scanf("%lld%lld", &(X), &(Y))
#define riii(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define dri(X) ll (X); scanf("%lld", &X)
#define drii(X, Y) ll X, Y; scanf("%lld%lld", &X, &Y)
#define driii(X, Y, Z) int X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define rs(X) scanf("%s", (X))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
typedef long long ll;
typedef std::vector< ll > vi;
typedef std::pair<ll, ll> pi;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
        tree_order_statistics_node_update>
        pbds;
const double pie = 3.14159265358979323846;
auto _C=clock();
/*
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;         ;;    ;;     ;;;;;;;     ;;     ;;  ;;;;     ;;
 ;;       ;;   ;;  ;;   ;;    ;;    ;;     ;;  ;; ;;    ;;
  ;;     ;;   ;;    ;;  ;;    ;;    ;;     ;;  ;;  ;;   ;;
   ;;   ;;    ;;;;;;;;  ;;;;;;;     ;;     ;;  ;;   ;;  ;;
    ;; ;;     ;;    ;;  ;;   ;;      ;;   ;;   ;;    ;; ;;
     ;;;      ;;    ;;  ;;    ;;       ;;;     ;;     ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
*/
int binpow(int base,int e,int mod=U)
{
	int res=1;
	while(e)
	{
		if(e&1) res=(base*res)%mod;
		base=(base*base)%mod;
		e>>=1;
	}
	return res;
}
int fact[N],inv[N];
void compute()
{
	fact[0]=1;
	fact[1]=1;
	rep(i,2,N)
	fact[i]=(fact[i-1]*i)%U;
	inv[N-1]=binpow(fact[N-1],U-2);
	rrep(i,N-2,0)
	inv[i]=(inv[i+1]*(i+1))%U;
}
signed main()
{		
	nitro;
	int CASE=1;
	//ri (CASE);
	//cin>>CASE;
	int ans=0;
	compute();
	while(CASE--)
	{
		int s;
		cin>>s;
		int n=1;
		while(s-3*n>=0)
		{
			ans+=((((fact[s-2*n-1]*inv[n-1])%U)*inv[s-3*n])%U);
			ans%=U;
			n++;
		}
		cout<<ans<<endl;
		//cout<<(fact[5]*inv[3])%U;
		
	}
	
	
	
	

//cerr<<"\n\n\nTime elapsed: "<<(double)(clock()-_C)*1000.0/CLOCKS_PER_SEC<<"ms\n";		

	return 0;
}



Measured memory_bytes: 5192
n = int(input())
a = list(map(int, input().split()))
x = 0
p = 0
r = 1
ans = 0
for l in range(n):
  while r <= n and x ^ a[r - 1] == p + a[r - 1]:
    x ^= a[r - 1]
    p += a[r - 1]
    r += 1
  ans += r - l
  x ^= a[l]
  p -= a[l]
print(ans - n)

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

int main(){
	int N, M, a[100], b[100], c[100], d[100], s, ans, i, j;
	cin >> N >> M ;
	for(i=0;i<N;i++) cin >> a[i] >> b[i];
	for(j=0;j<M;j++) cin >> c[j] >> d[j];

	for(i=0;i<N;i++){
		s = abs(a[i]-c[0])+abs(b[i]-d[0]);
		ans = 1;
		for(j=1;j<M;j++){
			if(s > abs(a[i]-c[j]) + abs(b[i]-d[j])){
				s = abs(a[i]-c[j])+abs(b[i]-d[j]);
				ans = j+1;
			}
		}
		cout << ans << endl;	
	}	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  long double n;
  cin >> n;
  cout << (n + n) * PI << endl;
  return 0;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	string u;
	int x,y;
	cin>>a>>b>>x>>y>>u;
	if(u==a)
	{
		cout<<x-1<<" "<<y;
	} 
	if(u==b)
	{
		cout<<x<<" "<<y-1;
	} 
	return 0;
}

Measured memory_bytes: 256
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[] x = new int[m];
        int[] d = new int[m-1];
        long sum = 0;
        for(int i = 0; i < m; i++){
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        for(int i = 0; i < m-1; i++){
            d[i] = x[i+1] - x[i];
        }
        Arrays.sort(d);
        for(int i = 0; i < m - n; i++){
            sum += d[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 50408
# -*- coding: utf-8 -*-

import sys
from bisect import bisect_right

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N = INT()
A = LIST()
A.sort()

# m番目の大きさのやつが、最後の1匹になれるか
def calc(m):
    # 番兵代わり
    if m == -1:
        return False
    # まず自分以下は全部取り込む
    a = sum(A[:m+1])
    # 自分の2倍まではいける
    idx = bisect_right(A, a*2)
    a += sum(A[m+1:idx])
    # 全て取り込んだ後で、その先に行ければ行く
    for i in range(idx, N):
        b = A[i]
        if a*2 >= b:
            a += b
        else:
            # 途中で取り込めなくなったらNG
            return False
    # 最後まで行けるなら、最後の1匹になれる
    return True

print(N-bisearch_min(-1, N-1, calc))


Measured memory_bytes: 14768
bfr = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    bfr[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print(' ' + ' '.join(map(str, bfr[b][f])))
    if b != 3:
        print('#'*20)


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int mx = max({ a, b, c });
    if ((mx - a) + (mx - b) + (mx - c) & 1) ++mx;
    printf("%d\n", mx * 3 - (a + b + c) >> 1);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
char name[100];
int t;
} P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
Q[tail]=x;
tail=(tail+1)%LEN;
}

P dequeue(){
P x=Q[head];
head=(head+1)%LEN;
return x;
}

int min(int s,int t){return s<t?s:t;}

int main(){
int elaps=0,a,b,i;
P c;
scanf("%d %d",&n,&b);
for(i=1;i<=n;i++){
scanf("%s",Q[i].name);
scanf("%d",&Q[i].t);
}
head = 1; tail=n+1;
while(head != tail){
c=dequeue();
a=min(b,c.t);
c.t-=a;
elaps+=a;
if(c.t>0)enqueue(c);
else{
printf("%s %d\n",c.name,elaps);
}
}
return 0;
}


Measured memory_bytes: 11888
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    r, D, x = map(int, readline().split())
    for _ in range(10):
        x = r * x - D
        print(x)
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <list>
#include <stack>
#include <climits>
#include <unordered_set>
#define m7 1000000007
#define m9 1000000009
#define ll long long
#define pii pair<int,int>
#define F first
#define S second

using namespace std;
int main()
{	
	int dp[100007],H[100007],n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> H[i];
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i+1]));
		if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
	}
	cout << dp[n-1];
	return 0;
}
/*
1
3 3 1
0 1
1 2
0 2
1
4 4 1
0 1
1 2
0 2
2 3

*/

Measured memory_bytes: 1024
let inline scan () = System.Console.ReadLine()
let inline split (s: string) = s.Split(' ')

let n = scan () |> int
let xs = scan () |> split |> List.ofArray |> List.map int

let noskip = 
  let x = xs |> List.fold (fun (budget, location) next -> (budget + abs (next - location), next)) (0, 0) |> fst
  x + abs (xs |> List.last)

let rec f = function
  | pred :: current :: next :: _ & _ :: tail ->
    noskip + abs (next - pred) - abs (current - pred) - abs (current - next)
      |> printfn "%i"
    f tail
  | pred :: current :: [] ->
    noskip + abs pred - abs (current - pred) - abs current
      |> printfn "%i"

f (0 :: xs)


Measured memory_bytes: 31808
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int x,y;
	cin>>x>>y;
	int t= (y-2*x);
	int c=  (4*x-y);
	if(t%2==0&&c%2==0&&t>=0&&c>=0)
	 cout<<"Yes";
	else 
	 cout<<"No";
	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    vector<f64> X(N);
    vector<string> U(N);
    const f64 BTC = 380000.0;
    REP(i, N) cin >> X[i] >> U[i];
    f64 s = 0;
    REP(i, N) {
        if (U[i] == "JPY") {
            s += X[i];
        } else {
            s += X[i] * BTC;
        }
    }
    cout << setprecision(8) << s << endl;

    return 0;
}

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};


// combination mod prime（mintが必要）
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// nCkを求めて結果をansに格納したい場合、
// combination c(n);
// mint ans = c(n, k);
// cout << ans.x << endl;
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
	
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n){
		int tmp;
		cin >> tmp;
		a[i] = tmp;
	}
	sort(all(a));
	mint ans = 0;
	
	combination c(n);
	
	for(int i = k-1; i < n; i++) {
		mint tmp = c(i, k-1);
		tmp *= a[i];
		ans += tmp;
	}
	for(int i = 0; i < n-k+1; i++) {
		mint tmp = c(n-i-1, k-1);
		tmp *= a[i];
		ans -= tmp;
	}
	cout << ans.x << endl;
	return 0;
}

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

int main(void) {

	long long X;
  
  	cin >> X;
  
 	int Ans = 0;
  	long long money = 100;
  
  	while(money < X) {
    	money += money /100;
      	Ans++;
    }
  	cout << Ans;
  	
  
  	return 0;
  	
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

void solve() {
  i64 N;
  cin >> N;
  std::set<i64> idx;
  rep(i,0,N) {
    idx.insert(i);
  }
  vector<pair<i64, i64>> left;
  vector<pair<i64, i64>> right;
  i64 ans = 0;
  rep(i,0,N) {
    i64 k, l, r;
    cin >> k >> l >> r;
    k--;
    if(l < r) {
      right.push_back({ k, r - l });
      ans += l;
    }
    else {
      left.push_back({ k, l - r });
      ans += r;
    }
  }
  sort(rbegin(left), rend(left));
  sort(begin(right), end(right));
  {
    i64 now = left.size();
    i64 li = 0;
    priority_queue<i64> que;
    while(now --> 0) {
      while(li < left.size() && left[li].first >= now) {
        que.push(left[li].second);
        li++;
      }
      if(que.empty()) {
      }
      else {
        ans += que.top();
        que.pop();
      }
    }
  }
  {
    i64 now = left.size();
    i64 ri = 0;
    priority_queue<i64> que;
    while(now < N) {
      while(ri < right.size() && right[ri].first < now) {
        que.push(right[ri].second);
        ri++;
      }
      if(que.empty()) {
      }
      else {
        ans += que.top();
        que.pop();
      }
      now++;
    }
  }
  cout << ans << endl;
}

int main() {
  i64 T;
  cin >> T;
  while(T--) {
    solve();
  }
}


Measured memory_bytes: 17540
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  int n; cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];

  mint res(1);
  int cnt = 0;
  int idx = 0;
  while(idx < n) {
    if(2*cnt+1 <= x[idx]) {
      cnt++;
    }
    else {
      res *= (mint)(cnt + 1);
    }
    idx++;
  }

  while(cnt > 0) {
    res *= cnt;
    cnt--;
  }

  cout << res.x << "\n";

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int cnt[2525][2525], cnt2[2525][2525];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int h, w;
	char s[2525][2525];
	cin>>h>>w;
	FOR(i, 1, h+1){
		FOR(j, 1, w+1){
			cin>>s[i][j];
		}
	}
	REP(i, h+2){
		s[i][0]=s[i][w+1]='#';
	}
	REP(i, w+2){
		s[0][i]=s[h+1][i]='#';
	}
	h+=2;
	w+=2;
	REP(i, h){
		int tmp=0, fst=0;
		REP(j, w){
			if(s[i][j]=='.'){
				++tmp;
			}
			if(s[i][j]=='#'){
				FOR(k, fst, j){
					cnt[i][k]=tmp;
				}
				tmp=0;
				fst=j+1;
			}
		}
	}
	REP(i, w){
		int tmp=0, fst=0;
		REP(j, h){
			if(s[j][i]=='.'){
				++tmp;
			}
			if(s[j][i]=='#'){
				FOR(k, fst, j){
					cnt2[k][i]=tmp;
				}
				tmp=0;
				fst=j+1;
			}
		}
	}
	int ans=0;
	REP(i, h){
		REP(j, w){
			if(cnt[i][j]>0 && cnt[i][j]>0){
				CHMAX(ans, cnt[i][j]+cnt2[i][j]-1);
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 47360
#include <bits/stdc++.h>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn = 1e5 + 10;
using namespace std;
int n, m, k, t, h[maxn], tot, ans[maxn];
set<int>comp[maxn];            //记录到这个点的最短路上一条边有哪些
struct node
{
        int to, nxt, com;
} e[maxn << 2];
void add(int x, int y, int z)
{
        tot++;
        e[tot].to = y;
        e[tot].com = z;
        e[tot].nxt = h[x];
        h[x] = tot;
}
priority_queue<pair<int, int> >p;
int main()
{
        int i, j;
        scanf("%d %d", &n, &m);
        
                for (int i = 1; i <= n; i++)
                {
                        h[i] = -1;
                        ans[i] = inf;
                        comp[i].clear();
                }
                tot = 0;
                while (m--)
                {
                        int a, b, c;
                        scanf("%d%d%d", &a, &b, &c);
                        add(a, b, c);
                        add(b, a, c);
                }
                p.push({0, 1});          //从1这点开始 初始值为0
                ans[1] = 0;
                while (!p.empty())
                {
                        int now = p.top().se, ca = -p.top().fi;   //因为优先队列是从大到小排 那么要优先处理路径小的  就存负数进去
                        p.pop();
                        if (ans[now] < ca)       //如果这个点又被更新过最优的话 这对pair就没意义了
                        {
                                continue;
                        }
                        for (i = h[now]; ~i; i = e[i].nxt)
                        {
                                int to = e[i].to, to_com = e[i].com;   //to为下一个点  to_com为所连边的值
                                int to_ca = ca + (!comp[now].count(to_com));//如果到now这个点的最短路  的上一条边有to_com值出现过就加0  （set去重了）没有出现过就+1
                                if (ans[to] > to_ca)               //如果有更优解就更新
                                {
                                        ans[to] = to_ca;
                                        p.push({ -to_ca, to});
                                        comp[to].clear();
                                        comp[to].insert(to_com);
                                }
                                else if (ans[to] == to_ca)    //如果最优解相同 那么把边加入集合记下来
                                {
                                        comp[to].insert(to_com);
                                }
                        }
                }
                printf("%d\n", ans[n] == inf ? -1 : ans[n]);   //没找到就是原来的最大值 输出-1

        return 0;
}


Measured memory_bytes: 20216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<deque>
using ll=long long;
using namespace std;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};




int main(){
	int n;
	cin>>n;
	vector<int>w(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>w[i];
		sum+=w[i];
	}
	int s1=w[0];
	int s2=sum-s1;
	int ans=abs(s1-s2);
	
	for(int i=1;i<n-1;i++){
		s1+=w[i];
		s2-=w[i];
		ans=min(ans,abs(s1-s2));
	}
	cout<<ans<<endl;

    return 0;
}

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int main(){
  int N,K,S;
  cin >> N >> K >> S;
  if(S!=1e9){
    for(int i=0;i<K;i++){
      cout << S << endl;
    }
    for(int i=K;i<N;i++){
      cout << 1000000000 << endl;
    }
  }
  if(S==1e9){
     for(int i=0;i<K;i++){
      cout << S << endl;
    }
    for(int i=K;i<N;i++){
      cout << 17 << endl;
    }
  }
  
}
      
  
  
  

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

int main(){
  int x; cin>>x;
  int ans=0;
  if(400<=x && x<=599){
    ans=8;
  }else if(600<=x && x<=799){
    ans=7;
  }else if(800<=x && x<=999){
    ans=6;
  }else if(1000<=x && x<=1199){
    ans=5;
  }else if(1200<=x && x<=1399){
    ans=4;
  }else if(1400<=x && x<=1599){
    ans=3;
  }else if(1600<=x && x<=1799){
    ans=2;
  }else if(1800<=x && x<=1999){
    ans=1;
  }

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

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

int main()
{
  int n, i=0;
  unsigned long long ans = 0;
  int d[50];
  
  cin >> n;
  
  for(int i=0; i<n; i++)
  {
    cin >> d[i];
  }
  
  for(int i=0; i<n-1; i++)
  {
    for(int j=i+1; j<n; j++)
    {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a string
	fmt.Scan(&a)
	tmp := strings.Replace(a, "1", "0", -1)
	b := strings.Replace(tmp, "9", "1", -1)
	ans := strings.Replace(b, "0", "9", -1)
	fmt.Println(ans)
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n, t;
	cin >> n >> t;
	vector<P> dish(n);
	rep (i, n) {
		cin >> dish[i].first >> dish[i].second;
	}
	sort(all(dish));
	// sort(dish.begin(), dish.end(), [](P a, P b) 
	// { if (a.second != b.second) return a.second < b.second; else return a.first < b.first;});
	// {return ((a.second < b.second) ? true : (a.first < b.first));});
	int dp[6001] = {}; // 0...n-1 normal n max
	// for (P d : dish) {
	rep (i, n) {
		P d = dish[i];
		for (int tt = t + d.first - 1; tt >= 0; tt--) {
		// rep (tt, t) {
			if (tt - d.first >= 0) {
				chmax(dp[tt], dp[tt - d.first] + d.second);
			} else {
				break;
			}
		}
	}
	// cout << endl;
	// rep (i, n) cout << dish[i].first << " " << dish[i].second << endl;
	// rep (i, t + 1) cout << dp[i] << " "; cout << endl; 
	int ans = 0;
	rep (i, 6000) chmax(ans, dp[i]);
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  string s;
  ll k;
  cin >> s >> k;

  vector<ll> v;
  int cnt = 1;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == s[i-1]) {
      cnt++;
    } else {
      v.push_back(cnt);
      cnt = 1;
    }
  }
  v.push_back(cnt);

  if (s.size() == 1) {
    cout << k / 2 << endl;
  } else if (v.size() == 1) {
    cout << v[0] * k / 2 << endl;
  } else {
    if (s[0] == s[s.size()-1]) {
      ll ans = 0;
      for (int i = 1; i < v.size() - 1; i++) {
        ans += v[i] / 2 * k;
      }
      ans += (v[0] + v[v.size()-1]) / 2 * (k - 1);
      ans += v[0] / 2 + v[v.size()-1] / 2;
      cout << ans << endl;
    } else {
      ll ans = 0;
      for (int i = 0; i < v.size(); i++) {
        ans += v[i] / 2 * k;
      }
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 300005
using namespace std;

int n, mx, b, a[N];
string s;
int main()
{
	int i;
	cin >> n >> s;
	s = ' ' + s;
	for (i = 1; i <= n; i++) {
		a[i] = a[i - 1];
		if (s[i] == 'E') a[i]++;
	}
	for (i = n; i > 0; i--) {
		if (s[i] == 'W') b++;
		mx = max(mx, a[i] + b);
	}
    cout << n - mx << endl;
    return 0;
}

Measured memory_bytes: 1888
#include<stdio.h>
int main(){
  int i ,j ,n ,tmp ,sort=0 ,numbers[110];
  while( scanf( "%d",&n ) != EOF ){
    if( n == 0 ){
      break;
    }
    
    for( i=0 ; i<n ; i++ ){
      scanf( "%d",&numbers[i] );
    }
    
    for( i=0 ; i<n-1 ; i++ ){
      for( j=n-1 ; j>i ; j-- ){
	if( numbers[j] < numbers[j-1] ){
	  tmp = numbers[j];
	  numbers[j] = numbers[j-1];
	  numbers[j-1] = tmp;
	  sort++;
	}
      }
    }
  
    printf( "%d\n",sort );
    sort = 0;
  }

  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cctype>

using namespace std;

int main(){

	int k,s;
	int count=0;
	int x=0,y=0,z=0;
	
	cin>>k>>s;
	
	for(x=0;x<=k;x++){
	for(y=0;y<=k;y++){
		z=s-x-y;
		if(0<=z && z<=k)count++;
		
	
	}
	}

cout<<count<<endl;

return 0;

}


Measured memory_bytes: 256
n,k=map(int,input().split())
S=list(input())
A=[]
a=1
c=0
for i in range(n):
  if int(S[i])==a:
    c=c+1
  else:
    A.append(c)
    a=(a+1)%2
    c=1
A.append(c)
if S[-1]=="0":
  A.append(0)
aa=len(A)
if k>=((aa-1)//2):
  print(n)
else:
  ans=0
  a=0
  for i in range(2*k+1):
    a=a+A[i]
  if a>ans:
    ans=a
  for i in range((aa-1)//2-k):
    a=a-A[2*i]-A[2*i+1]+A[2*(i+k)+1]+A[2*(i+k)+2]
    if a>ans:
      ans=a
  print(ans)

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;

vector<int>g[N];
int dp[N];

void dfs(int u){
    if(dp[u]) return;
    for(int to: g[u]){
        dfs(to);
        dp[u] = max(dp[u], dp[to] + 1);
    }

}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= m; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
    }
    for(int i = 1; i <= n; i++){
        if(dp[i] == 0){
            dfs(i);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        //cout << dp[i] << endl;
        ans = max(ans, dp[i]);
    }
    printf("%d\n", ans);

    
}

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

int main(){
  string S;
  cin>>S;
  vector<int>ans(S.size());
  vector<int>chk(S.size());
  vector<int>dim(S.size());
  
  for(ll i=0;i<S.size()-1;i++){
    if(S[i]=='R'&&S[i+1]=='L'){
      chk[i]++;
      chk[i+1]++;
    }
  }
  bool flag=false;
  int countL=0;
  for(ll i=1;i<S.size();i++){ 
if(S[i-1]=='R'&&S[i]=='L'){//Lの距離の記録
  flag=true;
  countL=0;
  dim[i]==countL;
}
    
    else if(S[i]=='L'){
      dim[i]=countL;
    }
    
    countL++;
      
  }
  ll countR=0;
    for(ll i=S.size()-2;i>=0;i--){ 
if(S[i]=='R'&&S[i+1]=='L'){//Rの距離の記録
  flag=true;
  countR=0;
  dim[i]==countR;
}
    
    else if(S[i]=='R'){
      dim[i]=countR;
    }
    
    countR++;
      
  }

  for(ll i=0;i<S.size();i++){
if(S[i]=='R'){//右方向の場合
 
  if(dim[i]%2==1){
    ans[i+dim[i]+1]++;
  }
  
  else{
    ans[i+dim[i]]++;
  }
}
    else{//左方向の場合
 
  
  if(dim[i]%2==1){
    ans[i-dim[i]-1]++;
  }
  
  else{
    ans[i-dim[i]]++;
  }
}
  }
      
for(ll i=0;i<S.size();i++){
  
  cout<<ans[i]<<" ";
}
    
    cout<<endl;
  
    
}

   

Measured memory_bytes: 1792