akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int N;
		cin>>N;
		if(N == 0) break;
		int size = 0;
		ll res = 0;
		vector<string> s(N);
		map<char, ll> omomil;
		map<char, ll> omomir;
		int perm[10];
		vector<int> out;
		REP(i, 10) {
			perm[i] = (int)i;
		}
		REP(i, N) cin>>s[i];
		REP(i, N) {
			REP(j, s[i].size()) {
				if(omomil.count(s[i][s[i].size() - 1 - j]) == 0) {
					omomil[s[i][s[i].size() - 1 - j]] = 0;
					omomir[s[i][s[i].size() - 1 - j]] = 0;
					++size;
				}
				if(i != N - 1) omomil[s[i][s[i].size() - 1 - j]] += pow(10, j);
				else omomir[s[i][s[i].size() - 1 - j]] += pow(10, j);
			}
		}
		map<char, ll>::iterator ite3 = omomil.begin();
		int foo = 0;
		while(ite3 != omomil.end()) {
			REP(i, N) {
				if(s[i].size() > 1 && s[i][0] == (*ite3).first) {
					out.pb(foo);
					//cout<<(*ite3).first<<":"<<foo<<endl;
					break;
				}
			}
			++ite3;
			++foo;
		}

		ll sugoil[10];
		ll sugoir[10];
		ite3 = omomil.begin();
		REP(i, size) {
			sugoil[i] = (*ite3).second;
			++ite3;
		}
		ite3 = omomir.begin();
		REP(i, size) {
			sugoir[i] = (*ite3).second;
			++ite3;
		}
		do {
			ll l = 0;
			ll r = 0;
			bool cont = false;
			int roc = 0;
			REP(i, out.size()) {
				if(perm[out[i]] == 0) {
					cont = true;
					break;
				}
			}
			if(cont) continue;
			while(roc < size) {
				l += perm[roc] * sugoil[roc];
				++roc;
			}
			roc = 0;
			while(roc < size) {
				r += perm[roc] * sugoir[roc];
				++roc;
			}
			if(l == r) ++res;
		} while(next_permutation(perm, perm + 10));

		ll hoge = 1;
		REP(i, 10 - size) {
			hoge *= 10 - size - i;
		}
		cout<<res / hoge<<endl;
	}
}

