akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            #define pi 3.14159265358979323846
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                lli i,t,n,j,k,m,g;
                cin>>n>>k;
                double ans=0.0;
                repp(i,1,n+1){
                    if(i>=k){
                        ans+=double(1.0/double(n));
                    }
                    else{
                        lli st=0;
                        j=i;
                        while(j<k){
                            j*=2;
                            st++;
                        }
                        ans+=(double(1.0/double(n))*double(pow(0.5,double(st))));
                    }
                }
                cout<<fixed<<setprecision(13)<<ans<<endl;


                return 0;
            }


Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
constexpr int INF = 100100100;

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

using namespace std;

int main() {
  // cout << fixed << setprecision(10);
  int N;
  cin >> N;
  int sign = 1;
  long long int sum = 0;
  long long int minm = 1e10;
  REP(i, N) {
    long long int A;
    cin >> A;
    if (A < 0) {
      sign *= -1;
      A *= -1;
    }
    sum += A;
    chmin(minm, A);
  }
  cout << sum - (sign < 0 ? minm * 2 : 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int m,n, odd = 0,even = 0;
scanf("%d %d",&m,&n);

for(int i = 2; i <= m; i++){
	odd = odd + i - 1;
	
}	
for(int i=2; i <=n; i++) {
	even = even + i - 1;
}
	printf("%d",odd + even);
	return 0;
}

Measured memory_bytes: 1736
N = gets.to_i
if N == 1
  p 1; exit
end

PTS = (0...N).map{ gets.split.map &:to_i }.sort

diffs = {}
(0...N).each{ |i|
  (i+1...N).each{ |j|
    dx = (PTS[i][0] - PTS[j][0])
    dy = (PTS[i][1] - PTS[j][1])
    next if dx == 0 && dy == 0
    diffs[[dx,dy]] = 1
  }
}

ans = N
pmap = Hash[PTS.map{ |x,y| [[x,y],1] }]
diffs.keys.each{ |a,b|
  done = {}
  r = 0
  (0...N).each{ |i|
    x,y = PTS[i]
    if !pmap[[x-a,y-b]]
      r += 1
    end
  }
  ans = [ans, r].min
}

p ans


Measured memory_bytes: 3836
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;
int N,A[100005],l,r,B[100005],x;
long long Ans,Ret;
int main(){
	scanf("%d",&N);
	for (int i=1;i<=N;++i) scanf("%d",A+i);
	std::sort(A+1,A+1+N),l=1,r=N,x=A[(N+1)/2];
	for (int i=1;i<N;++i){
		if (i&1) Ans+=abs(A[l]-x),x=A[l++];
			else Ans+=abs(A[r]-x),x=A[r--];
	}
	l=1,r=N,x=A[(N+1)/2];
	for (int i=1;i<N;++i){
		if (i&1) Ret+=abs(A[r]-x),x=A[r--];
			else Ret+=abs(A[l]-x),x=A[l++];
	}
	return printf("%lld",max(Ans,Ret)),0;
}

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

int main(){
	int n;
	cin >> n;
	int flag = 0;

	for(int i = 1;i<50001;i++){
		if(n == floor(i * 1.08)){
			cout << i << endl;
			flag = 1;
			break;
		}
	}

	if(flag == 0){
		cout << ":(" << endl;
	}
	/*	double ans = n / 1.08;

	if(ans / 1.08 != 0){
		cout << ':(' << endl;
	}else{
		cout << ans << endl;
	}*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d,count;
  a=0;b=0;c=0;d=0;
    char e;
  count =0;
  	string s;
  	cin>>a>>b>>c>>d;
cout<<min({a,b})+min({c,d})<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int r = Integer.parseInt(in.readLine());
    if(r<1200)
      System.out.println("ABC");
    else if(r<2800)
      System.out.println("ARC");
    else
      System.out.println("AGC");
  }
}

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


long long int solve(long long int a[],long long int n,long long int k)
{
	long long int i,j;
	long long int mod=1000000007;
	long long int dp[n+2][k+2];

	for(i=0;i<=k;i++)
	{
		dp[1][i]=(i>a[1])? 0 : 1;
	}
	for(i=2;i<=n;i++)
	{
		for(j=0;j<=k;j++)
		{
			if(j==0)
			{
				dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j]=(mod+dp[i][j-1] +dp[i-1][j]- ((j-a[i]-1)>=0 ? dp[i-1][j-a[i]-1] : 0))%mod;
			}	
		}
	}
	return(dp[n][k]);
}
int main()
{
	long long int n,k,i;
	cin>>n>>k;
	long long int a[n+2];
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	cout<<solve(a,n,k);
}

Measured memory_bytes: 78720
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

vector<vector<ll>> field(3, vector<ll>(3, 0));
vector<ll> coord1 = {0, 4, 8};
vector<ll> coord2 = {2, 4, 6};
void Main(){
    ll a;
    rep(i, 3){
        rep(j, 3){
            sll(a);
            field[i][j] = a;
        }
    }
    ll N;
    sll(N);
    set<ll> numbers;
    rep(i, N){
        sll(a);
        numbers.insert(a);
    }
    bool is_ok = false;
    rep(i, 3){
        bool ris_ok = true;
        bool cis_ok = true;
        rep(j, 3){
            ris_ok = ris_ok && (numbers.find(field[i][j]) != numbers.end());
            cis_ok = cis_ok && (numbers.find(field[j][i]) != numbers.end());
        }
        is_ok = is_ok || ris_ok;
        is_ok = is_ok || cis_ok;
    }

    bool e_is_ok = true;
    for(auto c:coord1){
        e_is_ok = e_is_ok && (numbers.find(field[c/3][c%3]) != numbers.end());
    }

    bool f_is_ok = true;
    for(auto c:coord2){
        f_is_ok = f_is_ok && (numbers.find(field[c/3][c%3]) != numbers.end());
    }

    is_ok = is_ok || (e_is_ok) || (f_is_ok);
    if(is_ok){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }


}

int main(){
    Main();
}

Measured memory_bytes: 3168
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)	cout<<k<<endl;
	else if(k<=a+b)	cout<<a<<endl;
	else 
	{
		int num=k-a-b;
		cout<<a-num<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

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


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int h,w;
  cin>>h>>w;
  char mp[h][w];
  pair<int,int> st;
  rep(i,h){
    rep(j,w){
      cin>>mp[i][j];
      
    }
  }
  queue<pair<int,int> > bfs;
  pair<int,int> nex;
  int ans=0;
  int mp2[h][w];
  rep(l,h){
    rep(m,w){
      if(mp[l][m]=='.'){bfs.push(make_pair(l,m));nex.fst=l;nex.scd=m;
      rep(i,h){
	rep(j,w){
	  mp2[i][j]=-1;
	}
      }
      mp2[nex.fst][nex.scd]=0;
      while(!bfs.empty()){
	nex=bfs.front();
	bfs.pop();
	rep(i,4){
	  if(nex.fst+dx[i]>=0 && nex.fst+dx[i]<h && nex.scd+dy[i]>=0 && nex.scd+dy[i]<w){
	    if(mp2[nex.fst+dx[i]][nex.scd+dy[i]]==-1 && mp[nex.fst+dx[i]][nex.scd+dy[i]]=='.'){
	      mp2[nex.fst+dx[i]][nex.scd+dy[i]]=mp2[nex.fst][nex.scd]+1;
	      bfs.push(make_pair(nex.fst+dx[i],nex.scd+dy[i]));
	    }
	  }
	}
      }
      ans=max(ans,mp2[nex.fst][nex.scd]);
      }
    }
  }
  cout<<ans<<endl;
  
	
    
  

  return 0;
}


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

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

	int ans = 0;
	int m = 0;
	for (int i=0; i<s.length(); i++)
	{
		if (s[i] == 'R')
			m++;
		else m = 0;
		ans = max(ans, m);
	}

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

Measured memory_bytes: 3636
N,M,C = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)
A = []
N.times{ A << gets.split(" ").map(&:to_i) }

count = 0
(0...N).each do |n|
    sum = 0
    A[n].each_with_index do |a, i|
        sum += a * b[i]
    end
    count += 1 if sum + C > 0
end
print count

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

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    queue<char> Acard;
    queue<char> Bcard;
    queue<char> Ccard;

    rep(i, A.size()) Acard.push(A[i]);
    rep(i, B.size()) Bcard.push(B[i]);
    rep(i, C.size()) Ccard.push(C[i]);

    char turn = Acard.front();
    Acard.pop();

    char winner;
    while(true) {
        if(turn == 'a') {
            if(Acard.empty()) {
                winner = 'A';
                break;
            }
            turn = Acard.front();
            Acard.pop();
        }
        else if(turn == 'b') {
            if(Bcard.empty()) {
                winner = 'B';
                break;
            }
            turn = Bcard.front();
            Bcard.pop();
        }
        else if(turn == 'c') {
            if(Ccard.empty()) {
                winner = 'C';
                break;
            }
            turn = Ccard.front();
            Ccard.pop();
        }
    }

    cout << winner << endl;
}


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

using namespace std;
using ll = long long;

struct UnionFind {
	vector<int> par;
	vector<int> r;

	UnionFind(size_t sz) {
		par.resize(sz);
		r.resize(sz, 0);
		for (int i = 0; i < sz; ++i) { par[i] = i; }
	}

	int find(int x) {
		if (par[x] == x) { return x; }
		else { return par[x] = find(par[x]); }
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) { return ; }

		if (r[x] < r[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (r[x] == r[y]) { ++r[x]; }
		}
	}

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

int main() {
	int N, M;
	cin >> N >> M;
	UnionFind uf(N + M);
	for (int i = 0; i < N; ++i) {
		int K; cin >> K;
		for (int j = 0; j < K; ++j) {
			int l; cin >> l;
			uf.unite(i, N + l - 1);
		}
	}

	for (int i = 0; i < N - 1; ++i) {
		if (!uf.same(i, N - 1)) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ll> H(n);
	rep(i, n) cin >> H[i];

	sort(all(H));
	reverse(all(H));

	ll sum = 0;
	for (int i = k; i < n; ++i) {
		sum += H[i];
	}

	dunk(sum);

	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void) {
    int L, R, d;
    int a = 0;
    scanf("%d %d %d", &L, &R,&d);

    for (int i = L; i <= R; i++) 
    {
        if (i % d == 0) {
            a += 1;
        }
    }
    printf("%d", a);
    return 0;
}


Measured memory_bytes: 3752
n = int(input())
d = list(map(int ,input().split()))
if d[0] != 0:
  print (0)
  exit()
d.sort()
mod = 998244353
s = [0 for i in range(max(d)+1)]

for i in range(n):
  s[d[i]] += 1
ans = 1
for i in range(len(s)):
  if s[i] == 0:
    print (0)
    exit()
  if i == 0:
    if s[i] > 1:
      print (0)
      exit()
    continue
  ans *= pow(s[i-1],(s[i]),mod)
  ans %= mod
print (ans%mod)

Measured memory_bytes: 20712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            Integer l[] = new Integer[n];
            int tmp = 0;
            for (int i = 0; i < n; i++) {
                l[i] = Integer.parseInt(in.next());
                tmp += l[i];
            }

            Arrays.sort(l, Comparator.reverseOrder());

            if (tmp - l[0] > l[0]) {
                out.println("Yes");
            } else {
                out.println("No");

            }

        }

    }
}



Measured memory_bytes: 21844
N,K = map(int,input().split())
mod = 10**9 +7
d = [0] * (K+1)

for i in range(1,K+1):
    d[i] = pow(K//i,N,mod)
for i in range(K,0,-1):
    for j in range(2*i,K+1,i):
        d[i] -= d[j]
        d[i] %= mod

ans = 0
for i in range(1,K+1):
    ans += d[i]*i
    ans %= mod
print(ans)

Measured memory_bytes: 68828
#include<iostream>
using namespace std;
int main(){
	int n,b,f,a[5][4][11]={0},r,v;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		a[b][f][r] = a[b][f][r]+v;
	}
	for(int i=1;i<4;i++){
		for(int j=1;j<11;j++){
			cout<<" "<<a[1][i][j];
		}
		cout<<endl;
	}
	cout<<"####################"<<endl;
		for(int i=1;i<4;i++){
		for(int j=1;j<11;j++){
			cout<<" "<<a[2][i][j];
		}
		cout<<endl;
	}
	cout<<"####################"<<endl;
		for(int i=1;i<4;i++){
		for(int j=1;j<11;j++){
			cout<<" "<<a[3][i][j];
		}
		cout<<endl;
	}
	cout<<"####################"<<endl;
		for(int i=1;i<4;i++){
		for(int j=1;j<11;j++){
			cout<<" "<<a[4][i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  string ans;
  cin >> a >> b >> c >> d;
  if(a+b > c+d) ans = "Left";
  else if (a+b < c+d) ans = "Right";
  else ans = "Balanced";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ac = min(a, c);
  int cc = max(c - ac, 0);
  int bc = min(b, cc);
  int bb = max(b - bc, 0);
  int ccc = max(cc - bc, 0);
  if (ccc) ccc = 1;
  ll ans = ac + (bc * 2) + bb + ccc;
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

//left<right??????true
bool comp(P left, P right)
{
	if (left.first == right.first) {
		return left.second < right.second;
	}
	return left.first > right.first;
	
}


int main()
{
	int n,m;
	while (1) {

		cin >> n >> m;
		if (n == 0 && m == 0)break;

		P a[105];
		int b;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cin >> b;
				a[j].second = j + 1;
				a[j].first += b;
			}
		}
		sort(a, a + m, comp);

		for (int i = 0; i < m - 1; i++) {
			cout << a[i].second << " ";
		}
		cout << a[m - 1].second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
<?php
fscanf(STDIN, "%s %s", $N,$Q);
fscanf(STDIN, "%s", $s);
$lr = [];
$ppp = [];
mas($s, $ppp);

for ($i = 0; $i<$Q; $i++) {
    fscanf(STDIN, "%s %s",$l,$r);
    $ff = $ppp[$r-1] - $ppp[$l-1];
    echo $ff."\n";
}

function mas($a, &$ppp) {
    $a = preg_split('//', $a, -1, PREG_SPLIT_NO_EMPTY);
    $ss = 0;
    $is_A_flag = 0;
    foreach ($a as $k => $s) {
        if ($s === 'A'){
            $is_A_flag = 1;
        } else if ($s === 'C' && $is_A_flag){
            $ss++;
            $is_A_flag = 0;
        } else {
            $is_A_flag = 0;
        }
        $ppp[$k] = $ss;
    }
}


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

bool include3(int n) {
    while (n > 0) {
        if (n % 10 == 3) {
            return true;
        } else {
            n /= 10;
        }
    }
    return false;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || include3(i)) {
            printf(" %d", i);
        }
    }
    printf("\n");
}


Measured memory_bytes: 3224
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int main(void) {
  long long N, M, T;
  long long A[10000];
  cin >> N >> M >> T;
  REP(i, 0, N) cin >> A[i];

  long long last = 0, ans = 0;
  REP(i, 0, N) {
    ans += max(A[i] - M - last, 0LL);
    last = A[i] + M;
  }
  ans += max(T - last, 0LL);

  cout << ans << endl;

  return 0;
}

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

using namespace std;

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

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif

#define ff first
#define ss second
int allowed[10];

int solve(int num){
    while (1){
        bool valid = true;
        string str = to_string(num);
        for (char c : str){
            if (!allowed[(int) c - '0'])
                valid = false;
        }
        if (valid) return num;
        num++;
    }
}

int main(){
    std::ios_base::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    for (int i = 0; i < 10; i++) allowed[i] = 1;
    for (int i = 0; i < k; i++){
        int dig; cin >> dig;
        allowed[dig] = 0;
    }
    cout << solve(n) << 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 RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
LL A[100001];
vector<LL>v;
typedef pair<LL,LL>P;
priority_queue<P>q;
priority_queue<P,vector<P>,greater<P> >qq;

int main(){
	cin>>N>>M;
	REP(i,N){
		cin>>A[i];
		v.push_back(A[i]);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	int mid=N-1;
	REP(i,N){
		if(v[i]<=i){
			mid=i;
			break;
		}
	}
	REP(i,mid){
		if(A[i]<=mid){
			qq.push(P(max((LL)i,A[i]),i));
		}
	}
	for(int i=mid;i<N;i++){
		if(A[i]>=mid){
			q.push(P(min((LL)i,A[i]),i));
		}
	}
	REP(i,M){
		if(q.empty())break;
		if(qq.empty())break;
		P p=q.top();q.pop();
		P pp=qq.top();qq.pop();
		if(pp.first>p.first)continue;
		//cout<<pp.second<<" "<<p.second<<endl;
		LL temp=A[p.second];
		A[p.second]=A[pp.second];
		A[pp.second]=temp;
	}
	LL ans=0;
	REP(i,N){
		ans+=(LL)abs(i-A[i]);
	}
	
	cout<<ans<<endl;
}


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

int main() {
  int n,p,d1,d2,max,pp;
  while(cin>>n, n) {
    max = 0;
    for(int i=0; i<n; ++i) {
      cin>>p>>d1>>d2;
      if(d1+d2 > max) {
	max = d1+d2;
	pp = p;
      }
    }
    cout<<pp<<" "<<max<<endl;
  }
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int x=n;
  int ans;

 /* for(int i=0;i<n;i++){
    x=x/k;
    ans++;
    if(x<k){
      ans++;
      break;
    }
  }*/
  while(x>0){
    x=x/k;
    ans++;
  }
  cout << ans << endl;
}

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

int main() {
    int A,B,C;
    cin >>A>>B>>C;
    if((A==B&&A!=C)||(A==C&&B!=C)||(C==B&&A!=C)){
        cout << "Yes";
        return 0;
    }
    cout <<"No";
    return 0;
}


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

int main()
{
	int count = 0;
	string S;

	cin >> S;

	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') {
			count += 100;
		}
	}
	count += 700;
	cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;
