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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    vi yui(n+1, 0);

    rep(i, m) {
        int2(a, b);
        for (int j = a; j < b; j++) {
            yui[j] = 1;
        }
    }

    int ans = n+1;
    rep(i, yui.size()) {
        ans += 2 * yui[i];
    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N, M; cin >> N >> M;
  if(M<=2) {
    cout << "Yes" << endl;
    return 0;
  }
  vector<pair<pair<ll,ll>,ll>> LRD(M);
  rep(i,M) {
    cin >> LRD[i].first.first >> LRD[i].first.second >> LRD[i].second;
    LRD[i].first.first--;
    LRD[i].first.second--;
    if(LRD[i].first.first>LRD[i].first.second){
      ll tmp = LRD[i].first.first;
      LRD[i].first.first = LRD[i].first.second;
      LRD[i].first.second = tmp;
      LRD[i].second *= -1;
    }
  }
  vector<vector<ll>> g(N);
  vector<vector<ll>> c(N);
  rep(i,M){
    ll l = LRD[i].first.first, r = LRD[i].first.second, d = LRD[i].second;
    g[l].pb(r);
    c[l].pb(d);
    g[r].pb(l);
    c[r].pb(-d);
  }
  vector<ll> pos(N,1e18);
  vector<bool> chk(N,false);
  queue<ll> q;
  rep(m,M){
    if(pos[LRD[m].first.first]==1e18){
      pos[LRD[m].first.first] = 0;
      q.push(LRD[m].first.first);
    }
    while(!q.empty()){
      ll l = q.front(); q.pop();
      if(chk[l]) continue;
      chk[l] = true;
      rep(i,sz(g[l])){
        ll r = g[l][i];
        if(pos[r]!=1e18){
          if(pos[r]-pos[l]!=c[l][i]){
            cout << "No" << endl;
            return 0;
          }
        }
        else{
          pos[r] = pos[l]+c[l][i];
          q.push(r);
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 23040
#include<stdio.h>
#include<stdlib.h>
#define N 256

int main(void){
    int n, i, j;
    int w[100];
    int s1, s2, sa;
    int pre = 10000;

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d", &w[i]);
    }

    for(i = 0; i < n - 1; i++){
        s1 = 0;
        s2 = 0;

        for(j = 0; j <= i; j++){
            s1 += w[j];
        }
        for(j = i + 1; j < n; j++){
            s2 += w[j];
        }
        sa = abs(s2 - s1);
        if(sa > pre) break;
        else pre = sa;
    }

    printf("%d", pre);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    vector<int> vec(3);
    cin>>vec[0]>>vec[1]>>vec[2];
    sort(vec.begin(), vec.end());
    if(vec[0]==vec[1] && vec[1]!=vec[2]){
        cout<<2<<endl;
    }else if(vec[0]!=vec[1] && vec[1]==vec[2]){
        cout<<2<<endl;
    }else if(vec[0]==vec[1] && vec[1]==vec[2]){
        cout<<1<<endl;
    }else{
        cout<<3<<endl;
    }
    return 0;
}

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

int main() {
  
  long long N, A, B; cin >> N >> A >> B;
  
  if((B-A)%2 == 0) cout << (B-A)/2 << endl;
  else cout << min(A-1, N-B) + 1 + (B-A-1)/2 << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner (System.in);
        int n = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();
        int ans[] = new int[n];
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                ans[dist(n,i,j,x,y)]++;
            }
        }
        for(int i=1;i<n;i++) System.out.println(ans[i]);
    }
    public static int dist(int n,int i,int j,int x,int y){
        int ans = j-i;
        int ans2 = Math.abs(x-i)+Math.abs(y-j)+1;
        int ans3 = Math.abs(x-j)+Math.abs(y-i)+1;
        return Math.min(Math.min(ans2, ans3), ans);
    }
}

Measured memory_bytes: 24404
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>

#include<vector>

#define INF 999999
using namespace std;
int main(){
    double high,Y,i;
    while(~scanf("%lf",&high)){
        int F=1;
        i=high/9.8;
        Y=4.9*(i*i);
        for(;;){
            if(Y<=0)break;
            Y-=5;
            F++;
        }
        cout<<F<<endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>

using namespace std;

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

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

	vector<bool> l1(n, false), l2(n, false);

	for(int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		if (a == 1) l1[b] = true;
		if (b == n) l2[a] = true;
	}

	for(int i = 2; i < n; i++)
	{
		if(l1[i] && l2[i])
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;
	return 0;
}


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


	if(S == "ABC")
		cout << "ARC";
	else
		cout << "ABC";

	cin >> S;
	
	return 0;	
}


Measured memory_bytes: 3624
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val k = scanner.nextInt()
    val array = IntArray(n)
    for(j in 0..k-1) {
        for (i in 0..scanner.nextInt() - 1) {
            array[scanner.nextInt() - 1]++
        }
    }
    var count = 0
    for(i in 0..n-1){
        if(array[i] === 0) count++
    }
    println(count)
}

Measured memory_bytes: 46852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, q;
  cin >> n >> q;
  vector<tuple<ll, ll, ll>> t;
  rep(i, n) {
    ll l, r, x;
    cin >> l >> r >> x;
    l -= x;
    r -= x;
    t.push_back({l, 0, x});
    t.push_back({r, -1, x});
  }
  rep(i, q) {
    ll d;
    cin >> d;
    t.push_back({d, 1, 0});
  }
  sort(all(t));
  set<ll> st;
  for(auto v : t) {
    ll s, i, x;
    tie(s, i, x) = v;
    if(i == -1)
      st.erase(x);
    else if(i == 0)
      st.insert(x);
    else
      cout << (st.empty() ? -1 : *st.begin()) << '\n';
  }
}

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