Measured memory_bytes: 3332
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define INF 1<<30

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N + 1);
    for (int i = 1; i <= N; i++) cin >> H.at(i);
    int DP[N+1];
    rep(i, N+1) DP[i] = INF;
    DP[1] = 0;
    for (int i = 1; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i + j > N) break;
            DP[i + j] = min(DP[i] + abs(H[i + j] - H[i]), DP[i + j]);
        }
    }
    cout << DP[N] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	string s;
	cin >> s;
	string ans;
	rep(i,s.size()){
		if(s[i] == '0'){
			ans.push_back('0');
		} else if (s[i] == '1'){
			ans.push_back('1');
		} else {
			if (ans.size()){
				ans.pop_back();
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3536
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string A, B;
  cin >> A >> B;
  enum class Comparison : int32_t { kEquals = 0, kGreater, kLess };
  Comparison result;
  if (A.length() > B.length()) {
    result = Comparison::kGreater;
  } else if (A.length() < B.length()) {
    result = Comparison::kLess;
  } else {
    const int32_t length = static_cast<int32_t>(A.length());
    for (int32_t i = 0; i < length; ++i) {
      if (A.c_str()[i] > B.c_str()[i]) {
        result = Comparison::kGreater;
        break;
      } else if (A.c_str()[i] < B.c_str()[i]) {
        result = Comparison::kLess;
        break;
      } else {
        result = Comparison::kEquals;
      }
    }
  }

  switch (result) {
    case Comparison::kEquals:
      cout << "EQUAL" << endl;
      break;
    case Comparison::kGreater:
      cout << "GREATER" << endl;
      break;
    default:
      cout << "LESS" << endl;
      break;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
int H, W;
const int INF = 1 << 29;

/**
 * 座標の構造体
 */
struct Position
{
    int x;
    int y;

    // return if other is same position
    bool operator==(const Position &other) {
        return x == other.x && y == other.y;
    }

    // return if other is next to this position
    bool isNext(const Position &other) {
        int d_x = abs(x - other.x);
        int d_y = abs(y - other.y);

        return (d_x + d_y) == 1;
    }
};

vector<Position> InputLoad()
{
    vector<Position> positions;

    // make load list
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            if (c == '.') {
                positions.push_back(Position{i, j});
            }
        }
    }
    return positions;
}

// warshall-floyd による解法
int main()
{
    cin >> H >> W;
    vector<Position> loads = InputLoad(); // posiitons where is '.'
    vector<vector<int>> dp(loads.size(), vector<int>(loads.size())); // distance list between two positions

    // initial cost calculation
    for (size_t i = 0; i < loads.size(); i++)
    {
        for (size_t j = 0; j < loads.size(); j++)
        {
            Position pos1 = loads[i];
            Position pos2 = loads[j];

            if (pos1 == pos2) {
                // 座標が同じならコストは 0
                dp[i][j] = 0;
            } else if (pos1.isNext(pos2) == true) {
                // 座標が隣ならコストは 1
                dp[i][j] = 1;
            } else {
                // 分からない場合はコスト INF にしておく
                dp[i][j] = INF;
            }
        }
    }

    // warshall-floyd で最小経路のコストを計算していく
    for (size_t k = 0; k < loads.size(); k++)
    {
        for (size_t i = 0; i < loads.size(); i++)
        {
            for (size_t j = 0; j < loads.size(); j++)
            {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    // output max distance
    int ans = 0;
    for (size_t i = 0; i < loads.size(); i++)
    {
        for (size_t j = 0; j < loads.size(); j++)
        {
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 896
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];

    auto dp = new long[][][](2, N, N);
    dp[0][0][0] = 1;

    int cur = 0;
    int tar = 1;

    foreach (i; 0..M) {
        foreach (j; 0..N) {
            foreach (k; 0..N) {
                dp[tar][j][k] = 0;
            }
        }
        foreach (j; 0..N) {
            foreach (k; 0..N) {
                if (dp[cur][j][k] == 0) {
                    continue;
                }
                if (j < N - 1) {
                    (dp[tar][j+1][k] += dp[cur][j][k]) %= MOD;
                }
                (dp[tar][j][k] += dp[cur][j][k] * (j - k) % MOD) %= MOD;
                (dp[tar][j][j] += dp[cur][j][k] * (k + 1) % MOD) %= MOD;
            }
        }
        swap(cur, tar);
    }

    long ans = dp[cur][N-1][N-1];
    foreach (i; 1..N) ans = ans * i % MOD;
    ans.writeln;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(l,k,h) for(int l = k; l <= h; ++l)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    int n, d, x, a;
    cin >> n >> d >> x;
    int res = n;
    d -= 1;
    rep(i,n) {
        cin >> a;
     res += d / a;
    }
    cout << res + x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
const int INF = 1001001001;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) {//最大公約数
    if(a<b){
        ll tmp = a;
        a = b;
        b = tmp; 
    }
    if (b==0) return a;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {//最小公倍数
    return a * b / gcd(a, b);
}

int main() {
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    vector<int>a(n);
    double sum=0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    double tmp = sum/(4*m);
    rep(i,n){
        if(a[i]>=tmp){
            ans++;
        }
    }
        if(m<=ans){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    return 0;
}




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

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=2000001;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

int main()
{
    //read("in.txt"),write("out.txt");
    int a,b,c;
    ini(a),ini(b),ini(c);
    outi((a*b)/2),nl;
    return 0;
}


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

int main() {
	int n;
	std::cin >> n;
	std::vector<double> seito(n);
	for (auto &s:seito) {
		std::cin >> s;
	}
	int i = 1;
	std::cout << i << ':';
	for (const auto &s : seito) {
		if (s < 165) {
			std::cout << '*';
		}
	}
	std::cout << '\n';
	for (const double &median : { 165, 170, 175, 180 }) {
		std::cout << ++i << ':';
		for (const auto &s : seito) {
			if (median <= s && s < median + 5) {
				std::cout << '*';
			}
		}
		std::cout << '\n';
	}
	std::cout << ++i << ':';
	for (const auto &s : seito) {
		if (s >= 185) {
			std::cout << '*';
		}
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

ll N,K;
v_ll V,V1,V2;
ll X,Y,Z;

int main(){
  cin >> N >> K;
  V.assign(N+10,0);
  for (ll i=1; i<=N; i++){
    cin >> V[i];
  }
  ll ans_best=100000000000000;
  ll ans=0;
  for (ll i=0;i<=K;i++){
    X=i;
    for (ll j=0;j<=K-X;j++){
      Y=j;
      Z=K-X-Y;
      if (X+Y>N) continue;
      //sort(V.begin()+1,V.begin()+1+X);
      //sort(V.begin()+N+1-Y,V.begin()+N+1);
      V1=v_ll();
      for (ll i=1;i<=X;i++)V1.push_back(V[i]);
      for (ll i=N-Y+1;i<=N;i++)V1.push_back(V[i]);
      ans=0;
      for (ll i=X+1;i<=N-Y;i++)ans+=V[i];
      sort(V1.begin(),V1.end());
      for (ll i=0;i<V1.size();i++){
        if (i<Z && V1[i]<0)ans+=V1[i];
      }
      //cout << "Z=" << X << Y << Z << " ";
      /*
      for (ll i=0;i<V1.size();i++){
        cout <<V1[i] << " ";
      }
      cout << endl;
*/
      if (ans<ans_best)ans_best=ans;
    }
  }
  ll all=0;
  for (ll i=1;i<=N;i++)all+=V[i];
  cout << all-ans_best << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
signed main(){
	string T;
	cin >> T;
	for(int i = 0; i < T.length(); i++){
		char c = T[i];
		if(c == '?')
			cout << 'D';
		else
			cout << c;
	}
	cout << endl;
 
	return 0;
}

Measured memory_bytes: 3716
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
int main(){	
    int n,m;
	cin>>n>>m;
	int a[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			a[i][j]=-1;
		}
	}
	char s[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>s[i][j];
		}
	}
	queue<pair<int,int> > q;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i][j]=='#'){
				q.push(mp(i,j));
				a[i][j]=0;
			}
		}
	}
	int dx[4]={1,0,-1,0};
	int dy[4]={0,1,0,-1};
	while(!q.empty()){
		int x=q.front().first,y=q.front().second;
		q.pop();
		for(int i=0;i<4;i++){
			if(x+dx[i]>=0&&x+dx[i]<n&&y+dy[i]>=0&&y+dy[i]<m&&a[x+dx[i]][y+dy[i]]==-1){
				q.push(mp(x+dx[i],y+dy[i]));
				a[x+dx[i]][y+dy[i]]=a[x][y]+1;
			}
		}
	}
	int ans=-1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			ans=max(ans,a[i][j]);
		}
	}
	cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 13328
#include <bits/stdc++.h>
#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 r;
  cin >> r;
  cout << 2*r*3.141592653589793 << endl;
  return 0;
}


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

int main(){
	string s,t;
	cin >> s >> t;
	int no = 0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i])no++;
	}
	cout << no;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int i;
  int left, right;
  int array_sum, total_sum;
  total_sum = 0;

  for(i = 0; i < N; i++){
    cin >> left >> right;
    array_sum = right - left + 1;
    total_sum += array_sum;
  }
  cout << total_sum;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = sc.nextInt();
        }

        System.out.println(minWateringMoves(heights));
    }

    static int minWateringMoves(int... heights) {
        int moves = heights[0];
        for (int i = 1; i < heights.length; i++) {
            int diff = heights[i] - heights[i - 1];
            if (diff > 0) {
                moves += diff;
            }
        }
        return moves;
    }

}


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

