akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<30
#define F first
#define S second
using namespace std;
typedef pair<string,int> P;
bool cmp(const P &p,const P &q){
  if(p.S != q.S){
    return p.S < q.S;
  }
  return p.F < q.F;
}
int main(){
  int n;
  string st;
  int Me;
  int DD;
  int m;
  while(cin >> n && n){
    int temi[40];
    for(int i=0;i<40;i++){
      temi[i] = 0;
    }
    string s[n+4];
    vector<int> d[n+3];  
    for(int i=0;i<n;i++){
      cin >> s[i];
      cin >> m;

      for(int j=0;j<m;j++){
	cin >> DD;
	d[i].push_back(DD);
	temi[DD]++;
      }
    }
    int cnt[n+4];
    for(int i=0;i<n;i++){
      cnt[i] = 0;
      for(int j=0;j<d[i].size();j++){
	if(temi[d[i][j]])cnt[i] += temi[d[i][j]]==n?1:n+1-temi[d[i][j]]; 
      }
    }
    vector<P> ve;
    for(int i=0;i<n;i++){
      ve.push_back(P(s[i],cnt[i]));
    }
    sort(ve.begin(),ve.end(),cmp);
    cout << ve[0].S << " " << ve[0].F << endl;
  }
    return 0;
}

Measured memory_bytes: 1248
#include <iostream>
using namespace std;
int main ()
{
    short A=1,B=1,C=1,D=1;
    cin>>A>>B>>C>>D;
    if ((A*B) == (C*D))
        cout<<(A*B)<<"\n";
    else if ((A*B)>(C*D))
        cout<<(A*B)<<"\n";
    else cout<<(C*D)<<"\n";
    return 0;
}


Measured memory_bytes: 256
a=str(input())
if a[0]=="R":
  if a[1]=="R":
    if a[2]=="R":
      print(3)
    else:
      print(2)
  else:
    print(1)
elif a[1]=="R":
  if a[2]=="R":
    print(2)
  else:
    print(1)
elif a[2]=="R":
  print(1)
else:
  print(0)

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