using namespace std;

bool ifKaibun(string s){
  size_t len = s.length();
  for(int i=0; i<len/2; i++) {
    //cout << s[i] << " " << s[len-i-1] << endl;
	if(s[i] != s[len-i-1]) return 0;
	}
  return 1;
}

int main(){
  string s;
  cin >> s;
  
  //cout << s << endl;
  
  if(!ifKaibun(s)) {
    cout << "No" << endl;
    return 0;
  }
  size_t n = s.length();
  
  //cout << s.substr(0, ((n-1)/2)) << endl;
  //cout << s.substr(((n+3)/2)-1, n-1) << endl;
  
  if(ifKaibun(s.substr(0, ((n-1)/2))) != ifKaibun(s.substr(((n+3)/2)-1, n-1))){
    cout << "No" << endl;
    return 0;
  }
  
  if(ifKaibun(s.substr(0, ((n-1)/2))) && ifKaibun(s.substr(((n+3)/2)-1, n-1))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
     
  return 0;
}

Measured memory_bytes: 256
import collections 
K = int(input())

l = collections.deque([1,2,3,4,5,6,7,8,9])

cnt = 0
while True:
    n = l.popleft()
    cnt +=1
    if cnt ==K:
        print(n)
        exit()

    if n%10 != 0:
        l.append(10*n+n%10-1)

    l.append(10*n+n%10)

    if n%10 != 9:
        l.append(10*n+n%10+1)
    


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n, m; cin >> n >> m;
    vector<ll> x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];

    ll X = 0, Y = 0;
    rep(i, n) { X += (2*i+1-n) * x[i]; chmod(X); }
    rep(i, m) { Y += (2*i+1-m) * y[i]; chmod(Y); }

    cout << (X*Y)%mod << endl;



    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
//---------------------------------------
void henkan(char inp[]);   //?°?????????¨??§???????????\?????????
//---------------------------------------

int main(void)
{
	string inp1;
	
	getline(cin, inp1);  //???????????????????????????????????????
	
	henkan(&inp1[0]);
		
	cout << inp1 << endl;   //????¨??????????C++ver

	
	return 0;
}

//------------------------------------------
void henkan(char inp[])
{	
	for(int i = 0; i < 1200; i++){
		if(inp[i] >= 'A' && inp[i] <= 'Z'){
			inp[i] += 32;
		}
		else if(inp[i] >= 'a' && inp[i] <= 'z'){
			inp[i] -= 32;
		}
	}
}

