akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 200005;

int n, k;
int cnt[MaxN + 5];
int num[MaxN + 5];

int main() 
{
	while(scanf("%d %d", &n, &k) != EOF)
	{
		int tot = 0;
		for(int i = 1; i <= n; i++) {
			int x;
			scanf("%d", &x);
			cnt[x]++;
		}
		for(int i = 1; i <= MaxN; i++)
			if(cnt[i] > 0)
				num[++tot] = cnt[i];
		//printf("tot = %d\n", tot);
		sort(num + 1, num + tot + 1);
		int ans = 0;
		for(int i = 1; i <= tot - k; i++)
			ans += num[i];
		printf("%d\n", ans);	
		memset(cnt, 0, sizeof(cnt));
	}
	return 0;
}

Measured memory_bytes: 1664
n = gets.chomp.to_i
v = gets.chomp.split(" ").map(&:to_i)
c = gets.chomp.split(" ").map(&:to_i)

cospa = n.times.to_a.map { |i| [i, v[i].to_f / c[i]] }.sort_by { |_, cp| cp }.reverse
x = y = 0
max_m = 0
n.times do |j|
  i = cospa[j][0]
  x += v[i]
  y += c[i]
  m = x - y
  break if m < max_m
  max_m = m
end
puts max_m


Measured memory_bytes: 1788
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    CSF = [list(map(int, input().split())) for _ in range(N - 1)]

    for i in range(N):
        t = 0
        for j in range(i, N - 1):
            if t < CSF[j][1]:
                t = CSF[j][1]
            elif t % CSF[j][2] == 0:
                pass
            else:
                t += CSF[j][2] - t % CSF[j][2]
            t += CSF[j][0]
        print(t)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int dx[4]{1, 0, -1, 0};
constexpr int dy[4]{0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(0);

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

    const int runtime = m * 1900 + (n - m) * 100;
    const int d = pow(2, m);
    const double ac = 1.0 / d;
    const double wa = 1.0 - ac;

    const double a = runtime * ac / wa;
    const double r = wa;

    const double ans = a * wa / pow(1.0 - wa, 2);
    cout << ans << 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();
		int m = sc.nextInt();
		sc.close();
		int ans = (n - 1) * (m - 1);
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

const int INF = 1e9 + 7;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;

	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= k && i - j >= 0; j++) {
			dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
# -*-coding: utf-8 -*-
N, K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))

h = sorted(h)

nearest = 1000000000
for i in range(N-K+1):
    if nearest > h[i+K-1] - h[i]:
        nearest = h[i+K-1] - h[i]

print(nearest)

Measured memory_bytes: 8280
def main():
    height, width = map(int, input().split())
    image = ["#" * (width+ 2)] * (height + 2)
    for i in range(1, height + 1):
        image[i] = "#" + input() + "#"
    for i in range(height + 2):
        print(image[i])


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int x = cin.nextInt();

        int[] a = new int[N];
        for (int i = 0; i < N; i++) a[i] = cin.nextInt();

        long ret = 0;
        for (int i = 0; i < N - 1; i++)
        {
            long eat = a[i + 1] + a[i] - x;
            if (eat > a[i + 1])
            {
                a[i + 1] = 0;
                a[i] -= (int)eat - a[i + 1];
                ret += eat;
            }
            else if (a[i + 1] >= eat && eat > 0)
            {
                a[i + 1] -= (int)eat;
                ret += eat;
            }
            
        }

        Console.WriteLine(ret);
        Console.Read();
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()  
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 25056
#include<bits/stdc++.h>
using namespace std;
#define LL long long

LL n;
vector<int> L,R;

int main()
{
#ifdef h10
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
	int i,pos=0;
	scanf("%lld",&n);
	n++;

	for (i=50;i>0;i--)
		if ((n>>i)&1) break;

	for (i--;i>=0;i--)
	{
		R.push_back(++pos);
		if ((n>>i)&1)
			L.push_back(++pos);
	}
	printf("%d\n",pos*2);
	for (i=1;i<=pos;i++)
		printf("%d ",i);
	for (i=(int)L.size()-1;i>=0;i--)
		printf("%d ",L[i]);
	for (i=0;i<(int)R.size();i++)
		printf("%d ",R[i]);
}


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


