akhauriyash/Code-Regression huggingface dataset:
dish = [int(input()) for _ in range(5)]
dishtime = [0]*5
for i,d in enumerate(dish):
  if int(d/10)*10 == d:
    dishtime[i] = d
  else:
    dishtime[i] = int(d/10)*10+10
mintime = [0]*5
for i in range(5):
  if dishtime[i] == dish[i]:
    mintime[i] = 10
  else:
    mintime[i] =  10+dish[i]-dishtime[i]
print(sum(dishtime)+min(mintime)-10)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

long long dp(long long curr, bool alreadySkipped, const vector<long long>& V, vector<vector<long long>>& memo) {
    if (memo[curr][alreadySkipped ? 1 : 0] >= 0) {
        return memo[curr][alreadySkipped ? 1 : 0];
    }
    long long ret = 0;
    if (alreadySkipped) {
        if (curr == V.size() - 2) {
            ret = __gcd(V[curr], V[curr + 1]);
        }
        else {
            ret = __gcd(V[curr], dp(curr + 1, alreadySkipped, V, memo));
        }
    }
    else {
        if (curr == V.size() - 2) {
            long long skip1 = V[curr];
            long long skip2 = V[curr + 1];
            long long take = __gcd(V[curr], V[curr + 1]);
            ret = max(max(skip1, skip2), take);
        }
        else {
            long long skip = dp(curr + 1, true, V, memo);
            long long take = __gcd(V[curr], dp(curr + 1, false, V, memo));
            ret = max(skip, take);
        }
    }
    memo[curr][alreadySkipped ? 1 : 0] = ret;
    return ret;
}

long long gcd(const vector<long long>& V) {
    long long ret = V[0];
    for (long long i = 1; i < V.size(); ++i) {
        ret = __gcd(ret, V[i]);
    }
    return ret;
}