Measured memory_bytes: 3208
input_list = input().split()
A = int(input_list[0])
B = int(input_list[1])

if (A+B) >= (A-B) and (A+B) >= (A*B):
    print(A+B)
elif (A+B) >= (A-B) and (A+B) <= (A*B):
    print(A*B)
elif (A+B) <= (A-B) and (A+B) >= (A*B):
    print(A-B)
elif (A+B) <= (A-B) and (A+B) <= (A*B):
    if (A-B) >= (A*B):
        print(A-B)
    else:
        print(A*B)

Measured memory_bytes: 3064
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

struct Node {
    int index;
    int value;
    Node *parent;
    vector<Node*> children;
};

vector<vector<int>> adj_mat;
vector<Node*> nodes;

void build(Node *node) {
    nodes[node->index] = node;
    vector<int> adj = adj_mat[node->index];
    if (adj.size() == 1 && node->parent != nullptr) return;

    for (int i = 0; i < adj.size(); i++) {
        if (node->parent != nullptr && adj[i] == node->parent->index) continue;
        Node *new_node = new Node{
            .parent = node, .index = adj[i], .children = vector<Node*>(), .value = 0};
        node->children.push_back(new_node);
        build(new_node);
    }
}

void add_counter(Node *node) {
    vector<Node*> children = node->children;
    if (children.size() == 0) return;
    for (int i = 0; i < children.size(); i++) {
        children[i]->value += node->value;
        add_counter(children[i]);
    }
}

int main(int argc, const char * argv[]) {
    int N, Q;
    cin >> N >> Q;
    nodes = vector<Node*>(N, nullptr);

    adj_mat = vector<vector<int>>(N, vector<int>());
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        adj_mat[a-1].push_back(b-1);
        adj_mat[b-1].push_back(a-1);
    }

    Node *root = new Node{.parent = nullptr, .index = 0, .children = vector<Node*>(), .value = 0};
    build(root);

    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        nodes[p-1]->value += x;
    }
    
    add_counter(nodes[0]);

    for (int i = 0; i < N; i++) {
        cout << nodes[i]->value;
        if (i < N - 1) cout << " ";
    }
    cout << endl;

    for (int i = 0; i < N; i++) {
        delete nodes[i];
        nodes[i] = nullptr;
    }

    return 0;
}

Measured memory_bytes: 55552
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int x1,x2,y1,y2;cin>>x1>>y1>>x2>>y2;
    int bufx=x2-x1,bufy=y2-y1;
    int x3=x2-bufy,y3=y2+bufx;
    int x4=x1-bufy,y4=y1+bufx;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

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

unsigned long yakusu(unsigned long n){
  unsigned long ans = n+1; 
  for(unsigned long i=1; i*i<=n; ++i){
    if(n%i == 0){
      unsigned long j = n/i;
      if(ans > i+j) ans = i+j;
    }
  }
  return ans;
}

