akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long    WW(long L) {
        if (1>=L) return 1;
        if (2==L) return 2;
        return WW(L-1)+WW(L-2);
}

int     main() {
        long H, W, K;
        cin >>H >>W >>K;
        long DD=1e9+7;
        vector<long> WWW(9);
        for (long i=0; i<9; i++) {
                WWW.at(i)=WW(i);
        }
        vector<vector<long>> D(H+1, vector<long>(W+1, 0));
        D.at(0).at(1)=1;
        for (int i=1; i<=H; i++) {
                for (int j=1; j<=W; j++) {
                        // straight down
                        long Left=WWW.at(j-1);
                        long Right=WWW.at(W-j);
                        D.at(i).at(j) = Left*Right*D.at(i-1).at(j)%DD;
                        // down right
                        if (j>1) {
                                Left=WWW.at(j-2);
                                Right=WWW.at(W-j);
                                D.at(i).at(j) = (D.at(i).at(j)+Left*Right*D.at(i-1).at(j-1))%DD;
                        }
                        // down left
                        if (j<W) {
                                Left=WWW.at(j-1);
                                Right=WWW.at(W-j-1);
                                D.at(i).at(j) = (D.at(i).at(j)+Left*Right*D.at(i-1).at(j+1))%DD;
                        }
                }
        }
        cout << D.at(H).at(K) << endl;
        return 0;
}

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

int main(){
  int N, Y;
  cin >> N >> Y;
  int ans10000=-1, ans5000=-1, ans1000=-1;
  for(int i=0; i<=N; ++i){
    for(int j=0; j<=N-i; ++j){
      int k = N - i - j;
      int total = 10000*i + 5000*j + 1000*k;
      if (total == Y){
        ans10000 = i;
        ans5000 = j;
        ans1000 = k;
      }
    }
  }
  cout << ans10000 << " " << ans5000 << " " << ans1000 << endl;
  return 0;
}

Measured memory_bytes: 256
//Be Name Khoda
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
const ll M=2e5+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll a,b,c;

int main()
{
    cin >> a >> b >> c;
    For(i,0,M)
    {
        if (a%2||b%2||c%2)
            RET(i);
        ll s=(a+b+c)/2;
        a=s-a/2;
        b=s-b/2;
        c=s-c/2;
    }   
    RET(-1);
}    


Measured memory_bytes: 256
<?php

fgets(STDIN);
$input = trim(fgets(STDIN));

$array[0] = explode(' ', $input);

$count = 0;

while (true) {
    $length = count($array[$count]);
    for ($i = 0; $i < $length; ++$i) {

        if ($array[$count][$i] % 2 !== 0) {
            goto END;
        }

        $array[$count + 1][$i] = $array[$count][$i] / 2;
    }
    $count++;
}

END:
echo $count;

Measured memory_bytes: 4728
#include <stdio.h>

int		main(void)
{
	int N;
	int A[200000];
	int i = -1;
	int ans[200000];

	scanf("%d", &N);
	while (++i < N - 1)
		scanf("%d", &A[i]);
	i = -1;
	while (++i < N)
		ans[i] = 0;
	i = -1;
	while (++i < N - 1)
		ans[A[i] - 1] += 1;
	i = -1;
	while (++i < N)
		printf("%d\n", ans[i]);
	return (0);
}


Measured memory_bytes: 3292
from math import ceil
A, B = map(int, input().split())

min_8 = ceil(A / 0.08)
max_8 = ceil((A+1) / 0.08)

min_10 = ceil(B / 0.1)
max_10 = ceil((B+1) / 0.1)

ans = -1

for i in range(min_8,max_8):
    if i in range(min_10,max_10):
        ans = i
        break

print(ans)


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll X[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    REP(i, N) {
        cin >> X[i];
    }
    ll ans = 0;
    FOR(i, N, 1) {
        ans += std::min((X[i] - X[i - 1]) * A, B);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int A[20],n;


int solve(int i, int m){
  int res;
  
  if(m==0)
    return 1;
  if(i>=n)
    return 0;
  res = solve(i+1, m)||solve(i+1,m-A[i]);
  return res;
}
      
  

int main(){
  int i,q,m;

  scanf("%d",&n);
  for(i=0; i<n; i++)
    scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&m);
    if(solve(0,m)==1)
      printf("yes\n");
    else
      printf("no\n");
  }
  return 0;
}
  