int main(){
    int n;
    cin >> n;

    vector<pair<string, pair<int, int>>> vec(n);

    REP(i,n){
        cin >> vec[i].first >> vec[i].second.first;
        vec[i].second.first *= -1;
        vec[i].second.second = i+1;
    }

    SORT(vec);

    REP(i,n){
        cout << vec[i].second.second <<endl;
    }
    
}


Measured memory_bytes: 256
#include<stdio.h>

int partition(int A[],int p,int r)
{
	int tmp;
	int x=A[r];
	int i=p-1;
	int j;
	for(j=p;j<=r-1;j++)
	{
		if(A[j]<=x)
		{
			i=i+1;
			tmp=A[i];
			A[i]=A[j];
			A[j]=tmp;
		}
	}
	
		tmp=A[i+1];
		A[i+1]=A[r];
		A[r]=tmp;
	
	return i+1;
}

int main()
{
	int A[500000];
	int i,n,x;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	
	x=partition(A,0,n-1);
	
	for(i=0;i<n;i++)
	{
		if(i)
		{
			printf(" ");
		}
		if(i==x)
		{
			printf("[");
		}
		printf("%d",A[i]);
		if(i==x)
		{
			printf("]");
		}
		
	}
	printf("\n");
	return 0;
}



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

char primes[10001];