int main(){
	int t1,t2,r1,r2;	cin>>t1>>t2>>r1>>r2;
	if(r1<0 || r2<0){
		if(t1<t2)cout<<"Alice"<<endl;
		else if(t1>t2)cout<<"Bob"<<endl;
		else cout<<"Draw"<<endl;
	}else{
		if(r1>r2) cout<<"Alice"<<endl;
		else if(r1<r2)cout<<"Bob"<<endl;
		else cout<<"Draw"<<endl;
	}

	return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define int long long
#define MOD 1000000007
#define mod 998244353
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
using namespace std;
void solve1();
void solve()
{
    int T;cin>>T;
    for(int z=1;z<=T;z++)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int n,k;cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int lo=1,hi=arr[n-1];
    int ans=hi;
    int c=((lo + hi)/2);
    while(lo!=hi)
    {
        c=((lo + hi)/2);
        int f=0;
        for(int i=0;i<n;i++)
        {
            if(arr[i]>c)
            {
                f+=((arr[i]-1)/c);
            }
        }
        if(f>k)
        {
            lo = c;
        }
        else
        {
            hi =c;
            ans=min(ans,c);
        }
        if(lo==hi-1)
        {
            break;
        }

    }
    if(k==0)
    {
        cout<<arr[n-1]<<endl;
    }
    else
    {
        int f=0;
        c=ans-1;
        if(c>0)
        {for(int i=0;i<n;i++)
        {
            if(arr[i]>c)
            {
                f+=((arr[i]-1)/c);
            }
        }
        if(f>k)
        {
            lo = c;
        }
        else
        {
            hi =c;
            ans=min(ans,c);
        }}
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 5196
from sys import stdin


def solve(N):
    if N % 2 == 1:
        return 0
    if N == 0:
        return 0

    a = N // 50
    b = N // 10

    ans = a + b

    for i in range(2, N):
        x = (5 ** i) * 10
        y = N // x
        if y == 0:
            break
        ans += y

    return ans


def main():
    N = int(stdin.readline().rstrip())
    result = solve(N)
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int P, Q, R;
    cin >> P >> Q >> R;

    int sum = P + Q + R;
    int m = max(P, max(Q, R));

    cout << sum - m << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <string>

using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

using pii = pair<i32, i32>;

#define rep(i, n) for (i32 i = 0; i < (n); ++i)
#define repr(i, n) for (i32 i = ((n)-1); i >= 0; --i)
#define urep(i, n) for (u32 i = 0; i < (n); ++i)
#define urepr(i, n) for (u32 i = ((n)-1); i >= 0 && i < (n); --i)
#define all(v) v.begin(), v.end()

int H, W;
int field[102][102];
int dx[4] = { 0, +1, 0, -1 };
int dy[4] = { -1, 0, +1, 0 };

int main()
{
	cin >> H >> W;
	int num_spaces = 0;
	rep(y, H) {
		string line;
		cin >> line;
		rep(x, W) {
			int available = (line[x] == '.');
			num_spaces += available;
			field[y+1][x+1] = available;
		}
	}

	queue<pair<i32, pii>> que;
	int x = 1, y = 1;
	field[y][x] = 0;
	que.emplace(make_pair(1, make_pair(x, y)));
	while (!que.empty()) {
		auto p = que.front();
		int depth = p.first;
		x = p.second.first;
		y = p.second.second;
		que.pop();
		if (x == W && y == H) {
			printf("%d\n", num_spaces - depth);
			return 0;
		}
		rep(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (field[ny][nx] == 0) continue;
			field[ny][nx] = 0;
			que.emplace(make_pair(depth + 1, make_pair(nx, ny)));
		}
	}
	printf("-1\n");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll z = *x;
  *x = *y;
  *y = z;
}
void print(vector<ll> vec){
  ll length = (ll)vec.size();
  rep(i,length){
    if(i != 0){cout << " ";}
    cout << vec[i];
  }
  cout << endl;
}
ll gcd(ll x,ll y){
  if(y == 0){
    return x;
  }
  return gcd(y,x%y);
}
int main() {
  string s;
  ll k;

  cin >> s;
  cin >> k;
  ll len = s.size();
  ll sum1=0,sum2=0,sum3=0,sum4=0,ans = 0;
  rep(i,len-1){
    if(s[i%len] == s[(i+1)%len]){
      sum1++;
      i++;
    }else{

    }
  }
  rep(i,len*2-1){
    if(s[i%len] == s[(i+1)%len]){
      sum2++;
      i++;
    }else{

    }
  }
  rep(i,len*3-1){
    if(s[i%len] == s[(i+1)%len]){
      sum3++;
      i++;
    }else{

    }
  }

  if(k % 2 == 0){
    ans = sum2 + (sum3-sum1) * ((k-1) / 2);
  }else{
    ans = sum1 + (sum3-sum1) * (k / 2);
  }
  cout << ans << endl;
}


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

using namespace std;

using ull = unsigned long long;
using ll = long long;

int main(void)
{
  int n;
  cin >> n;
  vector<int> as(3 * n);
  for (int i = 0; i < 3 * n; i++) {
    cin >> as[i];
  }
  sort(as.begin(), as.end());
  ull result = 0;
  ll lower = 0;
  bool to_del = false;
  for (ll i = as.size() - 1; i >= lower; i--) {
    if (to_del) {
      result += as[i];
      lower++;
    }
    to_del = !to_del;
  }
  cout << result << endl;
}


Measured memory_bytes: 1408
N = int(input())
A = [201] + list(map(int, input().split())) + [99]
UD = []

cnt = 0
temp = 1000

for i in range(N+1):
  if A[i] >= A[i+1]:
    UD.append(-1)
  else:
    UD.append(1)

for i in range(N):
  if UD[i] < UD[i+1]:
    cnt, temp = divmod(temp, A[i+1])
  if UD[i] > UD[i+1]:
    temp, cnt = temp + cnt * A[i+1], 0

print(temp)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

int main() {
	string s, t;
	cin >> s >> t;
	const int m = s.length(), n = t.length();
	vector < vector < int > > dp (m + 1, vector < int > (n + 1));
	// vector < vector < int > > ind (m + 1, vector < int > (n + 1));
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (s[i - 1] == t[j - 1]) {
				// ind[i][j] = i - 1;
				dp[i][j] = 1 + dp[i - 1][j - 1];
			} else {
				dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	//for (int i = 0; i <= m; i++) {
		//for (int j = 0; j <= n; j++) {
			//cout << dp[i][j] << " ";
		//}
		//cout << endl;
	//}
	int i = m, j = n;
	string ans;
	while (i > 0 && j > 0) {
		//cout << i << " " << j << endl;
		if (s[i - 1] == t[j - 1]) {
			ans += s[i - 1];
			i--, j--;
		} else if (dp[i - 1][j] > dp[i][j - 1]) {
			i--;
		} else {
			j--;
		}
	}
	reverse (ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	ll arr[n];
	input(arr,n);
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		ans+=arr[i]*arr[j];
	}
	cout<<ans;
}

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

namespace ALDS1_7D{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var preOrder = sr.Next<int>(N);
            var inOrder = sr.Next<int>(N);

            var cnt = 0;
            var res = new List<int>();

            Action<int, int> reconstruct = null;
            reconstruct = (l, r) =>{
                if(cnt >= N || l >= r) return;
                var cp = preOrder[cnt++];
                var m = Array.FindIndex(inOrder, x => x == cp);

                reconstruct(l, m);
                reconstruct(m + 1, r);
                res.Add(cp);
            };
            reconstruct(0, N);

            Console.WriteLine(string.Join(" ", res.Select(x => x.ToString()).ToArray()));
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int MOD=2019;
signed main(){
    fastio
    int s,w;cin>>s>>w;
    if(w>=s){
      cout<<"unsafe\n";
    }else{
      cout<<"safe\n";
    }
    return 0;
}

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

using namespace std;


///------------------- O(|V|*|E|) -------------------///
struct hungarian_bipartite {
    int l, r;
    vector< vector<int> > g;
    vector<bool> seen;
    vector<int> match; /// match[i] is the left matching of right node i
    hungarian_bipartite(int l, int r) : l(l), r(r), seen(l), match(l+r, -1), g(l+r) {}
    /// [0-l) left, [l, r) right
    /// a and b are 0-indexed
    void add_edge(int a, int b) {
        g[a].push_back(l+b);
        g[l+b].push_back(a);
    }
    bool go(int u) {
        if(seen[u]) return false;
        seen[u] = true;
        for(int i = 0; i < g[u].size(); i++) {
            int v = g[u][i];
            if(match[v] == -1 || go(match[v])) {
                match[v] = u;
                return true;
            }
        }
        return false;
    }
    int max_matching() {
        int ans = 0;
        for(int i = 0; i < l; i++) {
            fill(seen.begin(), seen.end(), false);
            ans += go(i);
        }
        return ans;
    }
};




int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n1, n2, m;
  cin>>n1>>n2>>m;
  hungarian_bipartite hp(n1, n2);
  for(int i = 0; i < m; i++){
      int u,v;
      cin>>u>>v;
      hp.add_edge(u, v);
  }
  cout<<hp.max_matching()<<"\n";
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)

void self_min(ll &a, ll b) {
	a = min (a,b);
}
template <class T>
void self_max(T &a, T b) {
	a = max(a,b);
}

int main() {
	ios::sync_with_stdio(false);

	ll N, W; cin >> N >> W;

	vl w(N), v(N);
	FOR(i,0,N) cin >> w[i] >> v[i];

	vvl dp(N+1, vl(W+3,0));

	FOR(i,0,N) {
		FOR(j,0,W+1) {
			self_max(dp[i+1][j], dp[i][j]);
			if (j + w[i] < W+1) {
				self_max(dp[i+1][j+w[i]], dp[i][j] + v[i]);
			}
		}
	}

	ll maxi = 0;
	FOR(j,0,W+1) {
		self_max(maxi, dp[N][j]);
	}
	cout << maxi << endl;
	return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;

  long long result = 0;
  long long min_sum = 0, max_sum = 0;
  for (int i = 0; i<k-1; i++){
    min_sum += i;
    max_sum += n-i;
  }
  for(int i=k;i<=n+1;i++){
    min_sum += i-1;
    max_sum += n-(i-1);
    result = result + (max_sum - min_sum + 1);
    // cout << min_sum << " " << max_sum << endl;  
  }
  cout << result%((int)pow(10, 9)+7) << endl;
  return 0;
}


Measured memory_bytes: 3636
from time import time
from random import randint

from numpy import int64

def func(s, x):
    last = [0] * 26
    score = 0
    for i, v in enumerate(x, 1):
        last[v] = i
        c = 0
        for j in range(26):
            c += s[j] * (i - last[j])
        score += s[i * 26 + v] - c
    return score

def main():
    start = time()
    d, *s = map(int, open(0).read().split())
    s = int64(s)
    x = int64(([*range(26)] * 15)[:d])
    M = func(s, x)
    while time() - start < 1.8:
        y = x.copy()
        if randint(0, 1):
            y[randint(0, d - 1)] = randint(0, 25)
        elif randint(0, 1):
            i=randint(0, d - 16)
            j=randint(i + 1, i + 15)
            y[i], y[j] = y[j], y[i]
        else:
            i = randint(0, d - 15)
            j = randint(i + 1, i + 7)
            k = randint(j + 1, j + 7)
            if randint(0, 1):
                y[i], y[j], y[k] = y[j], y[k], y[i]
            else:
                y[i], y[j], y[k] = y[k], y[i], y[j]
        t = func(s, y)
        if t > M:
            M = t
            x = y
    print(*x + 1, sep='\n')

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('func', 'i8(i8[:], i8[:])')(func)
    cc.compile()

if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import func
    main()

Measured memory_bytes: 28148
s = input()
q = int(input())

L = ["" for i in range(q)]
R = ["" for i in range(q)]
l, r = 0, 0

fliped = False
for i in range(q):
    query = input()
    if query[0] == "1":
        fliped = not fliped
    else:
        t, f, c = query.split()
        if (f == "1") ^ fliped:
            L[l] = c
            l += 1
        else:
            R[r] = c
            r += 1
s = "".join(L[::-1]) + s + "".join(R)
if fliped:
    s = s[::-1]
print(s)



Measured memory_bytes: 8044
N, M = [int(i) for i in input().split()]
AList = [int(i) for i in input().split()]

sumA = sum(AList)
ansList = list(filter(lambda x: x >= sumA / (4 * M), AList))

ans = "No"
if len(ansList) >= M:
    ans = "Yes"

print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int H,W,D,Q;
int A[305][305];
int dp[90001];
queue<int>q;

struct cd{
  int x,y;
};

cd f[90001];

int calc(int r){
  if(dp[r]>0)return dp[r];
  if(r<D)return 0;

  int cost=abs(f[r].x-f[r-D].x)+abs(f[r].y-f[r-D].y);
  int res=cost+calc(r-D);
  return dp[r]=res;
}

int main(){
  cin>>H>>W>>D;
  for(int h=1;h<=H;h++){
    for(int w=1;w<=W;w++){
      cin>>A[h][w];
      f[A[h][w]].x=w,f[A[h][w]].y=h;
    }
  }
  cin>>Q;
  for(int t=1;t<=Q;t++){
    int l,r;cin>>l>>r;
    int temp=calc(r)-calc(l);
    q.push(temp);
  }

  while(!q.empty()){
    cout<<q.front()<<"\n";
    q.pop();
  }
  return 0;
}


Measured memory_bytes: 5760
/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007  
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    //fastio();
    int a,b,c;
    cin >> a >> b >> c;
    b==a?(cout << c << endl):(cout << max(0,c-a+b) << endl); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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);
	
	
	int n,m; cin >> n >> m;
	
	vector<int> a(m); rep(i,m) cin >> a[i];
	
	sort(all(a));
	
	if(n>=m){
		cout << '0' << endl;
		return 0;
	}
	
	vector<int> b(m-1); rep(i,m-1) b[i]=a[i+1]-a[i];
	
	sort(all(b));//昇順を
	reverse(all(b));//降順に直す
	
	int sum=0;
	
	rep(i,n-1) sum+=b[i];
	
	int l=a[m-1]-a[0];
	
	
	cout << l-sum << endl;

	
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,ans=0,b=0;
    cin >> n;
    long long a[n];
    for(int i=0;i<n;i++){
      cin >> a[i];
      ans+=a[i];
      if(a[i]%10==0){
        b++;
      }
    }
    sort(a,a+n);
    if(ans%10==0){
      if(b==n){
        cout << 0 << endl;
      }else{
        for(int i=0;i<n;i++){
          if(a[i]%10!=0){
            cout << ans-a[i] << endl;
            return 0;
          }
        }
      }
    }else{
      cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    // input
    int n;
    cin >> n;
    char suit;
    int inputNumber;
    vector <int> spade(13), heart(13), club(13), diamond(13);
    
    for(int i = 0; i<n; i++){
        cin >> suit >> inputNumber;
        if(suit == 'S') spade.at(inputNumber - 1) = 1;
        else if(suit == 'H') heart.at(inputNumber - 1) = 1;
        else if(suit == 'C') club.at(inputNumber - 1) = 1;
        else if(suit == 'D') diamond.at(inputNumber - 1) = 1;
    }
    
    // cout << spade.at(9) << endl;
    
    // output
    for(int i=0; i<13; i++){
        if(spade.at(i) != 1) cout << "S " << i + 1 << endl;
    }
    for(int i=0; i<13; i++){
        if(heart.at(i) != 1) cout << "H " << i + 1<< endl;
    }
    for(int i=0; i<13; i++){
        if(club.at(i) != 1) cout << "C " << i + 1 << endl;
    }
    for(int i=0; i<13; i++){
        if(diamond.at(i) != 1) cout << "D " << i + 1 << endl;
    }
    return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

// ############################################################################################

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>

#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >

#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)

#define mod 1000000007
#define inf 1e18

#define FOREACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define FOR(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define FORE(i, a, n) for (i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define all(n) (n).begin(), (n).end()

#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// ############################################################################################

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2) res = (res * base) % mod;
        base = (base * base) % mod;
        exp /= 2;
    }
    return res % mod;
}

void a_k_s() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
}