Measured memory_bytes: 2104
import Foundation
func indexSum(_ num: Int) -> Int {
    var sum = 0
    var arr = Array(String(num))
    for i in 0 ..< arr.count {
        var k = Int(String(arr[i]))
        sum += k ?? 0
    }
    return sum
}
let rd = readLine()!.split(separator: " ").map({Int($0)!})
let N = rd[0]
var sum = 0

for i in 1 ... N {
    if rd[1] <= indexSum(i) && indexSum(i) <= rd[2] {
        sum += i
    }
}
print(sum)

Measured memory_bytes: 13512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    ll x, ans;
    cin>>x;
    ans = x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}


vector<vector<long long>> da;

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    int n; cin >> n;

    for(int i = 0; i < n; ++i){
        long long j, k; cin >> j >> k;
        da.push_back({-j - k, j, -k});
    }

    sort(da.begin(), da.end());

    long long a = 0;

    for(int i = 0; i < n; ++i)
        a += da[i][i % 2 + 1];

    cout << a << "\n";

    return 0;

}


Measured memory_bytes: 6452
import math
import itertools
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
a,b = 0,0
seq = [i for i in range(1,n+1)]
k = list(itertools.permutations(seq))
for i in range(math.factorial(n)):
    if k[i] == p:
        a = i
    if k[i] == q:
        b = i
print(abs(a-b))

Measured memory_bytes: 8052
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n,m;
  while(cin>>n>>m,n|m){
    vector<int> data(n);
    rep(i,n) cin>>data[i];

    int ans=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(data[i]+data[j]<=m)ans=max(ans,data[i]+data[j]);
      }
    }
    if(ans!=0)cout<<ans<<endl;
    else cout<<"NONE"<<endl;
  }
  return 0;
}



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

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

  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) {
    cin >> h.at(i);
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (h.at(i) >= K) {
      ans++;
    }
  }

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


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


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

    while(A > 0 || C > 0) {
        C -= B;
        if(C <= 0) {
            _PR("Yes");
            break;
        }
        A -= D;
        if(A <= 0) {
            _PR("No");
            break;
        }
    }


    return 0;
}

/*



*/

Measured memory_bytes: 3624
N, K = map(int, input().split())
H = list(map(int, input().split()))

INF = 10 ** 12
dp = [0] * N
dp[0] = 0

for n in range(1, N):
	dp[n] = dp[n - 1] + abs(H[n] - H[n - 1])
	for i in range(2, K + 1):
		if 0 <= n - i:
			dp[n] = min(dp[n], dp[n - i] + abs(H[n] - H[n - i]))
print(dp[-1])


Measured memory_bytes: 52576
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a>=13)
  {
    cout<<b;
  }
  else if(a<6)
  {
    cout<<0;
  }
  else if(a>5 && a<13)
  {
    cout<<b/2;
  }
  return 0;
}


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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int N, K;
  scanf("%d%d", &N, &K);
  int x;
  vi neg, pos;
  rep(i, 0, N) {
    scanf("%d", &x);
    if (x < 0) neg.pb(-x);
    else pos.pb(x);
  }
  sort(all(neg));
  sort(all(pos));
  
  int mn = 4e8;
  rep(i, 0, sz(neg)) {
    if (i + 1 >= K)
      mn = min(mn, neg[K - 1]);
    else if (K - 1 - i <= sz(pos))
      mn = min(mn, 2 * neg[i] + pos[K - 2 - i]);
  }
  rep(i, 0, sz(pos)) {
    if (i + 1 >= K)
      mn = min(mn, pos[K - 1]);
    else if (K - 1 - i <= sz(neg))
      mn = min(mn, 2 * pos[i] + neg[K - 2 - i]);
  }
  printf("%d\n", mn);
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  solve();
	return 0;
}



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

#define ll long long int
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define pb push_back
#define pii pair<ll,ll>
#define mp make_pair