int main()
{
    ll h,w,k;
    cin>>h>>w>>k;
    ll i,j;
    ll a[h][w];
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            char cc;
            cin>>cc;
            if(cc=='.')a[i][j]=0;
            else a[i][j]=1;
        }
    }
    ll no1 = (1ll<<h);
    ll res=0;
    ll no2 = (1ll<<w);
        
    for(i=0;i<no1;i++)
    {
       for(j=0;j<no2;j++)
       {
           bitset<32> b1,b2;
           b1=i,b2=j;
           ll bb[h][w];
           ll ii,jj;
           for(ii=0;ii<h;ii++)
           {
               for(jj=0;jj<w;jj++)
               {
                   bb[ii][jj]=a[ii][jj];
               }
           }
           for(ii=0;ii<h;ii++)
           {
               if(b1[ii])
               {
                   for(jj=0;jj<w;jj++)
                   {
                       bb[ii][jj]=2;
                   }
               }
           }
           for(ii=0;ii<w;ii++)
           {
               if(b2[ii])
               {
                   for(jj=0;jj<h;jj++)
                   {
                       bb[jj][ii]=2;
                   }
               }
           }
           ll tans=0;
           for(ii=0;ii<h;ii++)
           {
             ll noo=0;
               for(jj=0;jj<w;jj++)
               {
               //  cout<<bb[ii][jj]<<" ";
                   if(bb[ii][jj]==1)
                   {
                      tans++; 
                   }
               }
               //cout<<"\n";
             
           }
         
           
           //cout<<tans<<"\n";
           if(tans==k)
           {
            
               res++;
           }
       }
    }
    //cout<<no1<<" "<<no2<<"\n"; 
    cout<<res<<"\n";
    
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  for (int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }
  vector<vector<int>> E(200000);
  for (int i = 0; i < N; i++){
    E[x[i]].push_back(y[i] + 100000);
    E[y[i] + 100000].push_back(x[i]);
  }
  vector<int> c(200000, -1);
  int cnt = 0;
  for (int i = 0; i < 200000; i++){
    if (c[i] == -1){
      c[i] = cnt;
      queue<int> Q;
      Q.push(i);
      while (!Q.empty()){
        int v = Q.front();
        Q.pop();
        for (int w : E[v]){
          if (c[w] == -1){
            c[w] = cnt;
            Q.push(w);
          }
        }
      }
      cnt++;
    }
  }
  vector<int> xcnt(cnt, 0);
  for (int i = 0; i < 100000; i++){
    xcnt[c[i]]++;
  }
  vector<int> ycnt(cnt, 0);
  for (int i = 100000; i < 200000; i++){
    ycnt[c[i]]++;
  }
  long long ans = 0;
  for (int i = 0; i < cnt; i++){
    ans += (long long) xcnt[i] * ycnt[i];
  }
  cout << ans - N << endl;
}

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n),b(n);
  for(int i=0;i<n;i++)b.at(i)=0;
  for(int i=0;i<n;i++){
    int l;
    cin>>l;
    a.at(i)=l;
    b.at(l-1)++;
  }
  long long ans=0;
  for(int i=0;i<n;i++){
    ans+=1LL*b.at(i)*(b.at(i)-1)/2;
  }
  for(int i=0;i<n;i++){
    long long t=ans;
    t-=(b.at(a.at(i)-1)-1);
    cout<<t<<endl;
  }
}




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

