akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n,x;
  cin >> n >> x;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(all(a));
  ll snuck = x;
  ll count = 0;
  rep(i, n){
    snuck -= a[i];
    if (snuck >= 0){
      count++;
    }
    else{
      break;
    }
  }
  if(snuck>0){
    count--;
  }
  print(count);
}

Measured memory_bytes: 3608
a=[]
for i in range(3):
    a.extend(list(map(int,input().split())))

n=int(input())
for i in range(n):
    b=int(input())
    if(b in a):
        a[a.index(b)] = -1

if((a[0]==-1 and a[3]==-1 and a[6]==-1) or
   (a[1]==-1 and a[4]==-1 and a[7]==-1) or
   (a[2]==-1 and a[5]==-1 and a[8]==-1) or
   (a[0]==-1 and a[1]==-1 and a[2]==-1) or
   (a[3]==-1 and a[4]==-1 and a[5]==-1) or
   (a[6]==-1 and a[7]==-1 and a[8]==-1) or
   (a[0]==-1 and a[4]==-1 and a[8]==-1) or
   (a[2]==-1 and a[4]==-1 and a[6]==-1)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  std::vector<int64_t> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int64_t result_plus = 0, result_minus = 0;
  int64_t cum = 0;
  for (int i = 0; i < n; i++) {
    cum += a[i];
    if (i % 2 == 0) {
      if (cum <= 0) {
        result_plus += (-cum) + 1;
        cum = 1;
      }
    } else {
      if (cum >= 0) {
        result_plus += cum + 1;
        cum = -1;
      }
    }
  }
  cum = 0;
  for (int i = 0; i < n; i++) {
    cum += a[i];
    if (i % 2 == 0) {
      if (cum >= 0) {
        result_minus += (cum) + 1;
        cum = -1;
      }
    } else {
      if (cum <= 0) {
        result_minus += (-cum) + 1;
        cum = 1;
      }
    }
  }

  cout << std::min(result_minus, result_plus) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
 
int n;
ll x, ans = (ll)9e18, a[200005];
 
int main() {
    cin >> n >> x;
    for(int i = 1; i <= n; ++i) cin >> a[i], a[i] += a[i-1];
    for(int k = 1; k <= n; ++k) {
        ll coef = 3LL, sum = 0;
        for(int i = n; i >= 1; i -= k) {
            sum += (a[i]-a[max(0, i-k)])*max(coef, 5LL), coef += 2;
            if(sum >= ans) break; //防爆long long
        }
        ans = min(ans, sum+(k+n)*x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll H,W;
	ll ans=INFl;
	scan(H>>W);
	if(H>=3) ans=min(ans,W*(H%3!=0));
	if(W>=3) ans=min(ans,H*(W%3!=0));
	rep1(i,H-1){
		ll s1=i*W;
		ll s2=W/2*(H-i);
		ll s3=H*W-s1-s2;
	//	printf("i:%d %lld %lld %lld\n",i,s1,s2,s3);
		ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
	}
	rep1(i,W-1){
		ll s1=i*H;
		ll s2=H/2*(W-i);
		ll s3=H*W-s1-s2;
	//	printf("i:%d %lld %lld %lld\n",i,s1,s2,s3);
		ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			var temp = (Console.ReadLine().Split(' '));
			var x = int.Parse(temp[0]);
			var y = int.Parse(temp[1]);
			var group = 0;
			group = (x == 2) ? 2 :
				(x == 4) ? 1 :
				(x == 6) ? 1 :
				(x == 9) ? 1 :
				(x == 11) ? 1 : 0;
			if (group == ((y == 2) ? 2 :
					(y == 4) ? 1 :
					(y == 6) ? 1 :
					(y == 9) ? 1 :
					(y == 11) ? 1 : 0))
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}

Measured memory_bytes: 13140
#include<stdio.h>

int main(){

    int n,d,min,max,i;
    long sum;

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

    min = d;
    max = d;
    sum = d;
  
    for( i = 0; i < n-1;i++){

    scanf("%d",&d);

    if( d < min){
        min = d;
   }else if( d > max){
        max = d;
   }

    sum += d;
    }
   
    printf("%d %d %ld\n",min,max,sum);

    return 0;
}







Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__;
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,M; cin >> N >> M;
    int sum=0;
    vector<int> A(N); for(int i=0;i<N;i++){ cin >> A[i]; sum += A[i];}
    int cnt=0;
    for(int i=0;i<N;i++){
        if(1.0*A[i]>=0.25*sum/M) cnt++;
    }
    cerr << cnt << endl;
    if(cnt>=M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())

A = list(map(int, input().split()))
c = Counter(A)
S = sum(A)

Q = int(input())
for _ in range(Q):
    x, y = map(int, input().split())
    S += (c[x]*(y-x))
    print(S)
    c[y] += c[x]
    c[x] = 0

Measured memory_bytes: 23936
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (s, ) = input!(String);

    let mut previous = String::new();
    let mut count = 0;
    let mut current = String::new();

    for c in s.chars() {
        current.push(c);
        if previous != current {
            count += 1;
            previous = current;
            current = String::new();
        }
    }

    println!("{}", count);
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static int LCS(String x, String y) {
		int m = x.length();
		int n = y.length();
		int[][] matrix = new int[m+1][n+1];
		
		char[] s1 = new char[m+1];
		char[] s2 = new char[n+1];
		
		for(int i = 0; i < m; i++) {
			char c = x.charAt(i);
			s1[i+1] = c;
		}

		for(int i = 0; i < n; i++) {
			char c = y.charAt(i);
			s2[i+1] = c;
		}
		
		for(int i = 1; i < m+1; i++) {
			for(int j = 1; j < n+1; j++) {
				if ((s1[i]!=(s2[j]))) {
					matrix[i][j] = Math.max(matrix[i-1][j], matrix[i][j-1]);
				}
				else {
					matrix[i][j] = 1 + matrix[i-1][j-1];
				}
			}
		}
		
		
		return matrix[m][n];
	}
	

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int datasets = in.nextInt();
		
		
		for(int i = 0; i < datasets; i++) {
			String s1, s2;
			s1 = in.next();
			s2 = in.next();
			
			
			System.out.println(LCS(s1, s2));
		}

	}

}



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

int main(){

    int aa,bb,m;
    cin >> aa >> bb >> m;

    vector<int> a(aa),b(bb);

    int am=1e+6;
    int bm=1e+6;

    rep(i,aa){
        cin >> a[i];
        am=min(am,a[i]);
    } 
    rep(i,bb){
        cin >> b[i];
        bm=min(b[i],bm);
    }

    vector<int> x(m),y(m),c(m);

    rep(i,m){
        cin >> x[i] >> y[i] >> c[i];
    }

    int ans=am+bm;
    rep(i,m){   
        ans=min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 2176
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*  Compro by NULL_CT©  */
//////////////////////////
/*STL Libs*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

/*Boost to boost compile time*/
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long // Black Magic
#define REP(I, LIM) for (int I = 0; I < LIM; I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 10000007;

vector<int> divisor(int n) {
  vector<int> head, tail;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

//--------------------------------

void execute() {
  int n;
  cin>>n;
  vector<pair<int,int> > ll(n);
  REP(i,n){ cin>>ll[i].first>>ll[i].second; }
  int count=0;

  long double ans=0;
  sort(ALL(ll));
  do{
    count++;
    long double sum=0;

    for(int i=0;i<ll.size()-1;i++){
      sum+=sqrt(pow(ll[i].first-ll[i+1].first,2)+
                pow(ll[i].second-ll[i+1].second,2));
    }
    ans+=sum;
    cerr<<count<<":"<<sum<<endl;
  } while(next_permutation(ALL(ll)));
  cout<<ans/count<<endl;
}

//--------------------------------

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(20);

  execute();

  return (0);
}


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

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

int main(){
    int a[5];
    int k, n;
    vector<pair<int, int> > p(5);
    for(int i = 0; i < 5; i++){
        cin >> a[i];
        k  = a[i] % 10;
        if(k == 0){
            k = 9;
        }
        p[i] = make_pair(i, k);
    }

    sort(p.begin(), p.end(), compare_by_b);

    int ans = 0;

    for(int i = 0; i < 5; i++){
        ans += a[p[i].first];

        //cout << "+ " << ans << endl;

        if(ans % 10 != 0 && i != 4){
            ans += 10 - p[i].second;
        }
    }

    cout << ans << endl;

}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;
  int l = S.length();
  int ans = 1 << 29;
  for (int i = 0; i < l - 2; ++i) {
    int a =
        (S.at(i) - '0') * 100 + (S.at(i + 1) - '0') * 10 + (S.at(i + 2) - '0');

    ans = min(ans, abs(753 - a));
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, d; cin>>a>>b>>c>>d;
    int i = 0;
    while(a && c){
        if(i % 2 == 0) c = max(0, c-b);
        else a = max(0, a-d);
        i++;
    }
    printf(a > c ? "Yes\n" : "No\n");
}



Measured memory_bytes: 3776
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

ll SUM(ll A){
    if(A<=1) return A;
    ll count=2;
    ll ret=0;
    if(A%4==2 || A%4==1) ret=1;
    A++;
    
    while(count<A){
        ll x=A/count;
        ll y=A%count;
        if(x%2 && y%2) ret+=count;
        count*=2;
    }
    return ret;
}

int main(){
    ll A,B; cin>>A>>B;
    if(A>B) swap(A,B);
    if(A==0) cout<<SUM(B)<<endl;
    else cout<<(SUM(A-1)^SUM(B))<<endl;
    //cout<<SUM(A-1)<<':'<<SUM(B)<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
 
public class Beginner
{
 
    public static void Main()
    {
      var res = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
      var N = res[0];
      var R = res[1];
      if(10<=N){Console.WriteLine(R);}
      else{Console.WriteLine(R + 100*(10-N));}
    }
}

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

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

using namespace std;
using lint=long long;

vector<long long> divisors(long long a){
	vector<long long> res;
	for(long long i=1;i*i<=a;i++) if(a%i==0) {
		res.emplace_back(i);
		if(i*i<a) res.emplace_back(a/i);
	}
	sort(res.begin(),res.end());
	return res;
}

int main(){
	lint n; scanf("%lld",&n);

	lint ans=0;
	for(lint d:divisors(n)){
		lint m=d-1;
		if(n/d<m) ans+=m;
	}
	printf("%lld\n",ans);

	return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string S[100005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
    }
    sort(S, S + N);
    ll ans = 0;
    ll index = 0;
    while (true)
    {
        ll i = index;
        ll n = 0;
        while (S[i] == S[index] && index < N)
        {
            n++;
            index++;
        }
        ans += (n - 1) * n / 2;
        if (index >= N)
            break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ld a,b;
    cin>>a>>b;
    ld ans=a*b;
    ll ans1=a*b;
    cout<<ans1<<"\n";
}


Measured memory_bytes: 3748
#include<stdio.h>

int main(){
	int A,B,C,D;
  	scanf("%d%d%d",&A,&B,&C);
  	if(A > B){
    	D = A;
      	A = B;
      	B = D;
    }
  	if(A < C && B > C){
    	printf("Yes\n");
    } else {
    	printf("No\n");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	long int t[100005], x[100005], y[100005];
	for(int i=0;i<n;i++){
		cin >> t[i] >> x[i] >> y[i];
	}
	int xx = 0, yy = 0;
	int ts = 0;
	for(int i=0;i<n;i++){
		int xs = abs(x[i]-xx);
		int ys = abs(y[i]-yy);
		int d = xs+ys;
		if(d==(t[i]-ts)){
			xx = x[i];
			yy = y[i];
			ts = t[i];
		}else{
			if(d<t[i] && (d%2)==(t[i]-ts)%2){
				xx = x[i];
				yy = y[i];
				ts = t[i];
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	string S;
	cin >> S;

	int ans = INF;
	for (int i = 0; i < S.size() - 2; i++) {
		string s = S.substr(i, 3);
		int n = stoi(s);
		int d = abs(753 - n);
		ans = min(ans, d);
	}

	cout << ans << endl;
}

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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod 		1000000007
#define inf 		1e18
#define IOS 		ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

map<int, set<int>> adj;
vector<bool> vis;

void dfs(int src, int& x) {
	vis[src] = 1;
	x++;

	for (auto to : adj[src]) {
		if (vis[to])
			continue;
		dfs(to, x);
	}
}

int32_t main() {

	IOS;

	int n, m;
	cin >> n >> m;

	vis = vector<bool>(n);

	int a, b;

	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--, b--;

		adj[a].insert(b);
		adj[b].insert(a);
	}

	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (!vis[i]) {
			int x = 0;
			dfs(i, x);

			ans = max(ans, x);
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 59884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >>B;
  int ans = 0;
  
  for (int i = 1; i <= N; i++) {
    int s = i % 10;
    int t = (i / 10) % 10;
    int u = (i / 100) % 10;
    int v = (i / 1000) % 10;
    int w = i / 10000;
    int z = s + t + u + v + w;
    if (z >= A && z <= B) {
      ans += i;
    }
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int main() {
	long long q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	h = min(h, q * 2);
	s = min(s, h * 2);
	d = min(d, s * 2);
	n *= 4;
	cout << n / 8 * d + n % 8 / 4 * s + n % 4 / 2 * h + n % 2 * q << endl;
	return 0;
}

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

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

    int k = n;
    long long int ans = 0;

    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                ans += (__gcd(i, __gcd(j, l)));
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3676
#include<stdio.h>
main(){
  int n,i,x,xx;
  int sum=100000;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    sum=sum*1.05;
    x=sum/1000;
    x=x*1000;
    //   y=sum-x;
    if(sum-x > 0){
      x=x+1000;
    }
  sum=x;
  }
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MOD (ll)(998244353)
#define MAX (ll)(1e5 + 4)
#define INF (ll)(1e17)
using namespace std;
using ll =  long long;
using ld = long double;

int main () {
	int n, k, s;
	cin >> n >> k >> s;
	int ar[n];
	if (s == 1e9) {
		fill (ar, ar + n, s);
		for (int i = 0; i < n - k; i++) {
			ar[i] = s - 1;
		}
	}
	else {
		fill (ar, ar + n, s);
		for (int i = k; i < n; i++) {
			ar[i] = s + 1;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ar[i] << " ";
	}
	cout << "\n";
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll N;
  cin >> N;
  set<string> S;
  string s;
  REP(i, N) {
    cin >> s;
    S.insert(s);
  }

  cout << S.size() << endl;

  return 0;
}

Measured memory_bytes: 19204
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			double[] a = new double[11];
			a[1]=cin.nextDouble();
			double sum = 0;
			sum = a[1];
			for(int i = 2; i < 11; i++){
				if(i%2==0){
					a[i]=a[i-1]*2;
				}
				else{
					a[i]=a[i-1]/3.0;
				}
				sum += a[i];
			}
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 12000
n = gets.to_i
a = gets.split.map(&:to_i)
a.push(0)
m = 1000
s = 0
bp = 0
sp = 0
tr = -1
for i in 1..n do
  if a[i - 1] < a[i]
    if tr < 0
      bp = i - 1
    end
    tr = 1
  elsif a[i - 1] > a[i]
    if tr > 0
      sp = i - 1
#      puts "#{bp} #{sp}"
      ss = m / a[bp]
      s += ss
      m -= a[bp] * ss
#      puts "buy  #{m} #{s}"
      m += a[sp] * s
      s = 0
#      puts "sell #{m} #{s}"
    end
    tr = -1
  end
end
puts m


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int app() {
  COMinit();
  int x,y;
  cin>>x>>y;

  if((x+y)%3!=0) return 0;

  int a,b;
  a=(x*2-y)/3;
  b=(y*2-x)/3;

  return COM(a+b,a);
}

int main(){cout<<app()<<endl;return 0;}


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

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

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


int main(void){
    long a,b;
    cin >> a >> b;
    
    cout << lcm(a,b) << endl;
}


Measured memory_bytes: 3600
N,M=[int(x) for x in raw_input().split()]
A=[[] for i in range(N)]
B=[[] for i in range(N)]
C=[-1 for i in range(N)]
D=[0 for i in range(N)]
E=[0 for i in range(N)]

for i in range(M):
    a,b=[int(x)-1 for x in raw_input().split()]
    A[a].append(b) #to
    B[b].append(a) #from
F=[]
s=0
for i in range(N):
    D[i]=len(B[i])
    if D[i]==0:
        F.append(i)
        C[i]=0
        for a in A[i]:
            E[a]+=1
        s+=1
level=0
while s<N:
    level+=1
    Fnew=[]
    T=[]
    for f in F:
        for a in A[f]:
            if E[a]==D[a]:
                C[a]=level
                Fnew.append(a)
                s+=1
                E[a]=0
                for aa in A[a]:
                    T.append(aa)
    F=Fnew[:]
    for aa in T:
        E[aa]+=1
print max(C)


Measured memory_bytes: 56732
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[3007],b[3007];
int dp[3007],vis[3007],path[3007][3007];
int c[3007];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,t;
    cin>>n>>t;
    for(int i=1;i<=n;++i)
        cin>>a[i]>>b[i];
    int m=t-1;
    for(int i=1;i<=n;++i){
        for(int j=m;j>=a[i];--j){
            if(dp[j]<dp[j-a[i]]+b[i]){
                dp[j]=dp[j-a[i]]+b[i];
                path[i][j]=1;
            }
        }
    }
    int tamp=m;
    int cnt=0;
    int ans=dp[m];
    for(int i=n;i;--i){
        if(path[i][tamp]){
            vis[i]=1;
            tamp-=a[i];
        }
    }
    for(int i=1;i<=n;++i)
        if(!vis[i])
            c[++cnt]=b[i];
    int mx=0;
    for(int i=1;i<=cnt;++i)
        mx=max(mx,c[i]);
    ans+=mx;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

vector<vector<int>> g;
vector<bool> seen;
vector<int> d;


int main(){
   int n,m;
   cin >> n >> m;
   g.resize(n);
   seen.resize(n,false);
   d.resize(n,-1);
   d[0] = 0;
   rep(i,m){
      int x,y;
      cin >> x >> y;
      x--;y--;
      g[x].push_back(y);
      g[y].push_back(x);
   }

   queue<int> q;
   auto push = [&](int x){
      q.push(x);
   };
   push(0);
   while(!q.empty()){
      int nx = q.front();q.pop();
      seen[nx] = true; 
      for (auto w:g[nx]){
         if (seen[w] == true) continue;
         push(w);
         if (d[nx] != -1){
            d[w] = d[nx]+1;
         } 
      }
   }
   //rep(i,n) {
   //   if (d[i] == -1) continue;
   //   cout << d[i] << endl;
   //}
   if (d[n-1] != 2) cout << "IMPOSSIBLE" << endl;
   else cout << "POSSIBLE" << endl;
    return 0;
    
}



Measured memory_bytes: 13168
while(True):
    a=list(map(int,input().split()))
    if(a[0]==0 and a[1]==0):
        break
    for x in range(a[0]):
        if x==0 or x==a[0]-1:
            print("#"*a[1])
        else:
            print("#"+"."*(a[1]-2)+"#")
    print()

Measured memory_bytes: 7668
#include <cstdio>
int main(){
	int n, b, f, r, p;
	scanf("%d", &n);
	int h[4][3][10];
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				h[i][j][k] = 0;
			}
		}
	}
	while(n-- > 0){
		scanf("%d%d%d%d", &b, &f, &r, &p);
		h[b-1][f-1][r-1] += p;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				printf(" %d", h[i][j][k]);
			}
			puts("");
		}
		if(i < 3){
			for(int j = 0; j < 20; j++){
				putchar('#');
			}
			puts("");
		}
	}
}


Measured memory_bytes: 2760
N=int(input())
A=list(map(int,input().split()))
Min=min(A)
Max=max(A)
if Min>=0:
    cnt=N-1
    ans=[]
    for i in range(1,N):
        ans.append((i,i+1))
elif Max<=0:
    cnt=N-1
    ans=[]
    for i in range(N-1,0,-1):
        ans.append((i+1,i))
else:
    if abs(Min)>=abs(Max):
        idx=A.index(Min)
        ans=[]
        cnt=2*N-1
        for i in range(N):
            ans.append((idx+1,i+1))
        for i in range(N-1,0,-1):
            ans.append((i+1,i))
    elif abs(Min)<abs(Max):
        idx=A.index(Max)
        ans=[]
        cnt=2*N-1
        for i in range(N):
            ans.append((idx+1,i+1))
        for i in range(1,N):
            ans.append((i,i+1))
print(cnt)
for i in range(cnt):
    print(str(ans[i][0])+' '+str(ans[i][1]))

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


int main()
{
    int a,b;
    cin>>a>>b;
    
    if(a>=b)
    {
        for(int i=0;i<a;++i)
        {
            cout<<b;
        }
    }
    else
    {
        for(int i=0;i<b;++i)
        {
            cout<<a;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
def resolve():
    n, w = map(int, input().split())
    goods = [list(map(int, input().split())) for _ in range(n)]
    dp = [[0] * (w + 1) for _ in range(n + 1)]

    for i in range(1, n + 1):
        for j in reversed(range(w + 1)):
            tmp = dp[i - 1][j - goods[i - 1][0]] + goods[i - 1][1] if j >= goods[i - 1][0] else 0
            dp[i][j] = max(dp[i - 1][j], tmp)

    print(dp[n][w])

resolve()

Measured memory_bytes: 120412
#include <iostream>
#include <string>

using namespace std;

int main(){
	int bas[26],bat[26],l;
	bool flag = true;
	for(int i=0;i<26;++i){
		bas[i] = -1;
		bat[i] = -1;
	}
	string s,t;
	cin >> s;
	cin >> t;
	l = s.length();
	for(int i=0;i<l;++i){
		int k = s[i] - 97;
		if(bas[k] != -1){
			if(t[i] != t[bas[k]]){
				flag = false;
				break;
			}
		}
		bas[k] = i;
	}
	for(int i=0;i<l;++i){
		int k = t[i] - 97;
		if(bat[k] != -1){
			if(s[i] != s[bat[k]]){
				flag = false;
				break;
			}
		}
		bat[k] = i;
	}
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 776
// 2019年09月09日 (月曜日) 20:35:02
#include <bits/stdc++.h>
using namespace std;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

// void chmin(int &a, int b) {
//     if (a > b) a = b;
// }
// int chmin(int a, int b) {
//     if (a > b) a = b;
//     return a;
// }

int N, A, B, C;
vi  L;

int rec(int i, int a, int b, int c) {
    if (i == N) {
        // 終わったのに確定してない場合、解無し。
        // しかし、今回の条件では必ず解が出るようになっている。
        if (!a || !b || !c) return INF;
        // +-1+10などとしたこねくり回した差分を返す。＝答え
        return abs(a - A) + abs(b - B) + abs(c - C);
    }

    int res = rec(i + 1, a, b, c);

    // 再帰型の全探索
    // 常に最後まで検索して、最小値を記録していく。
    // i番目の最小を決める。
    res = min(res, rec(i + 1, a + L[i], b, c) + (a ? 10 : 0));
    res = min(res, rec(i + 1, a, b + L[i], c) + (b ? 10 : 0));
    res = min(res, rec(i + 1, a, b, c + L[i]) + (c ? 10 : 0));
    // 前半、記録してある最小値。
    // 中 a,b,cのどれかに木を足していく作業。 再帰 DFS
    // 後半、aが存在しているなら２本以上なので+10していく。

    // 何故木が重複しないのか？
    // それは木を１本づつ（iはその場で足すだけ）順番に見ていくので
    // 同じ木を再利用することはない。

    // 必要な魔力を返す。
    return res;
}

int main() {
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    cout << rec(0, 0, 0, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class Bridge{
public:
  int V;
  vector<vector<int> > G;
  vector<int> ord;
  vector<int> low;
  int ok;

  Bridge():V(-1),ok(false){};
  Bridge(int V):V(V),G(V),ord(V),low(V),ok(false){};
  
  void add_edge(int a,int b){
    ok = false;
    assert(a >=0 && b >= 0 && a < V && b < V);
    G[a].push_back(b);
    G[b].push_back(a);
  }

  void build(){
    ok = true;
    ord.clear(); ord.resize(V,-1);
    low.clear(); low.resize(V,-1);
    
    int cnt = 0;
    function<int(int,int)> dfs=[&](int pos,int pre){
      if(ord[pos] != -1) return low[pos];
      ord[pos] = low[pos] = cnt++;
      for(int to:G[pos]) if(to != pre) low[pos] = min(low[pos], dfs(to, pos));
      return low[pos];
    };

    for(int i=0;i<V;i++) low[i] = dfs(i, -1);
  }

  int isBridge(int a,int b){
    assert(ok);
    assert(a < V && b < V);
    assert(a >= 0 && b >= 0);
    if(ord[a] > ord[b]) swap(a, b);
    return ord[a] < low[b];
  }

};

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int V,E;
  cin>>V>>E;
  
  Bridge A(V);
  for(int i=0;i<E;i++){
    int a,b;
    cin>>a>>b;
    A.add_edge(a,b);
  }

  A.build();
  typedef pair<int,int> P;
  vector<P> ans;
  for(int i=0;i<V;i++)
    for(int j:A.G[i]) if(i < j && A.isBridge(i, j)) ans.push_back(P(i,j));
  
  sort(ans.begin(),ans.end());
  for(auto p:ans) cout<<p.first<<" "<<p.second<<endl;

  return 0;
}



Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<bool> vbl;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long>> vpl;
typedef vector<vector<long long>> mll;
typedef vector<string> vst;
const ll MOD = 1000000007;
const ld PI = 2 * acos(0.0);
#define maximize(x, y) x = min(x, y);
#define minimize(x, y) y = max(x, y);
#define square(x) ((x) * (x))
#define cube(x) ((x) * (x) * (x))

struct LineContainer {
   private:
    struct Line {
        mutable long long slope, constt, p;
        bool operator<(const Line &o) const {
            return slope < o.slope;
        }
        bool operator<(long long x) const {
            return p < x;
        }
    };

    multiset<Line, less<>> lines;
    // (for doubles, use inf = 1/.0, div(a,b) = a/b)
    bool __is_max_query = false;
    const long long inf = LLONG_MAX;
    long long __div(long long a, long long b) {  // floored division
        return a / b - ((a ^ b) < 0 && a % b);
    }
    bool __intersect(multiset<Line>::iterator x, multiset<Line>::iterator y) {
        if (y == lines.end()) {
            x->p = inf;
            return false;
        }
        if (x->slope == y->slope)
            x->p = x->constt > y->constt ? inf : -inf;
        else
            x->p = __div(y->constt - x->constt, x->slope - y->slope);
        return x->p >= y->p;
    }

   public:
    LineContainer(bool is_max = false) {
        this->__is_max_query = is_max;
    }
    void add(long long slope, long long constt) {
        if (!__is_max_query) {
            slope = -slope;
            constt = -constt;
        }
        auto z = lines.insert({slope, constt, 0}), y = z++, x = y;
        while (__intersect(y, z))
            z = lines.erase(z);
        if (x != lines.begin() && __intersect(--x, y))
            __intersect(x, y = lines.erase(y));
        while ((y = x) != lines.begin() && (--x)->p >= y->p)
            __intersect(x, lines.erase(y));
    }
    long long query(long long x) {
        assert(!lines.empty());
        auto l = *lines.lower_bound(x);
        return (l.slope * x + l.constt) * (__is_max_query ? 1 : -1);
    }
};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    LineContainer lhc(false);
    long long n, c;
    cin >> n >> c;
    vector<long long> h(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    vector<long long> dp(n, 0);
    deque<pair<long long, long long>> q;
    lhc.add(-2 * h[0], h[0] * h[0]);
    for (int i = 1; i < n; i++) {
        dp[i] = lhc.query(h[i]) + h[i] * h[i] + c;
        lhc.add(-2 * h[i], h[i] * h[i] + dp[i]);
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;
ll a[N];

int main()
{
    ll n,sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
		sum %= mod;
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		sum = (sum - a[i] + mod) % mod;
		ans = ans + sum * a[i] % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

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

	if(c-(a-b)>0)
		cout<<c-(a-b)<<endl;
	else
		cout<<0<<endl;


	return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappush, heappop

def solve():
    N, K = map(int, input().split())
    Ps = list(map(int, input().split()))

    ans = N - K + 1

    numAsc = 0
    num = 0
    P0 = -1
    for P in (Ps+[-1]):
        if P0 < P:
            num += 1
        else:
            if num >= K:
                numAsc += num-K+1
            num = 1
        P0 = P
    if numAsc > 0:
        ans -= numAsc - 1

    if K > 2:
        mins = [N] * N
        P = min(Ps[:K+1])
        mins[0] = P
        PQ = [(P, i) for i, P in enumerate(Ps[:K+1])]
        heapify(PQ)
        for i in range(K+1, N):
            heappush(PQ, (Ps[i], i))
            while True:
                P, pos = heappop(PQ)
                if i-K <= pos:
                    mins[i-K] = P
                    heappush(PQ, (P, pos))
                    break

        maxs = [-1] * N
        P = max(Ps[:K+1])
        maxs[0] = P
        PQ = [(-P, i) for i, P in enumerate(Ps[:K+1])]
        heapify(PQ)
        for i in range(K+1, N):
            heappush(PQ, (-Ps[i], i))
            while True:
                P, pos = heappop(PQ)
                if i-K <= pos:
                    maxs[i-K] = -P
                    heappush(PQ, (P, pos))
                    break

        isSorteds = [False] * N
        num = 0
        P0 = -1
        for i, P in enumerate(Ps+[-1]):
            if P0 < P:
                num += 1
                if num >= K-1:
                    isSorteds[i-K+1] = True  ###
            else:
                if num >= K:
                    numAsc += num-K+1
                num = 1
            P0 = P

        for i in range(N-K):
            L, R = Ps[i], Ps[i+K]
            minK, maxK = mins[i], maxs[i]
            if L == minK and R == maxK and not isSorteds[i]:
                ans -= 1

    print(ans)


solve()


Measured memory_bytes: 63656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<queue>
using Graph =vector<vector<int>>;

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

int main() {
    int k;
    cin>>k;
    int64_t Sum=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                Sum+=gcd(gcd(a,b),c);
            }
        }
    }
    cout<<Sum<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    string h = "hi";
    bool ok = false;
    int i = 0;
    for(int i = 0; i < 5; i++) {
        if(s == h)   
            ok = true;
        h += "hi";
    }
    
    if(ok)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
    return 0;
}

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

const int N = 1e5 + 10;
int n,m;
vector <int> a[N];
int deg[N],Res[N];
void doc() {
}
void solve() {
    int n;
    cin >> n;
    vector <int> A;
    long long Res = 0;
    for (int i = 0; i < n; i++) {
        int x,y;
        cin >> x >> y;
        Res -= y;
        A.push_back(x + y);
    }
    sort(A.begin(),A.end(),greater<int>());
    for (int i = 0; i < n; i += 2) Res += A[i];
    cout << Res;
}
int main(){
    doc();
	solve();
}


Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
const ll inf = 1e18+1;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool  Array_check(ll y, ll x,ll d,ll w) {
	if (x < 0 || x >= w || y<0 || y>=d) {
		return false;
	}
	else {
		return true;
	}
	
}
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;
}
//小文字=大文字+32
int main() {
	
	int n;
	int k;
	cin >> n>>k;
	vector<ll>h(n);
	vector<ll>cost(n);
	rep(i, n) {
		cin >> h[i];
		cost[i] = inf;
	}
	cost[0] = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < min(k,i)+1;j++) {
			chmin(cost[i],cost[i-j] + labs(h[i] - h[i-j]));
		}
	}
	cout << cost[n - 1];
	
}


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

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

  int ret = 0;
  int lvl = 0;
  for (char c : s) {
    if (c == 'S') {
      ++lvl;
    } else {
      if (--lvl < 0) {
        ++ret;
        lvl = 0;
      }
    }
  }
  cout << (ret + lvl) << "\n";
  return 0;
}


Measured memory_bytes: 640
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int a, b; scan(a, b);
    writeln(max(a + b, a - b, a * b));
}


Measured memory_bytes: 256
//This Message Will Self-Destruct in 5s

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    map<int,int>m{},l{};
    rep(i,0,n){
        m[a[i]-i]++;
        l[a[i]+i]++;
    }
    int ans = 0;
    for(auto i:m){
        ans+=l[-i.first]*i.second;
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 38904
package main

import "fmt"

func main() {
  var A, B, C, K int
  fmt.Scan(&A, &B, &C, &K)
  
  if K <= A {
    fmt.Println(K)
  } else if K-A <= B {
    fmt.Println(A)
  } else {
    fmt.Println(A-(K-A-B))
  }
}

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

int main() {
    //
    int num;

    cin >> num;

    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            if(i*4 + j*7 == num){
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";
    //
}


Measured memory_bytes: 3612