int main(){
  unsigned long N;
  cin >> N;
  unsigned long ans = yakusu(N);
  printf("%lu\n", ans-2);
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
const int mod=1e9+7;
const int maxn=1e5+50;
int n;
int f[maxn];
int nex[maxn];
int sum[maxn];
char s[maxn];
vector<int> pos[3];
inline int add(int x)
{
	return x>=mod?x-mod:x;
}
inline int idx(char c)
{
	return c=='a'?1:2;
}
int solve()
{
	bool flag=true;
	for(int i=1;i<n;++i)
	{
		if(s[i]==s[i+1])
		{
			flag=false;
			break;
		}
	}
	if(flag)
	{
		return 1;
	}
	for(int i=1;i<=n;++i)
	{
		sum[i]=(sum[i-1]+idx(s[i]))%3;
		pos[sum[i]].push_back(i);
	}
	nex[n]=n+1;
	for(int i=n-1;i>=0;--i)
	{
		nex[i]=s[i]==s[i+1]?i+1:nex[i+1];
	}
	f[0]=1;
	for(int i=0;i<n;++i)
	{
		f[i+1]=add(f[i+1]+f[i]);
		int c=idx('a'+'b'-s[i+1]);
		const vector<int> &v=pos[(sum[i]+c)%3];
		int p=lower_bound(v.begin(),v.end(),nex[i])-v.begin();
		if(p!=int(v.size()))
		{
			f[v[p]]=add(f[v[p]]+f[i]);
		}
	}
	int an=0;
	for(int i=1;i<=n;++i)
	{
		if(sum[i]==sum[n])
		{
			an=add(an+f[i]);
		}
	}
	return an;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	printf("%d\n",solve());
	return 0;
} 

Measured memory_bytes: 2172
#include<cstdio>
int a[100001];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	long long x = 2, y = 2;
	for (int i = n; i >= 1; i--) {
		if (x%a[i] == 0) x = x / a[i] * a[i];
		else x = (x / a[i] + 1) * a[i];
		y = y / a[i] * a[i] + a[i] - 1;
	}
	if (x > y) printf("-1\n");
	else printf("%lld %lld\n", x, y);
	return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, p[100001];
  cin >> n;
  rep(i, n) {
    cin >> p[i];
    p[i]--;
  }
  ll ans = 0;
  rep(i, n) {
    if (p[i] == i) {
      swap(p[i], p[i + 1]);
      ans++;
    }
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
const int maxnum = 10010;
int w[maxnum];          //w[i] -- the i-th item's weight
int v[maxnum];          //v[i] -- the i-th item's value
int N; //the total number of items
int W; //the maximum load capacity
int maxvalue[10010]={0};
void knapsack(int N, int W, int maxvalue[], int w[])
{
    for(int counter = 1;counter <= N;counter++)
    {
        for(int j = w[counter]; j <= W; j++)
        {
            maxvalue[j] = max(maxvalue[j],maxvalue[j-w[counter]]+v[counter]);
        }
    }
}
int main()
{
     
    cin>>N>>W;
    for(int i = 1;i <= N;i++)
    {
        cin>>v[i]>>w[i];
    }
    knapsack(N,W,maxvalue,w);
    cout<<maxvalue[W]<<endl;
    return 0;
}

Measured memory_bytes: 3128
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int n,A[36],B[36];
    char a[36],b[36];
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i] >> A[i];
        b[i]=a[i];B[i]=A[i];
    }
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(A[j]<A[j-1]){
                swap(A[j], A[j-1]);swap(a[j],a[j-1]);
            }
        }
    }
    
    
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(B[j]<B[minj]) minj=j;
        }
        if(minj!=i){
            swap(B[i], B[minj]);swap(b[i], b[minj]);
        }
    }
    
    
    
    
    
    for(int i=0;i<n;i++){
        if(i==0) cout << a[i]<<A[i];
        else cout <<" "<< a[i]<<A[i];
    }
    cout << endl << "Stable"<< endl;;
    for (int i=0; i<n; i++) {
        if(i==0) cout << b[i]<<B[i];
        else cout <<" "<< b[i]<<B[i];
    }
    cout << endl;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i] || A[i]!=B[i]){
            cout<<"Not stable" << endl;
            goto exit;
        }
    }
    cout << "Stable"<<endl;
exit:;
    return 0;
}