int main()
{
  std::string s;
  std::string::iterator it;
  std::cin >> s;

  int ans = 0;
  for (it = s.begin(); it != s.end(); it++) {
    if (*it == '1') {
      ans++;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int main() {
    char x;
    cin >> x;
    if (isupper(x)) cout << "A" << endl;
    else cout << "a" << endl;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 int ro, co, k;vector<string> vs(10);
 cin>>ro>>co>>k;
 rep(i, ro) cin>>vs[i];

 int ans = 0;
 for(int i = 0;i < (1 << ro);i++) {
   for(int j = 0;j < (1 << co);j++) {
     int counter = 0;

     rep(u, ro) rep(v, co) {
       if((i & (1 << u)) == 0 && (j & (1 << v)) == 0 && vs[u][v] == '#') {
         counter++;
       }
     }

     if(counter == k) ans++;
   }
 }
 cout << ans << endl;

 return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
#include<iostream>
#include<cstring>
#include<bitset>
#define mp(a,b) make_pair(a,b)
using namespace std;
bitset<10010> can[2010];
pair<int,int> vis[2][10010];
char s[2010][10010],ans[1000010];
int len[2010],n,k,cnt,ncnt;
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%s",s[i]),len[i]=strlen(s[i]);
	can[n+1][0]=1;
	for (int i=n;i>=1;i--)
		can[i]=can[i+1]|(can[i+1]<<len[i]);
	for (int i=1;i<=n;i++)
		if (can[i+1][k-len[i]]) vis[0][++cnt]=mp(i,0);
	int ii=0;
	for (int i=0;i<k;i++)
	{
		char minc='z';
		for (int j=1;j<=cnt;j++) minc=min(minc,s[vis[ii][j].first][vis[ii][j].second]);
		ans[i]=minc;
		int minid=n+1;
		ncnt=0;
		for (int j=1;j<=cnt;j++)
		{
			int nid=vis[ii][j].first,nlen=vis[ii][j].second;
			if (s[nid][nlen]!=minc) continue;
			if (nlen+1==len[nid]) minid=min(minid,nid);
			else vis[ii^1][++ncnt]=mp(nid,nlen+1);
		}
		for (int j=minid+1;j<=n;j++)
			if (k-len[j]-i-1>=0&&can[j+1][k-len[j]-i-1]) vis[ii^1][++ncnt]=mp(j,0);
		ii^=1;
		cnt=ncnt;
	}
	printf("%s",ans);
}

Measured memory_bytes: 22016
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
#define INT_MAX 1<<30
const ll mod = 1e9+7;



int main(){
	ll n,h,w; cin >> n >> h >> w;
	vl a(n),b(n);
	rep(i,n) cin >> a[i] >> b[i];
	ll ans = 0;
	rep(i,n){
		if(a[i]>=h && b[i]>=w) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int i=a;i<b;i++)
#define modulo 1000000007

int main()
{
        int n,x;
        cin>>n>>x;
        ll a[n+1],sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        sort(a,a+n);
        int cnt=0;
        double m=(1.0*sum)/(4*1.0*x);
        //cout<<m<<" "<<endl;
        for(int i=n-1;i>=0;i--)
        {
            //cout<<a[i]<<" ";
            if(a[i]>=m)
            {
                cnt++;
            }
        }

        //cout<<cnt<<endl;
        if(cnt>=x)
        {
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        long A = sc.nextLong();
	        double B = sc.nextDouble();
	        long C = Math.round(B*100);
	        long ans=A*C/100;
	        System.out.println(ans);
	    }
	}

Measured memory_bytes: 37344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A;
  cin >> A;
  if (A[1]==A[2] && A[2]==A[3]){
  cout << "Yes" << endl;
  }
  else if(A[0]==A[1] && A[1]==A[2]){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	string a;
	cin >>a;
	int b=a.size();
	cout<<a[0]<<b-2<<a[b-1];
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  ll K = nextLong();
  vector<int> A(N);
  REP(i, N) A[i] = nextInt();

  ll P = N * K;

  const int L = 40;
  vector<ll> nxt[L];
  REP(i, L) nxt[i] = vector<ll>(N);

  map<int, int> last;
  for (int i = 2*N-1; i >= 0; i--) {
    if (i < N) {
      nxt[0][i] = last[A[i]] - i + 1;
    }
    last[A[i%N]] = i;
  }

  for (int l = 1; l < L; l++) {
    REP(i, N) {
      nxt[l][i] = nxt[l-1][ (i + nxt[l-1][i]) % N ] + nxt[l-1][i];
    }
  }

  ll pos = 0;
  for (;;) {
    int l = L-1;
    while (l >= 0 && nxt[l][pos % N] + pos > P) l--;
    if (l == -1) break;
    pos += nxt[l][pos % N];
  }

  vector<int> stack;
  set<int> in;
  for (; pos < P; pos++) {
    if (in.count(A[pos % N])) {
      do {
        in.erase(stack.back());
        stack.pop_back();
      } while (in.count(A[pos % N]));
    } else {
      stack.push_back(A[pos % N]);
      in.insert(A[pos % N]);
    }
  }
  pv(ALL(stack));

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 84340
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
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; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    S += 'I';
    ll cnt = 1;
    vector<ll> R,L;
    vector<ll> ans(S.size(),0);
    REP(i,S.size()-1){
        if(S[i] == 'R'){
            if(S[i+1] != 'R'){
                R.pb(cnt);
                cnt = 1;
            }
            else{
                cnt++;
                ans[i] = 0;
            }
        }
        else{
            if(S[i+1] != 'L'){
                L.pb(cnt);
                cnt = 1;
            }
            else{
                cnt++;
                ans[i] = 0;
            }
        }
    }
    ll len = 0;
    ll P;
    REP(i,L.size()){
        ll M = len + R[i];
        if(L[i] > R[i]) P = L[i];
        else P = R[i];
        if((L[i] + R[i]) % 2 == 0){
            L[i] = R[i] = (L[i] + R[i])/2;
        }
      	else{
            if(L[i] > R[i]){
                R[i] = (L[i] + R[i])/2;
                L[i] = R[i]+1;
            }
            else{
                L[i] = (L[i] + R[i])/2;
                R[i] = L[i]+1;
            }
        }

        if(L[i] > R[i]){
            if((P-1) % 2 == 0){
                ans[M-1] = R[i];
                ans[M] = L[i];
                len += L[i] + R[i];
            }
            else if((P-1) % 2 == 1){
                ans[M-1] = L[i];
                ans[M] = R[i];
                len += L[i] + R[i];
            }
        }
        else if(L[i] < R[i]){
            if((P-1) % 2 == 0){
                ans[M-1] = R[i];
                ans[M] = L[i];
                len += L[i] + R[i];
            }
            else if((P-1) % 2 == 1){
                ans[M-1] = L[i];
                ans[M] = R[i];
                len += L[i] + R[i];
            }
        }
        else if(L[i] == R[i]){
            ans[M-1] = R[i];
            ans[M] = L[i];
            len += L[i] + R[i];
        }
    }
    REP(i,ans.size()-1){
        cout << ans[i] << ' ';
    }
}

Measured memory_bytes: 2372
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int num = r.ri();
		num = (int)Math.sqrt(num);		
		print((int)Math.pow(num, 2));		
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 21332
import sys
readline = sys.stdin.readline

#エラトステネスの篩と素因数分解

from collections import Counter
M = 10**6 + 4
prime = [0]*M
for i in range(2, M):
    if prime[i]:
        continue
    for j in range(i, M, i):
        if not prime[j]:
            prime[j] = i

def pd(x):
    C = Counter()
    while x > 1:
        C[prime[x]] += 1
        x //= prime[x]
    return C

N = int(readline())

ans = 0
for i in range(1, N):
    c = pd(i)
    res = 1
    for vi in c.values():
        res *= (1+vi)
    ans += res
print(ans)

Measured memory_bytes: 82412
#include <bits/stdc++.h>
using namespace std;
stack<char> n, m;
string temp;
int main(){
    cin >> temp;
    for(int i=0; i<temp.length();i++){
        if (!n.empty() && temp[i]=="B"[0]){
            n.pop();
        } else if (temp[i] != "B"[0]) {
            n.push(temp[i]);
        }
    }
    while (!n.empty()){
        m.push(n.top());
        n.pop();
    }
    while (!m.empty()){
        cout << m.top();
        m.pop();
    }
}

Measured memory_bytes: 256
n = gets.to_i
f = []
for i in 0...n do
  f[i] = gets.split.map(&:to_i)
end
p = []
for i in 0...n do
  p[i] = gets.split.map(&:to_i)
end
max_profit = -(10 ** 9)
for j in 1...(2 ** 10) do
  count = Array.new(n, 0)
  for b in 0...10 do
    ff = (j >> b) & 1
    for i in 0...n do
      count[i] += ff & f[i][b]
    end
  end
  profit = 0
  for i in 0...n do
    profit += p[i][count[i]]
  end
  max_profit = profit if max_profit < profit
end
puts max_profit


Measured memory_bytes: 2172
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#define maxn 100005
using namespace std;
int n,tot;
int dis[maxn],vis[maxn];
int head[maxn],nex[maxn*20],to[maxn*20],val[maxn*20];
void add(int x,int y,int z)
{
	to[++tot]=y; val[tot]=z;  nex[tot]=head[x]; head[x]=tot;
}
queue<int> q;
void spfa(int start)
{
	memset(dis,0x3f,sizeof(dis));

	dis[start]=0;

	q.push(start);
	while(!q.empty())
	{
		int now=q.front(); q.pop(); vis[now]=0;
		for(int i=head[now];i;i=nex[i])
		{
			if(dis[to[i]]>dis[now]+val[i])
			{
				dis[to[i]]=dis[now]+val[i];
				if(!vis[to[i]])
				{
					vis[to[i]]=1;
					q.push(to[i]);
				}
			}
		}
	}
}
int main()
{
	scanf("%d",&n);

	for(int i=0;i<=n-1;i++)
	{
		for(int j=0;j<=9;j++)
		{
			add(i,(i*10+j)%n,j);
		}
	}

	for(int i=1;i<=9;i++)
		add(n,i%n,i);

	spfa(n);

	printf("%d\n",dis[0]);
}


Measured memory_bytes: 19072
#include<stdio.h>
#include<math.h>
int main(){
	double a,b;
	scanf("%lf %lf",&a,&b);
	double x,y;
	scanf("%lf %lf",&x,&y);
	x*=60;
	x+=y; 
	double m=0.5,n=6;
	double l=fabs(x*m-y*n);
	if(l>=180)l=fabs(y*n-x*m);
	l=cos(l*3.141592653589/180);
	double c=sqrt(a*a+b*b-2*a*b*l);
	printf("%.20lf",c); 
	return 0;
}

Measured memory_bytes: 2600
program abc084c
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j
    integer(int32):: time, nt
    integer(int32), allocatable:: c(:), s(:), f(:),ans(:)

    read*, n
    allocate(c(n-1), s(n-1), f(n-1), ans(n))

    do i=1,n-1
        read*, c(i),s(i),f(i)
    end do
    ans(:) = 0
    do j=1,n-1
        time=0
        do i=j,n-1
            if (time <= s(i)) then
                time = s(i)+c(i)
            else
                nt=s(i)
                do while(time > nt)
                    nt=nt+f(i)
                end do
                time=nt+c(i)
            end if
        end do
        ans(j)=time
    end do

    print'(i0)', ans(:)
end program abc084c

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  int ans = -1;
  int cost = 0;
  vector<int> u(m, 0);

  function<void(int)> dfs = [&](int curr) {
    if (curr == n) {
      bool all_ok = true;
      rep(i, m) {
        if (u[i] < x) {
          all_ok = false;
          break;
        }
      }
      if (all_ok) {
        if (ans == -1)
          ans = cost;
        else
          ans = min(ans, cost);
      }

      return;
    }

    dfs(curr + 1);

    cost += c[curr];
    rep(i, m) u[i] += a[curr][i];
    dfs(curr + 1);

    cost -= c[curr];
    rep(i, m) u[i] -= a[curr][i];

    return;
  };

  dfs(0);
  cout << ans << endl;
  return 0;
}

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

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    double t, x;
    scan(t, x);
    auto ans = t / x;
    writefln("%.12f", ans);
}







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

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mxn 300007
#define ar array
#define mod 1000000007
#define ld long double
#define pb push_back
#define ar array
#define fi first
#define se second
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	ll n,i,k;
	cin>>n>>k;
	ll a[n],p,pr;
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=k;i<n;i++){
		pr=a[i];
		p=a[i-k];
		if(pr>p)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
		p=pr;
	}
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
ll a[51];
ll p[51];
ll solve(ll N,ll X){
  if(X == 0)
    return 0;
  if(a[N] == X){
    return p[N];
  }else{
    if(X >= (a[N]+1)/2 ){
      return 1+p[N-1]+solve(N-1,X-a[N-1]-2);
    }else{
      return solve(N-1,X-1);
    }
  }
}

int main()
{
  ll N,X;
  a[0] = 1;
  p[0] = 1;
  REP(i,50){
    a[i+1] = 2*a[i]+3;
    p[i+1] = p[i]*2+1;
  }
  cin >> N >> X;
  cout << solve(N,X) << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
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(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n;
    cin >> n;
    string a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    int ans = 0;
    rep(i,n){
        if(a[i] == b[i] && a[i] == c[i])continue;
        if(a[i] != b[i] && a[i] != c[i] && b[i] != c[i])ans += 2;
        else ans++;
    }
    cout << ans << endl;
}


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

int main(){
  long int n,sum;
  sum = 0;
  cin >> n;
  for(int i=1;i<=n;i++){
    sum += i;
    if(i%3 == 0||i%5 == 0){sum = sum-i;}
  }
  cout << sum << endl;
  return 0;
}

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

//|\\---------------//|\\
//|\\RISE FROM ASHES//|\\
//|\\---------------//|\\

int main() {
    int n,d;
    cin>>n>>d;
    int count=0;
    while(n--){
        int a,b;

        cin>>a>>b;
        if(sqrt(pow(a,2)+pow(b,2))<=d){
            count++;
        }

    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
using namespace std;
int main(void){
    int x,y,z;
    for(x = 1; x < 10; x++){
        for(y = 1; y < 10; y++){
            z = x*y;
            std::cout << x << "x"<< y << "=" <<z<< std::endl;
        }
    }
}

Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc  = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int cnt = 0;
        int all = 0;
        String flag = "No";
        int num[] = new int[n];
        double check = 0.0;
        //int x = 1;
        //System.out.println(x/2);

        for(int i = 0; i < n ; i++){
            int vote = sc.nextInt();
            num[i] = vote;
            all += vote;
            //System.out.println(num[i]);
        }
        //System.out.println(all);
        check = (double)all/(4*m);

        for(int i = 0; i < n; i++){
            if(num[i] >= check){ 
                cnt++;
                //System.out.println(num[i]);
            }
        }

        //System.out.println(cnt);
        if(cnt>=m){
            flag = "Yes";
        }
        System.out.println(flag);
    }
}

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

   typedef long long ll;

   const double EPS = (1e-7);
   const ll INF =(1e9);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

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


const ll MAX_N = 40;

ll n, W;
ll w[MAX_N], v[MAX_N];

pair<ll, ll> ps[1 << (MAX_N / 2)]; //(weight, value)

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //input
    cin >> n >> W;
    REP(i, n){
        cin >> v[i] >> w[i];
    }

    //前半 n/2個から自由に選ぶ組み合わせを全列挙
    //(w, v)の和をps[i]に保存
    int n2 = n / 2;
    REP(i, 1 << n2){
        ll sw = 0, sv = 0;
        REP(j, n2){
            if ((i >> j) & 1){
                sw += w[j];
                sv += v[j];
            }
        }
        ps[i] = mp(sw, sv);
    }

    //wの小さい順->vの小さい順、でソートする
    sort(ps, ps + (1 << n2));
    ll m = 1;
    FOR(i, 1, 1 << n2){
        if (ps[m - 1].second < ps[i].second){
            ps[m++] = ps[i];
        }
    }
    //m = psから(w, v)の関係が逆転している要素を覗いたときの要素数

    //後半を全列挙
    ll res = 0;
    REP(i, 1 << (n - n2)){
        ll sw = 0, sv = 0;
        REP(j, n - n2){
            if ((i >> j) & 1){
                sw += w[n2 + j];
                sv += v[n2 + j];
            }
        }
        if (sw <= W){
            ll tv = (lower_bound(ps, ps + m, mp(W - sw, INF)) - 1) -> second;
            res = max(res, sv + tv);
        }
    }
    cout << res << endl;


    return 0;
}


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

int main() {
    int n;
    cin >> n;
    map<string, int> S;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        S[s]++;
    }
    
    int Max = 0;
    for (auto p : S) {
        int x = p.second;
        Max = max(Max, x);
    }

    for (auto p : S) {
        string s = p.first;
        int x = p.second;
        if (x == Max) {
            cout << s << endl;
        }
    }
}