int main() {
    a_k_s();

    ll n;
    cin >> n;
    vector<ll> h(n + 1), dp(n + 1, 0);
    FOR(i, 1, n + 1) {
        cin >> h[i];
    }

    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);

    FOR(i, 3, n + 1) {
        ll op1 = dp[i - 1] + abs(h[i] - h[i - 1]);
        ll op2 = dp[i - 2] + abs(h[i] - h[i - 2]);
        dp[i] = min(op1, op2);
    }
    // FOR(i, 0, n + 1) {
    //     cout << dp[i] << ' ';
    // }
    // cout << endl;

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 4780
function main(input) {
	input = input.split(" ");
	var n = parseInt(input[0],10);
	var d = parseInt(input[1],10);
    var dcount = (d * 2) + 1;
    var kanshi = n / dcount;
 

    console.log(Math.ceil(kanshi))

}
	

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

Measured memory_bytes: 21064
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N;

int main() {
	cin >> N; N %= 10;
	if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) cout << "hon" << endl;
	if (N == 0 || N == 1 || N == 6 || N == 8) cout << "pon" << endl;
	if (N == 3) cout << "bon" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>


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

	int swapcount=0;
	int samecount=0;
	for(int i=0;i<n;i++){
		if(i+1==p[i]){
			samecount++;
		}
		else{
			swapcount+=(samecount+1)/2;
			samecount=0;
		}
	}
	swapcount+=(samecount+1)/2;
	
	
	printf("%d",swapcount);
	return 0;
} 

