akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int N,K;
	cin >> N >> K;
	int noz = 0;
	char mode = '2';
	vector<char> p(N);
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
		if (p[i] == '0' && mode != '0') {
			++noz;
		}
		mode = p[i];
	}

	int res = N;
	if (noz > K) {
		mode = '2';
		int ioz = 0;
		vector<int> count(noz,0);
		for (int i = 0; i < N; ++i) {
			if (p[i] == '1') {
				if (mode == '0') {
					++ioz;
				}
				++count[ioz];
			}
			else {
				++count[ioz];
			}
			mode = p[i];
		}

		mode = '2';
		int noo = 0;
		int noi = 0;
		int nop = 0;
		vector<int> memo(noz,0);
		for (int i = 0; i < N; ++i) {
			if (p[i] == '0') {
				if (mode != '0') {
					if (noo == K) {
						memo[noi] = nop;
						nop -= count[noi];
						++noi;
						--noo;
					}
					++noo;
				}
				++nop;
			}
			else {
				++nop;
			}
			mode = p[i];
		}
		memo[noz-1] = nop;
		res = 0;
		for (int i = 0; i < noz; ++i) {
			res = max(memo[i],res);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		double p = 0;

		for (int i = 1; i < N + 1; i++) {
			int cnt = 0;
			int pt = i;
			while (pt <= K - 1) {
				pt *= 2;
				cnt++;
			}

			p += (double) 1 / N * Math.pow(0.5, cnt);
		}

		System.out.println(p);

	}
}


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

struct Graph {
  int n;
  int time;
  vector<vector<int>> g;
  vector<int> num, low;
  vector<vector<int>> scc;
  stack<int, deque<int>> S;
  vector<bool> inS;

  Graph(int n) : n(n), g(n), num(n, -1), low(n, -1), inS(n) {}

  void addEdge(int u, int v) {
    g[u].push_back(v);
  }
  void dfs(int u) {
    num[u] = low[u] = time++;
    S.push(u);
    inS[u] = true;
    for (auto&& v : g[u]) {
      if (num[v] == -1) {
        dfs(v);
        low[u] = min(low[u], low[v]);
      } else if (inS[v]) {
        low[u] = min(low[u], num[v]);
      }
    }
    if (low[u] == num[u]) {
      scc.push_back({});
      while (true) {
        int v = S.top(); S.pop();
        inS[v] = false;
        scc.back().push_back(v);
        if (u == v) break;
      }
    }
  }
  void stronglyConnectedComponents() {
    for (int i = 0; i < n; ++i) {
      if (num[i] == -1) dfs(i);
    }
  }
};

