akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if (n + x == 0) {
                return;
            }

            int counter = 0;

            for (int i=1; i<n-1; ++i) {
                for (int j=i+1; j<n; ++j) {
                    for (int k=j+1; k<n+1; ++k) {
                        if (i + j + k == x) {
                            counter += 1;
                        }
                    }
                }
            }
            System.out.println(counter);
        }
    }
}


Measured memory_bytes: 26644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    if(N%2==1) cout<<0<<endl;
    else{
        N/=2;
        ll ans=0;
        ll tmp=5;
        while(tmp<=N){
            ans+=N/tmp;
            tmp*=5;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

function<LL(LL, LL)> gcdlambda = [](LL n, LL m) { return __gcd(n, m); };

bool solve() {
  LL A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A < B) return false;
  if (B > D) return false;

  LL val = gcdlambda(B, D);
  LL base = A % B;

  LL E = (B - base) / val * val + base;
  if (B == E) E -= val;

  assert(B > E);
  if (E > C) {
    return false;
  }
  return true;
}

int main() {
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    bool ok = solve();
    cout << (ok ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int A, B, check;
  int flag = 0;
  for (int i = 0; i < 10; i++) {
    A = b * 10 + i;
    // cout << "A=" << A << endl;
    check = A * 0.08;
    // cout << "check=" << check << endl;
    if (a == check) {
      cout << A;
      flag++;
      break;
    }
  }
  if (flag == 0) {
    cout << -1;
  }
}

Measured memory_bytes: 256
using System;

public class Program{
    public static void Main(){
        string a=Console.ReadLine();
        int Number=int.Parse(a);
        string[] b=Console.ReadLine().Split(' ');
        int[] Value=new int[Number];
        for(int i=0;i<Number;i++) {
            Value[i]=int.Parse(b[i]);
        }
        
        int count=0;
        
        while(true) {
            int flag=0;
            for(int i=0;i<Number;i++) {
                if(Value[i]%2==1) {
                    flag++;
                }
            }
            
            if(flag==0) {
                for(int j=0;j<Number;j++) {
                    Value[j]=Value[j]/2;   
                }
                count++;
            } else if(flag!=0) {
                break;
            }

        }
        
        Console.WriteLine(count);
        
    }
}


Measured memory_bytes: 11220
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  cin >> a >> b;
  int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
  while (M--) {
    int x, y, c;
    cin >> x >> y >> c;
    --x; --y;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans << '\n';

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int in(N);

  vector<int> dp(3, 0), dp2(3), v(3);
  rep(i, N) {
    cin >> v[0] >> v[1] >> v[2];
    rep(j, 3)
      dp2[j] = max(dp[(j+1)%3] + v[j], dp[(j+2)%3] + v[j]);
    swap(dp, dp2);
  }

  cout << max(dp[0], max(dp[1], dp[2])) << 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;
int main(){
  int h[10];
  rep(i,10){
    cin >> h[i];
  }
  sort(h,h+10);
  reverse(h,h+10);
  rep(i,3){
    cout << h[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
package main

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

func main() {
	N := ReadInt()
	for x := 0; x <= N; x++ {
		if x*108/100 == N {
			fmt.Println(x)
			return
		}
	}
	fmt.Println(":(")
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 1772
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  char chs[3];
  for (int i = 0; i < 3; i++) { cin >> chs[i]; }
  cout << (chs[0] == chs[1] && chs[1] == chs[2] ? "No" : "Yes") << endl;
}



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

int main(){
  int N ,A ;
  cin >> N >> A ;
  int x = N - (N / 1000) * 1000 ;
  if( x < 500 && x <= A){ cout << "Yes" << endl; }
  else if ( x < 500 && x > A ){ cout << "No" << endl; }
  else if( x >= 500 ){
    if( x - 500 <= A){ cout << "Yes" << endl; }
    else if( x - 500 > A){ cout << "No" << endl; }
                    
                     }

}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<ll> a(n);
	for (auto &i : a) cin >> i, i /= 2;

	bool even = true;
	ll lcm = 1;
	for (auto i : a)
	{
		even &= i % 2 == 0;
		lcm = lcm * i / __gcd(i, lcm);
		if (lcm > m)
		{
			cout << "0\n";
			return 0;
		}
	}

	ll ans = (m/lcm + 1) / 2;
	if (lcm % 2 == 0)
	{
		for (auto i : a)
			even &= lcm / i % 2 == 1;
		ans *= even;
	}
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 1024
N, A, B = map(int, input().split())
mod = 10 ** 9 + 7

# すべての取り方
ans = pow(2, N, mod) - 1

up = [N]
down = [1]
for i in range(1, B):
    down.append(down[-1] * (i+1) % mod)
    up.append(up[-1] * (N - i) % mod)


def comb(r):
    res = up[r - 1] * pow(down[r - 1], mod - 2, mod) % mod
    return res


ans = (ans - comb(A) + mod) % mod
ans = (ans - comb(B) + mod) % mod
print(ans)


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int cost_a (int n) {
  int r = (n % 5) * 380;
  r += (n - (n%5)) * 38 * 8;
  return r;
}

int cost_b (int n) {
  int r = (n % 4) * 550;
  r += (n - (n % 4)) * 55 * 85 / 10;
  return r;
}

int cost_c (int n) {
  int r = (n%3)*850;
  r += (n-(n%3)) * 88 * 85 / 10;
  return r;
}

int main() {
  map<string, vector<int>> s;
  for (;;) {
    string w; cin >> w;
    if (!cin) break;
    int p; cin >> p;
    s[w].push_back(p);
  }
  for (auto&x : s) {
    cout << car(x) << endl;
    sort(all(cdr(x)));
    cout << cdr(x)[0];
    iota (i, cdr(x).size() - 1, 1, 1) cout << ' ' << cdr(x)[i];
    cout << endl;
  }
    
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

int main(void){
  int r;
  cin>>r;
  cout<<r*r<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int m,n,flag=1,i;
    char s[15];
    scanf("%d%d",&n,&m);
    scanf("%s",s);
    for(i = 0;i<n;i++)
    {
        if(s[i]>='0'&&s[i]<='9') flag=1;
        else {flag=0;break;}
    }
    if(!flag) {printf("No\n");return 0;}
    if(s[i]!='-') {printf("No\n");return 0;}
    for(i = n+1;i<=n+m;i++)
    {
       // cout<<s[i]<<endl;
        if(s[i]>='0'&&s[i]<='9') flag=1;
        else {flag=0;break;}
    }
    if(!flag) {printf("No\n");return 0;}
    else printf("Yes\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int a;
	scanf("%d",&a);

	printf("%d\n",a+a*a+a*a*a);

	return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

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

	int len = S.length();

	string output = "";

	int rcount = 0;
	int lcount = 0;

	bool endflag = false;
	int ind = 0;
	while(true) {
		rcount = 0;
		lcount = 0;
		//R
		while (true) {
			if (S[ind] == 'R') {
				rcount++;
				ind++;
			}
			else {
				break;
			}
		}
		//L
		while (true) {
			if (S[ind] == 'L') {
				lcount++;
				ind++;
			}
			else {
				break;
			}
			if (ind == len) {
				endflag = true;
				break;
			}
		}
		for (int i = 0; i < rcount - 1; i++) {
			output += "0 ";
		}
		if (rcount % 2 == lcount % 2) {
			output += (to_string((rcount + lcount) / 2) + " ");
			output += (to_string((rcount + lcount) / 2) + " ");
		}
		else if (rcount % 2 == 1) {
			output += (to_string((rcount + lcount) / 2 + 1) + " ");
			output += (to_string((rcount + lcount) / 2) + " ");
		}else{
			output += (to_string((rcount + lcount) / 2) + " ");
			output += (to_string((rcount + lcount) / 2 + 1) + " ");
		}
		for (int i = 0; i < lcount - 1; i++) {
			output += "0 ";
		}
		if (endflag) {
			break;
		}
	}

	output.replace(output.length() - 1, 1, "");

	cout << output;

	return 0;
}


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

// 3^10
typedef long long LL;

vector<LL> vec;

void dfs(int cur,int pre,LL sum)
{
	vec.push_back(sum);
	if(cur>=10) return;
	for(int i=max(0,pre-1);i<=min(9,pre+1);i++)
		dfs(cur+1,i,sum*10+i);
}

int main()
{
	for(int i=1;i<=9;i++)
		dfs(1,i,i);
	vec.push_back(0);
	sort(vec.begin(),vec.end());
	//cout<<vec.size()<<endl;
	int n;
	cin>>n;
	cout<<vec[n]<<endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  vll A(N+1), B(N);
  REP(i,N+1) IN(A[i]);
  REP(i,N) IN(B[i]);
  ll ans1=0, ans2=0;

  vll A_copy = A;
  vll B_copy = B;

  REP(i,N){
    ll tmp = min(B[i], A[i]);
    A[i] -= tmp;
    B[i] -= tmp;
    ans1 += tmp;
    ll tmp2 = min(B[i], A[i+1]);
    A[i+1] -= tmp2;
    B[i] -= tmp2;
    ans1 += tmp2;
  }

  RREP(i,N-1){
    ll tmp = min(B[i], A[i+1]);
    A[i+1] -= tmp;
    B[i] -= tmp;
    ans2 += tmp;
    ll tmp2 = min(B[i], A[i]);
    A[i] -= tmp2;
    B[i] -= tmp2;
    ans2 += tmp2;
  }

  OUT(max(ans1, ans2));

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include<cstdint>

int const MAXK = 5000;

int64_t d[MAXK], dorg[MAXK];
int k, q;

void proc(int64_t n, int64_t x, int64_t m) {
  for(int i = 0; i < k; ++i) d[i] = dorg[i]%m;
  x %= m;
  int64_t ans = n-1; // j in [0, n-2]
  // remove count of: a_j == a_{j+1} (mod m)
  //     1. repeated in [(n-1)%k, n-1)
  int64_t c = 0;
  for(int i = 0; i < k; ++i) if(d[i] == 0) ++c;
  c *= (n-1)/k;
  ans -= c;
  //     2. in [0, (n-1)%k)
  for(int i = 0; i < (n-1)%k; ++i) if(d[i] == 0) --ans;

  // remove count of: a_j >= a_{j+1} (mod m)
  // i.e. count of multiple of m in (x, x+sum d[j%k])
  // i.e. that of (0, x+sum d[j%k]) (because x in [0, m))
  //   calc sum d[j%k]
  //     1. repeated j in [(n-1)%k, n-1)
  int64_t sum = 0;
  for(int i = 0; i < k; ++i) sum += d[i];
  sum *= (n-1)/k;
  //     2. in [0, (n-1)%k)
  for(int i = 0; i < (n-1)%k; ++i) sum += d[i];
  //   remove the count
  ans -= (x + sum)/m;
  std::cout << ans << std::endl;
}

int main() {
  std::cin >> k >> q;
  for(int i = 0; i < k; ++i) std::cin >> dorg[i];
  for(int i = 0; i < q; ++i) {
    int64_t n, x, m; std::cin >> n >> x >> m;
    proc(n, x, m);
  }
}


Measured memory_bytes: 384
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using D = double;
using T = tuple<D, D, D>;

int main() {
	vector<T> l;
	int N = in();
	D W = in(), V = 0;
	for (; N; N--) {
		const D v = in(), w = in();
		l.push_back(make_tuple(v / w, v, w));
	}
	sort(l.rbegin(), l.rend(), [](const T &a, const T &b) {return get<0>(a) < get<0>(b);});
	for (auto x: l) {
		const D w = get<2>(x), m = min(W, w);
		W -= m;
		V += get<1>(x) * (m / w);
		if (W <= 0)
			break;
	}
	printf("%f\n", V);
}


Measured memory_bytes: 5388
function main(input) {
  var digits = input.toString().length;
  var input = parseInt(input, 10);

  var divisor = Math.pow(10, digits - 1);
  var arr = [];
  for (var i = 0; i < digits; i++) {
  	arr.push(Math.floor(input / divisor))
  	input = input % divisor;
  	divisor /= 10;

  }
  var answer = arr.reduce((a, b) => a + b);
  if(answer == 1) {answer = 10;}

  console.log(answer);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 10000000;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

ll A[10050];
ll B[10050];
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &A[i]);
	for (i = 1; i <= N; i++) scanf("%lld", &B[i]);

	ll s = 0;
	for (i = 1; i <= N; i++) s += B[i] - A[i];
	if (s < 0) return !printf("No\n");

	ll mn = 0;
	for (i = 1; i <= N; i++) {
		if (A[i] > B[i]) mn += A[i];
		else if (A[i] % 2 != B[i] % 2) mn += B[i] + 1;
		else mn += B[i];
	}
	for (i = 1; i <= N; i++) mn -= B[i];
	if (mn > s) printf("No\n");
	else printf("Yes\n");
	return 0;
}
//*/

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

double area(double a,double b,double c){
	double s;

	s = (a+b+c)/2.0;

	return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main(){
	int i;
	double x[4],y[4],len[6],s[4];

	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3]) != EOF){
		for(i = 0;i < 3;i++){
			len[i] = sqrt(pow(x[(i+1)%3]-x[i],2)+pow(y[(i+1)%3]-y[i],2));
			len[3+i] = sqrt(pow(x[3]-x[i],2)+pow(y[3]-y[i],2));
		}
		for(i = 0;i < 3;i++){
			s[i] = area(len[i],len[3+i],len[(i+1)%3+3]);
		}
		s[3] = area(len[0],len[1],len[2]);

		if(fabs(s[3]-s[0]-s[1]-s[2]) < 1e-5){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
  lli n,W;
  cin>>n>>W;
  vector<lli> v,w;
  for(int i=0;i<n;i++) 
  {
      int weight,value;
      cin>>weight>>value;
      v.push_back(value);
      w.push_back(weight);
  }
  lli dp[n+1][W+1];
  for(int i=0;i<=n;i++)
  {
      for(int j=0;j<=W;j++)
      {
          if(i==0 || j==0) dp[i][j]=0;
          else if(w[i-1]>j) dp[i][j]=dp[i-1][j];
          else 
          {
              dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
          }
      }
  }
  
  cout<<dp[n][W]<<endl;
  return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int num[100010];
int maxl = -1000000000;
int main() {
	memset(num, 0, sizeof(num));
	int N;
	cin >> N;
	int a[N];
	for (int i = 0; i < N; i ++) {
		cin >> a[i];
		num[a[i]] ++;
	}
	sort(a, a + N);
	for (int i = -2; i < a[N - 1]; i ++) {
		maxl = max(num[i] + num[i + 1] + num[i + 2], maxl);
	}
	cout << maxl << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

signed main()
{
   int n, k; cin >> n >> k;
   vec<int> h(n);
   rep(i, 0, n) {
      cin >> h[i];
   }

   SORT(h);
   vec<int> d(n-k+1);
   rep(i, 0, n-k+1) {
      d[i] = h[i+k-1] - h[i];
   }

   SORT(d);
   cout << d[0] << endl;

   return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf n,cnt=0;
    string p;
    cin >>n;
    std::map<string,int> s;
    rep(i,n){
        cin>>p;
        s.try_emplace(p);
    } 

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


}

Measured memory_bytes: 19204
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 1000005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    ll a[m];
    ll sum = 0;
    for(int i=0;i<m;i++){
        cin>>a[i];
        sum += a[i];
    }
    if(sum>n){
        cout<<-1;
    }
    else{
        cout<<n-sum;
    }
	return 0;
}


Measured memory_bytes: 3684
n, *a = map(int, open(0).read().split())

b = []
for i in range(n):
    b.append((a[i], i))
b.sort()

ans = 0
for i in range(n):
    if b[i][1] % 2 != i % 2:
        ans += 1
print(ans // 2)


Measured memory_bytes: 23528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll=long long;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll r_cnt=0;
  ll g_cnt=0;
  ll b_cnt=0;
  rep(i,n){
    if(s[i]=='R') r_cnt+=1;
    else if(s[i]=='G')  g_cnt+=1;
    else b_cnt+=1;
  }
  ll total= r_cnt*g_cnt*b_cnt;
  ll cnt=0;
  rep(i,n){
    for(int j=1; j<n;j++){
      if(i+(2*j)<n){
        //cout << i << j;
        if((s[i]!=s[i+j])&(s[i]!=s[i+(2*j)])&(s[i+j]!=s[i+(2*j)])){
          cnt+=1;
        }
      }
    }
  }
  cout << total - cnt << endl; 
  //cout << cnt<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <map>
#define N 100010
#define ll long long 
using namespace std;
ll n,m,a[N],b[N];
map<ll,ll> p;

ll gcd(ll x,ll y) {
	if (!y) return x;
	return gcd(y,x%y);
}

int main() {
	scanf("%lld%lld",&n,&m);
	for (ll i=1; i<=n; i++) {
		char c; cin>>c;
		a[i]=c-'a'+1;
	}
	for (ll i=1; i<=m; i++) {
		char c; cin>>c;
		b[i]=c-'a'+1;
	}
	ll g=gcd(n,m),l=n*m/g; 
	for (ll i=1; i<=n; i++) 
		p[(i-1)*(l/n)+1]=a[i];
	for (ll i=1; i<=m; i++) {
		ll val=p[(i-1)*(l/m)+1];
		if (val && val!=b[i]) {
			puts("-1");
			return 0;
		}
	}
	printf("%lld",l);
}

Measured memory_bytes: 11904
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,d;
    cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d));
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int sum=0;
            for(int k=0;k<d;k++){
                int a=abs(x[i][k]-x[j][k]);
                a=a*a;
                sum+=a;
            }


            for(int l=1;l<=sqrt(sum);l++){
                if(l*l==sum){
                    ans++;
                    break;
                }
            }

        }
    }

    cout<<ans<<endl;



    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;
using vll = vector<ll>;

ll N, M, V, P; 
vll arr;

bool canAppear(ll index) {
    //cout << "DECIDING: " << arr[index] << endl;
    vll newArr;
    ll highest = arr[index] + M;

    ll judgeVotes = V - 1;
    
    ll bigger = 0;
    F0R(i, N) {
        if (i == index) continue;
        if (arr[i] > highest) {
            --judgeVotes;
            ++bigger;
            continue;
        }
        newArr.push_back(arr[i]);
    }
    

    ll remaining = M * judgeVotes;
    //cout << remaining << endl;
    vll probVotes (newArr.size());
    F0R(i, newArr.size()) {
        ll diff = highest - newArr[i];
        ll use = min(diff, M);
        probVotes[i] = use;
        remaining -= use;
        //cout << "USING: " << newArr[i] << " " << use << endl;
    }
    //cout << bigger << " " << remaining << endl;
    for (ll i = 0; i < newArr.size() && remaining > 0; ++i) {
        remaining -= M - probVotes[i];
        ++bigger;
    }
    return bigger < P;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> N >> M >> V >> P;
    arr.resize(N);
    F0R(i, N) cin >> arr[i];
    sort(arr.begin(), arr.end(), greater<ll>());
    ll lo = 0;
    ll hi = N-1;
    while (lo < hi) {
        ll mid = lo + (hi - lo+1) / 2;
        if (canAppear(mid)) 
            lo = mid;
        else
            hi = mid - 1;
    }
    cout << lo + 1 << endl;
}

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

int x[3000], y[3000];
bool f[5001][5001];

int main()
{
	int n;
	while (scanf("%d", &n), n){
		memset(x, 0, sizeof(x));
		memset(y, 0, sizeof(y));
		memset(f, 0, sizeof(f));
		
		for (int i = 0; i < n; i++){
			scanf("%d %d", &x[i], &y[i]);
			f[x[i]][y[i]] = true;
		}
		
		int maxi = 0;
		for (int i = 0; i < n; i++){
			for (int j = 1; j < n; j++){
				const int X = abs(x[i] - x[j]);
				const int Y = abs(y[i] - y[j]);
				
				if (x[i] + Y <= 5000 && y[i] + X <= 5000 && x[j] + Y <= 5000 && y[j] + X <= 5000){
					if (f[x[i] + Y][y[i] + X] && f[x[j] + Y][y[j] + X]){
						maxi = max(maxi, X * X + Y * Y);
					}
				}
			}
		}
		
		printf("%d\n", maxi);
	}
	
	return 0;
}

Measured memory_bytes: 25640
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
const double PI=3.14159265358979323846;

int main() {
    cout << std::setprecision(10);
    int a, b, x; cin >> a >> b >> x;
    if (1.0 * a * a * b / 2 <= x) {
        double k = 2.0 * b - 2.0 * x / (a * a);
        cout <<atan(1.0 * k / a) * 180.0 / PI << endl;
    } else {
        double k = 2.0 * x / (b * a);
        cout << atan(1.0 * b / k) * 180 / PI << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,m,q,cnt1[2020][2020],cnt2[2020][2020],cnt3[2020][2020];
char c[2020][2020];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m>>q;
    rep(i,n){
        rep(j,m){
            cin>>c[i][j];
        }
    }
    rep(i,n){
        rep(j,m){
            cnt1[i+1][j+1]=cnt1[i+1][j]+(c[i][j]-'0');
        }
    }
    rep(j,m){
        rep(i,n){
            cnt1[i+1][j+1]+=cnt1[i][j+1];
        }
    }
    rep(i,n){
        rep(j,m){
            if(c[i][j]==c[i][j+1]&&c[i][j]=='1'){
                cnt2[i+1][j+2]++;
            }
            if(c[i][j]==c[i+1][j]&&c[i][j]=='1'){
                cnt3[i+2][j+1]++;
            }
        }
    }
    rep(i,n){
        rep(j,m){
            cnt2[i+1][j+1]+=cnt2[i+1][j];
            cnt3[i+1][j+1]+=cnt3[i+1][j];
        }
    }
    rep(j,m){
        rep(i,n){
            cnt2[i+1][j+1]+=cnt2[i][j+1];
            cnt3[i+1][j+1]+=cnt3[i][j+1];
        }
    }
    while(q--){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        int c1=cnt1[x2][y2]-cnt1[x1-1][y2]-cnt1[x2][y1-1]+cnt1[x1-1][y1-1];
        int c2=cnt2[x2][y2]-cnt2[x1-1][y2]-cnt2[x2][y1]+cnt2[x1-1][y1];
        int c3=cnt3[x2][y2]-cnt3[x1][y2]-cnt3[x2][y1-1]+cnt3[x1][y1-1];\
        cout<<c1-c2-c3<<endl;
    }
    return 0;
}

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


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

int main() {
  int n, X; cin >> n >> X;
  vector<int> x(n+1), dx(n+1);
  rep(i,n+1) {
    if (i == 0) {
      x[i] = X;
      continue;
    }
    cin >> x[i];
    dx[i] = abs(x[i] - x[i-1]);
  }

  int gx = gcd(dx[2], dx[1]);
  int i = 3;
  while (i<n) {
    gx = gcd(gx, dx[i++]);
  }
  cout << gx << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int count=0;
    int d=n;
    while(n>0){
        count+=n%10;
        n/=10;
    }
    if(d%count==0)puts("Yes");
    else{puts("No");}
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class DDivGame {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            long n = s.nextLong(), sq = (long) Math.sqrt(n);
            int ans = 0;
            for (int i = 2; i <= sq; i++) {
                if (n % i == 0) {
                    int tot = 0, cur = 1;
                    while (n % i == 0) {
                        n /= i;
                        tot++;
                    }
                    while (tot >= cur) {
                        tot -= cur;
                        cur++;
                        ans++;
                    }
                }
            }
            if (n > 1) ans++;
            w.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public long nextLong() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }

            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25860
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;


#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) f(i,0,n-1)cin>>a[i]
#define in1(a,n) f(i,1,n)cin>>a[i]
#define out(a,n) f(i,0,n-1)cout<<fixed<<setprecision(20)<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define f(i,a,b) for (int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) f(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

const int N=(int)1e5+5;

int h[N],dp[N];

int main(int argc, char const *argv[])
{
	crap;
	int n;
	cin>>n;
	in1(h,n);
	dp[n]=0;
	dp[n-1]=abs(h[n]-h[n-1]);
	rf(i,n-2,1)
	{
		dp[i]=min(abs(h[i]-h[i+1])+dp[i+1],abs(h[i]-h[i+2])+dp[i+2]);
	}

	cout<<dp[1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
from collections import deque
from collections import defaultdict

N, M = map(int, input().split())
graph = defaultdict(list)

# defaultdictにグラフ構造（双方向）を格納
for _ in range(M):
    a, b = map(lambda x: int(x), input().split())
    graph[a].append(b)
    graph[b].append(a)

# 訪れたかどうかを判定するリストを準備
visited = [False] * (N + 1)

# 0は捨て番、1はstart地点のため更新されないようにvisitedにしておく
visited[0] = True
visited[1] = True

# 開始地点を指定
que = deque([1])

while que:
    # 幅優先なのでFIFO。最初はスタート地点をpop
    node = que.popleft()

    # popしたノードから辿れるノードがまだ訪れていないノードであれば更新し、キューにappend
    for n in graph[node]:
        if not visited[n]:
            visited[n] = node
            que.append(n)

# 判定結果はindex:2以降でスライスしたもの
visited = visited[2:]

# 全てTrue（全ノード訪れている）ならYes、そうでなければNo
if all(visited):
    print("Yes")
    print(*visited, sep="\n")
else:
    print("No")

Measured memory_bytes: 40004
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
int main()
{
    ll n ,a ;
    cin>>n>>a ;
    cout<<(n/a)+(n%a!=0)<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,m,x,y;
	cin >> n >> m >> x >> y;
	int a[n+1],b[m+1];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (int i = 0;i < m;i++) {
		cin >> b[i];
	}
	a[n] = x;b[m] = y;
	sort(a,a+n+1);
	sort(b,b+m+1);
	if (a[n] >= b[0]) {cout << "War" << endl;}
	else {cout << "No War" << endl;}
}

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

#define all(x) x.begin(), x.end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 17, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int f[26];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    string s; cin>>s;
    for (char c : s) {
        f[c-'a']++;
    }
    for (int i = 0; i < 26; i++){
        if(f[i]&1){
            cout<<"No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


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

int main(){
  int N;cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int cnt = 0;
  for(int i=0;i<N;i+=2){
    if(a[i]%2 == 1) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3628
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
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;

public class Main{
    //WRWWRWRR     wwwrrrrwwwwrrr
    PriorityQueue<int[]> pq = new PriorityQueue<>((a,b)->(a[0]-b[0]));
    public void solve(int testNumber, InputReader in, PrintWriter out) {
       int n = in.nextInt();
       int[][] arr = new int[n][3];
       for(int i=0;i<n;i++){
           arr[i] = new int[]{in.nextInt(),in.nextInt(),in.nextInt()};
       }
       int[][] ans = new int[n+1][3];
       for(int i=0;i<n;i++){
           ans[i+1][0] = Math.max(ans[i][1],ans[i][2])+arr[i][0];
           ans[i+1][1] = Math.max(ans[i][0],ans[i][2])+arr[i][1];
           ans[i+1][2] = Math.max(ans[i][1],ans[i][0])+arr[i][2];
       }

        out.println(Math.max(ans[n][0],Math.max(ans[n][1],ans[n][2])));
    }

    //int mod = (int)(1e9+7);


    public static void main(String[] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main solver = new Main();
//        int num = in.nextInt();
//        while(num-->0){
//            solver.solve(1, in, out);
//        }
        solver.solve(1, in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

Measured memory_bytes: 63244
s = input()
t = input()

list1 = [-1 for i in range(26)]
list2 = [-1 for i in range(26)]

for i in range(len(s)):
    a = ord(s[i]) - ord("a")
    b = ord(t[i]) - ord("a")
    
    if list1[a] != -1 or list2[b] != -1:
        if list1[a] != b or list2[b] != a:
            print("No")
            exit()
    else:
        list1[a] = b
        list2[b] = a

print("Yes")

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define str string
#define sec .second
 
ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
ll A[1000000] = {}, B[1000000] = {}, weight[1000] = {}, value[1000] = {};
ll dp[1000][100100] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, n = 0, su = 0, ma = INF, mi = -1;
double ans;
pair<str, ll> S[1000];
bool an = true, bn = false;
long long mod = 1e9 + 7;
 
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;
}
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> n >> a;
	for (int i = 0; i < n; i++)cin >> weight[i] >> value[i];
 
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= a; j++) {
			
			if (j >= weight[i])dp[i + 1][j] = max(dp[i][j - weight[i]] + value[i], dp[i][j]);
			dp[i + 1][j] = max(dp[i][j],dp[i+1][j]);
		}
	}
	cout << dp[n][a] << endl;
 
		return 0;
}


Measured memory_bytes: 81408
#グラフのパスを全探索する関数(再帰)
def dfs(now_node, depth):#deptt:今まで列挙した頂点数
    if seen[now_node]:#探索済みであった場合はreturn
        return 0
    if depth == N:#全ての頂点を通っていた場合、1を返す
        return 1
    seen[now_node] = True  #今から探索するノードを探索済みにする
    connect_nodes = graph[now_node]
    ans = 0
    for node in connect_nodes:#全ての遷移先をチェックする
        ans += dfs(node, depth+1)
    seen[now_node] = False  # 探索済みフラグを折る(ポイント)
    return ans

N, M = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(M)]#辺の集合
graph =[[] for i in range(N+1)]#隣接リスト
for edge in edges:
    graph[edge[0]].append(edge[1])
    graph[edge[1]].append(edge[0])

#訪問済みかどうかを表すリストを用意
seen = [False for i in range(N+1)]
seen[0] = True

print(dfs(1, 1))

Measured memory_bytes: 9160