Measured memory_bytes: 3080
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b, ab, x, y;
  cin >> a >> b >> ab >> x >> y;

  int ans = min(x, y) * min(a + b, 2 * ab);
  if(x < y) ans += (y - x) * min(b, 2 * ab);
  else ans += (x - y) * min(a, 2 * ab);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int b[100010] = {};
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[a[i]]++;
    }

    int max = 0;
    for (int i = 1; i < 100000; i++) {
        int temp = b[i - 1] + b[i] + b[i + 1];
        if (max < temp) {
            max = temp;
        }
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 4044
//
// Created on 2020/05/03.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans = 0;

    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int>snuke(n);
    for (int i = 0; i < k; ++i) {
        int d;
        cin>>d;
        for (int j = 0; j < d; ++j) {
            int a;
            cin>>a;
            a--;
            snuke[a] ++;
        }
    }
    for (int l = 0; l < n; ++l) {
        if(snuke[l] == 0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first               // For pairs
#define ss second              // For pairs
#define sz(a) int((a).size())  // Function to determine size of any container
#define pb push_back           // Pushback to vector
#define mp make_pair           // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)  //traversing macro
#define present(c, x) (c.find(x) != c.end())
#define mod 1e9
using namespace std;
typedef vector<ll> vi;            // Vector of long long
typedef vector<vi> vvi;           // Vector of vi
typedef vector<pair<ll, ll>> ii;  // Vector of pairs
typedef vector<ii> vii;           // Vector of ii

int main() {
    ll n;
    cin >> n;
    vector<ld> p(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> p[i];
    vector<vector<ld>> dp(n + 1, vector<ld>(n + 1));
    ld prod1 = 1, prod2 = 1;
    for (int i = 1; i <= n; i++) {
        prod1 *= p[i];
        dp[i][0] = prod1;
        prod2 *= (1 - p[i]);
        dp[0][i] = prod2;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i + j <= n)
                dp[i][j] = dp[i - 1][j] * p[i + j] + dp[i][j - 1] * (1 - p[i + j]);
        }
    }
    ld ans = 0;
    for (int i = 0; i <= n / 2; i++)
        ans += dp[n - i][i];
    printf("%0.10Lf\n", ans);
    return 0;
}

Measured memory_bytes: 141184
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
    using static System.Console;
    using static System.Math;

    class Program
    {
        static void Main(string[] args)
        {
            N = int.Parse(ReadLine());
            H = ReadLine().Split().Select(int.Parse).ToArray();
            Solve();
        }

        static int N;
        static int[] H;

        static void Solve()
        {
            var count = 0;
            var max = 0;
            for (int i = 0; i < N; i++)
            {
                if (H[i] >= max)
                {
                    count++;
                    max = H[i];
                }
            }
            WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
// AOJ DPL_5_D Balls and Boxes 4
// n 個の区別できないボールを k 個の区別できる箱に入れる
// とき、可能な入れ方の総数を求めてください。
// 答えは重複組み合わせ kHn = combi(k+n-1, n)
// 2019.3.11 bal4u

#include <stdio.h>
#include <stdlib.h>

#define MOD 1000000007
int tbl[2001][1001];

int combi(int n, int k)
{
	int ans;

	if (tbl[n][k]) return tbl[n][k];
	if ((k << 1) > n) k = n - k;
	if (k == 0) ans = 1;
	else if (k == 1) ans = n;
	else ans = combi(n - 1, k) + combi(n - 1, k - 1);
	return tbl[n][k] = ans % MOD;
}

int main()
{
	int n, k;

	scanf("%d%d", &n, &k);
	printf("%d\n", combi(n + k - 1, n));
	return 0;
}


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

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

    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        string S = to_string(i);
        
        if(S.length() % 2 == 1)
        {
            ans += 1;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;


int H,W;
ll dp[1010][1010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>H>>W;
  vector<string> a(H);
  repeat(i,H){
    cin>>a[i];
  }
  dp[0][0]=1;
  repeat(i,H){
    repeat(j,W){
      if(a[i][j]=='#')continue;
      if(i>0)dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;
      if(j>0)dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;
    }
  }
  cout<<dp[H-1][W-1]<<endl;
  return 0;
}


Measured memory_bytes: 9216
#include <stdio.h>
int main ()
{
    int a, b, x;
    scanf ("%d %d %d", &x, &a, &b);
    if ((x>=1) && (x<=1000) && (a>=1) && (x<=1000) && (b>=1) && (x<=1000)){

    a = abs (a-x);
    b = abs (b-x);
    if (a>b)
    {
        printf("B\n");
    }
    else printf ("A\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        HashMap<Integer,Long> map = new HashMap<>();
        map.put(0,1L);
        long now = 0;
        for(int i = 0; i < n; i++){
            now += sc.nextLong();
            int modn = (int)(now%m);
            if(map.containsKey(modn)){
                map.put(modn,map.get(modn)+1L);
            }else{
                map.put(modn,1L);
            }
        }
        long ans = 0;
        for(Map.Entry<Integer,Long> e : map.entrySet()){
            long v = e.getValue();
            ans += (v*(v-1))/2;
        }
        System.out.println(ans);
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 44312
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int binomialCoeff(int n,int r){
    int res=1;
    if(r>n-r)r=n-r;
    for(int i=0;i<r;i++){
        res*=(n-i);
        res/=(i+1);
    }
    return res;
}


int power(int x,int n,int mod){
    //(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

int inverseMod(int x,int mod){
    return power(x,mod-2,mod);
}


int32_t main() {

    simplify

    int h,w,total;
    cin>>h>>w>>total;

    int ans=0;

    vector<string>grid(h);

    for(int i=0;i<h;i++){
        cin>>grid[i];
    }

    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int blacks=0;
            for(int k=0;k<h;k++){
                for(int l=0;l<w;l++){
                    if(i&(1<<k) || j&(1<<l)){
                        continue;
                    }
                    else if(grid[k][l]=='#'){
                        blacks++;
                    }
                }
            }
            if(blacks==total)ans++;
        }
    }
    cout<<ans;
    

    return 0;
}



Measured memory_bytes: 3636
#include <cmath>
    // #include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cassert>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define FOR(j,k,n) for (int j = k; j < (int)(n); j++)
#define MAXN 100000000000000000
#define newl printf("\n")
#define test(t)  int t; cin>>t; for(int tes = 0; tes < t; tes++)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
const int MM = 2200000;
lli m,n,k,p1,p2,p3,p,f,a[MM];
lli powmod(lli a1,lli b1,lli modx) {lli res=1; if(b1 < 0) return 0; a1%=modx; for(;b1;b1>>=1) {if(b1&1)res=res*a1%modx; a1=(a1*a1)%modx;}return res;}
int main(){

    cin>>n>>p;
    for (int i=0; i<n; i++) {
        cin>>a[i];
        p1 += a[i]%2;
        p2 += 1-(a[i]%2);
    }
    if(p1 == 0 && p)
    {
        cout<<0;
        return 0;
    }
    else if(p1==0)
    {
        cout<<powmod(2, p2, MAXN);
        return 0;
    }
    cout<<powmod(2, p1-1, MAXN)*powmod(2, p2, MAXN);
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll k; cin>>k;

    vector<bool> v(k,false);
    ll m = 0;
    ll ans = 1;

    while(true){
        m = (m*10 + 7)%k;
        if(m==0){
            cout<<ans<<endl;
            return 0;
        }
        if(v[m])break;
        v[m] = true;
        ans++;
    }


    cout<<-1<<endl;

    return 0;

}

Measured memory_bytes: 3704
#!/usr/bin/env python3
while True:
    t, n = input().split()
    t = int(t)
    if t == 0:
        exit()
    L = len(n)
    m = 0
    parts = []
    f = False
    for b in range(1 << (L - 1)):
        c = int(n[0])
        s = 0
        li = []
        for k in range(L - 1):
            if b >> k & 1 == 1:
                s += c
                li.append(c)
                c = 0
            c = 10 * c + int(n[k + 1])
        s += c
        li.append(c)
        c = 0
        if s > t:
            continue
        if s >= m:
            f = (s == m)
            m = s
            parts = li
    if f:
        print('rejected')
    elif m == 0:
        print('error')
    else:
        print(m, *parts, sep=' ')



Measured memory_bytes: 5592
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long mod = 1000000007;
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
		long answer = 1;
    int restCount = 0;

    for(int i = 0; i < n; i++)
    {
      restCount++;
      if(nums[i] < 2*restCount-1)
      {
        answer *= restCount;
        answer %= mod;
        restCount--;
      }
    }
    answer *= ModFactorial(restCount,mod);
    answer %= mod;

		Console.WriteLine(answer);
	}

  static long ModFactorial(long x, long p)//戻り値はx!(mod p)
  {
    long answer = 1;
    for(int i = 2; i <= x; i++)
    {
      answer *= i;
      answer %= p;
    }
    return answer;
  }
  
}

Measured memory_bytes: 20832
import math


def main():
    #infile = open("compprog.txt", mode="r")
    n = int(input())
    res = f(1, n)
    i = 2
    while i <= math.sqrt(n):
        if n % i == 0:
            this_f = f(i, n // i)
            res = this_f if this_f < res else res
        i += 1
    print(res)
    #infile.close()


def f(a, b):
    return max(len(str(a)), len(str(b)))


if __name__ == "__main__":
    main()


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

using namespace std;

const int maxn=2e5+5;
typedef long long ll;

int top=0;
int head[maxn];

void init(){
	memset(head,-1,sizeof(head));
	top=0;
}

struct Edge{
	int to,next;
}edge[2*maxn];

ll num[maxn];

void dfs(int u,int fa,ll sum){
	sum+=num[u];
	num[u]=sum;
	for(int i=head[u];i!=-1;i=edge[i].next){
		int to=edge[i].to;
		if(to==fa) continue;
		dfs(to,u,sum);
	}
}

void addedge(int x,int y){
	edge[top].to=y;
	edge[top].next=head[x];
	head[x]=top++;
	edge[top].to=x;
	edge[top].next=head[y];
	head[y]=top++;
}

int main(){
	init();	
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n-1;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y);
	}
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		num[x]+=y;
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++){
		printf("%lld ",num[i]);
	}
	return 0;
} 

Measured memory_bytes: 17280
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-10 22:46:14
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

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

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n, m, x; cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));

  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }

  int ans = (int)1e9;

  for (int i = 0; i < (1 << n); ++i) {
    vector<int> t(m, 0);
    int mn = 0;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        mn += c[j];
        for (int k = 0; k < m; ++k) {
          t[k] += a[j][k];
        }
      }
    }
    if (all_of(all(t), [&](int e){ return e >= x; })) {
      ans = min(ans, mn);
    }
  }

  if (ans == (int)1e9) ans = -1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
	string s;
	cin >> s;
	if (s[1] == 'B') cout << "ARC" << endl;
	else cout << "ABC" << endl;
}