int main() {
  int n, m; cin >> n >> m;
  Graph g(n);
  while (m--) {
    int s, t; cin >> s >> t;
    g.addEdge(s, t);
  }

  g.stronglyConnectedComponents();
  cout << (g.scc.size() != n) << endl;
  return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  if ((s[a] == '-') && (s.size() == (a + b + 1))){
    for (int i = 0; i < s.size(); i++){
      if (i == a){
        continue;
      }
      if (s[i] == '-'){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }
  else {
    cout << "No" << endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    REP(i,n) cin >> a[i] >> b[i] >> c[i];

    vector<vector<int>> dp(n+1,vector<int>(3));

    REP(i,n) REP(j,3) {
        int x,y;
        switch (j)
        {
        case 0:
            x = max(dp[i][1],dp[i][2]);
            y = a[i];
            break;
        case 1:
            x = max(dp[i][0],dp[i][2]);
            y = b[i];
            break;
        case 2:
            x = max(dp[i][0],dp[i][1]);
            y = c[i];
            break;
        default:
            x = 0;
            y = 0;
            break;
        }
        dp[i+1][j] = x + y;
    }

    int ans = 0;
    REP(i,3) ans = max(ans,dp[n][i]);
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 6912
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
d = [0,0,0,0]
d[a1-1] += 1
d[b1-1] += 1
d[a2-1] += 1
d[b2-1] += 1
d[a3-1] += 1
d[b3-1] += 1
r = sum([1 for x in d if x%2==1])
print("YES" if r == 0 or r == 2 else "NO")

Measured memory_bytes: 3064
#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
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;

int main(){
    int a,b;
    cin >> a >> b;
    int ans=max(a+b,a-b);
    ans=max(ans,a*b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long L[87];
    cin>>n;
    L[0]=2;
    L[1]=1;
    for(int i=2;i<=n;i++)
        L[i]=L[i-1]+L[i-2];
    cout<<L[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

int main() {
    int N, Y;
    cin >> N >> Y;

    int total = 0;

    for (int i = 0; i < N + 1; i++) {
        for (int j = 0; j < N + 1 -i; j++) {
            for (int k = 0; k < N + 1 -i -j; k++) {
                if ((10000 * i + 5000 * j + 1000 * k) == Y) {
                    if ((i + j + k) == N) {
                        cout << i << " " << j << " " << k << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>


using namespace std;
#define RENT 100000

int main(){
  int n;
  int cnt=0;

  float a, b, c, d, e, f;
  while(cin >> a >> b >> c >> d >> e >> f){

    float detA = a*e - b*d;
    float x = (e*c -b*f)/(detA);
    float y = (-(d*c) + a*f)/(detA);

    if(x==0)x=0;
    if(y==0)y=0;

    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
}

Measured memory_bytes: 1280
def main():
    # 解説AC
    N, K = (int(i) for i in input().split())
    S = input()
    ans = 0  # 初期スコア
    for i in range(N-1):
        if S[i] == S[i+1]:
            ans += 1
    # 1回の操作で+2できる、最大スコアはN-1なのでminを取る
    print(min(ans + 2*K, N-1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???

str = input()
op_num = int( input() )
for i in range(op_num):
	op = input().split()
	a = int(op[1])
	b = int(op[2])
	if op[0]=="replace":
		# str = str.replace(str[ a:b+1 ], op[3])
		str = str[0:a] + op[3] + str[b+1:]
	elif op[0]=="reverse":
		# str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
		str = str[:a] + str[a:b+1][::-1] + str[b+1:]
	# elif op[0]=="print":
	else:
		print(str[a:b+1])

Measured memory_bytes: 7684
x,k,d = [int(x) for x in input().split()]
t = abs(int(x/d))
if x < 0:
    d = -d
if t >= k:
    print(abs(x-d*k))
elif t == 0:
    if k % 2 == 0:
        print(abs(x))
    else:
        print(min(abs(x-d),abs(x+d)))
elif t < k:
    if abs(x-d*t) < abs(x-d*t-d):
        if (k-t)%2==0:
            print(abs(x-d*t))
        else:
            print(min(abs(x-d*t+d),abs(x-d*t-d)))
    elif abs(x-d*t) == abs(x-d*t-d):
        print(abs(x-d*t))
    else:
        if (k-t-1)%2==0:
            print(abs(x-d*t-d))
        else:
            print(min(abs(x-d*t),abs(x-d*t-2*d)))


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

int main() {
    int n, c;
    cin >> n >> c;
    vector<vector<int>> color(c, vector<int>(c));
    vector<vector<int>> grid(n, vector<int>(n));
    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            cin >> color[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> grid[i][j];
            grid[i][j]--;
        }
    }

    vector<int> cost_zero(c), cost_one(c), cost_two(c);

    for (int i = 0; i < c; i++) {
        int cost_i = 0;
        for (int ii = 0; ii < n; ii++) {
            for (int jj = (3 - (ii % 3)) % 3; jj < n; jj += 3) {
                cost_i += color[grid[ii][jj]][i];
            }
        }
        cost_zero[i] = cost_i;
        int cost_j = 0;
        for (int ii = 0; ii < n; ii++) {
            for (int jj = (4 - (ii % 3)) % 3; jj < n; jj += 3) {
                cost_j += color[grid[ii][jj]][i];
            }
        }
        cost_one[i] = cost_j;
        int cost_k = 0;
        for (int ii = 0; ii < n; ii++) {
            for (int jj = (5 - (ii % 3)) % 3; jj < n; jj += 3) {
                cost_k += color[grid[ii][jj]][i];
            }
        }
        cost_two[i] = cost_k;
    }

    int ans = 500 * 500 * 1000 + 1000000;
    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            if (j == i) continue;
            for (int k = 0; k < c; k++) {
                if (k == i || k == j) continue;
                ans = min(ans, cost_zero[i] + cost_one[j] + cost_two[k]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
#include<cstdio>
int abs(int x) {return x>0?x:-x;}
int min(int x,int y) {return x<y?x:y;}
int d(int x,int y)
{
	if(x%2) return min(abs(y-x/2),abs(y-x/2-1));
	else return abs(y-x/2);
}
int a[100005];
int main()
{
	int n,x=-1,p;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>x) x=a[i],p=i;
	}
	int y,mn=x+1;
	for(int i=1;i<=n;i++)
	if(i!=p&&d(x,a[i])<mn) y=a[i],mn=d(x,a[i]);
	printf("%d %d\n",x,y);
	return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;




int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n, k;
	cin >> n >> k;
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		int hc;
		cin >> hc;
		if (hc >= k)
			res++;
	}
	cout << res;
	return 0;
}

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

long double dp[3010][3010];


int main(){
    int N; cin >> N;
    long double p[3010];
    for(int i=0; i<N; i++){
        cin >> p[i+1];
    }
    dp[0][0]=1.0;
    for(int i=1; i<=N; i++){
        for(int j=0; j<=i;j++){
            if(j==0){
                dp[i][j] = dp[i-1][j]*(1-p[i]);
            }
            else{
                dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
            }
        }
    }
    long double ans=0.0;
    for(int k=N; k>N/2; k--){
        ans +=dp[N][k];
    }
    cout << fixed << setprecision(10) << ans << endl;

}

Measured memory_bytes: 139776
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;
static const double PI = 3.141592653589793;

long long powmod(long long x, long long n, long long mod = 0) {
  if (mod == 0) {
      long long res=1;
    while (n > 0) {
      if (n%2 == 1) {
        res = ( res*x );
      }
      x = (x*x);
      n /= 2;
    }
    return res;
  }

  long long res=1;
  while (n > 0) {
    if (n%2 == 1) {
      res = ( res*x ) % mod;
    }
    x = (x*x) % mod;
    n /= 2;
  }
  return res;
}

long long modinverse(long long x, long long mod) {
  // mod must be prime number.
  return powmod(x, mod-2, mod);
}

long long cutBranch(int n) {
  //深さn の完全に分岐の頂点数
  long long ans=0;
  long long res=1;
  for (int i=0; i<=n; i++) {
    ans += res;
    res *= 2;
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<int> A(n+1);
  for (int i=0; i<=n; i++) {
    cin >> A.at(i);
  }

  if (n==0) {
    int b=1;
    if (A.at(0) != 1) b=-1;
    cout << b << endl;
    return 0;
  }

  if (A.at(0) != 0) {
    cout << -1 << endl;
    return 0;
  }

  vector<long long> gyakurui(n+1,0);
  for (int i=n-1; i>=0; i--) {
    gyakurui.at(i) = gyakurui.at(i+1) + A.at(i+1);
  }

  long long ans=1;
  long long prevNode=1;
  for (int i=1; i<=n; i++) {
    long long leaf = A.at(i);
    long long node = min(prevNode*2-leaf, gyakurui.at(i));
    if (node < 0) {
      cout << -1 << endl;
      return 0;
    }
    ans += node + leaf;
    prevNode = node;
  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 4268
#include<stdio.h>
#include<stdlib.h>
#define INF 1000000001
typedef struct vertice
{
  int cost;
  int status;
  int numOfAdj;
  int *adjList;
  int *costList;
} ver;
ver *v;
int n;//the number of vertices
void init();
void setArray(int);
void dijkstra(void);
int main(void)
{
  int i,j;//counter
  int key;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++)
    {
      scanf("%d",&key);
      scanf("%d",&v[key].numOfAdj);
      setArray(key);
      for(j=0;j<v[key].numOfAdj;j++) scanf("%d%d",&v[key].adjList[j],&v[key].costList[j]);
    }
  dijkstra();
  free(v);
  return 0;
}
void init(void)
{
  int i;//counter
  v=(ver*)malloc(sizeof(ver)*n);
  for(i=0;i<n;i++)
    {
      v[i].numOfAdj=0;
      v[i].status=0;
      v[i].cost=INF;
    }
}
void setArray(int key)
{
  v[key].adjList=(int*)malloc(sizeof(int)*v[key].numOfAdj);
  v[key].costList=(int*)malloc(sizeof(int)*v[key].numOfAdj);
}
void dijkstra(void)
{
  int i;//count
  int current=0;
  int viewing;
  int next;
  int minCost;
  v[0].cost=0;
  for(;;)
    {
      v[current].status=1;
      minCost=INF;
      for(i=0;i<v[current].numOfAdj;i++)
	{
	  viewing=v[current].adjList[i];
	  if(v[viewing].status==0)
	    {
	      if(v[current].cost+v[current].costList[i]<v[viewing].cost)
		{
     		  v[viewing].cost=v[current].cost+v[current].costList[i];
		  //printf("v[%d].cost=%d\n",viewing,v[viewing].cost);
		}
	    }
	}
      for(viewing=0;viewing<n;viewing++)
	{
	  if(v[viewing].status==0&&v[viewing].cost<minCost)
	    {
	      minCost=v[viewing].cost;
	      next=viewing;
	    }
	}
      if(minCost==INF) break;
      //printf("next->%d\n",next);
      current=next;
    }
  for(i=0;i<n;i++) printf("%d %d\n",i,v[i].cost);
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main() {
int A[1000001];
A[0]=1;
rep3(i,100000){
    if((is_prime(i))&&(is_prime((i+1)/2))){
        A[i]=A[i-1]+1;
    }
    else{
        A[i]=A[i-1];
    }

}
int Q;
cin>>Q;
int ans[Q];
rep(i,Q){
    int l,r;
    cin>>l>>r;
    ans[i]=A[r]-A[l-1];

}
rep(i,Q){
    cout<<ans[i]<<endl;
}
    
return 0;
}

Measured memory_bytes: 3200
A, B, C, D, E, F = map(int,input().split())
T = list(range(31))
ret = [100*A, 0]
for a in T:
  for b in T:
    SMax = min((A*a+B*b)*E,F-100*(A*a+B*b))
    for d in range(SMax//D+1):
      c = ( SMax - d*D ) // C
      S = C*c+D*d
      W = 100*(A*a+B*b) + S
      if (ret[1] * W) < (ret[0] * S):
        ret = [W,S]
print(*ret)

Measured memory_bytes: 3064
/*
lakshaygpt28
Lakshay Gupta
*/

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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

int main() {
    fast_io();
    ll n, a, b;
    cin >> n >> a >> b;
    if (n * a < b) {
        cout << n * a << "\n";
    } else {
        cout << b << "\n";
    }
    return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    vector<int> abc;
    for(int i=0;i<3;i++) {
        int atmp;
        cin >> atmp;
        abc.push_back(atmp);
    }
    sort(abc.begin(), abc.end());
    if(abc.at(0)==5&&abc.at(1)==5&&abc.at(2)==7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,m;
	int h,w;
	bool ok;
	int s = 1;
	int siro = 0;
	cin >> h >> w;
	char st[h+2][w+2];
	int sta[h+2][w+2];
	for (n = 1; n < h+1;n++){
		for (m = 1; m < w+1;m++){
			cin >> st[n][m];
			if (st[n][m] == '.'){
				sta[n][m] = 0;
				siro++;
			}
			else{
				sta[n][m] = -1;
			}
		}
	}
	for (n = 0; n < h+2; n++){
		sta[n][0] = -1;
		sta[n][w+1] = -1;
	}
	for (m = 0; m < w + 2; m++){
		sta[0][m] = -1;
		sta[h+1][m] = -1;
	}
	sta[1][1] = 1;
	while (sta[h][w] == 0){
		ok = true;
		for (n = 1; n < h + 1; n++){
			for (m = 1; m < w + 1; m++){
				if (sta[n][m] == 0 && (sta[n - 1][m]>0 || sta[n][m - 1]>0 || sta[n + 1][m] >0 || sta[n][m + 1] > 0)){
					sta[n][m] = -2;
					ok = false;
				}
			}
		}
		for (n = 1; n < h + 1; n++){
			for (m = 1; m < w+1; m++){
				if (sta[n][m] == -2){
					sta[n][m] = 2;
				}
			}
		}
		if (ok){
			s = siro + 1;
			break;
		}
		s++;
	}
	cout << siro-s << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

N = int(sys.stdin.readline().strip())

a_list = [None for _ in range(N)]
b_list = [None for _ in range(N)]
c_list = [None for _ in range(N)]

for i in range(N):
    a, b, c = list(map(int, sys.stdin.readline().strip().split(" ")))
    a_list[i] = a
    b_list[i] = b
    c_list[i] = c
    
tmp = [a_list, b_list, c_list]
happy = [[0 for _ in range(3)] for __ in range(N)]

happy[0][0] = a_list[0]
happy[0][1] = b_list[0]
happy[0][2] = c_list[0]

for i in range(1, N):
    for j in range(3):
        #今日なにするか
        max_h = 0
        for k in range(3):
            #昨日なにしてたか
            if k == j:
                continue
            #print(i, j, k)
            #print(tmp)
            max_h = max(max_h, happy[i-1][k] + tmp[j][i])
        happy[i][j] = max_h

#print(happy)
print(max(happy[N-1]))
    

"""

happy = [0 for _ in range(N)]
select = [None for _ in range(N)]

ind = np.argmax([a_list[0], b_list[0], c_list[0]])
select[0] = [0, 1, 2][ind]
happy[0] = [a_list[0], b_list[0], c_list[0]][ind]

if N == 1:
    print(happy[0])
    sys.exit()

ind = np.argmax([a_list[0] + b_list[1], a_list[0] + c_list[1], b_list[0] + a_list[1], b_list[0] + c_list[1], c_list[0] + a_list[1], c_list[0] + b_list[1]])
happy[1] = [a_list[0] + b_list[1], a_list[0] + c_list[1], b_list[0] + a_list[1], b_list[0] + c_list[1], c_list[0] + a_list[1], c_list[0] + b_list[1]][ind]
select[1] = [1, 2, 0, 2, 0, 1][ind]

if N == 2:
    print(happy[1])
    sys.exit()

for i in range(2, N):
    max_h = 0
    for j in range(3):
        for k in range(3):
            if k == j:
                continue
            if j == select[i-2]:
                continue
            if max_h < tmp[k][i] + tmp[j][i-1] + happy[i-2]:
                max_h = tmp[k][i] + tmp[j][i-1] + happy[i-2]
                select[i] = k
            #print(tmp[k][i-1], tmp[j][i-2])
    happy[i] = max_h

print(happy[N-1])
"""
    


Measured memory_bytes: 45112
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

typedef long long ll;

int main()
{
    ll N, M, mod=1000000007;
    cin >> N >> M;
    if(abs(N-M)>=2){
        cout << 0;
    }else{
        ll tmp=min(N, M);
        ll ans=1;
        for(int i=1; i<=tmp; i++){
            ans*=i;
            ans%=mod;
        }
        ans*=ans;
        ans%=mod;
        if(N==M) ans*=2;
        else ans*=max(N,M);
        ans%=mod;
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 888
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!(usize; n);

    let mut max1 = vec![0; n+1];
    let mut max2 = vec![0; n+1];

    for i in 0..n {
        max1[i+1] = max!(a[i], max1[i]);
    }
    for i in (0..n).rev() {
        max2[i] = max!(a[i], max2[i+1]);
    }

    for i in 0..n {
        println!("{}", max!(max1[i], max2[i+1]));
    }
}


Measured memory_bytes: 15996
#include<iostream>
using namespace std;
int main(){
  int n; cin >> n;
  int a[10001];

  int count = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];

    while(a[i] % 2 == 0){
      a[i] /= 2;
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int MAX_N = 100;
int N;
int A[MAX_N];
int D;
int X;
int main(){
scanf("%d", &N);
scanf("%d%d", &D, &X);
for(int i = 0; i < N; ++i){
scanf("%d", A + i);
}
int ans = X;
for(int i = 0; i < N; ++i){
int tmp = (D - 1) / A[i] + 1;
ans += tmp;
}
printf("%d\n", ans);
return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll n,z,w;
	cin >> n >> z >> w;

	ll a[n];
	rep(i,n) cin >> a[i];

	// xはabs(a[n-1] - w)とするかabs(a[n-1] - a[n-2])とするかをコントロール可能
	// 仮にxが2枚以上残し、かつ上記2手より良い手を望んだとしても、
	// yはスコアを最小化すべく、1枚残してabs(a[n-1] - a[n-2])とできるため、
	// そのような手は実現されない

	if(n == 1) cout << abs(a[n-1] - w) << endl;
	else cout << max(abs(a[n-1] - w),abs(a[n-1] - a[n-2])) << endl;	
}

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

using namespace std;

stack<int> s;
int f(int n){
  if(n){
    for(int i=n;i>0;--i){
      if(s.empty()||s.top()>=i){
	s.push(i);f(n-i);s.pop();
      }
    }
  }
  else{
    if(!s.empty()){
      stack<int> t(s);
      int a[31];
      int b=t.size();
      for(int i=1;i<=b;++i){
	a[b-i]=t.top();t.pop();
      }
      cout<<a[0];
      for(int i=1;i<b;++i) cout<<' '<<a[i];
      cout<<endl;
    }
  }
  return 0;
}
int main(){
  int n;
  while(cin>>n,n){
    f(n);
  }
  return 0;
}

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

ll solve(ll a[], ll i, ll k, ll n, vector<ll>& dp){
	if(i==(n-1)) return 0;
	if(i>=n) return INT_MAX;
	
	if(dp[i] != -1)
		return dp[i];
		
	ll mn=LONG_MAX;
	
	for(ll step=1; step<=k; step++){
		if(i+step < n)
			mn=min(mn, abs(a[i]-a[i+step]) + solve(a, i+step, k, n, dp) );
	}
	
	return dp[i]=mn;
}

void solve() {
	ll n, k;
	cin >> n >> k;
	
	ll h[n]={};
	
	vector<ll> dp(n+1, -1);
	
	for(ll i=0; i<n; i++)
		cin >> h[i];
		
	cout << solve(h, 0, k, n, dp) << "\n";
}

int main(){
	solve();
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define gc getchar()
#define ll long long
#define int long long
#define ri register int
#define rc register char
#define rb register bool
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
using namespace std;
    
const int N=200000+10,inf=1e9;
int n,q,pre,nw,tag[N<<2];
ll tr1[N<<2],tr2[N<<2];

il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}
il void pushdown(int nw) 
{
    if (!tag[nw])return;
    tag[ls(nw)] += tag[nw];
    tag[rs(nw)] += tag[nw];
    tr1[ls(nw)] += tag[nw];
    tr2[ls(nw)] += tag[nw];
    tr1[rs(nw)] += tag[nw];
    tr2[rs(nw)] += tag[nw];
    tag[nw] = 0;
}
void modify(ri nw,ri l,ri r,ri to,ll dat)
{
	if(l==r){tr1[nw]=min(tr1[nw],dat-to),tr2[nw]=min(tr2[nw],dat+to);return;}
	pushdown(nw);ri mid=(l+r)>>1;to<=mid?modify(nw<<1,l,mid,to,dat):modify(nw<<1|1,mid+1,r,to,dat);
	tr1[nw]=min(tr1[nw<<1],tr1[nw<<1|1]);tr2[nw]=min(tr2[nw<<1],tr2[nw<<1|1]);
}
ll query1(ri nw,ri l,ri r,ri to_l,ri to_r)
{
	if(to_l<=l && r<=to_r)return tr1[nw];
	pushdown(nw);ri mid=(l+r)>>1;ll ret=inf;
	if(to_l<=mid)ret=query1(nw<<1,l,mid,to_l,to_r);
	if(mid<to_r)ret=min(ret,query1(nw<<1|1,mid+1,r,to_l,to_r));
	return ret;
}
ll query2(int rl, int rr, int l, int r, int nw) 
{
    if (rl == l && rr == r)return (tr2[nw]);
    int mid = (l + r) >> 1;pushdown(nw);
    if (rl > mid)return (query2(rl, rr, mid + 1, r, rs(nw)));
    if (rr <= mid)return (query2(rl, rr, l, mid, ls(nw)));
    return (min(query2(rl, mid, l, mid, ls(nw)), query2(mid + 1, rr, mid + 1, r, rs(nw))));
}
ll query(int l, int r, int nw) 
{
    if (l == r)return (tr1[nw] + l);
    int mid = (l + r) >> 1;pushdown(nw);return (min(query(l, mid, ls(nw)), query(mid + 1, r, rs(nw))));
}
signed main() 
{
//	freopen("2558.in","r",stdin);
    n = read(), q = read(), pre = read();memset(tr1, 63, sizeof(tr1));memset(tr2, 63, sizeof(tr2));modify(1,1,n,read(),0);
    while(q--)
	{
        int nw=read();ll dat=min(query1(1,1,n,1,nw)+nw,query2(nw,n,1,n,1)-nw);
        tag[1]+=abs(nw-pre);tr1[1]+=abs(nw-pre);tr2[1]+=abs(nw-pre);modify(1,1,n,pre,dat);
        pre=nw;
    }
    printf("%lld\n",query(1,n,1));
    return (0);
}

Measured memory_bytes: 18816
#include<iostream>
#include<cstdio>
using namespace std;
const int SIZE = 200000 + 10, mod = 1000000007;
const int p = 500000004;
long long n, A[SIZE], s, t, ans;
int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; ++ i) scanf("%lld", &A[i]);
	s = t = 0;
	for(int i = 0; i < n; ++ i)
	{
		s = (s + A[i]) % mod;
		t = (t + A[i] * A[i]) % mod;
	}
	s = s * s % mod;
	ans = (s - t + mod) % mod;
	printf("%d\n", (long long)(ans * p) % mod);
	return 0;
}

Measured memory_bytes: 5312
import sys

def resolve():
    N, M = map(int, input().split())
    A = []
    for i in range(N):
        A.append(input())
    B = []
    for i in range(M):
        B.append(input())

    for i in range(N - M + 1):
        for j in range(N - M + 1):
            for k in range(M):
                if B[k] != A[i+k][j:j+M]:
                    break
                if k == M-1:
                    print('Yes')
                    return

    print('No')

if __name__ == "__main__":
    resolve()


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

int main() {
  int N, K, sum; 
  cin >> N >> K;
  sum = 1;
  
  for (int i = 0; i < N; i++) {
    if (sum <= K) 
      sum *= 2;
    else
      sum += K;
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118
"""
import sys



def solve(data):
    size = len(data[0])
    data.insert(0, ['0' for _ in range(size)])
    data.insert(len(data), ['0' for _ in range(size)])

    processing_area = []
    area_id = 0
    for y in range(1, len(data)-1):
        for x in range(1, len(data[0])):
            # print('y:{}, x:{}'.format(y, x))
            mark = data[y][x]
            data[y][x] = '0'
            if mark != '0':
                area_id += 1
                processing_area.append((y, x))

                while processing_area:
                    yy, xx = processing_area.pop()
                    if data[yy-1][xx] == mark: #  ???
                        data[yy-1][xx] = '0'
                        processing_area.append((yy-1, xx))
                    if data[yy+1][xx] == mark: #  ???
                        data[yy+1][xx] = '0'
                        processing_area.append((yy+1, xx))
                    if data[yy][xx-1] == mark: #  ???
                        data[yy][xx-1] = '0'
                        processing_area.append((yy, xx-1))
                    if data[yy][xx+1] == mark: #  ???
                        data[yy][xx+1] = '0'
                        processing_area.append((yy, xx+1))
                mark = '0'
    return area_id



def main(args):
    # data = []
    # data.append(['0', '#', '#', '#', '#', '*', '*', '*', '*', '*', '@', '0'])
    # data.append(['0', '@', '#', '@', '@', '@', '@', '#', '*', '#', '*', '0'])
    # data.append(['0', '@', '#', '#', '*', '*', '*', '@', '@', '@', '*', '0'])
    # data.append(['0', '#', '*', '*', '*', '*', '#', '*', '@', '*', '*', '0'])
    # data.append(['0', '#', '#', '@', '*', '#', '@', '@', '*', '#', '#', '0'])
    # data.append(['0', '*', '@', '@', '@', '@', '*', '@', '@', '@', '#', '0'])
    # data.append(['0', '*', '*', '*', '#', '@', '*', '@', '#', '#', '*', '0'])
    # data.append(['0', '*', '@', '@', '@', '*', '@', '@', '#', '#', '@', '0'])
    # data.append(['0', '*', '@', '*', '#', '*', '@', '#', '#', '*', '*', '0'])
    # data.append(['0', '@', '*', '*', '*', '*', '#', '@', '@', '#', '@', '0'])

    while True:
        h, w = [int(x) for x in input().split(' ')]
        if h == 0 and w == 0:
            break
        data = []
        for _ in range(h):
            temp = list(input())
            temp.insert(0, '0')
            temp.append('0')
            data.append(temp)

        result = solve(data)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 8048
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define N 200010
using namespace std;
long long lz1[N * 4], lz2[N * 4];
int a[N];
void Push_down(int node, int l, int r)
{
	if(!lz1[node] && !lz2[node]) return ;
	long long d = (lz2[node] - lz1[node]) / (r - l);
	int mid = (l + r) / 2;
	lz1[node << 1] += lz1[node];
	lz2[node << 1] += lz1[node] + d * (mid - l);
	lz1[node << 1 | 1] += lz1[node] + d * (mid - l + 1);
	lz2[node << 1 | 1] += lz2[node];
	lz1[node] = lz2[node] = 0;
}
void update(int node, int l, int r, int left, int right, int d1, int d2)
{
	if(l >= left && r <= right)
	{
		long long d = (d2 - d1) / (right - left);
		long long t1 = 1LL * d1 + d * (l - left), t2 = 1LL * d1 + d * (r - left);
		lz1[node] += t1;
		lz2[node] += t2;
		return ;
	}
	int mid = (l + r) / 2;
	Push_down(node, l, r);
	if(left <= mid) update(node << 1, l, mid, left, right, d1, d2);
	if(right > mid) update(node << 1 | 1, mid + 1, r, left, right, d1, d2);
}
long long query(int node, int l, int r, int k)
{
    if(l == r)
        return lz1[node];
    int mid = (l + r) / 2;
    Push_down(node, l, r);
    if(mid >=k)
        return query(node << 1, l, mid, k);
    else
        return query(node << 1 | 1, mid + 1, r, k);
}
int main()
{
	int n, m, i;
	long long t = 0;
	scanf("%d%d", &n, &m);
	for(i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(i = 2; i <= n; ++i)
	{
		if(a[i - 1] < a[i])
		{
		    t += a[i] - a[i - 1];
		    if(a[i] == a[i - 1] + 1) continue;
			update(1, 1, m * 2, a[i - 1] + 1, a[i], 0, a[i] - a[i - 1] - 1);
		}else
		{
		    t += a[i] - a[i - 1] + m;
		    if(a[i] + m == a[i - 1] + 1) continue;
			update(1, 1, m * 2, a[i - 1] + 1, a[i] + m, 0, a[i] + m - a[i - 1] - 1);
		}
	}
	long long maxn = 0;
	for(i = 1; i <= m; ++i) maxn = max(maxn, query(1, 1, 2 * m, i) + query(1, 1, 2 * m, i + m));
    printf("%lld\n", t - maxn);
	return 0;
}


Measured memory_bytes: 12160
import java.util.Scanner;

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

    int[] A = new int[5];
    for(int i=0; i<5; i++){
      A[i] = scanner.nextInt();
    }

    int ans = 0;

    for(int i=0; i<5; i++){
        if(A[i] == 0){
            ans = i + 1;
        }
      }
    System.out.println(ans);
    scanner.close();
    return;

  }
}

Measured memory_bytes: 35728
function main(input) {
  const s = input.trim();
  const dp = [];
  dp[0] = Array(13).fill(0);
  dp[0][0] = 1;
  for (let i = 0; i < s.length; i++) {
    const char = s[i];
    for (let j = 0; j < 10; j++) {
      if (char !== "?" && char !== "" + j) continue;
      for (let k = 0; k < 13; k++) {
        if (!dp[i+1]) {
          dp[i+1] = Array(13).fill(0);
        }
        dp[i+1][(k*10 + j)%13] += dp[i][k];
      }
    }
    for (j = 0; j < 13; j++) {
      dp[i+1][j] %= 10**9 + 7;
    }
  }
  const result = dp[s.length][5];
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 50992
#include<stdio.h>

int main()
{

    int a,b,x,c,v;
    scanf("%d %d",&a,&b);
    if(a >= -100 && b <= 100){
    x=a+b;
    c=a-b;
    v=a*b;
    if(x >= c && x >= v) {
        printf("%d",x);
    }
    else if(c>=x && c>=v) {
        printf("%d",c);
    }
    else
        printf("%d",v);
}
}


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

int main() {
	int n;
	int cnt=0;
	cin>>n;
	for(int i=0;i*7<=n;i++){
		for(int j=0;j*4<=n;j++){
			if((i*7+4*j)==n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main
{
    static class Process {
        private String name;
        private int time;

        public Process(String name, int time)
        {
            this.name = name;
            this.time = time;
        }

        public String getName()
        {
            return this.name;
        }
        public void setName(String name)
        {
            this.name = name;
        }
        public int getTime()
        {
            return this.time;
        }
        public void setTime(int time)
        {
            this.time = time;
        }
    }

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        Queue<Process> queue = new LinkedList<Process>();
        int n = scan.nextInt();
        int q = scan.nextInt();

        Process[] p = new Process[n];

        for (int i = 0; i < n; i++)
        {
            String name = scan.next();
            int time = scan.nextInt();
            p[i] = new Process(name, time);
            queue.offer(p[i]);
        }

        List<Process> finishProcesses = new ArrayList<Main.Process>();

        int currentTime = 0;
        while (queue.size() > 0) {
            Process current = queue.poll();
            if (current.getTime() > q) {
                current.setTime(current.getTime() - q);
                queue.offer(current);
                currentTime += q;
            }
            else {
                finishProcesses.add(new Process(current.name, currentTime + current.getTime()));
                currentTime += current.getTime();
            }
        }

        for (Process process : finishProcesses)
        {
            System.out.println(process.name + " " + process.time);
        }

        scan.close();
    }

}

Measured memory_bytes: 68504
n,a,b=map(int,input().split())
res=[]
for i in range(1,n+1,1):
	i_x=0
	x=i
	while True:
		if x//10!=0:
			i_x+=x%10
			x=x//10
		else:
			i_x+=x
			break
	if a<=i_x<=b:
		res.append(i)
print(sum(res))

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a>=13) cout << b << endl;
    else if(a>=6) cout << b / 2 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
s = input()
tmp = s
flag=0
while tmp != '':
  if tmp[-7::] =='dreamer':
    tmp = tmp[0:-7]
  elif tmp[-6::] == 'eraser':
    tmp = tmp[0:-6]
  elif tmp[-5::] == 'dream' or tmp[-5::] == 'erase':
    tmp = tmp[0:-5]
  else:
    flag=1
    break
    
if flag ==0:
  print('YES')
else:
  print('NO')


Measured memory_bytes: 3316
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define PAUSE \
    int t;    \
    cin >> t
#define int long long
#define vi vector<long long>
#define mapii map<long long, int>
#define mapci map<char, int>
#define append(x) push_back(x)
#define tcase          \
    long long t;       \
    scanf("%lld", &t); \
    while (t--)
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int>>
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
// #define debug(x, y) cout << "case #" << x << " at itr #" << y << endl
#define debug(x) cout << "case #" << x << endl
#define ff first
#define ss second
#define range(ini, x) for (int itr = ini; itr < x; itr++)
#define takearr(x)    \
    for (auto &i : x) \
    cin >> i
#define print(x)     \
    for (auto i : x) \
        cout << i << " ";
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define foreach(i, x) for (auto i : x)
#define setbitcount __builtin_popcount
// #define range(ini, x, step) for( int itr = ini, i < x; itr += step )
using namespace std;
// using namespace __gnu_pbds;
// template < class type > using oset=tree<type, null_type,less<type>, rb_tree_tag,tree_order_statistics_node_update>;
const int mmx = 1e5 + 1;
const int mnx = 1e4 + 1;
const int mmod = 1e9 + 7;

int dp[mmx][101];

int n;

int solve(vi &wtarr, vi &valarr, int weight, int index)
{

    if (index == n)
    {
        return 0;
    }

    if (dp[weight][index] != -1)
    {
        return dp[weight][index];
    }

    if (weight >= wtarr[index])
    {
        dp[weight][index] = max(valarr[index] + solve(wtarr, valarr, weight - wtarr[index], index + 1),
                                solve(wtarr, valarr, weight, index + 1));
    }
    else
    {
        dp[weight][index] = solve(wtarr, valarr, weight, index + 1);
    }

    return dp[weight][index];
}

signed main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int N, W;

    cin >> N >> W;

    vi wtarr(N), valarr(N);

    memset(dp, -1, sizeof dp);

    n = N;

    for0(i, N)
    {
        cin >> wtarr[i] >> valarr[i];
    }

    cout << solve(wtarr, valarr, W, 0) << endl;

    return 0;
}


Measured memory_bytes: 82516
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

func (p *problem) solve() {
	n := p.NextInt()
	d := p.NextInts()
	c := n / 2

	sort.Ints(d)
	p.PrintInt(d[c] - d[c-1])
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N;
    cin >> N;
    vector<ll> ps(N, 0);
    for (auto &&i: boost::irange(0LL, N)) {
        ll p;
        cin >> p;
        p--;
        ps.at(i) = p;
    }
    vector<bool> bs(N, false);
    for (auto &&i: boost::irange(0LL, N)) {
        bs.at(i) = ps.at(i) == i ? true : false;
    }
    ll count{0};
    for (auto &&i: boost::irange(0LL, N - 1)) {
        if (bs.at(i) == true && bs.at(i + 1) == true) {
            bs.at(i) = false;
            bs.at(i+1) = false;
            count++;
        } else if (bs.at(i) == true){
            bs.at(i) = false;
            count++;
        }
    }
    if (bs.at(N-1) == true)count++;
    cout << count;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
    {
        static void Main(string[] args)
        {
            //s>t>s>t
            var Array = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int sx = Array[0];
            int sy = Array[1];
            int tx = Array[2];
            int ty = Array[3];

            //U D L R で示す
            //sx<tx sy<tyなので必ず右上にいる
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < tx - sx; i++)
                sb.Append("R");
            for (int i = 0; i < ty - sy; i++)
                sb.Append("U");
            for (int i = 0; i < tx - sx; i++)
                sb.Append("L");
            for (int i = 0; i < ty - sy; i++)
                sb.Append("D");
            //一段下げる
            sb.Append("D");
            for (int i = 0; i < tx - sx + 1; i++)
                sb.Append("R");
            for (int i = 0; i < ty - sy + 1; i++)
                sb.Append("U");
            //下げた分戻す
            sb.Append("LU");
            for (int i = 0; i < tx - sx + 1; i++)
                sb.Append("L");
            for (int i = 0; i < ty - sy + 1; i++)
                sb.Append("D");
            sb.Append("R");

            Console.WriteLine(sb);

        }
    }

Measured memory_bytes: 11348
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=sc.nextInt();
		}
		int count=0;
		Arrays.sort(arr);
	   for(int i=0;i<n-2;i++)
	   {
		   for(int j=i+1;j<n-1;j++)
		   {
			   if(arr[i]==arr[j])
			   {
				   continue;
			   }
			   else
			   {
				   for(int k=j+1;k<n;k++)
				   {
					   if(arr[i]==arr[k]||arr[j]==arr[k])
					   {
						   continue;
					   }
					   else
					   {
						   if(arr[i]+arr[j]>arr[k])
						   {
							   count++;
						   }
					   }
				   }
			   }
		   }
	   }
		System.out.println(count);
	}

}

Measured memory_bytes: 36604