int main(){
  int i,j,n,m;

  primes[0]=1;
  primes[1]=1;
  n=sqrt(10000);
  for(i=2;i<n;i++){
    m=10000/i+1;
    for(j=2;j<m;j++) primes[i*j]=1;
  }
  while(scanf("%d",&n)!=EOF){
    for(i=1,m=0;i<n;i++)
      if(!primes[i]&&!primes[n-i+1]) m++;
    printf("%d\n",m);     
  }
  return 0;
}
      

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define INF (2000000000)
#define MOD (1000000007)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;
typedef vector<long> VL;
typedef vector<long>::iterator VLI;
typedef pair<int, int> P;

long a[1001];
VL score;

int main()
{
	int N;
	long M;
	
	while (scanf("%d %ld", &N, &M), N + M){
		for (int i = 1; i <= N; i++){
			scanf("%ld", &a[i]);
		}
		for (int i = 0; i <= N; i++){
			for (int j = 0; j <= N; j++){
				score.push_back(a[i] + a[j]);
			}
		}
		sort(score.begin(), score.end());
		
		int size = score.size();
		long maxi = 0;
		int l = 0;
		int r = size - 1;
		while (l < r){	
			if (score[l] + score[r] <= M){
				maxi = max(maxi, score.at(l) + score.at(r));
				l++;
			}
			else {
				r--;
			}
		}
		
		printf("%ld\n", maxi);
		score.clear();
	}
	
	return 0;
}