Measured memory_bytes: 3032
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
struct node{
    int key;
    struct node *parent;
    struct node *left;
    struct node *right;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insertNode(int key){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = (node *)malloc(sizeof(struct node));
    z->key = key;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    
    if(y == NIL) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
}

void inorederNode(Node tree){
    if(tree->left != NIL) inorederNode(tree->left);
    cout << " " << tree->key;
    if(tree->right != NIL) inorederNode(tree->right);
}

void preorederNode(Node tree){
    cout << " " << tree->key;
    if(tree->left != NIL) preorederNode(tree->left);
    if(tree->right != NIL) preorederNode(tree->right);
}

int main(void){
    int n, key;
    string command;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> command;
        
        if(command[0] == 'p'){
            inorederNode(root);
            cout << endl;
            preorederNode(root);
            cout << endl;
        }
        else if(command[0] == 'i'){
            cin >> key;
            insertNode(key);
        }
    }
}



Measured memory_bytes: 26636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println((in.nextInt() - 1) * (in.nextInt() - 1));
        }

    }

    static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                String nextLine = null;
                try {
                    nextLine = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (nextLine == null)
                    return null;
                st = new StringTokenizer(nextLine);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}
 

Measured memory_bytes: 21460
#include <stdio.h>
#include <math.h>