int main()
{
	int q1, b, c1, c2, q2;
	
	while (cin>>q1,q1){
		bool flag=false;
		cin >> b >> c1 >> c2 >> q2;
		for (int i = q2; i > 0&&!flag; i--){
		int x = b - c1 * i;
		if (x < 0) continue;
		int tori = x / c2;
		if (i + tori < q1) continue;

		cout << i << " "<< tori << endl;
		flag = true;
	}
		if(!flag)cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
a,b,c=map(int,input().split())



F=0
kekka=0
i=0
l=[]

while F==0:
    A=(a*i)%b
    if A==c:
        kekka="YES"
        F=1
    else:
        if l.count(A)==0:
            l.append(A)
            i+=1
        else:
            kekka="NO"
            F=1
            
print(kekka)





Measured memory_bytes: 3060
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int N;
    cin >> N;
    vector<int> a(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    vector<int> ans(N + 1, 0);
    int cnt = 0;
    for (int i = N; i >= 1; i--) {
        if (a[i] == 1) {
            ans[i] = 1;
            cnt += 1;
            for (int j = 1; j <= sqrt(i); j++) {
                if (i % j == 0) {
                    a[j] = a[j] == 1 ? 0 : 1;
                    if (i / j != j) {
                        a[i / j] = a[i / j] == 1 ? 0 : 1;
                    }
                }
            }
        } else {
            ans[i] = 0;
        }
    }
    cout << cnt << endl;
    for (int i = 1; i <= N; i++) {
        if (ans[i] == 1) {
            if (i == 1)
                cout << i;
            else
                cout << " " << i;
        }
    }
    cout << endl;
    return 0;
}


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


void solve(std::string T){
  for (int i=0; i<T.size(); i++) {
    if (T[i] == '?') T[i] = 'D';
  }
  cout << T << endl;
}

int main(){
    std::string T;
    std::cin >> T;
    solve(T);
    return 0;
}


Measured memory_bytes: 3920
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i += 2){
        cout << s[i];
    }
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func searchMin(l int, r int) int {
	min := 2019
	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			mod := (i * j) % 2019
			if mod < min {
				min = mod
			}
			if min == 0 {
				return 0
			}
		}
	}
	return min
}