Measured memory_bytes: 10792
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.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() {
    int N,M,K;
    int count;
    scanf("%d %d",&N,&M);
    int tenboudai[N+1];
    int counter[N+1];
    for(int i = 1; i <=N; ++i){
        scanf("%d",&tenboudai[i]);
        counter[i] = 1;
    }
    for(int i = 0; i < M; ++i){
        int a,b;
        scanf("%d %d",&a,&b);
        if(tenboudai[a] > tenboudai[b]){
            counter[b] = 0;
        }
        else if(tenboudai[a] < tenboudai[b]){
            counter[a] = 0;
        }
        else{
            counter[a] = 0;
            counter[b] = 0;
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; ++i){
        if(counter[i] == 1){
            ans++;
        }
    }
    printf("%d",ans);

}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
const int N=3e5+9;

int n,k,x;
int seg[4*N];

 
int get(int p,int l,int r,int a,int b){
     if(l>=a&&r<=b)return seg[p];       
     if(r<a||l>b) return 0;
    int mid=(l+r)/2;
    if(b<=mid) return get(p*2,l,mid,a,b);
    if(a>mid) return get(p*2+1,mid+1,r,a,b);
    return max(get(p*2,l,mid,a,b),get(p*2+1,mid+1,r,a,b));
}
 
void update(int p,int l,int r,int idx,int v){
    if(l==r){
        seg[p]=v;
        return ;
    }
    int mid=(l+r)/2;
    if(idx<=mid)update(p*2,l,mid,idx,v);
    else update(p*2+1,mid+1,r,idx,v);
    seg[p]=max(seg[p*2],seg[p*2+1]);
 
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    cin>>n>>k;
    for(int i=0;i<n;i++){
    	cin>>x;
    	x++;
    	int l=max(1,x-k);
    	int r=min(N,x+k);
    	int cur=get(1,1,n,x,x);
    	int go=get(1,1,N,l,r);
    	if(cur<=go)update(1,1,N,x,go+1);
    	else update(1,1,N,x,1);

    }
    cout<<get(1,1,N,1,N)<<'\n';
}

Measured memory_bytes: 7696
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

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

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int solve() {
	int n; cin >> n;
	vi v(n); rep(i, n) cin >> v[i];
	vi cnt1(1e5+1, 0), cnt2(1e5+1, 0);
	for(int i=0;i<n;i+=2) cnt1[v[i]]++;
	for(int i=1;i<n;i+=2) cnt2[v[i]]++;
	priority_queue<ii> pq1, pq2;
	for(int i=1;i<=100000;i++) if(cnt1[i]) {
		pq1.push(ii(cnt1[i], i));
	}
	for(int i=1;i<=100000;i++) if(cnt2[i]) {
		pq2.push(ii(cnt2[i], i));
	}
	pq1.push(ii(0,0));
	pq2.push(ii(0,0));
	auto a = pq1.top(); pq1.pop();
	auto b = pq1.top(); pq1.pop();
	auto c = pq2.top(); pq2.pop();
	auto d = pq2.top(); pq2.pop();
	if(a.second != c.second) {
		cout << n - a.first - c.first;
		return 0;
	}
	cout << n - max(a.first+d.first, b.first+c.first);
}

int main() {
	fastio;
	solve();
}



Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rall(x) x.rbegin(),x.rend()
#define mu(x) x.resize(unique(all(x))-x.begin());
#define srt(x) sort(all(x));
#define rev(x) reverse(all(x));
#define each(x,a) for(auto& x:a)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define PER(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define debug_v(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y<<" "; cerr<<'\n';}
#define debug_vp(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y.ff<<" "<<y.ss<<'\n'; cerr<<'\n';}
#ifndef BTW
	#define cerr if(false)cerr
#endif
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int main(){
	fastio;
	int n;
	cin>>n;
	vi a(n);
	vi cnt(n+1);
	rep(i,n)cin>>a[i];
	ll ans=0;
	rep(i,n){
		cnt[a[i]]++;
	}
	REP(i,1,n){
		ans+=(ll)cnt[i] * (cnt[i]-1)/2;
	}
	rep(i,n){
		ans-=(ll)cnt[a[i]] * (cnt[a[i]]-1)/2;
		cnt[a[i]]--;
		ans+=(ll)cnt[a[i]] * (cnt[a[i]]-1)/2;
		cout<<ans<<"\n";
		ans-=(ll)cnt[a[i]] * (cnt[a[i]]-1)/2;
		cnt[a[i]]++;
		ans+=(ll)cnt[a[i]] * (cnt[a[i]]-1)/2;
	}
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll i,j,k,m,n,t,p;
	string s1,s2;
	cin>>s1>>s2;
	n=s1.length();
	ll ans=0;
	for(i=0;i<n;i++)
	if(s1[i]!=s2[i]) ans++;
	cout<<ans;
}

Measured memory_bytes: 3912
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(ll V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

ll froot(ll n) 
{ 
    // Base cases 
    if (n == 0 || n == 1) 
        return n; 
  
    // Initialize result 
    ll res = 0; 
  
    // Keep incrementing res while res^5 is 
    // smaller than or equal to n 
    while (res*res*res*res*res <= n) 
        res++; 
  
    // Return floor of 5'th root 
    return res-1; 
} 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll x; cin >> x;
	forl(i, 0, 10001) {
		ll val = i*i*i*i*i;
		if(val > x) {
			ll lft = val-x;
			ll f = froot(lft);
			if(f*f*f*f*f == lft) { cout << i << " " << f << endl; return 0; }
		}
		else {
			ll lft = x-val;
			ll f = froot(lft);
			if(f*f*f*f*f == lft) { cout << i << " -" << f << endl; return 0; }
		}
	}
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll a;
   long double b;
   cin>>a>>b;
   
   a*=b;
   cout<<a<<endl;
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 3748
while true
	n,x = gets.chomp.split(" ").map(&:to_i)
	break if n == 0 && x == 0
	nums = [n]
	count = 0
	n.times do |i|
		nums[i] = i + 1
	end
	for i in 0..n - 1 do
		for j in i + 1..n - 1 do
			for k in j + 1..n - 1 do
					count += 1 if nums[i] + nums[j] + nums[k] == x
			end
		end
	end
	puts count
end

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

int main() {
  bool flag=false;
  string s;
  cin >> s;
  while(s.size()<9)s=s+'0';
  if(s.size()<=9&&s[0]=='A'){		//A????????
    if(s[1]=='K'&&s[2]=='I'&&s[3]=='H'){
      if(s[4]=='A'&&s[5]=='B'){			//AKIHAB???
        if(s[6]=='A'&&s[7]=='R'){		//AKIHABAR?
          if(s[8]=='A'||s[8]=='0')flag=true;
        }
        else if(s[6]=='R'){				//AKIHABR?
          if(s[7]=='A'||s[7]=='0')flag=true;
        }
      }
      else if(s[4]=='B'){				//AKIHB???
        if(s[5]=='A'&&s[6]=='R'){		//AKIHBAR?
          if(s[7]=='A'||s[7]=='0')flag=true;
        }
        else if(s[5]=='R'){				//AKIHBR?
          if(s[6]=='A'||s[6]=='0')flag=true;
        }
      }
    }
  }
  else if(s.size()<=9&&s[0]=='K'&&s[1]=='I'&&s[2]=='H'){		//KIH?????
      if(s[3]=='A'&&s[4]=='B'){					//KIHAB???
        if(s[5]=='A'&&s[6]=='R'){
          if(s[7]=='A'||s[7]=='0')flag=true;
        }
        else if(s[5]=='R'){
          if(s[6]=='A'||s[6]=='0')flag=true;
        }
      }
      else if(s[3]=='B'){						//KIHB???
        if(s[4]=='A'&&s[5]=='R'){
          if(s[6]=='A'||s[6]=='0')flag=true;
        }
        else if(s[4]=='R'){
          if(s[5]=='A'||s[5]=='0')flag=true;
        }
      }
  }
  if(flag)cout<<"YES"<<endl;
  else cout << "NO"<<endl;
}


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();
		long sum = 0;
		for(int i = 1; i <= n; i++) {
			if(i % 3 == 0 || i % 5 == 0) continue;
			sum += i;
		}

		System.out.println(sum);

		sc.close();
	}
}