int main()
{
    ll n,wt;
    cin>>n>>wt;
    ll w[n+1],v[n+1];

    for(ll i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }


    ll dp[n+1][wt+1];

    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=wt;j++)
        {
            if(i==0 || j==0)
            dp[i][j] = 0;

            else if(j>=w[i])
            {
                dp[i][j] = max(dp[i-1][j-w[i]] + v[i],dp[i-1][j]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
            
        }
    }

    cout<<dp[n][wt];


    return 0;
}

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

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

	string S;
	int count = 0;
	int i = 0;

	cin >> S;
	while (true) {
		if (S[i + 1] == 'W' || S[i + 1] == 'B') {
			if (S[i + 1] != S[i]) {
				count++;
			}
		} else {
			break;
		}
		i++;
	}

	printf("%d", count);
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
char str[1001];

 void print(int a,int b){
      int i;
      for(i=a;i<=b;i++){
          printf("%c",str[i]);
          }
      printf("\n");
      }

 void reverse(int a,int b){
      int i,tmp[1001];
      for(i=a;i<=b;i++){tmp[i]=str[i];}
      for(i=a;i<=b;i++){str[i]=tmp[b-(i-a)];}
      }

 void replace(int a,int b){
      int i;
      char rep[1001];
      scanf("%s",rep);
      for(i=a;i<=b;i++){
           str[i]=rep[i-a];
           }
      }

int main(){
    int i,q,a,b;
    char p[10],rep[1002];

    scanf("%s",&str);
    scanf("%d",&q);

    for(i=0;i<q;i++){
          scanf("%s %d %d",p,&a,&b);
          if(p[2]=='i'){print(a,b);}
          else if(p[2]=='v'){reverse(a,b);}
          else if(p[2]=='p'){replace(a,b);}
          }
    return 0;
    }





Measured memory_bytes: 2120
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};


int main(){
    int h, w, d;
    cin >> h >> w >> d;

    int a[310][310];
    int x[100010], y[100010];

    REP(i, h) REP(j, w){
        cin >> a[i][j];
        x[a[i][j]] = i;
        y[a[i][j]] = j;
    }

    int q;
    cin >> q;
    int l[100010], r[100010];
    
    REP(i, q){
        cin >> l[i] >> r[i];
    }

    vector<vector<int>> dist;
    dist = vector<vector<int>>(d + 1, vector<int>((h * w + d) / d, 0)); 

    FOR(i, 1, d + 1){
        dist[i][0] = 0;
        int num = i;
        FOR(j, 1, (h * w + d) / d){
            int tmp = num + d;
            dist[i][j] = dist[i][j - 1] + abs(x[tmp] - x[num]) + abs(y[tmp] - y[num]);
            num = tmp;
        }
    }

    REP(k, q){
        int tmp = l[k] % d;
        if(tmp == 0) tmp = d;
        if(l[k] - tmp == 0){
            cout << dist[tmp][(r[k] - tmp) / d] << endl;
        }else{
            cout << dist[tmp][(r[k] - tmp) / d] - dist[tmp][(l[k] - tmp) / d] << endl;
        }
    }
}

Measured memory_bytes: 7168
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n,t;
	cin>>n>>t;
	int mi=INT_MAX;
	for(int i=0;i<n;i++){
		int u,w;
		cin>>u>>w;
		if(w<=t){
			mi=min(mi,u);
		}
	}
	if(mi==INT_MAX){
		cout<<"TLE"<<endl;
	}
	else{
		cout<<mi<<endl;
	}
}

Measured memory_bytes: 256
/* ITP1_2_C: Sorting Three Numbers */
/* 20181118 */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

void swap(int *x, int *y);

int main(void){
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if(a > b) swap(&a, &b);
	if(b > c){
		swap(&b, &c);
		if(a > b) swap(&a, &b);
	}

	printf("%d %d %d\n", a, b, c);

	return 0;
}

void swap(int *x, int *y){
	int temp = *x;
	 *x = *y;
	 *y = temp;
}


Measured memory_bytes: 1928
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

string s; int k;
int dp[2][105][10];

int slv(int fg, int index, int nz){
    if(nz > k) return 0;
    if(index == s.length()){
        if(nz==k) return 1;
        else return 0;
    }
    if(dp[fg][index][nz]!=-1) return dp[fg][index][nz];
    int upto = 9;
    int res = 0;
    if(fg == 0) upto = s[index] - '0';
    for(int i=0; i<=upto; ++i){
        int nnz = (i!=0) ? nz+1 : nz, nindex = index+1;
        int nfg = (fg==0 && i==upto) ? 0 : 1;
        res += slv(nfg, nindex, nnz);
    }
    return dp[fg][index][nz] = res;
}