func main() {
	sc.Split(bufio.ScanWords)
	l := nextInt()
	r := nextInt()

	min := searchMin(l, r)
	fmt.Println(min)
}


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

int main(){
     int n;
     cin>>n;
     int h[n];
     for(int i=0;i<n;i++){
          cin>>h[i];
     }
     
     int max=INT_MAX;
     
     vector<int> dp(n, INT_MAX);
     dp[0]=0;
     for(int i=0;i<n;i++){
          for(int j :{i+1, i+2}){
               if(j<n){
                    dp[j]=min(dp[j], dp[i]+abs(h[i]-h[j]));
               }
          }
     }
     
     cout<<dp[n-1]<<endl;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1, 0);
    vector<int> b(n+1, 0);
    vector<int> c(n, 0);

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

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += b[a[i]];
        if (i == 1) continue;
        if (a[i] - 1 == a[i-1]) {
            ans += c[a[i-1]];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
open Buffer;;
let n = 4 in
let abcd = Array.init n @@ fun _ -> Scanf.scanf " %1d" @@ (+) 0 in
let b = create 0 in
for i = 0 to 1 lsl (n - 1) - 1 do
  let sum = ref abcd.(0) in
  clear b;
  add_char b @@ char_of_int @@ 48 + abcd.(0);
  for j = 1 to n - 1 do
    let m = abcd.(j) in
    let x, y = if i lsr (j - 1) land 1 = 1 then m, '+' else -m, '-' in
    sum := !sum + x;
    add_char b y;
    add_char b @@ char_of_int @@ 48 + m
  done;
  if !sum = 7 then 
    (add_string b "=7";
    to_bytes b |> Bytes.to_string |> print_endline; exit 0)
done

Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    // Your code here!
    string s;
    bool flag = true;
    cin >> s;
    reverse(s.begin(),s.end());
    for(;s.size() != 0;){
        if(s.substr(0,7) == "remaerd"){
            s.erase(0,7);
            continue;
        }
        if(s.substr(0,6) == "resare"){
            s.erase(0,6);
            continue;
        }
        if(s.substr(0,5) == "maerd"){
            s.erase(0,5);
            continue;
        }
        if(s.substr(0,5) == "esare"){
            s.erase(0,5);
            continue;
        }
        flag = false;
        break;
    }
    cout << (flag ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)


















int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n);
    REP(i, m){
        ll s, t;
        cin >> s >> t;
        s--; t--;
        g[s].push_back(t);
    }
    double ans = INF;
    REP(idx, n - 1){
        vector<double> dp(n);
        for(ll i = n - 2; i >= 0; i--){
            double sum = 0.0, mx = 0.0;
            ll sz = g[i].size();
            for(auto next : g[i]){
                sum += dp[next];
                mx = max(mx, dp[next]);
            }
            if(sz >= 2 && i == idx){
                sum -= mx;
                sz--;
            }
            dp[i] = sum / (double)sz + 1.0;
        }
        ans = min(ans, dp[0]);
    }
    printf("%.08lf\n", ans);
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>