void Main() {
    long long N;
    cin >> N;
    vector<long long> V(N, 0);
    for (long long i = 0; i < N; ++i) {
        cin >> V[i];
    }

    vector<vector<long long>> memo(V.size() + 10, vector<long long>(2, -1));
    long long ans = dp(0, false, V, memo);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 15668
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <locale>
#include  <memory>
#include  <cerrno>
#include  <time.h>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <list>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
int a[11];
ll n,l,ans;
void dfs(int i,ll x,ll s)
{
    if(i>l)
    {
        s+=x;
        ans+=s;
        return;
    }
    dfs(i+1,a[i],s+x);
    if(i>1)
    dfs(i+1,x*10+a[i],s);
}
int main()
{
    cin>>n;
    while(n)
    {
        a[++l]=n%10;
        n/=10;
    }
    reverse(a+1,a+1+l);
    dfs(1,0,0);
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
   long i,j,k;
   long f;
   long n;
   long q;
   long cnt = 0;
   long h;
   long left,right,mid;
   long ans = 0;
   long a[100];
   scanf("%ld",&n);
   for (i = 0; i < n; i++) {
      scanf("%ld",&a[i]);
   }
   for (i = n-1; i > 0; i--) {
      printf("%ld ",a[i]);
   }
   printf("%ld\n",a[0]);
   return 0;
}

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

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

}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String a;
		int count = 1;
		String flag = "Yes";
		Scanner sc = new Scanner(System.in);
		a = sc.next();
		String[] as = a.split("");
		for (String i : as) {
			if (count % 2 == 0 && i.equals("R")) {
				flag = "No";
			}
			if (count % 2 != 0 && i.equals("L")) {
				flag = "No";
			}
			count++;
		}

		sc.close();

		System.out.println(flag);

	}

}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
  int N, ans;
  cin >> N;
  int X[N];
  ans = 1000000000;
  rep(i, N) cin >> X[i];
  for(int i = 1; i <= 100; ++i){
    int tmp = 0;
    for (int j = 0; j < N; ++j) {
      tmp += (i - X[j]) * (i - X[j]);
    }
    if (ans > tmp) {
      ans = tmp;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
/*
   Aizu Vol-1 0157: Russian Dolls
   2017.8.14 bal4u@uu
   ???????¢????????????±???????????????????????????LIS???
*/
#include <stdio.h>

#define MAX 200
int h[MAX + 5], r[MAX + 5], N;
int lis[MAX + 5];   /* LIS */

int LIS(void)
{
	int i, j, m;

	lis[N - 1] = 1;
	for (i = N - 2; i >= 0; i--) {
		m = 0;
		for (j = i + 1; j < N; j++) {
			if (h[i] < h[j] && r[i] < r[j] && lis[j] > m) m = lis[j];
		}
		lis[i] = m + 1;
	}
	return lis[0];
}

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

	while (1) {
		scanf("%d", &n); if (!n) break;
		N = n, i = 0;
		while (n--) scanf("%d%d", h + i, r + i), i++;
		scanf("%d", &m);
		N += m;
		while (m--) scanf("%d%d", h + i, r + i), i++;
		for (i = 0; i < N; i++) {
			k = i;
			for (j = i + 1; j < N; j++) if (h[k] > h[j]) k = j;
			if (k != i) {
				t = h[i], h[i] = h[k], h[k] = t;
				t = r[i], r[i] = r[k], r[k] = t;
			}
		}
		printf("%d\n", LIS());
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
int main(void)
{
	int H, W, i, k;
	while(scanf("%d%d", &H,&W), H!=0 || W!=0){
		for(k=0;k<W;k++) printf("#");
		puts("");
		for(i=1;i<H-1;i++){
			printf("#");
			for(k=1;k<W-1;k++) printf(".");
			puts("#");
		}
		for(k=0;k<W;k++) printf("#");
		puts("");
		puts("");
	}
	return 0;
}

Measured memory_bytes: 588
#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;

int main() {
    ll X;
    cin >> X;
    ll n = 1;
    ll sum = 0;
    while (true) {
        sum += n++;
        if (sum >= X)
            break;
    }
    cout << n - 1 << endl;
    return 0;
}

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

int N;
int ans[32];

int main() {
  cin >> N;
  ll buf = 0;

  if (N >= 0) {
    ll x = 1, i = 0;
    while (buf < N) {
      buf += x;
      x *= 4;
      i += 2;
    }
    for (int j = i-2; j >= 0; --j) {
      if (buf - (ll)pow(2, j) >= N) {
        buf -= (ll)pow(2, j);
        if (j%2) ans[j] = 1;
      }
      else if (!(j%2)) ans[j] = 1;
      
    }
  }
  else {
    ll x = -2, i = 1;
    while (buf > N) {
      buf += x;
      x *= 4;
      i += 2;
    }
    for (int j = i-2; j >= 0; --j) {
      if (buf + (ll)pow(2, j) <= N) {
        buf += (ll)pow(2, j);
        if (!(j%2)) ans[j] = 1;
      }
      else if (j%2) ans[j] = 1;
    }
  }
  bool f = false;
  for (int i = 31; i >= 0; --i) {
    if (f || ans[i]) {
      cout << ans[i];
      f = true;
    }
  }
  if (!f) cout << 0;
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N, T;
  cin >> N >> T;
  int c[N], t[N];
  int cost=1001;
  REP(i, N) {
    cin >> c[i] >> t[i];
  }
  REP(i, N){
    if(t[i]<=T){
      cost = min(cost, c[i]);
    }
  }
  if(cost==1001) cout << "TLE" << endl;
  else cout << cost << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int N;
int cnt[26];
bool comp(int i,int j){return cnt[i]>cnt[j];}

string f(){
	memset(cnt,0,sizeof(cnt));
	vector<char>c(N);
	REP(i,N)cin>>c[i];
	REP(i,N){
		cnt[c[i]-'A']++;
		int ma = 0;
		REP(j,26){
			if(j==c[i]-'A')continue;
			CHMAX(ma,cnt[j]);
		}
		vector<int>id(26,0);
		iota(ALL(id),0);
		sort(ALL(id),comp);
		if(cnt[id[0]]>cnt[id[1]]+N-i-1){
			string ret = "";
			ret += id[0]+'A';
			ret += " ";
			ret += to_string(i+1);
			return ret;
		}
	}
	return "TIE";
}

signed main(){
	vector<string>ans;
	while(cin>>N,N)ans.push_back(f());
	for(auto e:ans)cout<<e<<endl;
}


Measured memory_bytes: 3368
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const ll MOD = 1000000000007;
const int MAX = 60;

ll C[MAX][MAX];

void com(){
    C[0][0]=1;
    for(int i=1;i<51;i++){
        for(int j=0;j<i+1;j++){
            if(j==0||j==i) C[i][j]=1;
            else{
                C[i][j]=C[i-1][j-1]+C[i-1][j];
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,cnt,x;
    cin>>n>>a>>b;
    vector<ll> v(n);
    double ans;
    ll res=0;
    rep(i,n) cin>>v[i];
    sort(all(v));
    for(int i=n-1;i>=n-a;i--){
        ans+=(double)v[i];
    }
    ans/=a;
    cnt=(int)(upper_bound(all(v),v[n-a])-lower_bound(all(v),v[n-a]));
    x=(int)(upper_bound(all(v),v[n-a])-v.begin()-(n-a));
    // cout<<cnt<<" "<<x<<endl;
    com();
    // cout<<C[2][1]<<" "<<C[3][1]<<endl;
    if(upper_bound(all(v),v[n-a])==v.end()){
        for(int i=a;i<b+1;i++){
            res+=C[cnt][i];
        }
    }
    else if(cnt>x){
        res=C[cnt][x];
    }
    else res=1;
    cout<<fixed<<setprecision(7)<<ans<<endl;
    cout<<res<<endl;
    return 0;
}


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

int main() {
	int W, H, N;
	cin >> W >> H >> N;
	int x, y, a;
	int left = 0, right = W, top = H, bottom = 0;
	for (int i = 0; i < N; i++) {
		cin >> x >> y >> a;
		if (a == 1 && x > left)left = x;
		if (a == 2 && x < right)right = x;
		if (a == 3 && y > bottom)bottom = y;
		if (a == 4 && y < top)top = y;
	}
	if (left > right || top < bottom)cout << 0 << endl;
	else cout << (top - bottom)*(right - left) << endl;
	return 0;
}

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

int main(){
    int n; cin >> n;
    int f=0;
    rep(i,n){
        int a; cin >> a;
        if(a%2==0){
            if(a%3!=0 && a%5!=0){
                    f++;
                    break;
            }
        }
    }
    if(f) cout << "DENIED" << endl;
    else cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
    ll n;
    cin >> n;
  vector<vector<ll>> c(10,vector<ll>(10,0));
  rep(i,n){
      int a=(i+1)%10,b;
      int u=i+1;
      while(true){
          if(u/10==0){
              b=u;
              break;
          }
          u/=10;
      }
      c[a][u]++;
  }
  ll ans=0;
  rep(i,10){
      rep(j,10) ans+=c[i][j]*c[j][i];
  }
  cout << ans << endl;
}


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

int main() {
    ll A,B,K;
    ll a,b;
    cin >> A >> B >> K;
    if(A >= K) {
        a = A - K;
        b = B;
    } else if(A + B > K) {
        a = 0;
        b = A + B - K;
    } else {
        a = 0;
        b = 0;
    }
    cout << a << " " << b << endl;
}

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

#define rep(i, n) for(long long i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    ll n, m;
    cin >> n >> m;
    vector<ll> x;
    rep(i, m){
        ll temp;
        cin >> temp;
        x.pb(temp);
    }
    if(m <= n){
        print(0);
        return 0;
    }
    sort(ALL(x));
    vector<ll> sub;
    rep(i, m - 1){
        sub.pb(x[i + 1] - x[i]);
    }
    sort(ALL(sub));
    int ans = 0;
    rep(i, sub.size() - n + 1){
        ans += sub[i];
    }
    print(ans);
}

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




int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    string T;
    cin >> T;
    for(int i=0;i<N;i++){
        cout<<S.at(i)<<T.at(i)
    ;}
    

return 0;


}  



Measured memory_bytes: 256
#include <stdio.h>
main(void){
  int x;
  int i;
  long int total=0;
  scanf("%d",&x);
  for(i=1;i<=x;i++){
    if(i%3!=0 && i%5!=0)total+=i;
  }
  printf("%ld",total);
  return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e18;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

ll pas[100][100];

void pascal(int n)
{
    memset(pas, 0, sizeof(pas));
    for (int i = 0; i <= n; i++)
    {
        pas[i][0] = 1;
        for (int j = 1; j <= i; j++)
            pas[i][j] = pas[i - 1][j - 1] + pas[i - 1][j];
    }
}

ll fastPow(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return fastPow(x * x % MOD, n / 2);
    else
        return x * fastPow(x, n - 1) % MOD;
}

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

    pascal(60);

    int n, a, b;
    ll v[51];

    cin >> n >> a >> b;
    REP(i, n)
    cin >> v[i];

    sort(v, v + n);

    long double ave = 0;

    bool sm = false;

    if (a < n)
    {
        if (v[n - 1] == v[n - a - 1])
            sm = true;
    }

    for (int i = 0; i < a; i++)
    {
        ave += v[n - i - 1];
    }

    ave /= (long double)a;

    ll res = 0;

    if (sm)
    {
        int al = 0;
        for (int i = 0; i < n; i++)
            al += v[n - 1] == v[n - 1 - i];

        int cnt = a;

        for (int i = a; i <= b; i++)
        {
            if (v[n - i] != v[n - 1])
                break;
            res += pas[al][cnt];

            cnt++;
        }
    }
    else
    {
        int al = 0;
        for (int i = 0; i < n; i++)
            al += v[n - a] == v[n - 1 - i];

        int cnt = 0;

        for (int i = 0; i < a; i++)
            cnt += v[n - a] == v[n - 1 - i];

        res += pas[al][cnt];
    }

    cout << setprecision(20) << ave << endl
         << res << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define yes puts("YES")
#define no puts("NO")
#define PI 3.141592653589793238462643383279
const long long iinf = INT64_MAX - 1;
const int inf = INT32_MAX - 1;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int dir8[8][2] = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};
using namespace std;

void solve()
{
    int w, s; cin >> s >> w;
    if(w >= s) cout << "unsafe";
    else cout << "safe";

}
#define testcases 0             // 0 -> no test case. 1 -> test case
int main()
{
	int t = 1;

    if(testcases) cin >> t;

	// int i = 1;
	while(t--){
	// cout << "Case #" << i++ << ": \n";
	solve();
	// if(t)printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3584
n, m = map(int, input().split())

data = []

for i in range(n):
    a, b = map(int, input().split())
    data.append([a, b])

data.sort(key = lambda x: x[0])
buy = 0
ans = 0
for i in range(n):
    buy = min(data[i][1], m)
    ans += buy * data[i][0]
    m -= buy
    if m == 0:
        break


print(ans)

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int n;
long long W;
const long long INF = 1e16;

long long dp[110][100100];
int main() {
    cin >> n >> W;
    vector<long long> w(n, 0);
    vector<int> v(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> w.at(i) >> v.at(i);
    }

    int Vmax = n*1000;
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= Vmax; ++j) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= Vmax; ++j) {
            if(j+v.at(i) <= Vmax) {
                dp[i+1][j+v.at(i)] = dp[i][j]+w.at(i);
            }
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    long long ans = 0;
    for(int j = 0; j <= Vmax; ++j) {
        if(dp[n][j] <= W) {
            ans = j;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 80128
#include<cstdio>

int b[3005][3005], w[3005][3005];
int b_cs[3005][3005], w_cs[3005][3005];
int n, k;

int func_b(int x, int y) {
  return b_cs[x + k][y + k] - b_cs[x + k][y] - b_cs[x][y + k] + b_cs[x][y];
}

int func_w(int x, int y) {
  return w_cs[x + k][y + k] - w_cs[x + k][y] - w_cs[x][y + k] + w_cs[x][y];
}


int main() {
  scanf("%d %d\n", &n, &k);
  int k2 = k * 2;
  for (int i = 0; i < n; i++){
    int x, y;
    char c;
    scanf("%d %d %c\n", &x, &y, &c);
    x %= k2;
    y %= k2;
    if (c == 'B') {
      b[x][y] += 1;
      if (x < k) b[x + k2][y] += 1;
      if (y < k) b[x][y + k2] += 1;
      if (x < k && y < k) b[x + k2][y + k2] += 1;
    } else {
      w[x][y] += 1;
      if (x < k) w[x + k2][y] += 1;
      if (y < k) w[x][y + k2] += 1;
      if (x < k && y < k) w[x + k2][y + k2] += 1;
    }
  }

  for (int i = 0; i <= k * 3 + 1; i++) {
    for (int j = 0; j <= k * 3 + 1; j++) {
      b_cs[i + 1][j + 1] = b_cs[i + 1][j] + b_cs[i][j + 1] - b_cs[i][j] + b[i][j];
      w_cs[i + 1][j + 1] = w_cs[i + 1][j] + w_cs[i][j + 1] - w_cs[i][j] + w[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      int cand = 0;
      cand += func_b(i, j);
      cand += func_b(i + k, j + k);
      cand += func_w(i + k, j);
      cand += func_w(i, j + k);
      // printf("%d %d %d\n", i, j, cand);
      if (cand > ans) ans = cand;

      cand = 0;
      cand += func_w(i, j);
      cand += func_w(i + k, j + k);
      cand += func_b(i + k, j);
      cand += func_b(i, j + k);
      // printf("%d %d %d\n", i, j, cand);
      if (cand > ans) ans = cand;
    }
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 141184
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	M, D := r.nextInt(), r.nextInt()

	cnt := 0
	for i := 2; i <= 9; i++ {
		for j := 2; j <= 9; j++ {
			if i*j <= M && i*10+j <= D {
				cnt++
			}
		}
	}

	fmt.Fprintln(stdout, cnt)
}


Measured memory_bytes: 640
N, M = map(int, input().split())

q = []
for i in range(M):
    a, b = map(int, input().split())
    q.append((a, b))

q = sorted(q, key=lambda x: (x[0], x[1]))

e = 0
ans = 0
for i in range(M):
    a, b = q[i]
    if a >= e:
        ans += 1
        e = b
    elif b < e:
        e = b

print(ans)


Measured memory_bytes: 60684
#include<bits/stdc++.h>
using namespace std;
const int N=111;
int n,m;
int a[N][N];
bool f[N][N];
int cp[N];
bool vis[N];
bool dfs(int x){
	vis[x]=true;
	for(int i=0;i<n;i++){
		if(f[x][i]&&(cp[i]==-1||(!vis[cp[i]]&&dfs(cp[i])))){
			cp[i]=x;
			return true;
		}
	}
	return false;
}
void qaq(){
	memset(cp,-1,sizeof(cp));
	for(int i=0;i<n;i++){
		memset(vis,false,sizeof(vis));
		assert(dfs(i));
	}
}
void solve(){
	for(int k=0;k<m;k++){
		memset(f,0,sizeof(f));
		for(int i=0;i<n;i++){
			for(int j=k;j<m;j++){
				f[i][a[i][j]/m]=true;
			}
		}
		qaq();
		for(int i=0;i<n;i++){
			int r=cp[i];
			for(int j=k;j<m;j++){
				if(a[r][j]/m==i){
					swap(a[r][k],a[r][j]);
					break;
				}
			}
		}
	}
}
void rev(){
	for(int i=0;i<N;i++){
		for(int j=0;j<i;j++){
			swap(a[i][j],a[j][i]);
		}
	}
}
void print(){
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			printf("%d ",a[i][j]+1);
		}
		printf("\n");
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			scanf("%d",&a[i][j]);
			a[i][j]--;
		}
	}
	solve();
	print();
	rev();
	for(int j=0;j<m;j++){
		sort(a[j],a[j]+n);
	}
	rev();
	print();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll N;
    cin >> N;

    if (N % 2 == 0)
    {
        cout << N << endl;
    }
    else
    {
        cout << N * 2 << endl;
    }
    
}


Measured memory_bytes: 384
import java.io.PrintWriter
import java.lang.Math

val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val paras = listOfInt()
    val res = Math.max(paras[0]+paras[1], Math.max(paras[0]-paras[1],paras[0]*paras[1]))
      println(res)
}

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

fun println(value : Any) {
    pw.println(value)
}


Measured memory_bytes: 36016
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

struct P{
	int x, y;
	P(int x_, int y_){ x = x_; y = y_;}
	P(){}
};
struct State{
	int t, x, y;
	State(int t_, int x_, int y_){ t = t_; x = x_; y = y_; }
};
bool operator<(const State& a, const State& b){
	return a.t > b.t;
}

const int INF = 1e+8;
int w, h;
int m[201][201];
int G[20][20];
int dx[4] = {0,0,1,-1};
int dy[4] = {-1,1,0,0};

int bfs(P s, P g){
	int d[201][201];
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			d[y][x] = INF;
		}
	}
	d[s.y][s.x] = 0;
	priority_queue<State> q;
	q.push( State(0,s.x,s.y) );
	
	int res=INF;
	while( !q.empty() ){
		int t = q.top().t;
		int x = q.top().x;
		int y = q.top().y;
		q.pop();
		
		if( x == g.x && y == g.y ){
			res = t;
			break;
		}
		
		for(int i=0 ; i < 4 ; i++ ){
			int mx = x + dx[i];
			int my = y + dy[i];
			if( mx < 0 || my < 0 || w <= mx || h <= my ) continue;
			if( m[my][mx] == INF ) continue;
			
			if( t + m[y][x] < d[my][mx] ){
				d[my][mx] = t + m[y][x];
				q.push( State( t + m[y][x] , mx , my ) );
			}
		}
	}
	return res;
}

void hole(int ax, int ay){
	for(int y = ay-2 ; y <= ay+2 ; y++ ){
		for(int x = ax-2 ; x <= ax+2 ; x++ ){
			m[y][x] = max( m[y][x] , 2 );
		}
	}
	for(int y = ay-1 ; y <= ay+1 ; y++ ){
		for(int x = ax-1 ; x <= ax+1 ; x++ ){
			m[y][x] = max( m[y][x] , 3 );
		}
	}
	m[ay][ax] = INF;
}

int main(){
	cin >> w >> h;
	vector<string> s(h);
	for(int y=0 ; y < h ; y++ ){
		cin >> s[y];
	}
	
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			m[y][x] = 1;
		}
	}
	vector<P> v;
	int sx, sy, gx, gy;
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			if( s[y][x] == 'S' ){
				sx = x; sy = y;
				s[y][x] = '.';
			}
			if( s[y][x] == 'G' ){
				gx = x; gy = y;
				s[y][x] = '.';
			}
			if( s[y][x] == 'M' ){
				s[y][x] = '.';
				v.push_back( P(x,y) );
			}
			if( s[y][x] == '#' ){
				hole(x,y);
			}
		}
	}
	for(int i=0 ; i < v.size() ; i++ ){
		int cost = bfs( P(sx,sy) , v[i] );
		G[0][i+1] = cost;
		cost = bfs( v[i] , P(gx,gy) );
		G[i+1][v.size()+1] = cost;
		for(int j=0 ; j < v.size() ; j++ ){
			cost = (i == j)? 0 : bfs( v[i] , v[j] );
			G[i+1][j+1] = cost;
		}
	}
	
	vector<int> a;
	for(int i=0 ; i < v.size() ; i++ ) a.push_back(i);
	int ans = INF;
	do{
		int cost = G[0][a[0]+1];
		for(int i=1 ; i < a.size() ; i++ ){
			cost += G[a[i-1]+1][a[i]+1];
		}
		cost += G[a[a.size()-1]+1][a.size()+1];
		ans = min( ans , cost );
	}while( next_permutation(a.begin(),a.end()) );
	cout << ans << endl;
}

Measured memory_bytes: 1432
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

K = ii()
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,m;
  cin>>n>>m;
  
  int as[200001] = {0}, bs[200001] = {0};
  
  rep(i,m) {
    int a,b;
    cin>>a>>b;
    
    if(a==1) as[b-1] = 1;
    if(b==n) bs[a-1] = 1;
  }
  
  rep(i,n) {
    int a = as[i];
    int b = bs[i];
    
    if(a==1 and b==1) {
      cout<<"POSSIBLE";
      return 0;
    }
  }
  
  cout<<"IMPOSSIBLE";
  
  return 0;
}

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