void solve(){
    memset(dp, -1, sizeof(dp));
    cin>>s>>k;
    cout<<slv(0,0,0);
    return;
}
int main(){
    fastIO;
    solve();
    return 0;
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

int main() {
	int n=read(); ll x=read(),y=read();
	for (int i=2;i<=n;++i) {
		int a=read(),b=read();
		ll d=max(x/a+(x%a!=0),y/b+(y%b!=0));
		x=a*d,y=b*d;
	}
	printf("%lld\n",x+y);
	return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>

int max(int a,int b);

int main(void){

	int r,c;
	int i,j;
	
	scanf("%d",&r);
	scanf("%d",&c);
	
	int a[r][c];
	int rtot[r];
	int ctot[c];
	int tot=0;
	
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=0;i<r;i++){
		rtot[i]=0;
		for(j=0;j<c;j++){
			rtot[i]+=a[i][j];
		}
	}
	
	for(j=0;j<c;j++){
		ctot[j]=0;
		for(i=0;i<r;i++){
			ctot[j]+=a[i][j];
		}
	}
	
	for(i=0;i<r;i++){
		tot+=rtot[i];
	}
	
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			printf("%d ",a[i][j]);
		}
		printf("%d\n",rtot[i]);
	}
	
	for(j=0;j<c;j++){
			printf("%d ",ctot[j]);
	}
	
	printf("%d\n",tot);
	
	return 0;
}