Measured memory_bytes: 27244
def solve(K, D):
    N = len(K)
    MOD = 1_000_000_007
    dp = [[[0] * D for _ in range(2)] for _ in range(N + 1)]
    dp[0][0][0] = 1
    for i in range(N):
        for is_less in range(2):
            for k in range(D):
                for l in range(10 if is_less else K[i] + 1):
                    is_less_ = is_less or l < K[i]
                    k_ = (k + l) % D
                    dp[i + 1][is_less_][k_] += dp[i][is_less][k]
                    dp[i + 1][is_less_][k_] %= MOD
    return (dp[N][0][0] + dp[N][1][0] - 1) % MOD


print(solve(list(map(int, input())), int(input())))


Measured memory_bytes: 86380
#include <bits/stdc++.h>
using namespace std;
int main(){
  list<int> lst;
  int n;
  cin >> n;
  char query[100];
  int key;
  list<int>::iterator itr;
  while(n--){
    scanf("%s",query);
    if(!strcmp(query,"insert")){
      scanf("%d",&key);
      lst.push_front(key);
    }
    if(!strcmp(query,"delete")){
      scanf("%d",&key);
      for(itr = lst.begin();itr != lst.end();itr++){
	if(*itr == key){lst.erase(itr);break;}
      }
    }
    if(!strcmp(query,"deleteFirst"))lst.pop_front();
    if(!strcmp(query,"deleteLast"))lst.pop_back();
  }
  for(itr = lst.begin();itr != --lst.end();itr++){
    printf("%d ",*itr);
  }
  printf("%d\n",*itr);
  return 0;
}