int main(void){
double x1,y1,x2,y2;
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);

printf("%.8lf\n",(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))));
return 0;
}

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

int main(){
  int n,k,nm=0;
  cin>>n>>k;
  vector<int>x(n+1);
  for(int i=1;i<=n;i++){
    cin>>x[i];
  }
  for(int i=1;i<=n;i++){
    if(x[i]!=k-x[i]){
      nm+=min(x[i]*2,2*(k-x[i]));
    }
    else{
      nm+=x[i]*2;
    }
  }
  cout<<nm<<endl;
}
            
  


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();

    let ans = a + a * a + a * a * a;

    return ans.to_string();
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int S;
    cin >> S;
    int h = S / 3600;
    int m = S % 3600 / 60;
    int s = S % 3600 % 60;
    cout << h << ":" << m << ":" << s << endl;
}



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

using namespace std;

#define ll long long
#define ull unsigned long long
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int maxn = 2e5 + 10;
const int maxm = 1e4 + 10;
const ll mod = 1e9 + 7;

string s;
ll f[maxn][20];

int main() {
    __;
    cin >> s;
    f[0][0] = 1;
    for (int i = 1; i <= s.size(); ++i) {
        for (int j = 0; j < 13; ++j) {
            if (s[i - 1] == '?') {
                for (int k = 0; k <= 9; ++k) {
                    f[i][(k + j * 10) % 13] += f[i - 1][j];
                    f[i][(k + j * 10) % 13] %= mod;
                }
            } else {
                int k = s[i - 1] - '0';
                f[i][(k + j * 10) % 13] += f[i - 1][j];
                f[i][(k + j * 10) % 13] %= mod;
            }
        }
    }
    cout << f[s.size()][5] << endl;
    return 0;
}