Measured memory_bytes: 512
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int N=1e3+5;

int h,w;
int sx,sy,ex,ey;
int d[N][N];
string s[N];

int check(int x,int y)
{
    if(x>=0&&x<h&&y>=0&&y<w&&s[x][y]=='.')
        return 1;
    return 0;
}
void bfs()
{
  deque<pair<int,int>> q;
  q.push_back({sx,sy});
  d[sx][sy]=0;
  while(!q.empty()){
    int x= q.front().first;
    int y= q.front().second;
    q.pop_front();
    for(int i= -2;i<=2;i++)
       for(int j=-2;j<=2;j++)
       {
          if(i==0&&j==0) continue;
          if(abs(i)+abs(j)==1)
          {
             int tx= x+i;
             int ty= y+j;
             if(check(tx,ty)&&d[tx][ty]>d[x][y])
             {
                 d[tx][ty]=d[x][y];
                 q.push_front({tx,ty});
             }
          }
          else
          {
             int tx= x+i;
             int ty= y+j;
             if(check(tx,ty)&&d[tx][ty]>d[x][y]+1)
             {
                 d[tx][ty]=d[x][y]+1;
                 q.push_back({tx,ty});
             }
          }
       }
  }
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>h>>w;
    cin>>sx>>sy>>ex>>ey;
    for(int i=0;i<h;i++)
        cin>>s[i];
    sx--;
    sy--;
    ex--;
    ey--;
    memset(d,0x3f,sizeof(d));
    bfs();
    if(d[ex][ey]==0x3f3f3f3f)
        cout<<-1<<endl;
    else
        cout<<d[ex][ey]<<endl;
}

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