Measured memory_bytes: 32420
#include<stdio.h>
#include<ctype.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int IN(void)
{
  int x=0,f=1;char c=getchar();
  while(!isdigit(c)&&c!='-')c=getchar();
  if(c=='-')f=-f,c=getchar();
  while(isdigit(c))x=x*10+c-48,c=getchar();
  return f*x;
}
void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
int main(void)
{
  int N=IN(),A[200001]={0};
  rep(i,N-1)A[IN()-1]++;
  rep(i,N)OUT(A[i]),puts("");
}

Measured memory_bytes: 2268
#include <cstdio>
#include <algorithm>
using namespace std;
double arr[100];
int main() {
    int a;
    char str[50];
    scanf("%d",&a);
    scanf("%s",str);
    if (a>=3200)
        printf("%s\n",str);
    else
        printf("red\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    private static Map<Integer, List<Integer>> mp = new HashMap<>();
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<Integer> leafs = new HashSet<>();
        int N = sc.nextInt();
        int u = sc.nextInt()-1;
        int v = sc.nextInt()-1;
        for(int i=0;i<N-1;i++){
            int A = sc.nextInt()-1;
            int B = sc.nextInt()-1;
            mp.computeIfAbsent(A,(p)->new ArrayList<>() ).add(B);
            mp.computeIfAbsent(B,(p)->new ArrayList<>() ).add(A);
        }
        for(int i=0;i<N-1;i++){
            if(mp.get(i).size() == 1){
                leafs.add(i);
            }
        }
        Map<Integer, Integer> aokiMap = new HashMap<>();
        Map<Integer, Integer> takaMap = new HashMap<>();
        traverseAoki(v, aokiMap);
        //traverseAoki(u, takaMap);
        System.out.println(dijkstraTaka(u, aokiMap));
    }


    private static int dijkstraTaka(int u, Map<Integer, Integer> aokiMap){
        PriorityQueue<Taka> pq = new PriorityQueue<>(Comparator.comparingInt(a -> -aokiMap.get(a.now)));//Reverse order of larger to smaller
        Map<Integer, Integer> takaMap = new HashMap<>();
        int maxAoki=0;
        pq.add(new Taka(u,-1,0));
        while(!pq.isEmpty()){
            Taka top = pq.poll();
            Integer now = top.now;
            Integer from = top.from;
            Integer walk = top.walk;
            if(walk >= aokiMap.get(now)){
                continue;
            }
            if(mp.get(now).size() == 1){
                maxAoki = Math.max(maxAoki, aokiMap.get(now)-1);
            }
            for(Integer nei: mp.get(now)){
                if(nei.equals(from)){
                    continue;
                }
                pq.add(new Taka(nei, now, walk+1));
            }
        }
        return maxAoki;
    }

    private static void traverseAoki(int v, Map<Integer, Integer> aokiMap){
        Queue<Integer> q = new LinkedList<>();
        q.add(v);
        aokiMap.put(v,0);
        while(!q.isEmpty()){
            Integer now = q.poll();
            for(Integer nei:mp.get(now)){
                if(aokiMap.containsKey(nei)){continue;}//already traversed.
                aokiMap.put(nei, aokiMap.get(now)+1);
                q.add(nei);
            }
        }
    }

    private static class Taka{
        int now;
        int from;
        int walk;
        Taka(int n, int f, int w){
            now = n;
            from = f;
            walk = w;
        }

        @Override
        public boolean equals(Object obj) {
            if(obj.getClass() == this.getClass()){
                Taka o = (Taka)obj;
                return o.from==from && o.now ==now && o.walk == walk;
            }
            return super.equals(obj);
        }

        @Override
        public int hashCode() {
            return now * 200_000 + from + walk;
        }
    }
}


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