int max(int a,int b){
	if(a>=b){
		return a;
	}else{
		return b;
	}
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

template<typename T> class P
{
public:
  T x,y;
  P(){};P(T x,T y):x(x),y(y){};
  T dist(const P&q) {return abs(x-q.x)+abs(y-q.y);}
};

int main(int argc, char const *argv[]) {
  int N; cin >> N;
  vector<ll> a(N); REP(i,N) cin >> a[i];
  vector<ll> b(N); REP(i,N) cin >> b[i];
  vector<ll> c(N), d(N);
  ll ans = 0;
  for(int k=0; k<30; k++) {
    ll t=1<<k;
    REP(i,N) c[i] = a[i] % (t*2);
    REP(i,N) d[i] = b[i] % (t*2);
    sort(d.begin(),d.end());
    ll cnt = 0;
    REP(i,N) {
      auto l1 = lower_bound(d.begin(), d.end(), t-c[i]);
      auto r1 = lower_bound(d.begin(), d.end(), 2*t-c[i]);
      cnt += (r1-l1);
      auto l2 = lower_bound(d.begin(), d.end(), 3*t-c[i]);
      auto r2 = lower_bound(d.begin(), d.end(), 4*t-c[i]);
      cnt += (r2-l2);
    }
    if(cnt%2==1) ans += t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#define maxn 505
#include<cstring>
#define ll long long
const ll mod=1e9+7;
using namespace std;
int n,c;
ll dp[maxn][maxn];
ll sum[maxn][maxn];
ll p[maxn][maxn];
int a[maxn];
int b[maxn];
int main()
{
    scanf("%d%d",&n,&c);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&b[i]);
memset(dp,0,sizeof(dp));
dp[0][0]=1;

  for(int i=1;i<=400;i++)
  {p[i][0]=1;

      for(int j=1;j<=400;j++)
    p[i][j]=(p[i][j-1]*i)%mod;

}
for(int i=1;i<=400;i++)
{

    for(int j=0;j<=400;j++)
    {
      sum[0][j]=0;
        sum[i][j]=(sum[i-1][j]+p[i][j])%mod;
}
}
for(int i=1;i<=n;i++)
{
    for(int j=0;j<=c;j++)
    {
        for(int x=0;x<=j;x++)
        {
            int t=(sum[b[i]][x]-sum[a[i]-1][x]+mod)%mod;

            dp[i][j]=(dp[i][j]+dp[i-1][j-x]*t)%mod;

    }
    }
}
printf("%lld\n",dp[n][c]);
return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,ans;
  string op;
  cin >> A >> op >> B;
  if(op == "+"){
   ans = A + B;
  }
  else{
   ans = A - B;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
if __name__ == '__main__':
    a, b, c = map(int, input().split())

    table = set()
    x = 1
    while True:
        mod = (a * x) % b
        if mod in table: break

        table.add(mod)
        x += 1

    ans = "YES" if c in table else "NO"
    print(ans)


Measured memory_bytes: 3060
//Tonight's the night and it is going to happen again and again.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define T ll t; cin>>t; while(t--)
#define mod 1000000007
#define mem(name,val) memset(name,val,sizeof(name))
#define f(n) for(ll i = 0;i<n;i++)
#define endl "\n"
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
int main()
{
   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 n;cin>>n;int a[n];f(n){cin>>a[i];}
   int c=0;
   f(n)
   {
    for(int j=i+1;j<n;j++)
    {
      for(int k=j+1;k<n;k++)
      {
        if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
        {
          if(a[i]+a[j]>a[k]&&a[k]+a[j]>a[i]&&a[i]+a[k]>a[j]){c++;}
        }
      }
    }
   }
   cout<<c; 
}

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

int main()
{
    string str;
    cin >> str;
    int n = str.size();
    int loss = 0;
    for (int i = 0; i < n; i++)
    {
        if (str[i] == 'x')loss++;
    }
    if (loss >= 8)cout << "NO";
    else cout << "YES";
}

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

int main() {
  long n,h,ans=0;
  cin >> n >> h;
  vector<long> a(n);
  vector<long> b(n);
  for(long i=0;i<n;i++) cin >> a[i] >> b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  for(long i=n-1;i>=0;i--) {
    if(b[i]<a.back()) break;
    ans++;
    h-=b[i];
    if(h<=0) break;
  }
  if(h>0) ans+=(h+a.back()-1)/a.back();
  cout << ans << endl;
}

Measured memory_bytes: 1792
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int D, x; readf("%d\n%d\n", &D, &x);
    int[] xs, ys;
    foreach (i; 0 .. x) {
        string a; int p;
        readf("%s %d\n", &a, &p);
        if (a == "D") xs ~= p;
    }
    int y; readf("%d\n", &y);
    foreach (i; 0 .. y) {
        string a; int q;
        readf("%s %d\n", &a, &q);
        if (a == "DD") ys ~= q;
    }

    x = cast(int) xs.length;
    y = cast(int) ys.length;

    xs.sort!("a > b");
    ys.sort!("a > b");

    int sum(int[] xs, int k) {
        int ret = 0;
        foreach (i; 0 .. k) {
            ret += xs[i];
        }
        return ret;
    }

    int ans = 0;
    foreach (i; 0 .. y + 1) {
        foreach (j; 0 .. x + 1) {
            if (i * 2 + j <= D) {
                ans = max(ans, sum(ys, i) + sum(xs, j));
            }
        }
    }
    ans.writeln;
}

Measured memory_bytes: 1104
#include <iostream>

using namespace std;
int main() {
    int K;
    cin >> K;
    int array[] = {
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << array[K-1] << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define ll long long
using namespace std;

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

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

using namespace std;

bool comp(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

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

    vector< pair<int, int> > v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }

    sort(v.begin(), v.end(), comp);

    bool ans = true;
    int sum = 0;

    for (int i = 0; i < n; i++) {
        sum += v[i].first;
        if (sum > v[i].second) ans = false;
    }

    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
   
    return 0;
} 


Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
int main(){
    ll A,B;
    cin >> A >> B;
    ll ans = A * B / 2;
    if (A % 2 != 0 && B % 2 != 0){
        ans++;
    }
    if (A == 1 || B == 1) ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
          long long int a,b,i,x=0,c;
          cin>>a>>b;
          while(b--)
          {
                    cin>>c;
                    x=x+c;
          }
          if((a-x) < 0)
                   cout<<"-1"<<endl;
          else
                    printf("%d\n",a-x);
          return 0;
}

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


int main() {
  int h , w ;
  cin >> h >> w ;
  
  vector<string> vec(h);
  for(int i=0;i<h;i++){
    cin >> vec.at(i);
    cout << vec.at(i)<<endl;
    cout << vec.at(i)<<endl;
    
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}

#if 1

class UnionFind {
public:
  UnionFind(int size) : size(size) {

    par = vector<int>(size, -1);
  }

  int GetRoot(int v) {
    int root = v;
    while (par[root] >= 0) {
      root = par[root];
    }
    if (root != v) {
      par[v] = root;
    }
    return root;
  }

  bool IsUnion(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    return ra == rb && ra >= 0;
  }

  int GetUnionSize(int a) {
    return -par[GetRoot(a)];
  }

  void Unite(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    if (ra == rb) return;

    if (GetUnionSize(ra) > GetUnionSize(rb)) {
      par[ra] += par[rb];
      par[rb] = ra;
    }
    else {
      par[rb] += par[ra];
      par[ra] = rb;
    }
  }

protected:

  // 親がいれば、親のindexを入れる
  // 親がいなければ、グループのサイズを負にして入れておく（一人なら-1）
  vector<int> par;

  int size;
};

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  UnionFind uf(N);

  auto lc = [](const pair<int, int>& l, const pair<int, int>& r) {
    return l.first > r.first;
  };
  priority_queue<pair<int, int>, deque<pair<int, int>>, decltype(lc)> pq(lc);

  vector<pair<int, int>> as(N);
  F0R(i, N) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    as[x] = { y, i };
  }

  F0R(x, N) {
    
    //debug(x);
    auto [y, i] = as[x];
    if (pq.size() && pq.top().first < y) {
      int my = pq.top().first;
      while (pq.size() && pq.top().first < y) {
        uf.Unite(i, pq.top().second);
        //cout << "unite " << i << " " << pq.top().second << newl;
        pq.pop();
      }
      pq.emplace(my, i);
    }
    else {
      pq.emplace(y, i);
      //cout << "emp " << y << " " << i << newl;
    }
  }

  F0R(i, N) {
    cout << uf.GetUnionSize(i) << newl;
  }
}
#endif


Measured memory_bytes: 5844
#include <iostream>
using namespace std;
int number(int x, int y){
  int z;
  if(x-y<0)z=y-x;
  else z=x-y;
  return z;
}
int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(number(a, x)>number(b, x))cout << 'B' << endl;
  else cout << 'A' << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int a,b;
	char c;
	cin >> a >> c >> b;
	if (c=='+') cout << a+b;
	if (c=='-') cout << a-b; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>
#include <set>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

vector<P> place;
set<P> stars;
int n, m;

int main(void)
{
	while(cin >> m && m)
	{
		stars.clear();
		place.resize(m);
		for (int i = 0; i < m; i++)
		{
			int x, y;
			cin >> x >> y;
			place[i] = P(x, y);
		}
		P original = place[0];
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			int x, y;
			cin >> x >> y;
			stars.insert(P(x, y));
		}

		int xsa = place[0].first, ysa = place[0].second;
		for (int i = 0; i < m; i++)
		{
			place[i].first -= xsa;
			place[i].second -= ysa;
		}

		int ansx = INF, ansy = INF;
		for(set<P>::iterator it = stars.begin(); it != stars.end(); it++)
		{
			bool flag = true;
			int sx = (*it).first, sy = (*it).second;
			for (int i = 0; i < m; i++)
			{
				int nx = place[i].first + sx, ny = place[i].second + sy;
				if(!stars.count(P(nx, ny)))
					flag = false;
			}
			if(flag)
			{
				ansx = sx;
				ansy = sy;
				break;
			}
		}

		cout << ansx - original.first << " " << ansy - original.second << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s;
    cin >> s;
    int N = s.size();
    bool f=false;
    for(int i=1;i<N-1;i++) if(s[i-1] != s[i+1]){
        f=true;
        break;
    }
    if(!f){
        cout << "Second" << endl;
        return 0;
    }

    if(s[0]==s[N-1]) N--;

    if(N%2==0){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
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 mt make_tuple
#define pb push_back
#define eb emplace_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--)
#define TR(X) ({if(0) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
    ll N, M, K; cin >> N >> M >> K;

    bool ans = false;
    FOR(i, 0, N+1) {
        ll cnt = i * M;
        FOR(j, 0, M+1) {
            if (cnt + (N-i) * j - i * j == K) {
                ans = true;
            }
            TR(i);
            TR(j);
            TR(cnt+(N-i)*j-i*j);
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
} //cin.tie(0) bei schnellem Wechseln


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

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

Measured memory_bytes: 3796
while True:
  n = int(input())
  if not n: break
  m = int(input())
  s = input()
  ind = 0
  ans = 0
  while ind < m:
    if s[ind] == "I":
      count = 0
      while ind + 2 < m:
        if s[ind + 1] == "O" and s[ind + 2] == "I":
          count += 1
          ind += 2
        else:
          break
      if count - n + 1 >= 0:
        ans += (count - n + 1)
    ind += 1
  print(ans)


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

int main() {
	int A, B, C;

	cin >> A >> B >> C;

	if (C > B) {
		if (C - B > A) {
			cout << 2 * B + A  + 1 << endl;
		}
		else {
			cout << 2 * B + (C - B)  << endl;
		}
	}

	else
	{
		cout << B + C << endl;
	}

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  char S[10];
  int len,out;
  out=0;
  scanf("%s",S);
  for(int i=0;i<=10;++i){
    len=0;
    for(int j=i;j<=10;++j){
      if(S[j]=='A' || S[j]=='C' || S[j]=='G' || S[j]=='T'){
        ++len;
      }else{
        if(len>out){
          out=len;
        }
        if(S[j]=='\0'){
          printf("%d",out);
          return 0;
        }
        len=0;
      }
    }
  }
  printf("%d",out);
  return 0;
}

Measured memory_bytes: 128
tax8 = 0.08
tax10 = 0.1

a,b = map(int,input().split())

t8  = int(a / tax8)
t10 = int(b / tax10)

tmp8 = 0
for i in range(t8,0,-1):
  if(not (int(i * tax8) == a)):
    tmp8 = i + 1
    break

l = []
for i in range(tmp8,tmp8+20):
  if(int(i * tax8) == a):
    l += [i]
  else:
    break

ll = []
for i in l[::-1]:
  if(int(i * tax10) == b):
    ll += [i]

if(not (ll == [])):
  print(min(ll))
else:
  print(-1)

Measured memory_bytes: 3064
left = list("qwertasdfgzxcvb")
right = list("yuiophjklnm")

while 1:
    S = list(input())
    if S == ["#"]:
        break

    cnt = 0
    s = S.pop(0)
    if s in left:
        pos = 0
    else:
        pos = 1

    for s in S:
        if pos == 0 and s in right:
            cnt += 1
            pos = 1
        elif pos == 1 and s in left:
            cnt += 1
            pos = 0

    print(cnt)



Measured memory_bytes: 5564
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;

template<class T>
using vec2d = std::vector<std::vector<T>>;

template<class T>
using vec3d = std::vector<std::vector<std::vector<T>>>;


template<class T>
vec3d<T> makeVec3d(const int n1, const int n2, const int n3, const T initValue) {
  return vec3d<T>(n1, vec2d<T>(n2, vec<T>(n3, initValue)));
}


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


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  vec<int> c(3, 0);
  FOR(i, n) {
    auto x = next<int>(in) - 1;
    ++c[x];
  }
  vec3d<double> f = makeVec3d<double>(n + 1, n + 1, n + 1, -1);
  function<double(int, int, int)> rec = [&](int a, int b, int c) -> double {

    if (!a && !b && !c) {
      return 0.0;
    }
    auto& res = f[a][b][c];
    if (res > -0.5) {
      return res;
    }
    res = 0;

    int d = n - a - b - c;

    double pa = double(a) / double(n);
    double pb = double(b) / double(n);
    double pc = double(c) / double(n);
    double pr = 1. - pa - pb - pc;

    if (a) {
      res += pa * (rec(a - 1, b, c) + 1);
    }
    if (b) {
      res += pb * (rec(a + 1, b - 1, c) + 1);
    }
    if (c) {
      res += pc * (rec(a, b + 1, c - 1) + 1);
    }
    // M = M1 + pr * (M + 1)
    // M(1-pr) = M1 + pr
    res += pr;
    res /= (1. - pr);
    return res;
  };
  out << fixed << setprecision(10) << rec(c[0], c[1], c[2]) << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 216960
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)
#define PI 3.14159265358979323846

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

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

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}

#define MAX 1000000000000000000

int main() {
    int n;
    cin >> n;
    ll temp = 0;
    ll ans = 1;
    int flag = 0;
    rep(i, n, 0) {
        cin >> temp;
        if (temp == 0) {
            cout << 0 << endl;
            return 0;
        }

        if (ans <= (MAX / temp)) {
            ans = ans * temp;
        } else {
            flag = 1;
        }
    }

    if (flag == 0) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

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

#define gc() std::getchar()
#define pc(i) std::putchar(i)

template <typename T>
inline T read(){ 
	T x = 0;
	char ch = gc();
	bool f = 0;
	while(!std::isdigit(ch)){ 
		f = (ch == '-');
		ch = gc();
	} 
	while(std::isdigit(ch)){ 
		x = x * 10 + (ch - '0');
		ch = gc();
	} 
	return f ? -x : x; 
}

template <typename T>
void put(T x){ 
	if (x < 0){ 
		x = -x;
		pc('-');
	} 
	if (x < 10){ 
		pc(x + 48);
		return;
	} 
	put(x / 10);
	pc(x % 10 + 48);
	return ;
} 

#define For(i, j, k) for(int i = j; i <= k; ++i)
#define Rep(i, j, k) for(int i = j; i >= k; --i)
#define rdi() read <int> ()
#define rdl() read <long long> ()
#define pti(i) put <int> (i), putchar(' ')
#define ptl(i) put <long long> (i), putchar(' ')
#define pub(i) push_back(i)
#define pob() pop_back()

typedef long long ll;
typedef float fl;
typedef double db;

void fake_main(){ 
	const int N = 1100;
	char s[N], t[N];
	
	scanf("%s%s", s + 1, t + 1);
	int lens = strlen(s + 1), lent = strlen(t + 1);
	
	int ans = lent;
	for (int i = 1; i <= lens - lent + 1; ++i) { 
		int cnt = 0;
		for (int j = 0; j < lent; ++j) if (s[i + j] != t[j + 1]) ++cnt;
		ans = std::min(ans, cnt);
	} 
	
	printf("%d\n", ans);
} 

int main(){ 
	fake_main();
	
	return 0;
} 

Measured memory_bytes: 3824
N = int(input())
A = list(map(int,input().split()))


while len(A)>1:
    m = min(A)
    A.remove(m)
    A = set(A)
    A = {i%m for i in A}
    if 0 in A:
        A.remove(0)
    A = list(A)
    A.append(m)

print(A[0])

Measured memory_bytes: 14252
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int x, y, z; cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << ' ' << y << ' ' << z << '\n';
  return 0;
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  vector<int> array;
  array.push_back(a);
  array.push_back(b);
  array.push_back(c);
  array.push_back(d);
  array.push_back(e);

  for (int i = 0; i < array.size()-1; i++) {
    for (int j = i+1; j < array.size(); j++) {
      if (array[j] - array[i] > k) {
	cout << ":(" << endl;
	return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  
  return 0;
}

Measured memory_bytes: 256
a,b,c,d = gets.split.map(&:to_i)
if a <= c && b <= d && b-c > 0
  puts b-c
elsif a <= c && b >= d && d-c > 0
  puts d-c
elsif a >= c && b <= d && b-a > 0
  puts b-a
elsif a >= c && b >= d && d-a > 0
  puts d-a
else 
  puts 0
end

Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in);) {
            String src = sc.nextLine();
            String res = src.replaceAll("eraser", "").replaceAll("erase", "").replaceAll("dreamer", "").replaceAll("dream", "");
            System.out.println(res.length() == 0 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 28740
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint N, A, B;
	cin >> N >> A >> B;
	lint sum = A + B;
	lint div = N / sum;
	cout << div * A + min(A, N % sum) << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  REP(i,n){
    ll a;
    cin >> a;
    if(i%2==1) continue;
    if(a%2==0) continue;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n)cin>>a[i];
  int x,y,z;
  x=y=z=0;
  rep(i,n){
    if(a[i]%4==0)x++;
    if(a[i]%4==2)y++;
    }
  z=n-x-y;
  bool ans;
  if(y==0)
    ans=(x>=z-1);
  else
    ans=(x>=z);
  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
  }



Measured memory_bytes: 640