Measured memory_bytes: 16848
# サンプルコード計算量お試し

import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
typedef struct{
	int head;
	int tail;
	int right;
	int left;
	int up;
	int down;
	void s() {
		int buf;
		buf = tail;
		tail = down;
		down = head;
		head = up;
		up = buf;
	}
	void n() {
		int buf;
		buf = tail;
		tail = up;
		up = head;
		head = down;
		down = buf;
	}
	void e() {
		int buf;
		buf = head;
		head = left;
		left = tail;
		tail = right;		
		right = buf;
	}
	void w() {
		int buf;
		buf = head;
		head = right;
		right = tail;
		tail = left;
		left = buf;
	}
} dice;
int main() {
	int a[6];
	string str;
	dice d;
	rep(i,6) {
		cin >> a[i];
	}
	cin >> str;
	d.head = a[0];
	d.down = a[1];
	d.right = a[2];
	d.left = a[3];
	d.up = a[4];
	d.tail = a[5];
	rep(i,str.length()) {
		if(str[i] == 'S') d.s();
		else if(str[i] == 'N') d.n();
		else if(str[i] == 'E') d.e();
		else if(str[i] == 'W') d.w();
	}
	cout << d.head << endl;
	return 0;
}
	

Measured memory_bytes: 1204
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

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

template<typename T>
constexpr T divide_ceil(T a, T b)
{
	T remainder = a % b;
	return remainder == 0 ? a / b : (a + (b - remainder)) / b;
}

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

	int ans = 0;
	int num = 1;
	while (num < M)
	{
		num += N - 1;
		++ans;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
#define ls (rt << 1)
#define rs (rt << 1 | 1)
int a[maxn], f[maxn], T[maxn << 2];
int n, k, Max, ans;
void pushup(int rt)
{
	T[rt] = max(T[ls], T[rs]);
}
int query(int rt, int l, int r, int a, int b)
{
	if(a <= l && r <= b) return T[rt];
	int ret = 0, mid = l + r >> 1;
	if(a <= mid) ret = max(ret, query(ls, l, mid, a, b));
	if(b > mid) ret = max(ret, query(rs, mid + 1, r, a, b));
	return ret;
}
void update(int rt, int l, int r, int x, int val)
{
	if(l == r)
	{
		T[rt] = val;
		return;
	}
	int mid = l + r >> 1;
	if(x <= mid) update(ls, l, mid, x, val);
	else update(rs, mid + 1, r, x, val);
	pushup(rt);
}
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &a[i]);
		Max = max(Max, a[i]);
	}
	for(int i = 1; i <= n; ++i)
	{
		f[i] = query(1, 1, Max, max(1, a[i] - k), min(Max, a[i] + k)) + 1;
		ans = max(ans, f[i]);
		update(1, 1, Max, a[i], f[i]);
	}
	printf("%d\n", ans);
	return 0;
}
	

Measured memory_bytes: 10236