using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 2000000000
#define LLINF 4000000000000000000
#define SIZE 50010

struct DEC{
    
    int num[SIZE+2];
    int keta;
    
    void times(int a){
        int num2[SIZE+2]={0};
        
        for(int i=0;;i++){
            int k = a%10;
            
            for(int j=0;j<keta;j++){
                num2[i+j]+=num[j]*k;
            }
            
            a/=10;
            if(a==0) break;
        }
        
        for(int i=0;i<keta;i++){
            if(num2[i] >= 10){
                num2[i+1]+= num2[i]/10;
                num2[i]%=10;
            }
            num[i] = num2[i];
        }
    }
    
    void div(int k){
        int num2[SIZE+2]={0};
        int a=0;
        
        for(int i=keta-1;i>=0;i--){
            a*=10;
            a+=num[i];
            
            num2[i]=a/k;
            a%=k;
        }
        
        for(int i=0;i<keta;i++){
            num[i]=num2[i];
        }
    }
    
    
    DEC(){
        for(int i=0;i<SIZE+2;i++){
            num[i] = 0;
        }
        keta=50000;
    }
    
};


int main(){
    DEC ans;
    int n,m,r;
    
    
    scanf("%d%d%d",&n,&m,&r);
    
    if(n*m > r){
        puts("0");
        return 0;
    }
    
    ans.num[0] = 1;
    
    for(int i=max(r-m*n,n-1)+1;i<=r+n-m*n-1;i++){
        ans.times(i);
    }
    
    for(int i=1;i<=min(r-m*n,n-1);i++){
        ans.div(i);
    }
    
    bool p = false;
    
    for(int i=ans.keta-1;i>=0;i--){
        if(ans.num[i] > 0)
            p = true;
        
        if(p)
            printf("%d",ans.num[i]);
    }
    
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 1592
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  vector<ll> vec;
  for(ll i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  ll xorsum=vec[0],norsum=vec[0];
  ll r=1;
  while(1){
    if(r>=n) break;
    if((xorsum^vec[r])!=(norsum+vec[r])) break;
    xorsum=xorsum^vec[r];
    norsum+=vec[r];
    r++;
  }

  vector<ll> ans(n,0);
  ans[0]=r;
  for(int l=1;l<n;l++){
    if(r<=l){
      r=l+1;
      xorsum=vec[l];
      norsum=vec[l];
    }
    else{
      xorsum-=vec[l-1];
      norsum-=vec[l-1];
    }
    while(1){
      if(r>=n) break;
      if((xorsum^vec[r])!=(norsum+vec[r])) break;
      xorsum=xorsum^vec[r];
      norsum+=vec[r];
      r++;
    }
    ans[l]=r-l;
  }
  ll asum=0;
  for(ll i=0;i<n;i++) asum+=ans[i];
  cout<<asum<<endl;
}


Measured memory_bytes: 3440
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

bool light[50][50];

bool gauss(const mat &A, const vec &b){
	int n = A.size();
	mat B(n, vec(n+1));
	rep(i, n)rep(j, n){
		B[i][j] = A[i][j];
	}
	rep(i, n) B[i][n] = b[i];
	rep(i, n){
		int pivot = i;
		rep2(j, i, n){
			if(B[j][i]){
				pivot = j;
				break;
			}
		}
		swap(B[i], B[pivot]);
		if(B[i][i] == 0){
			continue;
		}

		rep(j, n){
			if(i != j && B[j][i]){
				rep2(k, i, n + 1) if(B[i][k]) B[j][k] = (1 - B[j][k]);
			}
		}
	}

	rep(i, n){
		bool f = false;
		rep(j, n) if(B[i][j]) f = true;
		if(!f && B[i][n]) return false;
	}

	return true;
}

int main(){
	int m, n, d;
	int s;
	while(cin >> m >> n >> d && (m || n || d)){
		rep(i, n)rep(j, m){
			cin >> s;
			if(s) light[i][j] = true;
			else light[i][j] = false;
		}
		int sz = m * n;
		mat A(sz, vec(sz));
		vec b(sz);
		rep(i, n)rep(j, m){
			int a = i * m + j;
			rep(k, n)rep(l, m){
				if(d == abs(k - i) + abs(l - j) || 0 == abs(k - i) + abs(l - j)){
					A[a][k*m+l] = 1;
				}else{
					A[a][k*m+l] = 0;
				}
			}
		}
		rep(i, n)rep(j, m){
			if(light[i][j]) b[i*m+j] = 1;
			else b[i*m+j] = 0;
		}
		if(gauss(A, b)) cout << 1 << endl;
		else cout << 0 << endl;
	}
	return 0;
}

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

def main():
    s = list(input())
    t = list(input())

    s.sort()
    t.sort(reverse=True)

    if len(set(s)) == 1 and len(set(t)) == 1 and set(s) == set(t) and len(s) < len(t):
        print('Yes')
        exit()
 
    for i in range(min(len(s), len(t))):
        if ord(s[i]) < ord(t[i]):
            print('Yes')
            exit()
    print('No')
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (N, K, S) = readInputLine().split(" ").map { it.toInt() }

    val ans = IntArray(N)

    for (i in 0 until K) {
        ans[i] = S
    }

    for (i in K until N) {
        if (S == 1000000000) {
            ans[i] = 1
        } else {
            ans[i] = 1000000000
        }
    }

    println(ans.joinToString(" "))
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 44816
(N,D) = map(int,input().split())

P = []
for n in range(N):
  P_ = input().split()
  P = P + [P_]
ct = 0
for n in range(N):
  for m in range(n+1,N):
    dist = 0
    for d in range(D):
      dist += (int(P[n][d])-int(P[m][d]))**2
    if int(dist**0.5)**2==dist:
      ct += 1
print(ct)

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

int main()
{
    int N, K;

    cin >> N >> K;

    int p[N];

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

    sort(p, p+N);

    int T = 0;

    for(int i=0; i<K; i++)
    {
        T = T + p[i];
    }

    cout << T;

    return 0;
}

Measured memory_bytes: 3636
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
    int n,p;
    cin >> n;
    set<int> s;
    for(int i=0; i<n; i++){
        cin >> p;
        s.insert(p);
    }
    if(s.size()==n)cout << "YES" << endl;
    else cout << "NO" << endl;
  
   return 0;
}