Measured memory_bytes: 3664
#include <stdio.h>

int main(void) {
	int A, B, C;
	int asumi, iguti, ogurayui, hikasayouko;
	if (scanf("%d%d%d", &A, &B, &C) != 3) return 1;
	asumi = A * 7 + B;
	iguti = C / asumi;
	ogurayui = C - asumi * iguti;
	hikasayouko = (ogurayui + A - 1) / A;
	if (hikasayouko > 7) hikasayouko = 7;
	printf("%d\n", iguti * 7 + hikasayouko);
	return 0;
}



Measured memory_bytes: 2144
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var toukous []int
	for i := 0; i < n; i++ {
		var h int
		fmt.Scan(&h)
		toukous = append(toukous, h)
	}

	result := make([]int, n)
	for i, t := range toukous {
		result[t-1] = i + 1
	}

	for _, r := range result {
		//if i == n-1 {
			//fmt.Print(r)
		//} else {
			fmt.Print(r, " ")
		//}
	}
}


Measured memory_bytes: 7552
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>

#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;

// <<fixed<<setprecision(6)<<

int gcd(lint x, lint y){
	return y==0 ? x:gcd(y,x % y);
}


int main(){
  long double n,k,t,c,i;
  long double r;
  bool TEST = false;
  vector<long double> L;
  cin>>n>>k;
  for(i=1;i<=n;i++){
    t=i;
    c=0.0;
    for(lint j=0;t<k;j++){
      t*=2;
      c++;
    }
    r=1.0/n*pow(0.5,c);
    L.pb(r);
  }
  long double sum = accumulate(all(L),0.0);
  cout<<fixed<<setprecision(12)<<sum;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int
#include <limits.h>
#include <math.h>

using namespace std;

/*lli gcd(lli a,lli b)
{
	if(a==0)return b;
	return gcd(b%a,a);
}*/

int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
    lli n,m,l,h,i;
    cin>>n>>m;
    if(n%2)
    {
        l=1;
        h=n;
        for(i=0;i<m;i++)
            cout<<l++<<" "<<h--<<endl;
    }
    else
    {
        l=1;
        h=n;
        int flag=0;
        for(i=0;i<m;i++)
        {
            if(h-l>n/2 || flag)
                cout<<l++<<" "<<h--<<endl;
            else
            {
                l++;
                flag=1;
                cout<<l++<<" "<<h--<<endl;
            }
        }
    }
    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int a, b;
	cin >> a >> b;
	if (b == 1) {
		cout << 0 << endl;
		return 0;
	}
	FOR(i, 1, 30){
		if (i * a - i + 1 >= b) {
			cout << i << endl;
			return 0;
		}
	}
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

Measured memory_bytes: 256
N = int(input())
A = [(int(a), 0) for a in input().split()]
combine = lambda a, b: a if a[1] >= b[0] else b if b[1] >= a[0] else (a[0], b[0]) if a[0] > b[0] else (b[0], a[0])

for i in range(N):
    ii = 1 << i
    for j in range(1<<N)[::-1]:
        if j & ii:
            A[j] = combine(A[j], A[j^ii])

ANS = [0] * (1<<N)
for i in range(1, 1<<N):
    ANS[i] = max(ANS[i-1], sum(A[i]))

print("\n".join(map(str, ANS[1:])))

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

const int MOD = 998244353;
 
template <class T>
T fexp(T x, long long e) {
	T ans(1);
	for(; e > 0; e /= 2) {
		if(e & 1) ans = ans * x;
		x = x * x;
	}
	return ans;
}
 
template <int mod = MOD>
struct modBase {
	modBase(int v = 0) : val(v) {}
	int val;
 
	modBase<mod> operator * (modBase<mod> o) { return (long long) val * o.val % mod; }
	modBase<mod> operator / (modBase<mod> o) { return *this * fexp(o, mod - 2); }
	modBase<mod> operator + (modBase<mod> o) { return val + o.val > mod ? val + o.val - mod : val + o.val; }
	modBase<mod> operator - (modBase<mod> o) { return val - o.val < 0 ? val - o.val + mod : val - o.val; }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  const int N = 1000001;
  vector<modBase<>> all(N), ant(N);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    int q = (long long int) x * x % MOD;
    all[x] = all[x] + x;
    ant[x] = ant[x] + q;
  }
  for (int i = 1; i < N; i++) {
    for (int j = i + i; j < N; j += i) {
      all[i] = all[i] + all[j];
      ant[i] = ant[i] + ant[j];
    }
  }
  for (int i = 1; i < N; i++) {
    all[i] = all[i] * all[i] - ant[i];
    all[i] = all[i] / 2;
  }
  for (int i = N - 1; i >= 1; i--) {
    for (int j = i + i; j < N; j += i) {
      all[i] = all[i] - all[j];
    }
  }
  modBase<> ans(0);
  for (int i = 1; i < N; i++) {
    ans = ans + all[i] / modBase<>(i);
  }
  cout << ans.val << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  string A, B, C; cin >> A >> B >> C;
  int result = 0;
  rep(i,N) {
    bool ab = A[i]==B[i], bc = B[i]==C[i], ca = C[i]==A[i];
    if (!ab&&!bc&&!ca) result += 2;
    else if (ab&&bc) continue;
    else result += 1;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <math.h>


using namespace std;
int zero=0;
    
    
    


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

    
    





Measured memory_bytes: 3156
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI a;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,x;
  cin>>n>>x;
  a.resize(n+2);
  forn(i,n)
    cin>>a[i+1];
  in sm=0;
  for(in i=1;i<=n;++i){
    if(a[i]+a[i-1]>x){
      sm+=a[i]+a[i-1]-x;
      a[i]=x-a[i-1];
    }
  }
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 1024