Measured memory_bytes: 25216
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(br.readLine());
		long s = Long.parseLong(br.readLine());
		Solver sol = new Solver();
		System.out.println(sol.solve(n, s));
	}

}

class Solver {

	long solve(long n, long s) {
		long temp;
		if (s > n)
			return -1;
		if (s == n)
			return n + 1;
		for (long b = 2; b * b <= n; b++) {
			if (findSum(b, n) == s) {
				return b;
			}
		}

		for (long i = (long) Math.ceil(Math.sqrt(n) - 1); i >= 1; i--) {
			temp = ((n - s) / i) + 1;
			if (temp == 1)
				continue;
			if (temp > 1 && findSum(temp, n) == s) {
				return temp;
			}
		}
		return -1L;
	}

	long findSum(long b, long n) {
		long temp = 0L;
		while (n >= b) {
			temp += n % b;
			n /= b;
		}
		return temp + n;

	}

}


Measured memory_bytes: 21460
#include <iostream>
#include <iomanip>
#include <algorithm>
  
using namespace std;
  
int main(void)
{
	int N;
	cin >> N;
  
	int Arr[102] = {0};
	for (int i = 0; i < N; i++){
		cin >> Arr[i];
	}
  
	for (int i = 0; i < N; i++){
		cout << Arr[i];
		if(i!=N-1) cout<<" ";
	}
	cout << endl;
  
	int Tmp = 0, j = 0;
	for (int i = 1; i < N; i++){
		Tmp = Arr[i];
		j = i-1;
		while (j >= 0 && Arr[j] > Tmp){
			Arr[j+1] = Arr[j];
			j--;
		}
		Arr[j+1] = Tmp;
		for (int i = 0; i < N; i++){
			cout << Arr[i];
			if(i!=N-1) cout<<" ";
		}
		cout<<endl;
	}
  
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k>a){
    if(k>a+b){
      cout<<a-(k-a-b)<<endl;
    }else{
      cout<<a<<endl;
    }
  }else{
    cout<<k<<endl;
  }
  
}