Measured memory_bytes: 9600
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int[] x=new int[26];
		for(int i=0;i<s.length();i++){
			x[s.charAt(i)-'a']++;
		}
		for(int i=0;i<26;i++){
			if(x[i]==0){
				System.out.print((char)(i+'a'));
				break;
			}
			if(i==25)
				System.out.print("None");
		}
	}
}


Measured memory_bytes: 23336
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, cnt=0; cin >> n;
    int num[100000] = {0};
    REP(i, n){
        int a; cin >> a;
        num[a-1]++;
    }
    REP(i, 100000){
        if(num[i]) cnt++;
    }
    cout << (cnt%2 ? cnt : cnt-1) << endl;
    return 0;
    
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
	int a,b,d,r;
	double f;
	cin >> a >> b;
	d=a/b;
	r=a%b;
	f=(double)a/b;
	
printf("%d %d %.5lf\n",d,r,f);
return 0;
};

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>

typedef long long int ll;

using namespace std;

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

  A = (ll)N / 1.08;
  B = (ll)(N + 1) / 1.08;
  C = (ll)A * 1.08;
  D = (ll)B * 1.08;

  if(N==C){
    cout << A<< endl;
  }
  else if(A==B){
    cout << ":(" << endl;
  }
  else if((N+1)==D){
    cout << ":(" << endl;
  }
  else{
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
#define MAX_N 16
#define INF 20 * 100000
using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;

    int t[n][n + 1];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= n; j++) {
	cin >> t[i][j];
      }
    }

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

    dp[0] = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
      //if (dp[i] == INF) continue;
      for (int i = 0; i < n; i++) {
	if ((bit & (1 << i)) != 0) continue;
	int cost = t[i][0];

	for (int j = 0; j < n; j++) {
	  if ((bit & (1 << j)) == 0) continue;
	  cost = min(t[i][j + 1], cost);
	}
	
	int current = (bit + (1 << i));
	dp[current] = min(dp[current], dp[bit] + cost);
      }
    }

    //for (int i = 0; i < (1 << n); i++) {
    //  cout << dp[i] << " ";
    //}
    //cout << endl;
    
    cout << dp[(1 << n) - 1] << endl;
  }
}