const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};
int main(void)
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, 0, n) cin >> v[i];
    int ans = n, cta = 1;
    rep(i, 0, n) if (v[i] == cta) cta++;
    if (n == n - cta + 1)
        cout << -1 << endl;
    else
        cout << n - cta + 1 << endl;
}

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define floot10 cout<<fixed<<setprecision(10);
#define int long long

signed main(){
	int n,a;
	cin>>n;
	int ans=1;
	lp(i,n){
		cin>>a;
		if(a%2!=0) ans=0;
	}
	if(ans==0) cout<<"first"<<endl;
	else cout<<"second"<<endl;
	return 0;
}



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

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

    for(int c=1; c<=3; c++){
        if(a*b*c%2){
            cout << "Yes" << endl;
            break;
        }
        else if(c==3) cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("Yes"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  int ren = 0;
  rep(i,n) {
    int a,b;
    scanf("%d%d",&a,&b);
    if (a == b) ++ren; else ren = 0;
    if (ren == 3) dame;
  }
  cout<<"No"<<endl;
  return 0;
}






















Measured memory_bytes: 3656
n = int(input())
s = input()

def alp_number(char):
    return ord(char) - ord('A')

def num_to_char(num):
    return chr(num + ord('A'))

ord_chars = [(alp_number(char) + n) % 26 for char in s]

answer = ''.join([num_to_char(num) for num in ord_chars])

print(answer)

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

using namespace std;

int main(void){
    string S;
    string T;
    int ans = 0;
    cin >> S;
    cin >> T;
    for(int i = 0 ; i < 3; i++){
        if(S[i] == T[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
program main
    implicit none
    integer :: n, k, h(100000), i, c=0

    read(*,*)n,k
    read(*,*)(h(i), i = 1, n)
    do i = 1, n
      if (h(i) >= k) then
        c = c + 1
      end if
    end do
    
    write(*,*)c
end program main

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

int main() {
  int n,ans;
  ans=0;
  cin >> n;
  vector<int> b(n-1);
  for(int i=0;i<n-1;i++) cin >> b.at(i);
  for(int i=0;i<n;i++){
    if(i==0) ans+=b.at(i);
    else if(i==n-1) ans+=b.at(i-1);
    else ans+=min(b.at(i-1),b.at(i));
  };
  cout << ans << endl;
}

Measured memory_bytes: 256
// review
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

ll n;
map<ll, ll> m;
ll dfs(ll n) {
  if (m[n] != 0) {
    return m[n];
  }
  if (n == 0) {
    return 1;
  }
  if (n == 1) {
    return 2;
  }
  return m[n] = (dfs(n/2) + dfs((n-1)/2) + dfs((n-2)/2)) % MOD;
}

void solve() {
  cout << dfs(n) << endl;
}

int main() {
  cin >> n;
  solve();
}


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

using namespace std;
typedef long long LL;

#define LOG(...) fprintf (stderr, __VA_ARGS__)
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fll;
const double pi = acos(-1); 
double a, b, x; 
int main() {
    cin >> a >> b >> x; 

    double len = 2 * x / a / b; 


    if (len <= a) cout << fixed << setprecision(10) << atan(b / len) / pi * 180 << endl; 
    else {
        double y = (2*x / a / a) - b;

        cout << fixed << setprecision(10) << atan((b-y) / a) / pi * 180 << endl; 
    }
    return 0;
}

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

int compare (const void * a, const void * b) {
   return ( *(char*)a - *(char*)b );
}

int main() {
    char word[5];
    char l[2];
    int result = 1;
    int count1, count2 = 0;

    for (int i = 0; i < 4; i++) {
        word[i] = getchar();
    }
    qsort(word, 4, sizeof(char), compare);
    if ((word[0] == word[1]) && (word[2] == word[3]) && (word[0] != word[2]))
        printf("Yes\n");
    else
        printf("No\n");
    
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin>>n){
    if(n==0) break;
    int s[n],mems[n];
    for(int i=0;i<n;i++){
      cin >> s[i];
      mems[i] = 0;
    }
    int count = 0;
    bool ok = false;
    while(!ok){
      count++;
      for(int i=0;i<n;i++){
	int cou = 0;
	for(int j=0;j<n;j++){
	  if(s[i]==s[j]) cou++;
	}
	mems[i] = cou;
      }
      ok = true;
      for(int i=0;i<n;i++){
	if(s[i]!=mems[i]) ok = false;
	s[i] = mems[i];
      }
    }
    cout << count-1 << endl;
    for(int i=0;i<n;i++){
      if(i!=n-1) cout << s[i] << ' ';
      else cout << s[i] << endl;;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000000+7;

long long int modper(long long n){
    long long int x = 1;
    for(int i = 1; i <= n; i++){
        x *= i;
        x = x % MOD;
    }
    return x;
}

int main() {
    int n,m;
    cin >> n >> m;
    if(abs(n-m) > 1){
        cout << 0 << endl;
        return 0;
    }

    if((n+m) % 2 == 1){
        cout << modper(n) * modper(m) % MOD << endl;
    }else{
        cout << ((modper(n) * modper(m) % MOD) * 2) % MOD << endl;
    }
    return 0;
}




Measured memory_bytes: 256
# coding: utf-8
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: -1 * x, A))
# A.sort(reverse=True)
heapq.heapify(A)
for i in range(M):
    tmp = heapq.heappop(A)
    heapq.heappush(A, -1 * (-tmp // 2))
print(-sum(A))

Measured memory_bytes: 14180
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        //int k = 1000;

        int[] a = new int[n];
        int[] max = new int[n];
        Arrays.fill(max, n);

        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            //a[i] = 0;
        }

        for(int i = 0; i < k; i++){
            int[] b = new int[n];
            for(int j = 0; j < n; j++){
                int l = Math.max(0, j - a[j]);
                int r = Math.min(n - 1, j + a[j]);
                b[l]++;
                if(r + 1 < n){
                    b[r + 1]--;
                }
            }
            for(int j = 1; j < n; j++){
                b[j] += b[j - 1];
            }

            if(Arrays.equals(b, max)){
                skip(n);
                return;
            }
            a = b;
        }

        StringBuilder sb = new StringBuilder();
        for(int i : a) {
            sb.append(i).append("\n");
        }
        System.out.print(sb.toString());

    }

    static void skip(int n){
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(n).append("\n");
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 63336
#include <stdio.h>
#include <string.h>
#define rep(i, n)   for(int i = 0; i < (int)(n); i++)
int main(){
  char s[100+1]={0};
  scanf("%s",s);
  int n = strlen(s);
  rep(i,n){
    if((i+1)%2){
      if(s[i]=='L'){ printf("No\n"); return 0; }
    }else{
      if(s[i]=='R'){ printf("No\n"); return 0; }
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 1660
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

const int INF = 1e9 + 7;
int q;

int main() {
	INIT
	int a, b;
	int e, f;
	
	//long long c;
	cin >> a >> b;
	for (int i = 1; i <= 1100; ++i) {
		e = 1.0 * i * 0.08;
		f = 1.0 * i * 0.1;
		if (e == 0 || f == 0) continue;
		if (e == a && f == b) {
			cout << i;
			return 0;
		}
	}	
	cout << "-1";
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String... args) {
   	Scanner input = new Scanner(System.in);
  	String first = input.next();
    String second = input.next();
    
    int n = first.length();
    
    if (second.length() != n + 1) {
      System.out.println("No");
      return;
    }
    
    if (!second.substring(0, n).equals(first)) {
      System.out.println("No");
      return;
    }
    
    System.out.println("Yes");
  }
}

Measured memory_bytes: 35596
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	double x,y;
	cin >> x;
    y = 2*x*M_PI;
	cout << y << "\n";
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vll water(31, 0), sugar(3001, 0);
    REP(i, 31){
        REP(j, 31){
            if(a * i + b * j > 30) continue;
            water[a * i + b * j] = 1;
        }
    }
    REP(i, f + 1){
        REP(j, f + 1){
            if(c * i + d * j > 3000) continue;
            sugar[c * i + d * j] = 1;
        }
    }
    ll resw, ress, init = 1;
    FOR(i, 1, 30){
        FOR(j, 1, 3000){
            if(!water[i] || !sugar[j]) continue;
            ll w = 100 * i, s = j;
            if(w + s > f || s > e * i) continue;
            if(init){
                init = 0;
                resw = w;
                ress = s;
            }
            else if(s * (resw + ress) > ress * (w + s)){
                resw = w;
                ress = s;
            }
        }
    }
    if(init){
        cout << a * 100 << " " << 0 << endl;
        return 0;
    }
    cout << resw + ress << " " << ress << endl;
    return 0;
}

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

int main() {
	int m[10];

	for(int i = 0;i<10;i++) cin>>m[i];

	sort(m,m+10,greater<int>());

	for(int i = 0;i<3;i++) cout<<m[i]<<endl;

	return 0;
}

Measured memory_bytes: 1176
n,m = map(int,input().split())
src = []
for i in range(n):
    a,b = map(int,input().split())
    src.append([a,b])

src.sort(key = lambda x:-x[0])
sum_pay = 0
while 1:
    a,b = src.pop()
    if m > b:
        sum_pay += a*b
        m -= b
    else:
        sum_pay += a*m
        break
print(sum_pay)

Measured memory_bytes: 24344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >>S;
  int N=S.size();
  int A=1;
  int B=(N-1)/2;
  int C=(N+3)/2;
  cin >>N>>A>>B>>C;
  
  for (int i = 0; i < B; i++) {
    if (S.at(i)!=S.at(N-i-1)){
      A*=0;
    }
  }
  for (int i = 0; i < B; i++) {
    if (S.at(i)!=S.at(B-i-1)){
      A*=0;
    }
  }
  if (A==1){
    cout <<"Yes"<<endl;
  }
  else {
    cout <<"No"<<endl;
  }

    
  
    
  

}


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

nums = list(map(int, input().split()))
count = 0
is_div = True

while is_div:
    for i in range(n):
        q, m = divmod(nums[i], 2)
        if m:
            is_div = False
            break
        else:
            nums[i] = q

    if is_div:
        count += 1
    else:
        break

print(count)

Measured memory_bytes: 9180
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a*b%2==0){
        cout << "No";
    }else{
        cout << "Yes";
    }
}

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

namespace ConsoleApp16 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int maxCount = 0;

            for (int i = 0; i < N; i++) {
                if (a[i] - 1 == maxCount) {
                    maxCount++;
                }
            }
            if (maxCount == 0) {
                Console.WriteLine(-1);
            } else {
                Console.WriteLine(N - maxCount);
            }

            

        }
    }
}


Measured memory_bytes: 34268
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    ans := (n+1)/2*(n/2)
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
/*
* @Author: wxyww
* @Date: 2020-03-15 20:42:29
* @Last Modified time: 2020-03-15 20:47:52
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 1010;
ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int a[N][N];
int main() {
	int K = read();
	if(K == 1) {
		puts("1\n1");
		return 0;
	}	
	int n = (K + 3) / 4 * 2;
	printf("%d\n",n);
	for(int i = 1;i <= n;++i) {
		if(i & 1) {
			for(int j = 1;j <= n;++j) {
				int t = (i + j - 2) % n + 1;
				if(t > K) t -= n;
				printf("%d ",t);
			}
		}
		else {
			for(int j = 1;j <= n;++j) {
				int t = (i + j - 2) % n + n + 1;
				if(t > K) t -= n;
				printf("%d ",t);
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1152