Measured memory_bytes: 3636
#include <stdio.h>
#include<math.h>
int main()
{
long int a=0,b=0,w=0,i,str1=0,str2=0,flag,j;
char x[101][101],y[101][101];
scanf("%ld",&a);

if(a>=1200)
{
    printf("ARC");
}else{
    printf("ABC");
}
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#define MAX 100007
#define scn1(a) scanf("%d", &a);
#define scn2(a, b) scanf("%d %d", &a, &b);
#define scn3(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define lscn1(a) scanf("%lli", &a);
#define lscn2(a, b) scanf("%lli %lli", &a, &b);
#define lscn3(a, b, c) scanf("%lli %lli %lli", &a, &b, &c);
#define prnt(a) printf("%d\n", a);
#define for0(i, n) for(i=0;i<n;i++)
#define for1(i, n) for(i=1;i<=n;i++)
typedef unsigned long long int ll;
using namespace std;


int main()
{
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//	#endif
	int tt=1;
//	scn1(tt);
	while(tt--)
    {
        int a, b;
        scn2(a, b);
        if(a>9 || b>9)
            printf("-1\n");
        else
            printf("%d\n", a*b);
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

template <class T>
T calc_divisor_num(const T& x, const T& n)
{
    return x / n;
}

template <class T>
T calc_gcd(const T& x, const T& y)
{
    return y ? calc_gcd(y, x % y) : x;
}

template <class T>
T calc_lcm(const T& x, const T& y)
{
    const auto gcd = calc_gcd(x, y);
    return x / gcd * y;
}

int main() {
    long long A, B, C, D;
    std::cin >> A >> B >> C >> D;

    const auto lcm = calc_lcm(C, D);

    const auto calc_up_to_x = [&](long long x) {
        return x
            - calc_divisor_num(x, C)
            - calc_divisor_num(x, D)
            + calc_divisor_num(x, lcm);
    };
    
    const auto ret = calc_up_to_x(B) - calc_up_to_x(A - 1);

    std::cout << ret << std::endl;    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,max;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            max = a + b;
            if (max < a - b) max = a - b;
            if (max < a * b) max = a * b;

           
            Console.WriteLine(max);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>
using namespace std;

const int N = 12;
int n, m, k;
int c[N];
int a[N][N];

int main() 
{
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", c + i);
		for (int j = 0; j < m; ++j) scanf("%d", a[i] + j);
	}
	int mask = 1 << n;
	int mn = ~(1 << 31);
	for (int bit = 1; bit < mask; ++bit) {
		int cost = 0;
		int al[N] = {0};
		for (int i = 0; i < n; ++i) if (bit & (1 << i)) {
			cost += c[i];
			for (int j = 0; j < m; ++j) al[j] += a[i][j];
		}
		bool ok = true;
		for (int j = 0; j < m; ++j) if (al[j] < k) ok = false;
		if (ok) mn = min(mn, cost);
	}
	if (mn == ~(1 << 31)) printf("-1\n");
	else printf("%d\n", mn);
	return 0;
}


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

int factorial(int x) {
  int ans=0,point = 2,i=1;
  double p;
  while(point > 1) {
    p = x / pow(5.0,i);
    i++;
    point = (int)floor(p);
    ans += point;
  }
  return ans;
}

int main() {
  int a;
  while(cin >> a,a) {
     cout << factorial(a) << endl;
     // factorial(a);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=998244353;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};
vector<mint> Ikano_Array(int n){
  vector<mint> res(n+1);
  rep1(i,n) res[i] = (mint)1/i;
  
  rep1(i,n){
    for(int j=i*2;j<=n;j+=i){
      res[j] -= res[i];
    }
  }
  return res;
}
int main()
{
  int n;
  cin >> n;
  vector<mint> a(n);
  int mx = 0;
  rep(i,n){
    cin >> a[i].x;
    mx = max(mx,(int)a[i].x);
  }
  vector<mint> num(mx+1);
  rep(i,n) num[a[i].x].x++;
  
  vector<mint> c = Ikano_Array(mx);
  
  vector<mint> sum(mx+1),sumeq(mx+1);

  rep1(i,mx){
    for(int j=i;j<=mx;j+=i){
      mint jj(j);
      sum[i] += num[j]*jj;
      sumeq[i] += jj*jj*num[j];
    }
  }

  mint res(0);
  rep1(i,mx){
    sum[i] = (sum[i]*sum[i]-sumeq[i])/2;
    res += c[i] * sum[i];
  }

  cout << res.x << "\n";
  
  return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 998244353

struct RangeMaxQuery{
  ll dat[(1<<20)-1];
  int size;

  void init(int n_){
    size=1;
    while(size<n_) size*=2;
    for(int i=0;i<2*size-1;i++)dat[i]=-INF;
  }

  void update(int k,ll a){
    k+=size-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
  }

  ll subquery(int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return -INF;
    if(a<=l&&r<=b)return dat[k];
    else{
      return max(subquery(a,b,k*2+1,l,(l+r)/2),subquery(a,b,k*2+2,(l+r)/2,r));
    }
  }
  
  ll query(int a,int b){
    return subquery(a,b,0,0,size);
  }
};

RangeMaxQuery seg;

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

  ll N;
  cin>>N;
  vector<P> ps;
  vector<ll> ds;
  rep(i,N){
    ll a,b;
    cin>>a>>b;
    ps.push_back(P(a,a+b));
    ds.push_back(a); ds.push_back(a+b);
  }
  sort(all(ds));
  uni(ds);
  rep(i,N){
    ps[i].fi=lower_bound(all(ds),ps[i].fi)-ds.begin();
    ps[i].se=lower_bound(all(ds),ps[i].se)-ds.begin();
  }
  sort(all(ps),[](const P& a,const P& b){
    if(a.fi==b.fi)return a.se>b.se;
    else return a.fi>b.fi;
  });

  ll M=ds.size();
  vector<ll> en(M+1,-INF);
  seg.init(M+1);
  rep(i,N){
    en[ps[i].fi]=max(seg.query(ps[i].fi,ps[i].se),ps[i].se);
    seg.update(ps[i].fi,en[ps[i].fi]);
  }
  vector<ll> dp(M+1,0);
  dp[M]=1;
  for(ll i=M-1;i>=0;i--){
    if(en[i]==-INF){
      (dp[i]+=dp[i+1])%=mod;
    }else{
      (dp[i]+=dp[i+1]+dp[en[i]])%=mod;
    }
  }
  cout<<dp[0]<<endl;

  return 0;
}


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

typedef long long ll;


int main() {
	int s;
	cin >> s;
	
	vector<int> a(1000000);
	a[0]=s;
	map<int,int> m;
	m[s]++;

	for (int i = 1; i < 1000000; i++) {
		if (a[i - 1] % 2 == 0) {
			a[i] = a[i-1]/2;
		}
		else {
			a[i] = 3*a[i-1]+1;
		}
		m[a[i]]++;
		if (m[a[i]] == 2) {
			cout << i+1 << endl;
			return 0;
		}
		
	}



}
	


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define slowanddetermined ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define int long long
using namespace std;



int32_t main()
{
    //p_p_m();

    int n;
    cin>>n;

    std::vector<int > arr(n);
    map<int,int>mp;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        mp[arr[i]]++;
    }
    int res=0;
    //map<int,int>ans;
    for(auto i:mp ){
        if(i.second>1)
        res=res+(i.second*(i.second-1))/2;
    }
    int c,ans;
    for(int i=0;i<n;i++){
        c=mp[arr[i]];
        //ans=res;
        //if(mp[val]>1)
        cout<<((res-(c*(c-1))/2)+max(0LL,((c-1)*(c-2))/2))<<endl;
       // cout<<ans<<endl;
    }




    return 0;

}


Measured memory_bytes: 12800
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  double v;
  while(cin>>v){
    for(int n=0; ; n++){
      double h = n*5;
      double tmp = 9.8 * sqrt( h / 4.9 );
      if(tmp >= v){
	cout << n+1 << endl;
	break;
      }
    }
  }
  return 0;
}

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

 
int main() {
    int n;
    cin>>n;
    vector<int> A(n);
    vector<int> B(n);

    rep(i,n)cin>>A[i];
    rep(i,n)cin>>B[i];

    int maxsum=0;
    rep(i,n){//iは下へ行く位置
        int sum=0;
        for(int j=0;j<=i;j++) sum+=A[j];
        for(int j=i;j<n;j++)sum+=B[j];
        maxsum=max(maxsum,sum);
    }

    cout<<maxsum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
#define all(obj) (obj).begin(), (obj).end()
/*卍卍卍 #define int long long 卍卍卍*/
signed main () {
  int n;cin >> n;
  vector<int> a(n+1,0);rep(i,n) cin>>a[i];
  int ans=0;int want=1;
  rep(i,n+1){
    if(a[i]==want){want+=1;a[n]=-1;}
    else if(a[i]==0) ans=-1;
    else if(i!=n) ans+=1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4044