int main() {
  int h, w;
  vector<string> str(101);
  
  cin >> h >> w;
  
  rep(i, h)
    cin >> str.at(i);
  
  rep(i, w + 2)
    cout << "#";
  cout << endl;
  
 rep(i, h){
   cout << "#" << str.at(i) << "#" << endl;
 }
   
  
  rep(i, w + 2)
    cout << "#";
  cout << endl;

}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# いっこ入力
n =int(input())

# 空白区切りの数列をリストに代入
k = [int(i) for i in input().split()]

p = sorted(k)
diff=0
for i in range(n):
    if k[i] != p[i]:
        diff += 1

if diff<3:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 21420
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}
func getNextWord(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextWord(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	// scanner := bufio.NewScanner(fp)
	// scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)

	scanner := bufio.NewReader(fp)
	ll := getNextLine(scanner)

	l := len(ll)
	dp := make([][2]int, l+1)
	dp[0][0] = 2
	dp[0][1] = 1

	for i := 1; i < l; i++ {
		for ii := 0; ii < 2; ii++ { // 未満確定かどうか
			if ii == 1 {
				dp[i][1] += dp[i-1][ii] * 3
				dp[i][1] %= 1000000007
				continue
			}
			dp[i][0] += dp[i-1][ii]

			if ll[i] == '1' {
				dp[i][0] += dp[i-1][ii]
				dp[i][1] += dp[i-1][ii]
			}
			dp[i][0] %= 1000000007
			dp[i][1] %= 1000000007
		}
	}

	fmt.Fprintln(writer, (dp[l-1][0]+dp[l-1][1])%1000000007)

	writer.Flush()
}


Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int city[100005];
int main()
{
	int n, m;
	while (cin >> n >> m)
	{
		REP(i, n - 1) cin >> city[i];

		int s[100005];
		memset(s, 0, sizeof(s));
		FOR(i, 1, n)
		{
			s[i] = s[i - 1] + city[i-1];
		}
		int stay = 0;
		int sum = 0;
		REP(i, m)
		{
			int a;
			cin >> a;
			sum = (sum+(abs(s[stay] - s[stay + a]))) % 100000;
			stay += a;
		}
		cout << sum << endl;
		return 0;
	}
}

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

#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;

#define sqr(a) ((a)*(a))
#define forn(i, n) for(int i = 0; i < (int)n; ++i)
#define rep(i, k, n) for(int i = (int)k; i <= (int)n; ++i)
#define nrof(i, n) for(int i = (int)n - 1; i >= 0; --i)
#define x first
#define y second
#define mp make_pair
#define sz(a) (int)(a.size())
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1e6 + 9;
const int M = 2e3 + 9;
const int INFINT = 1e9 + 9;
const ll INFLL = 1e18 + 9;
const ll MOD = (ll) (1000000007);


void solve() {
    string s;
    cin >> s;
    int cnt = 0;
    s += 'S';
    int ans = 0;
    forn(i, sz(s)) {
        if (s[i] == 'R') ++cnt;
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans << endl;
}

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

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t;
    t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
    int d,r;
    int a,b;
    double f;
    
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %f\n",d,r,f);
    
    return 0;
}


Measured memory_bytes: 2052
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int n;
    char s[110],t[10];
    strcpy(t,"keyence");
    scanf("%s",s);
    n=strlen(s);
    for(int i=0;i<7;i++){
        int flag=1;
        for(int j=0;j<7;j++){
            if(j<i){
                if(s[j]!=t[j]){
                    flag=0;
                    break;
                }
            }
            else{
                if(s[j+n-7]!=t[j]){
                    flag=0;
                    break;
                }
            }
        }
        if(flag){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
}

Measured memory_bytes: 128
n, q = map(int, input().split())
s = input()
acc = [0 for _ in range(n)]
for i in range(1, n):
    acc[i] = acc[i - 1]
    if s[i - 1:i + 1] == "AC":
        acc[i] += 1
for _ in range(q):
    l, r = map(int, input().split())
    print(acc[r - 1] - acc[l - 1])

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

int main(){
	int N, K, h, i, ans = 0;
	scanf("%d%d", &N, &K);
	for(i = 0; i < N; i++){
		scanf("%d", &h);
		if(h >= K){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define MOD 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

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

int main(){

	string S;
	cin >> S;
	int ans = 0;
	bool flag;
	for(int i = 0; i < S.size(); i ++){
		for(int j = i; j < S.size(); j ++){
			flag = true;
			for(int k = i; k <= j; k ++){
				if(!(S[k] == 'A' || S[k] == 'C' || S[k] == 'G' || S[k] == 'T')){
					flag = false;
					break;
				}
			}
			if(flag){
				ans = max(ans, j - i + 1);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int keisan(int a,int b,int c,int d){
        char cms[] = {'+','-','*'};
        for(int i = 0;i < 3;i++){
            for(int j = 0;j < 3;j++){
                for(int k = 0;k < 3;k++){
                    if(calc(calc(calc(a,b,i),c,j),d,k) == 10){
                        System.out.println("((("+a+" "+cms[i]+" "+b+") "+cms[j]+" "+c+") "+cms[k] + " " + d +")");
                        return 1;
                    }else if(calc(calc(a,calc(b,c,j),i),d,k) == 10){
                        System.out.println("(("+a+" "+cms[i]+" ("+b+" "+cms[j]+" "+c+")) "+cms[k] + " " + d +")");
                        return 1;
                    }else if(calc(calc(a,b,i),calc(c,d,k),j) == 10){
                        System.out.println("(("+a+" "+cms[i]+" "+b+") "+cms[j]+" ("+c+" "+cms[k] + " " + d +"))");
                        return 1;
                    }
                }
            }
        }
        return 0;
    }
     
    static int calc(int a,int b,int c){
        if(c == 0)return a+b;
        else if(c==1)return a-b;
        return a*b;
    }
     public static void main(String[] args) {
        while(true){
            int a[] = new int [4];
            
           for(int i=0;i<4;i++){
        	   a[i]=sc.nextInt();
           }
            if(a[0]+a[1]+a[2]+a[3]==0)break;
            int num = 0;
            for(int i = 0;i < 4;i++){
                for(int j = 0;j < 4;j++){
                    for(int k = 0;k < 4;k++){
                        for(int l = 0;l < 4;l++){
                            if(i == j || i == k || i == l || j == k || j == l || k == l)continue;
                            num = keisan(a[i],a[j],a[k],a[l]);
                            if(num == 1)break;
                        }
                        if(num == 1)break;
                    }
                    if(num == 1)break;
                }
                if(num == 1)break;
            }
            if(num == 0){
                System.out.println(0);
            }
        }
    }
 
}

Measured memory_bytes: 18392
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;//*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
	while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
const int N=5011;
struct Edge{
	int v;Edge *nxt;
} pl[N<<1],*cur=pl,*G[N];
inline void addedge(int u,int v){cur->v=v,cur->nxt=G[u],G[u]=cur++;}
int n,v[N],g[N],b[N];
void dfs(int x){
	int f[N];memset(f,0,sizeof f);
	f[0]=1;int S=0;
	Es(x,i){
		dfs(i->v);
		S+=v[i->v]+b[i->v];
		memset(g,0,sizeof g);
		rep(j,0,v[x]){
			g[j]=(j>=v[i->v]&&f[j-v[i->v]])||(j>=b[i->v]&&f[j-b[i->v]]);
		}
		memcpy(f,g,sizeof f);	
	}
	int i=v[x];
	for(;~i&&!f[i];i--);
	if(i==-1)puts("IMPOSSIBLE"),exit(0);
	b[x]=S-i;
}
int main(){
#ifdef flukehn
	freopen("test.txt","r",stdin);
#endif
	n=rd();
	rep(i,2,n){
		int fa=rd();
		addedge(fa,i);
	}
	rep(i,1,n)v[i]=rd();
	dfs(1);
	puts("POSSIBLE");
}

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

int main(){
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  
  cout << w*h/2 << " ";
  
  if(x==w/2&&y==h/2)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  int64 count = 0;
  for (int a = 1; a <= n - 1; a++) {
    count += (n - 1) / a;
  }
  cout << count << endl;
}

Measured memory_bytes: 3652
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    # N = int(input())
    N, D = [int(a) for a in input().split()]

    if N% (2 * D + 1)==0:


        print(N// (2 * D + 1))
    else:
        print(N // (2 * D + 1)+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); // 県の個数
		int m = in.nextInt(); // 市の個数

		int city[][] = new int[m + 1][4]; // id, pref, year, number in pref

		// 県、年でソート
		for ( int id = 1; id <= m; id++ ) {
			city[id][0] = id;
			city[id][1] = in.nextInt();
			city[id][2] = in.nextInt();
		}
		Arrays.sort(city, new Comparator<int[]>() {

			@Override
			public int compare(int[] o1, int[] o2) {
				if ( o1[1] != o2[1] ) {
					return o1[1] - o2[1];	// １．prefでソート
				} else {
					return o1[2] - o2[2];	// ２．yearでソート
				}
			}
		});

		DecimalFormat df = new DecimalFormat("000000");
		String result[] = new String[m];
		int pref = 0;
		int num = 0;
		for ( int i = 1; i <= m; i++ ) {
			int p = city[i][1];
			if ( pref != p ) {
				pref = p;
				num = 1;
			} else {
				num++;
			}
			result[city[i][0] -1] = df.format(pref) + df.format(num);
		}
		
		// PrintWriter pw = new PrintWriter(System.out);
		StringBuilder sb = new StringBuilder();
		for ( String s : result ) {			
			sb.append(s).append("\n");
			// pw.println(s);
		}
		System.out.println(sb);
		// pw.flush();
		in.close();
	}
}


Measured memory_bytes: 98660
#include <bits/stdc++.h>
    using namespace std;
    int main(){
        //freopen("in.txt","r",stdin);
        double a,b;
        cin>>a>>b;
        bool sw = false;
        int x,y;
        for(int i = 0 ; i <= 1000 ; i++){
            x = (double)(i)*0.08;
            y = (double)(i)*0.1;
            if(x == a and y == b){
                cout<<i<<"\n";
                sw = true;
                break;
            }
        }
        if(!sw) cout<<"-1\n";
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int m, f, r;
    while (1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        if (m == -1 || f == -1) cout << "F" << endl;
        else if (80 <= m + f) cout << "A" << endl;
        else if (65 <= m + f) cout << "B" << endl;
        else if (50 <= m + f) cout << "C" << endl;
        else if (30 <= m + f) {
            if (50 <= r) cout << "C" << endl;
            else cout << "D" << endl;
        } else cout << "F" << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include <stdio.h>
int main(){
int i,N,x=0,max=0;
char s[101];
scanf("%d",&N);
scanf("%s",s);
for(i=0;i<N;i++){
if(s[i]=='I'){x++;}
else{x--;};
if(max<x){max=x;}
}
printf("%d",max);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel";
    }else{
        cout << "consonant";
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 105
int h, w;
int n;

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

    cin >> h >> w >> n;
    if(h < w) swap(h, w);
    cout << (n+h-1)/h << "\n";    

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int R, C;
	while(cin >> R >> C, R) {
		vvi senbei(R, vi(C));
		REP(i, R) {
			REP(j, C) {
				cin >> senbei[i][j];
			}
		}

		int ans = 0;
		REP(i, 1<<R) {
			int tmp = 0;
			REP(j, C) {
				int line = 0;
				REP(k, R) {
					if(i&(1<<k)) {
						line += !senbei[k][j];
					} else {
						line += senbei[k][j];
					}
				}
				tmp += max(line, R-line);
			}
			ans = max(ans, tmp);
		}

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

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 2);
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    int ans = n + 1;
    for(int tans = 1; tans <= n; ++tans) {
        vector<bool> reach(n + 2);
        function<bool(int)> dfs = [&](int now) {
            reach[now] = true;
            if(now == n + 1) return true;
            bool res = false;
            for(int mv = 1; mv <= tans && now + mv <= n + 1; ++mv) {
                const int nxt = now + mv;
                if(reach[nxt] || a[nxt] == 1) continue;
                res |= dfs(nxt);
            }
            return res;
        };
        if(dfs(0)) {
            ans = tans;
            break;
        }
    }
    cout << ans << endl;
}



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

int main(){
  
  int N, R;
  cin >> N >> R;
  
  if (N >= 10) {
    
    cout << R << endl;
    return 0;
  } else {
    
    
    cout << R + 100 * (10 - N) << endl;
    return 0;
  }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int &i : A)
    {
        cin >> i;
    }
    int cnt=0;
    int ttl = accumulate(A.begin(), A.end(), 0);
    double x = (double) ttl/(4*M);
    for (int i = 0; i <N; i++)
    {

        if(A[i]>=x ) cnt++;
    }
    if(cnt>=M) cout << "Yes" << endl;
    else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256