akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	int n;
	cin>>n;
	set<int>s;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		s.insert(a);
	}
	if(s.size()==n){
		cout<<"YES";
	}else{
		cout<<"NO";
	}
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
inline void solve()
{
	ll n,m;cin>>n>>m;
	while(m--)
	{
		ll x;
		cin>>x;
		n-=x;
	}
	cout<<(n>=0?n:-1)<<endl;
}
int main()
{
	IOS();
	solve();
	return 0;
}




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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

const int mini = -1000000;
const int maxi = 1000000;

int main(){
  int K, X;
  cin >> K >> X;

  FOR(i, max(mini, X-K+1), min(maxi, X+K)){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n, m;
	cin >> n >> m;
	int corr = 0, pena = 0;
	map<int, int> ma;
	vector<int> ac(n);
	forn(i, m) {
		int p;
		cin >> p;
		string s;
		cin >> s;
		if(!ac[p-1]) {
			if(s == "WA") ma[p]++;
			else {
				corr++;
				pena += ma[p];
				ac[p-1] = true;
			}
		}
	}
	cout << corr << " " << pena << endl;
	return 0;
}



Measured memory_bytes: 8164
#include<bits/stdc++.h>
using namespace std;
bool all(const vector<bool>&xs){
  for(const auto&x:xs)if(!x)return false;
  return true;
}
void Print(const vector<bool>&xs){
  for(const auto&x:xs)cout<<x<<",";
}
int N,M;
vector<vector<bool>>xss;
int f(int from,vector<bool>visited){
  visited[from]=true;
  // cout<<from<<"...";Print(visited);cout<<endl;
  if(all(visited))return 1;
  int n_paths=0;
  for(int i=0;i<N;++i){
    if(xss[from][i]&&!visited[i])
      n_paths+=f(i,visited);
  }
  return n_paths;
}
main(){
  cin>>N>>M;
  xss=vector<vector<bool>>(N,vector<bool>(N));
  for(int i=1;i<=M;++i){
    int a,b;
    cin>>a>>b;
    --a;
    --b;
    xss[a][b]=true;
    xss[b][a]=true;
  }
  int n_paths=f(0,vector<bool>(N));
  cout<<n_paths<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <bitset>
#include <algorithm>

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

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


int main() {
    ll a;
    double b;
    cin >> a >> b;

    int b_int = b * 100 + 0.5;
    ll ans = (a * b_int) / 100;
    cout << ans << endl;
}

Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

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

int main(){
    int N, K;   cin >> N >> K;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    for(int i = 0; i < K; i++){
        vector<int> nex(N+1, 0);
        for(int j = 0; j < N; j++){
            int s = max(0, j - a[j]);
            int e = min(N, j + a[j] + 1);
            nex[s]++;
            nex[e]--;
        }
        for(int j = 0; j < N; j++){
            nex[j+1] += nex[j];
            a[j] = nex[j];
        }

        bool al = true;
        for(int j = 0; j < N; j++){
            if(a[j] < N){
                al = false;
            }
        }
        if(al){
            break;
        }
    }

    for(int i = 0; i < N; i++){
        cout << a[i] << " ";
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 4760
#include <iostream>

using namespace std;

typedef long long ll;

ll dp[405][405];
ll a[405];
int n;
const ll INF = 1e14;
ll rec(int l, int r) {
  if(l + 1 >= r) return 0;
  if(dp[l][r] != INF) return dp[l][r];

  ll res = INF;
  for(int i = l + 1; i < r; i++) {
    res = min(res,rec(l,i) + rec(i,r) + a[r] - a[l]);
  }
  // cout << "dp["<<l<<"]["<<r<<"] = "<<res << endl;
  return dp[l][r] = res;
}


int main() {
  cin >> n;

  for(int i = 1; i <= n; i++) {
    int A;
    cin >> A;
      a[i] = a[i-1] + A;
    }

  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= n; j++) {
      dp[i][j] = INF;
    }
  }

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


Measured memory_bytes: 1536
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    string str;
    cin >> str;
    long long sum = 0;

    for (int i = 0; i < str.length(); i++)
    {
        string temp;
        temp += str[i];
        sum += stoi(temp);
    }
    sum % 9 == 0 ? cout << "Yes" : cout << "No";
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

signed main() {
  int X,K,D; cin >> X >> K >>D;
  if(X < 0) X = -X;
  int ans = 0;
  if((double)X > (double)K * (double)D){
    ans = X - K * D;
    PRINT("test")
  }
  else{
    if((X/D) % 2 == 1 && K%2 == 1){
      ans = X % D;
      PRINT("1")
    } else if ((X / D) % 2 != 1 && K % 2 != 1) {
      ans = X % D;
      PRINT("2")
    } else {
      ans = D - X % D;
      PRINT("3")
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const int Mod = 998244353;
const int MN = 100005, MS = 1 << 9;

inline void Add(int &x, int y) { x -= (x += y) >= Mod ? Mod : 0; }

int N, f1[MN], f2[MN], f3[MN];
std::vector<int> G1[MN], G2[MN], G3[MN];

inline void ReadGraph(std::vector<int> *G) {
	int M;
	scanf("%d", &M);
	while (M--) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x > y) std::swap(x, y);
		G[x].push_back(y);
	}
}
inline void SolveSG(std::vector<int> *G, int *f) {
	static int buk[MN];
	for (int i = N; i >= 1; --i) {
		for (int x : G[i]) buk[f[x]] = 1;
		f[i] = 0;
		while (buk[f[i]]) ++f[i];
		for (int x : G[i]) buk[f[x]] = 0;
	}
}

int pw[MN];
int b1[MS], b2[MS], b3[MS], Ans;

int main() {
	scanf("%d", &N);
	ReadGraph(G1);
	ReadGraph(G2);
	ReadGraph(G3);
	SolveSG(G1, f1);
	SolveSG(G2, f2);
	SolveSG(G3, f3);
	pw[0] = 1;
	for (int i = 1; i <= N; ++i) pw[i] = pw[i - 1] * 716070898ll % Mod;
	for (int i = 1; i <= N; ++i) Add(b1[f1[i]], pw[i]);
	for (int i = 1; i <= N; ++i) Add(b2[f2[i]], pw[i]);
	for (int i = 1; i <= N; ++i) Add(b3[f3[i]], pw[i]);
	for (int i = 0; i < MS; ++i)
		for (int j = 0; j < MS; ++j)
			Ans = (Ans + (LL)b1[i] * b2[j] % Mod * b3[i ^ j]) % Mod;
	printf("%d\n", Ans);
	return 0;
} // vjudge pink_rabbit

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 2000005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    combInit();
    int x, y;
    cin >> x >> y;
    int n, m;
    if((y - 2 * x) % 3 != 0 ) {
        cout << 0 << endl;
        return 0;

    }

    m = (y - 2 * x) / (-3);
    n = x - (2 * m);

    if( n < 0 || m < 0 ) {
        cout << 0;

    } else {
        cout << comb(n + m, n);

    }
    cout << endl;

    return 0;
}



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

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

    int n, m;
    cin >> n >> m;
    vector<int> A(n, 0);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        A[a]++;
        A[b]++;
    }

    for(auto x : A){
        cout << x << endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		double r = scanner.nextDouble();
		
		System.out.print(String.format("%.6f", r * r * Math.PI) + " " + String.format("%.6f", 2 * r * Math.PI));
	}
} 



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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int main() {

	FAST;

	int n;
	cin >> n;
	int k = n % 10;
	if (k == 2 || k == 4 || k == 5 || k == 7 ||
		k == 9) cout << "hon\n";
	else if (k == 0 || k == 1 || k == 6 || k == 8) cout << "pon\n";
	else cout << "bon\n";
	return 0;
}

Measured memory_bytes: 3556
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math, std.typecons;


void main() {
    int n, q;
    scan(n, q);

    auto wuf = WeightedUnionFind!int(n);

    foreach (_ ; 0 .. q) {
        auto line = readln.split.to!(int[]);

        if (line[0] == 0) {
            wuf.merge(line[1], line[2], line[3]);
        }
        else {
            auto dif = wuf.diff(line[1], line[2]);
            writeln(dif < int.max ? dif.to!string : "?");
        }
    }
}



struct WeightedUnionFind(T) {
    private {
        int[] _parent, _rank;
        T[] _diff;
    }

    this(int N) {
        _parent = new int[](N);
        _rank = new int[](N);
        _diff = new T[](N);

        foreach (i ; 0 .. N) {
            _parent[i] = i;
        }
    }

    int findRoot(int x) {
        if (_parent[x] != x) {
            int r = findRoot(_parent[x]);
            _diff[x] += _diff[_parent[x]];
            _parent[x] = findRoot(r);
        }

        return _parent[x];
    }

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

    T weight(int x) {
        findRoot(x);
        return _diff[x];
    }

    // x, y が異なるグループに属すならinf(十分大きい値)を返す
    T diff(int x, int y) {
        return same(x, y) ? weight(y) - weight(x) : T.max;
    }

    import std.algorithm : swap;

    // weight(y) = weight(x) + w
    bool merge(int x, int y, T w) {
        w += weight(x) - weight(y);

        int u = findRoot(x);
        int v = findRoot(y);

        // x, y が既に同じグループであるなら距離の更新はしない
        if (u == v) return false;

        if (_rank[u] < _rank[v]) {
            swap(u, v);
            w = -w;
        }

        if (_rank[u] == _rank[v]) {
            _rank[u]++;
        }

        _parent[v] = u;
        _diff[v] = w;

        return true;
    }
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



Measured memory_bytes: 4520
#include <stdio.h>
int main(void){
	int a[3];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	int i, j, tmp;
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(a[i]<a[j]){
				tmp		=	a[i];
				a[i]	=	a[j];
				a[j]	=	tmp;
			}
		}
	}
	int ans = 0;
	ans += a[0]-a[1];
	a[2] += ans;
	if((a[0] - a[2])%2 == 0){
		ans += (a[0]-a[2])/2;
		printf("%d",ans);
		return 0;
	}else{
		ans += (a[0]-a[2])/2;
		ans +=2;
		printf("%d",ans);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    ll N,M; cin >> N >> M;
    vector<ll> red(N); red[0]=1;
    vector<ll> total(N);
    for(ll i=0;i<N;i++)total[i]=1;

    for(ll i=0;i<M;i++){
        ll x,y; cin >> x >> y; x--;y--;
        if(red[x]){
            if(total[x]==0) {red[x]=0;}
            if(total[x]==1) {red[x]=0; red[y]=1;}
            else red[y]=1;
        }
        total[x]--; total[y]++;
    }
    ll ans=0;
    for(ll i=0;i<N;i++){
        if(red[i]&&total[i])ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE a(n), b(n); rep(i, n)cin >> a[i] >> b[i];
	vector<P>tmp;
	rep(i, n)tmp.push_back(make_pair(a[i], b[i]));
	sort(ALL(tmp));
	int ans = 0;
	rep(i, n) {
		ans += tmp[i].first * min(m, tmp[i].second);
		m -= min(m, tmp[i].second);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3956
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=1000000007;
const int N=100050;
int a[205],f[205],d[205],dp[205][N];
void exgcd(int a,int b,int &x,int &y){
	if(!b){x=1;y=0;}
	else{
		exgcd(b,a%b,y,x);
		y-=a/b*x;
	}
}
inline int inv(int a){
	int x,y;
	exgcd(a,mod,x,y);
	return x<0?x+mod:x;
}
int dfs(int m,int x){
	if(!m)return x;
	if(x<a[1])return (ll)x*f[m]%mod;
	if(dp[m][x]!=-1)return dp[m][x];
	int i,ans=0;
	for(i=1;i<=m;++i)ans=(ans+(ll)dfs(i-1,x%a[i])*f[m-1]%mod*d[i-1])%mod;
	return dp[m][x]=ans;
}
int main(){
	int n,x,i;
	scanf("%d%d",&n,&x);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	sort(a+1,a+n+1);
	f[0]=f[1]=d[0]=d[1]=1;
	for(i=2;i<n;++i){
		f[i]=(ll)f[i-1]*i%mod;
		d[i]=inv(f[i]);
	}
	memset(dp,-1,sizeof(dp));
	printf("%d\n",dfs(n,x));
	return 0;
}

Measured memory_bytes: 80384
/**
 *  author: Haunted_Cpp
**/
 
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
 
template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
 
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
 
#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

typedef long long i64;
typedef pair<long, long> pi64;

const int MAX_N = 1e6 + 5;
const i64 INF = 1e18;

i64 arr[MAX_N], dp[MAX_N];

i64 f(pi64 linha, int x) {
	return linha.first * x + linha.second;
}

struct LiChao {
	const int L;
	vector<pi64> seg;
	LiChao(int n) : L(n + 5) {
		seg.clear();
		seg = vector<pi64>(4 * L, {0, INF});
	}
	void add(pi64 linha, int l, int r, int node) {
		int mid = l + (r - l) / 2;
		bool left = f(linha, l) < f(seg[node], l);
		bool middle = f(linha, mid) < f(seg[node], mid); 
		if (middle) {
			swap(seg[node], linha);
		}
		if (r == l) {
			return;
		} else if (left != middle) {
			add(linha, l, mid, 2 * node + 1);
		} else {
			add(linha, mid + 1, r, 2 * node + 2);
		}	
	}
	i64 get(int l, int r, int where, int node) {
		int mid = l + (r - l) / 2;
		if (r == l) {
			return f(seg[node], where);
		} else if (where < mid) {
			return min(f(seg[node], where), get(l, mid, where, 2 * node + 1));
		} else {
			return min(f(seg[node], where), get(mid + 1, r, where, 2 * node + 2));
		}
	}
};

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  i64 c;
  cin >> n >> c;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	LiChao hull(MAX_N);
	dp[0] = 0;
	hull.add({-2 * arr[0], dp[0] + c + arr[0] * arr[0]}, 0, MAX_N, 0);
	for (int i = 1; i < MAX_N; i++) dp[i] = INF;
	for (int i = 1; i < n; i++) {
		dp[i] = hull.get(0, MAX_N, arr[i], 0) + arr[i] * arr[i];
		hull.add({-2 * arr[i], dp[i] + c + arr[i] * arr[i]}, 0, MAX_N, 0);
	}
	cout << dp[n - 1] << '\n';
  return 0;
}


Measured memory_bytes: 74992
#include <stdio.h>
int a,b,k,cnt;
int min(int x,int y){
  return x<y?x:y;
}
int main(void){
  scanf("%d%d%d",&a,&b,&k);
  int ans;
  for(ans=min(a,b);ans>=1;--ans)
    if(a%ans==0&&b%ans==0){
      ++cnt;
      if(cnt==k) break;
    }
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

int main(){
	int N, Y;
	cin >> N >> Y;
	int flag = 0;
	for(int i = 0; i <= N; i++){
		if(i*10000 > Y || flag == 1){
			break;
		}
		for(int j = 0; j <= N-i; j++){
			if(i*10000+j*5000 > Y || flag == 1){
				break;
			}
			if(i*10000+j*5000+(N-i-j)*1000 == Y){
				cout << i << " " << j << " " << N-i-j << "\n";
				flag = 1;
			}
		}
	}
	if(flag == 0){
		cout << "-1 -1 -1\n";
	}
}


Measured memory_bytes: 256
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

ans=0

for i in range(n-1):
    if(a[i]+a[i+1]>x):
        rem =  a[i+1] + a[i] - x
        if(rem<=a[i+1]):
            a[i+1]-=rem
        else:
            rem-=a[i+1]
            ans+=a[i+1]
            a[i]-=rem
            a[i+1]=0
        ans+=rem
print(ans)


Measured memory_bytes: 14132
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	vector<int> dif(N-1);
	int max = v.at(N - 1);
	for (int i = N-2; i >= 0; i--) {
		int n = v.at(i);
		if (n < max) {
			dif.at(i) = abs(max - n);
		}
		else {
			max = n;
		}
	}

	sort(dif.begin(), dif.end());
	reverse(dif.begin(), dif.end());

	cout << count(dif.begin(), dif.end(), dif.at(0)) << endl;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //切り出しする文字列
        int K = sc.nextInt();
        String S = sc.next();
        if(S.length() <= K){
            System.out.println(S);
        }else{
            System.out.println(S.substring(0,K) + "...");
        }
    }
}


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


int main(){
    int n;
    cin>>n;
    vector<int> hights(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>hights[i];
    }
    vector<int> dp(n+1,0);
    dp[2] =abs(hights[2]-hights[1]);
    
    for(int i=3;i<=n;i++){
        dp[i] = min(dp[i-1]+abs(hights[i]-hights[i-1]),dp[i-2]+abs(hights[i]-hights[i-2]));
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#define int long long
using namespace std;
int n,m,a[200010],s[200010],f[200010],q[200010],front=1,back=0;
double getslope(int i,int j){
	return (double)(f[i]+s[i]*s[i]-f[j]-s[j]*s[j])/(double)(2*s[i]-2*s[j]);
}
signed main(){
	scanf("%lld %lld",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",&s[i]);
	front=1;
	back=0;
	q[++back]=1;
	for(int i=2;i<=n;i++){
		while(front<back&&getslope(q[front+1],q[front])<=s[i]) front++;
		f[i]=f[q[front]]+(s[i]-s[q[front]])*(s[i]-s[q[front]])+m;
		while(front<back&&getslope(i,q[back])<=getslope(q[back],q[back-1])) back--;
		q[++back]=i;
	}
	printf("%lld\n",f[n]);
}

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

int main() {

    double x, y, s;

    cin >> x >> y >> s;

    s /= x;

    double h;
    double theta;
    if(x * y / 2 <= s) {

        h = 2 * (x * y - s) / x;
        theta = atan2(h, x);
    }
    else {
        h = 2 * s / y;
        theta = atan2(y, h);
    }

    double pi = acos(-1);

    printf("%.10f", theta / (pi * 2) * 360);


}

Measured memory_bytes: 512
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count=0

for i in range(0,a+1,1):
    for j in range(0,b+1,1):
        for k in range(0,c+1,1):
            if i*500+j*100+k*50==x:
                count+=1

print(count)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
       int n = sc.nextInt();
       int[] p = new int[n];
       for (int i = 0; i < n; i++) {
           p[i] = sc.nextInt();
       }
       int ans = 0;
       for (int i = 0; i < n; i++) {
           if (i < n-2) {
               if ((p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2])) {
                   ans++;
               }
           }
       }
       System.out.println(ans);
    }

}


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

void solve(){

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

    int n;
    cin>> n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int cnt1=0,cnt2=0;
    sort(a.begin(),a.end(),greater<int>());
    rep(i,n){
        if(i%2==0){
            cnt1+=a[i];
        }
        else{
            cnt2+=a[i];
        }
    }
    cout << cnt1 - cnt2;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  


int main(){
  ll n, m, k; cin >> n >> m >> k;
  string ans="No";
  
  for(int i=0; i<=m; i++){
    for(int j=0; j<=n; j++)
      if((n-j)*i+(m-i)*j==k) ans="Yes";
  }
    
    
  
  cout << ans << endl;  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

ll a, b, c, p, q;

int main() {
    cin >> q;
    priority_queue<ll, vector<ll>, greater<>> bigger;
    priority_queue<ll, vector<ll>, less<>> smaller;
    ll sum_bigger = 0, sum_smaller = 0;
    for (ll i = 0; i < q; i++) {
        cin >> c;
        if (c == 1) {
            cin >> a >> b;
            p += b;
            if (bigger.size() == smaller.size()) {
                smaller.push(a);
                sum_smaller += a;
            } else {
                bigger.push(a);
                sum_bigger += a;
            }
            while ((!bigger.empty()) && smaller.top() > bigger.top()) {
                ll s = smaller.top(), t = bigger.top();
                smaller.pop();
                bigger.pop();
                sum_smaller -= s;
                sum_bigger -= t;
                smaller.push(t);
                bigger.push(s);
                sum_smaller += t;
                sum_bigger += s;
            }
        } else if (c == 2) {
            ll r = 0;
            ll center = smaller.top();
            r += center * smaller.size() - sum_smaller;
            r += sum_bigger - center * bigger.size();
            cout << center << ' ' << r + p << endl;
        } else {
            throw;
        }
    }
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m[4][3][10];
    int n;
    cin>>n;
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                m[i][j][k]=0;
            }
        }
    }
    for(int i=0;i<n;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        m[a-1][b-1][c-1]+=d;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout<<' '<<m[i][j][k];
            }
            cout<<endl;
        }
        if(i==3){
            break;
        }
        for(int j=0;j<20;j++){
            cout<<'#';
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3112
package main

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

func uppperBound(a []int, x int) int {
	return sort.Search(len(a), func(i int) bool { return a[i] > x })
}

func scan(n int, s *bufio.Scanner) []int {
	buf := make([]int, n)
	for i := range buf {
		s.Scan()
		v, _ := strconv.Atoi(s.Text())
		buf[i] = v
	}
	return buf
}

func main() {
	var n int
	fmt.Scan(&n)
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	a := scan(n, s)
	b := scan(n, s)
	c := scan(n, s)
	sort.Ints(a)
	sort.Ints(c)
	var ans int64
	for _, e := range b {
		j := sort.SearchInts(a, e)
		k := uppperBound(c, e)
		ans += int64(j) * int64(n-k)
	}
	fmt.Println(ans)
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string a;
  cin >> a;
  map<char,ll> mp;
  rep(i,a.size()){
    mp[a[i]]++;
  }
  ll ans = 1 + a.size() * (a.size() - 1) / 2;
  for(auto x: mp){
    if(x.second == 0) continue;
    ans -= (x.second)*(x.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 100001
#define ll long long
using namespace std;

int main(){
    ll n;
    cin>>n;
    
    vector<ll> a[3];
    
    for (int i=0; i<=2; i++){
        for (ll j=0; j<n; j++){
            ll p;
            cin>>p;
            a[i].push_back(p);
        }
    }
    
    for (int i=0; i<=2; i++) sort(a[i].begin(),a[i].end());
    
    ll sum=0;
    for (ll i=0; i<n; i++){
        ll p,q;
        
        if (a[0][0]>=a[1][i]) continue;
        if (a[2][n-1]<=a[1][i]) continue;
        
        auto it1=lower_bound(a[0].begin(),a[0].end(),a[1][i]);
        p=it1-a[0].begin();
        
        auto it2=upper_bound(a[2].begin(),a[2].end(),a[1][i]);
        auto memo=it2-a[2].begin();
        q=a[2].size()-memo;
        
        sum+=p*q;
    }
    
    cout<<sum<<endl;
}

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

using namespace std;

pair<int, int> p[100010];

int main() {
	int n;
	long long k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p+n);
	for (int i = 0; i < n; ++i) {
		k -= p[i].second;
		if(k <= 0) {
			cout << p[i].first << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
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;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
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;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n,m,k;
    cin>>n>>m>>k;
    vi a(n),b(m);
    rep(i,0,n)cin>>a[i];
    rep(i,0,m)cin>>b[i];
    vll asum(n+1,0),bsum(m+1,0);
    rep(i,0,n)asum[i+1]=asum[i]+a[i];
    rep(i,0,m)bsum[i+1]=bsum[i]+b[i];
    ll ans=0;
    rep(i,0,n+1){
        if(asum[i]>k)break;
        ll rest=k-asum[i];
        //asum[i]との和がkを超える要素
        auto pos=upper_bound(bsum.begin(),bsum.end(),rest);
        if(pos!=bsum.begin())
            pos--;
        if(*pos+asum[i]<=k){
            chmax(ans,(ll)distance(bsum.begin(),pos)+i);
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 7984
#include <cstdio>

using namespace std;

int tbl[10010];
int ans[110][110];

int main () {
	int h,w;
	scanf("%d%d",&h,&w);
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		scanf("%d",&tbl[i]);
	}
	int curr=0,curc=0;
	int di=1;
	for (int i=0;i<n;i++) {
		for (int j=0;j<tbl[i];j++) {
			//printf("%d %d\n",curr,curc);
			ans[curr][curc]=i+1;
			if (curr==h-1&&di==1) {
				di=-1;
				curc++;
			} else if (curr==0&&di==-1) {
				di=1;
				curc++;
			} else {
				curr+=di;
			}
		}
	}
	for (int i=0;i<h;i++) {
		for (int j=0;j<w;j++) {
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256
N = input()
n = len(N)
K = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(N[i])
a.insert(0,0)
dp = [[[0,0,0,0],[0,0,0,0]] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(1,n+1):
    for f in range(2):
        if f == 0:
            for k in range(4):
                if a[i] != 0:
                    if k !=0:
                        dp[i][0][k] = dp[i-1][0][k-1]
                    dp[i][1][k] += dp[i-1][0][k]
                    if k == 3:
                        continue
                    dp[i][1][k+1] += dp[i-1][0][k] * (a[i] - 1)
                if a[i] == 0:
                    dp[i][0][k] = dp[i-1][0][k]
        if f == 1:
            for k in range(4):
                if k!=0:
                    dp[i][1][k] += dp[i-1][1][k] + dp[i-1][1][k-1] * 9
                if k == 0:
                    dp[i][1][k] += dp[i-1][1][k]
ans = dp[n][0][K] + dp[n][1][K]
print(ans)

Measured memory_bytes: 3064
N = int(input())
L = [0 for i in range(86+1)]
for i in range(N+1): 
  if(i == 0):
    L[i] = 2
  elif(i == 1):
    L[i] = 1
  else:
    L[i] = L[i-2] + L[i-1]
print(L[N])

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    char c; cin >> c;
    if(c == 'A') cout << 'T' << endl;
    else if(c == 'C') cout << 'G' << endl;
    else if(c == 'G') cout << 'C' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  sort(all(A));
  VI X(N);
  rep(i,N){
    if(i==0 or i==N-1) X[i]=1*pow(-1,i%2);
    else X[i]=2*pow(-1,i%2);
  }
  sort(all(X));
  ll ans=0;
  rep(i,N) ans+=X[i]*A[i];
  rep(i,N){
    if(i==0 or i==N-1) X[i]=-1*pow(-1,i%2);
    else X[i]=-2*pow(-1,i%2);
  }
  sort(all(X));
  ll tmp=0;
  rep(i,N) tmp+=X[i]*A[i];
  ans=max(ans,tmp);
  cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int x,y;
    cin >> x >> y;
    int r1=INT_MAX;
    int r2=INT_MAX;
    int r3=INT_MAX;
    int r4=INT_MAX;

    if(x<=y) r1 = y-x;
    x = -x;
    if(x<=y) r2 = y-x + 1;
    x = -x;
    y = -y;
    if(x<=y) r3 = y-x + 1;
    x = -x;
    if(x<=y) r4 = y-x + 2;

    cout << min(r1,min(r2,min(r3,r4))) << endl; 

    return 0;
} 

Measured memory_bytes: 384
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    vector<int> A(N);
    REP(i, N)
    cin >> A[i];

    int ans = 0;
    for (int i = 0; i < N; i += 2)
    {
        if (A[i] % 2 == 1)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3196
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long N;
    cin >> N;

    vector<long long> A(N), B(N);
    for (int i = 0; i < N; i++)cin >> A[i] >> B[i];
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        if ((A[i] + ans) % B[i] != 0) {
            long long d = ((A[i] + ans) / B[i]) + 1;
            ans += d * B[i] - (A[i] + ans);
        }
    }

    cout << ans << endl;

}



























Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll fib[100005]{};
ll  fibonacii(int n,int height[])
 {    fib[0]=0;
      fib[1]=0;
       fib[2]=abs(height[2]-height[1]);
    for(int i=3;i<=n;i++)
  {
      fib[i]=min(fib[i-1]+abs(height[i]-height[i-1]),fib[i-2]+abs(height[i]-height[i-2]));
  }
 
  return fib[n];
 }
int main()
{
  int n;
  cin>>n;
  int height[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>height[i];
  }
  cout<<fibonacii(n,height);
  
  return 0;
}

Measured memory_bytes: 4692
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  bool ans = false;
  for (int i = 0; i <= n / 4; i++) {
    if ((n - i * 4) % 7 == 0) {
      ans = true;
      break;
    }
  }
  
  if (ans) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    ll n,k;
    cin >> n >> k;
    int x = n*2;
    int y = n*4;

    if(k>=x && k<=y){
        if(k%2==0) cout << "Yes\n";
        else cout << "No\n";
    }
    else cout << "No\n";
    return 0;
}




Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  map<char,int>cnt;
  map<char,int>::iterator I;
  int i,j,f=0;
  string a;
  cin>>a;
   for(i=0;i<a.size();i++)
   {
      cnt[a[i]]++;
   }

   for(I=cnt.begin();I!=cnt.end();I++)
   {
       if(I->second%2==1)
        f=1;
   }

    if(f==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	ll n,k;
	ll total=0,total2=0;
	ll t2=0;

	cin>>n>>k;
	if(k%2>0){
		rep(i,n){
			if((i+1)%k==0)total++;
		}
		t2=total*total*total;
	}else{
		rep(i,n){
			if((i+1)%k==0)total++;
			else if((i+1)%k==k/2)total2++;
		}
		t2=total*total*total;
		t2+=total2*total2*total2;
	}
	cout<<t2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    int c = 0;
    rep(i, N) {
        if(P[i] - 1 != i)
            c++;
    }
    if(c > 2)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
const ll INF=1<<30;
ll ans=0;


int main()
{ 
string s;
cin >> s; 
vector<ll> v;
ll tem=1;
rep(i,s.size()-1){
    if(s[i]==s[i+1])tem++;
    else {v.push_back(tem);tem=1;}
}
v.push_back(tem);
if(v.size()==1){
    cout << s.size() << endl;
    return 0;
}
if(v.size()==2){
    cout << max(v[0],v[1]) << endl;
    return 0;
}

int l=v[0];
int r=v[v.size()-1];
int ll=0;
int rr=v.size()-1;


for(int aaa = 0; aaa < v.size()-2; aaa++){
    if(l>=r){
        r=r+v[rr-1];
        rr--;
    }
    else{
        l=l+v[ll+1];
        ll++;
    }
}

cout << max(l,r) << endl;
return 0;
} 

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

int dp[502][2][10][500][3], m, len[2];
char S[2][550];

int solve(int o) {
	memset(dp, 0, sizeof(dp));
	dp[0][0][0][0][0] = 1;
	rep(i, len[o])rep(j, 2)rep(k, 10)rep(l, m)rep(d, 3) {
		if (dp[i][j][k][l][d] == 0)continue;
		int s, g, p = S[o][i] - '0';
		if (d == 1) { s = k + 1; g = (j ? 9 : p); }
		else if (d == 2) { s = 0; g = (j ? k - 1 : min(k - 1, p)); }
		else { s = 0; g = (j ? 9 : p); }
		for (int x = s; x <= g; x++) {
			if (x&&k == x)continue;
			int y;
			if (d == 1)y = 2;
			else if (d == 2)y = 1;
			else {
				if (k == 0)y = 0;
				else if (x < k)y = 1;
				else y = 2;
			}
			(dp[i + 1][j || x < p][x][(l * 10 + x) % m][y] += dp[i][j][k][l][d]) %= MOD;
		}
	}
	int sum = 0;
	rep(j, 10)rep(t, 3) {
		(sum += dp[len[o]][1][j][0][t]) %= MOD;
		if (o)(sum += dp[len[o]][0][j][0][t]) %= MOD;
	}
	return sum;
}
int main() {
	scanf("%s%s%d", S[0], S[1], &m);
	rep(i, 2)len[i] = strlen(S[i]);
	printf("%d\n", (solve(1) + MOD - solve(0)) % MOD);
}

Measured memory_bytes: 62032