Measured memory_bytes: 3324
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 200005;

/*******************************************************************/




int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t, z = 1; cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	int n; cin >> n;
	string ans = "";
	while (n != 0) {
		int x = n % 26, f = 0;
		x--;
		if (n % 26 == 0) x = 25, f = 1;
		ans = (char)('a' + x) + ans;
		n /= 26;
		if (f == 1) n--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
n=int(input())

for k in range(n):
    s=input()
    tmp=[0]*26
    for i in range(len(s)):
        tmp[ord(s[i])-ord("a")]+=1

    if k==0: ans=tmp 
    else:
        for i in range(26):
            ans[i]=min(ans[i],tmp[i])

p=ord("a")
for i in range(26):
    for _ in range(ans[i]):
        print(chr(p+i),end="")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,A,B,C;
    cin >> n >> A >> B >> C;
    int l[n];
    int INF= 1e9;
    for(int i=0;i<n;i++) cin >> l[i];
    function<int (int,int,int,int)> dfs=[&](int cur,int a,int b, int c){//cur:今まで見た番号、a,b,c：それぞれの長さ
        if(cur==n){
            if(min({a,b,c})>0) return abs(A-a)+abs(B-b)+abs(C-c)-30;
            else return INF;
        }
        int ret = dfs(cur+1,a,b,c);
        int ret1 = dfs(cur+1,a+l[cur],b,c)+10;
        int ret2 = dfs(cur+1,a,b+l[cur],c)+10;
        int ret3 = dfs(cur+1,a,b,c+l[cur])+10;
        return min({ret,ret1,ret2,ret3});
    };
    cout << dfs(0,0,0,0) << endl;
}


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

using namespace std;

#define debug(x) cerr << endl << "DEBUG: (" << (#x) << " = " << x << ")" << endl;
#define debugArray(v) for (auto i : v) cerr << i << " "; cerr << endl;

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);

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

    int t;

    cin >> t;

    map<string, int> mp;
    while (t--) {
        string s;

        cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
        if (x-r>=0&&x+r<=W&&y+r<=H&&y-r>=0) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }














    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <stdio.h>
#include <memory.h>
#include <sstream>
int main()
{
	int n;
	std::cin >> n;
	std::vector <int> v (n), a(n);
	for (int i = 0; i < n; i++)
	{
		std::cin >> v[i];
		a[i] = v[i];
	}
	std::sort(a.begin(), a.end());
	std::map<int, int> st;
	for (int i = 0; i < n; i++)
		st[a[i]] = i;
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		int j = st[v[i]];
		if (i % 2 != j % 2) cnt++;
	}
	std::cout << cnt / 2 << std::endl;
}

Measured memory_bytes: 5760
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N,K; cin >> N >> K;
    int x[N]; REP(i,N) cin >> x[i];

    int ans = 0;
    REP(i,N) ans += min(x[i], K-x[i]);
    cout << 2*ans << endl;
    return 0;
}

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

// void debug(vector<int> *v)
// {
// 	cout << "debug :";
// 	for (int i = 0; i<v->size(); i++)
// 		cout << " " << v->at(i);
// 	cout << endl;
// }

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

	if (a.at(a.size() - 1) == b.at(0)) {
		if (b.at(b.size() - 1) == c.at(0)) {
			cout << "YES";
		}
		else {
			cout << "NO";
		}
	}
	else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i, n, k, sum=0;
    cin>>n>>k;

    for(i=k;i<=n+1;i++)
    {
        sum+=i*(n-i+1)+1;
        sum=sum%1000000007;
    }
    cout<<sum<<endl;

    return 0;
}


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

#define PI 3.1415926536

int main()
{
	int a, b, x;
	scanf("%d %d %d", &a, &b, &x);
	
	double tmp, ans;
	if (x * 2 <= a * a * b) {
		tmp = (double)x * 2 / (a * b);
		ans = atan(b / tmp) * 180 / PI;
	} else {
		tmp = (double)(a * a * b - x) * 2 / (a * a);
		ans = atan(tmp / a) * 180 / PI;
	}
	
	printf("%f\n", ans);
	fflush(stdout);
	return 0;
}

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

public static partial class Program
{
    public static void Main()
    {
        var nl = CRL().ArrayInts();
        var n = nl[0];
        var l = nl[1];

        var val = new List<int>();
        for (int i = 0; i < n; i++)
        {
            val.Add(l + i);
        }
        
        val.Sort((x, y) => Math.Abs(x) - Math.Abs(y));
        CWL(val.Skip(1).Sum());
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = {0, -1, 0, 1};
    public static readonly int[] Dy = {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToLong();
    public static int ToInt(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}


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

int main(void){
	int n;
	cin>>n;
	n%=10;
	switch (n)
	{
	case 0:
	case 1:
	case 6:
	case 8:
		cout<<"pon";
		break;
	case 3:
		cout<<"bon";
		break;
	default:
		cout<<"hon";
		break;
	}
	return 0;
}	

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
ll k,a,b;
cin>>k>>a>>b;
ll bb=1,y=0;
double x=(b*1.0-a*1.0)/2.0;
ll doun;
ll ans=0;
if(x<=1)
{
	bb+=k;
	ans=bb;
}
else
{

 doun=k-(a-1)-(k-(a-1))%2;
 doun/=2;
 ans=a+doun*(b-a)+(k-(a-1))%2;

}
cout<<ans;
}



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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  st s, t;
  cin >> s >> t;
  st tt = "";
  rep(i, 0, s.size()) tt += t.at(i);
  cout << (s == tt ? "Yes" : "No") << endl;
}

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



int main(){
    int n,k,i,max=0,head=0,tail=0;scanf("%d%d",&n,&k);
    int a[n+1],sum[n+1];for(i=1;i<=n;i++){scanf("%d",&a[i]);}


    for(i=1;i<=n;i++){sum[i]=0;}
    for(i=1;i<=k;i++){sum[1]+=a[i];}//sumは隣接k項の和
    head=k;tail=1;
    max=sum[1];
    
    for(i=2;i<=n-k+1;i++){
        sum[i]=sum[i-1]+a[++head]-a[tail++];
        if(sum[i]>max){max=sum[i];}
    }

    printf("%f\n",(max+k)/2.0);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long n, long long m, long long d){
  long long tot = n * n;
  long long bea = (d * 2) + (n - (d * 2)) * 2;
  if (d == 0) {
    bea = n;
  }
  double ret = (static_cast<double>(bea) * static_cast<double>(m-1)) / static_cast<double>(tot);
  std::cout << fixed << setprecision(10) << ret << std::endl;
}

int main(){
  long long m;
  long long d;
  long long n;
  scanf("%lld",&n);
  scanf("%lld",&m);
  scanf("%lld",&d);
  solve(n, m, d);
  return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string s, t;
    cin >> s >> t;
    string f = t.substr(0, s.size());
    if (s == f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3616
#!/usr/bin/env ruby

while line = gets
  args = line.chomp.split

  case args[1]
  when '+'
    puts args[0].to_i + args[2].to_i
  when '-'
    puts args[0].to_i - args[2].to_i
  when '*'
    puts args[0].to_i * args[2].to_i
  when '/'
    puts args[0].to_i / args[2].to_i
  when '?'
    break
  end

end

Measured memory_bytes: 6884
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main(){
	int num[3];
	cin >> num[0];
	cin >> num[1];
	cin >> num[2];

	sort( num, num + 3 );

	for ( int i = 0; i < 3; i++ ) {
		if ( i < 2 ) {
			cout << num[i] << " ";

		} else if ( i == 2 )
			cout << num[i] << endl;
		}
}

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

int main(){
  int a, b, c, k;
  int ans = 0;


  cin >> a >> b >> c >> k;

  while (a > 0){
    ans++;
    a--;
    k--;
    if (k == 0){
      cout << ans << endl;
      return 0;
    }
  }

  while (b > 0){
    b--;
    k--;
    if (k == 0){
      cout << ans << endl;
      return 0;
    }
  }

  while (c > 0){
    c--;
    ans--;
    k--;
    if (k == 0){
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3624
res = 0
n = int(input())
l = []
for i in range(n):
    a, b = map(int,input().split())
    l.append([a + b, a, -b])
l = sorted(l)[::-1]
for i in range(n):
    if i % 2 == 0:
        res += l[i][1]
    else:
        res += l[i][2]
print(res)


Measured memory_bytes: 24404