akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}
long long power(int a,int b) {
  long long res = 1;
  REP(i,b) res *=a;
  return res;
}

int main(void) {
  int n;cin>>n;
  int a = log10(n);
  ll res=0;
  for(int j=0;j<a;j+=2) {
    res+=((power(10,j+1)-1)-power(10,j)+1);
  }
  if(a%2==0) {
    res+=(n-power(10,a)+1);
  }
  pr(res);
  return 0;
}


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

int main() {

	ll n, d; cin >> n >> d;
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ll x, y; cin >> x >> y;
		if (x * x + y * y <= d * d) ans++;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    cout << pow(n, 3) << ln;
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	string S;
	int m;
	char x;
	while (cin >> S) {
		if (S == "-") {
			break;
		}
		cin >> m;
		vi h(m);
		for (int i = 0; i < m; i++) {
			cin >> h[i];
			for (int j = 0; j < h[i]; j++) {
				x = S[0];
				for (int k = 0; k < S.size() - 1; k++) {
					S[k] = S[k + 1];
				}
				S[S.size() - 1] = x;
			}
		}
		cout << S << endl;
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#define MAX_M 100
#define INF 1e9
using namespace std;

int dp_cost[MAX_M][MAX_M];
int dp_time[MAX_M][MAX_M];
int m;

void warshall_froyd(){
  for(int k=0;k<m;k++){
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
        dp_cost[i][j] = min(dp_cost[i][j], dp_cost[i][k] + dp_cost[k][j]);
        dp_time[i][j] = min(dp_time[i][j], dp_time[i][k] + dp_time[k][j]);
      }
    }
  }
}

int main(){
  int n;
  
  while(cin >> n >> m){
    if(n == 0 && m == 0) break;
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
        dp_time[i][j] = (i==j ? 0 : INF);
        dp_cost[i][j] = (i==j ? 0 : INF);
      }
    }
    
    for(int i=0;i<n;i++){
      int a,b,cost,time;
      cin >> a >> b >> cost >> time;
      a--;
      b--;
      dp_cost[a][b] = cost; dp_cost[b][a] = cost;
      dp_time[a][b] = time; dp_time[b][a] = time;
    }
    
    warshall_froyd();
    
    int k,p,q,r;
    cin >> k;
    for(int i=0;i<k;i++){
      cin >> p >> q >> r;
      p--; q--;
      cout << (r == 0 ? dp_cost[p][q] : dp_time[p][q]) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
#define n 10

int main(){
  int A[n], i, j, b;

  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }
  for(i = 0 ; i < n-1 ; i++){
    for(j = i+1 ; j < n ; j++){
      if(A[j] > A[i]){
	b = A[i];
	A[i] = A[j];
	A[j] = b;
      }
    }
  }
  for(i = 0 ; i < 3 ; i++){
    printf("%d\n",A[i]);
  }

  return 0;

}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	while(cin>>n,n){
		vi dp(86400);
		int a,b,c,s,t;
		char q;
		rep(i,n){
			cin>>a>>q>>b>>q>>c;
			s=a*3600+b*60+c;
			cin>>a>>q>>b>>q>>c;
			t=a*3600+b*60+c;
			dp[s]++;
			dp[t]--;
		}
		rep(i,86400-1)dp[i+1]+=dp[i];
		int out=0;
		rep(i,86400)out=max(out,dp[i]);
		cout<<out<<endl;
	}
}

Measured memory_bytes: 3404
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int f(int num)
{
    int res = 0;
    while(num>0)
    {
        res += num%10;
        num /= 10;
    }
    return res;
} 

int main() {
	int n; cin >> n;
    cout << (n%f(n)==0?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
nl = [input() for i in range(n)]
m = int(input())
ml = [input() for j in range(m)]

ndict = dict(Counter(nl))
mdict = dict(Counter(ml))

difflist = []

for k1, v1 in ndict.items():
    if k1 in mdict:
        diff = v1 - mdict[k1]
        difflist.append(diff)
    else:
        difflist.append(v1)

if max(difflist) < 0:
    print(0)
else:
    print(max(difflist))


Measured memory_bytes: 3316
#include <stdio.h>

int max2(int, int);
int max3(int, int, int);


int main()
{
  int A, B;
  int s, d, p;
  
  scanf("%d %d", &A, &B);
  
  printf("%d\n", max3(A+B, A-B, A*B));

  return 0;
}


int max2(int a, int b)
{
  return a > b ? a : b;
}

int max3(int a, int b, int c)
{
  return max2(a, max2(b, c));
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var answer = 0;
            for (var i = 1; i <= n; i += 2)
            {
                var count = 0;
                for (var j = 1; j <= i; j++)
                {
                    if (i % j == 0) count++;
                }
                if (count == 8) answer++;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11092
import sys
import math
import bisect


def main():
    n, m = map(int, input().split())
    A = []
    while n:
        A.append(n % m)
        n //= m
    if len(A) == 0:
        A.append(0)
    print(len(A))

if __name__ == "__main__":
    main()


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

int main() {
  int s;
  cin >> s;
  
  int ans = 4;
  while (s > 4 || s == 3) {
    s = (s % 2 == 0) ? s / 2 : s * 3 + 1;
    ++ans;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

using llint = long long;

const int MAXN = 1e2+2;
const int MAXW = 1e5+5;

int n, w;
int weight[MAXN], value[MAXN];
llint dp[MAXN][MAXW];

int main() {
  scanf("%d%d", &n, &w);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", weight+i, value+i);
  }

  dp[0][0] = 0;
  dp[0][weight[0]] = value[0];

  for (int i = 1; i < n; ++i) {
    for (int j = 0; j <= w; ++j) {
      dp[i][j] = dp[i-1][j];
    }
    for (int j = weight[i]; j <= w; ++j) {
      dp[i][j] = max(dp[i][j], dp[i-1][j-weight[i]]+value[i]);
    }
  }

  llint sol = 0;
  for (int i = 0; i <= w; ++i) {
    sol = max(sol, dp[n-1][i]);
  }

  printf("%lld\n", sol);
  return 0;
}




Measured memory_bytes: 77568
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,n,ans=0;
  cin >> a >> b >> c >> n;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if((n-i*a-j*b)%c==0 and (n-i*a-j*b)>=0){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    string S;
    cin >> S;

    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else if (S == "Rainy") cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a = [list(input()) for _ in range(n)]
    b = [list(input()) for _ in range(m)]

    for i in range(n - m + 1):
        for j in range(n - m + 1):
            is_exist = True

            for dx in range(m):
                for dy in range(m):
                    if a[i + dx][j + dy] != b[dx][dy]:
                        is_exist = False
                        break

            if is_exist:
                print('Yes')
                exit()

    print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define rep(i, k) for (i = 0; i < k; i++) 
typedef long long ll;
typedef pair<ll, ll> l_l;
int i, j;

ll b, k, n = 0, z = 0, x, y, p[1000010] = {};
	vector<ll> v,vec;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> b;
		p[b]++;
	}

	for (i = 1; i <= 1000000; i++) {
		if (p[i] == 0)continue;
		else {
			if (p[i] == 1)z++;
			k = i;
			for (j = 1; j * k <= 1000000; j++)p[j * k] = 0;
		}
	}
	cout << z;
	return 0;

}


Measured memory_bytes: 11436
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define pii pair<long long,long long>
#define reset(a,b) memset(a,b,sizeof a)
#define ll long long
#define MOD 1000000009
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define dalam fl<=l && r<=fr
#define kiwo 2*(idx),l,MID
#define tengen 2*idx+1,MID+1,r
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 100003
#define pc(x) putchar_unlocked(x);

long long n,C,x[mx],v[mx],pref[mx],jaw;
priority_queue<pair<ll,ll>>pq;

int main(){
	//freopen("1.in","r",stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>C;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>v[i];
	for(int i=1;i<=n;i++){
		pref[i]=pref[i-1]+v[i];
	}	
	//clockwise dulu
	x[n+1]=C;
	pref[n+1]=pref[n];
	pq.push({0,n+1});
	for(int i=1;i<=n;i++){
		pq.push({pref[n]-pref[i-1]-C+x[i],i});
	}
	for(int i=0;i<=n;i++){
		while(!pq.empty() && pq.top().s<=i)
			pq.pop();
		jaw=max(jaw,pref[i]-x[i]*2+pq.top().f);
		//debug(jaw);
	}
	while(!pq.empty())
		pq.pop();
	for(int i=1;i<=n;i++){
		pq.push({pref[i]-x[i],i});
	}
	pq.push({0,0});
	for(int i=n+1;i>=1;i--){
		while(!pq.empty() && pq.top().s>=i)
			pq.pop();
		jaw=max(jaw,pref[n]-pref[i-1]-(C-x[i])*2+pq.top().f);
		/*debug(jaw);
		debug(pref[n]-pref[i-1]);
		debug(C-x[i]);
		debug(pq.top().f);
		debug(pq.top().s);*/
	}
	cout<<jaw<<endl;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[2200];
pint Ai[2200];
int dp[2200][2200];
signed main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        Ai[i] = {A[i], i};
    }
    sort(Ai, Ai + N);
    reverse(Ai, Ai + N);
    rep(i, 2200)rep(j, 2200) { dp[i][j] = LLONG_MIN; }
    dp[0][0] = 0;
    rep(i, N) {
        int Ac = Ai[i].first, x = Ai[i].second;
        rep(j, 2199) {
            chmax(dp[i + 1][j], dp[i][j] + Ac * abs(x - (N - 1 - (i - j))));
            chmax(dp[i + 1][j + 1], dp[i][j] + Ac * abs(x - j));
        }
    }
    int ans = 0;
    rep(i, 2200) { chmax(ans, dp[N][i]); }
    cout << ans << endl;
}

Measured memory_bytes: 41420
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;

int top, S[1000];

void push(int num) {
    S[++top] = num;
}
    
int pop() {
    top--;
    return S[top+1];
}

int main(void){
    // Your code here!
    char s[100];
    int a, b;
    
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-') {
            a = pop();
            b = pop();
            push(b - a);
        }
        else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        }
        else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
    
    
    
    
    
    
    
    
}



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

int main()
{
    int i, x, y, q, flag;

    string s, f, b, s1;

    cin >> s >> q;

    flag=0;
    for(i=0; i<q; i+=1)
    {   
        cin >> x;
        if(x==1)
            flag=(flag+1)%2;
        else
        {
            cin >> y >> s1;
            if(flag==0)
            {
                if(y==1)
                    f+=s1;
                else
                    b+=s1;
            }
            else
            {
                if(y==1)
                    b+=s1;
                else
                    f+=s1;
            }
        }
    }

    if(flag==0)
    {
        reverse(f.begin(), f.end());
        cout << f << s << b << endl;
    }
    else
    {
        reverse(s.begin(), s.end());
        reverse(b.begin(), b.end());
        cout << b << s << f << endl;
    }
}

Measured memory_bytes: 1088
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var n = ScanInt();
      var a = ScanLongArray();
      var c = a.Count(_=>_<=0);
      a = a.Select(_=>Math.Abs(_)).ToArray();
      long res = a.Sum() - (c%2==1 ? 2*a.Min() : 0);
      WriteLine(res);
    }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 29532
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for(auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n + 1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for(auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for(auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for(auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int>> name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num)) + 1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)                                                                                                          \
  cerr << "[";                                                                                                         \
  REPI(itr, v) { cerr << *itr << (itr != --v.end() ? ", " : ""); }                                                     \
  cerr << "]" << endl;
#define dpa(v)                                                                                                         \
  cerr << "[ " << endl;                                                                                                \
  REPI(itr, v) {                                                                                                       \
    cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl;            \
  }                                                                                                                    \
  cerr << "]" << endl;

void solve(long long A, long long B) { cout << A * B << endl; }

signed main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
}


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n;
    string s;
    int A=0, B=0, O=0, AB=0;
    while(cin >> s) {
        string c = s.substr(s.size()-2, s.size()-1);
        if (c==",A") A++;
        else if (c==",B") B++;
        else if (c==",O") O++;
        else if (c=="AB") AB++;
    }
    P(A);
    P(B);
    P(AB);
    P(O);
    return 0;
}

Measured memory_bytes: 3140
x = list(map(int, input().split()))
ans=0
while(x[0]!=x[1])or(x[1]!=x[2]):
    x.sort()
    if(x[0]==x[1]):
        x[0]+=1
        x[1]+=1
    else:
        x[0]+=2
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


int main() {
    int r, D, x_2000;
    cin >> r >> D >> x_2000;

    for (int i = 1; i <= 10; i++) {
        x_2000 = r * x_2000 - D;
        cout << x_2000 << endl;
    }

    return 0;
}


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

const static int MAX = 16;
int field[MAX+1][MAX+1];

int rec(int x,int y,int w,int h) {
  if(x == w && y == h) {
    return 1;
  }
  else if(x > w || y > h) {
    return 0;
  }
  else if(field[x][y] == -1) {
    return 0;
  }
  return rec(x+1,y,w,h) + rec(x,y+1,w,h);
}

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

  int w,h,m;
  while(cin >> w >> h) {
    if( w+h == 0 ) break;
    for(int i=1;i<=h;i++) {
      for(int j=1;j<=w;j++) {
        field[i][j] = 0;
      }
    }
    cin >> m;
    for(int i=0;i<m;i++) {
      int x,y;
      cin >> x >> y;
      field[x][y] = -1;
    }

    cout << rec(1,1,w,h) << endl;
  }
}

Measured memory_bytes: 1192
#include <cstdio>
#include <algorithm>
#include <vector>

#define size_t int

using namespace std;

int main(int argc, char const *argv[]) {
  int A, B;
  scanf("%d %d", &A, &B);
  if (A*B % 2) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


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

int main() {
	vector<int> candy(3);
  	for(int i = 0;i < 3;i++){
      cin >> candy.at(i);
    }
  sort(candy.begin(),candy.end());
  if(candy.at(0) + candy.at(1) == candy.at(2)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }  
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long ll;

int main() {
	ll a, b, c;
	scanf("%lld %lld.%lld", &a, &b, &c);

	ll part1 = a * b;
	ll part2 = a * c;

	part1 = part1 + (part2 / 100);
	printf("%lld", part1);
}

Measured memory_bytes: 3236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder.ABC122.C
{
    class Program
    {
        public static void Main()
        {
            // Solve(8, 3, "ACACTACG", new Tuple<int, int>[] {
            //     new Tuple<int, int>(3, 7),
            //     new Tuple<int, int>(2, 3),
            //     new Tuple<int, int>(1, 8)
            // });
            // Solve(10, 5, "ACACTACGAC", new Tuple<int, int>[] {
            //     new Tuple<int, int>(1, 9),
            //     new Tuple<int, int>(2, 9),
            //     new Tuple<int, int>(3, 9),
            //     new Tuple<int, int>(2, 10),
            //     new Tuple<int, int>(1, 10)
            // });

            var a = Console.ReadLine().Split(' ');
            var N = int.Parse(a[0]);
            var Q = int.Parse(a[1]);
            var S = Console.ReadLine();
            var pairs = new Tuple<int, int>[Q];
            for (int i = 0; i < Q; ++i)
            {
                var b = Console.ReadLine().Split(' ');
                pairs[i] = new Tuple<int, int>(int.Parse(b[0]), int.Parse(b[1]));
            }
            Solve(N, Q, S, pairs);
        }
        static void Solve(int N, int Q, string S, Tuple<int, int>[] pairs)
        {
            string searchWord = "AC";
            var t = new int[N + 1];
            //始めの位置を探す
            int foundIndex = S.IndexOf(searchWord);
            for (int i = 0; i < N - 1; ++i)
            {
                t[i + 1] = t[i] + ((S[i] == 'A' && S[i + 1] == 'C') ? 1 : 0);
            }
            for (int i = 0; i < Q; ++i)
            {
                Console.WriteLine(t[pairs[i].Item2 - 1] - t[pairs[i].Item1 - 1]);
            }
        }
        Dictionary<int, int> cache = new Dictionary<int, int>();
        static int Count(string S, int begin, int end)
        {
            return CountChar(S.Substring(begin, end - begin + 1), "AC");
        }
        public static int CountChar(string s, string c)
        {
            return (s.Length - (s.Replace(c, "").Length)) / c.Length;
        }
    }
}



Measured memory_bytes: 23876
def d_Katana_Thrower(N, H, S):
    import numpy
    import math
    swing = numpy.asarray([x[0] for x in S])
    throw = numpy.asarray([x[1] for x in S])

    swing_max = numpy.max(swing)

    throw_t = throw[throw >= swing_max]
    throw_t = sorted(throw_t, reverse=True)
    hp = H
    ans = 0
    for d in throw_t:
        if hp <= 0:
            break
        hp -= d
        ans += 1

    if hp > 0:
        ans += math.ceil(hp / swing_max)
    return ans
  
N,H=[int(i) for i in input().split()]
S=[[int(i) for i in input().split()] for j in range(N)]
print(d_Katana_Thrower(N, H, S))

Measured memory_bytes: 36624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

struct xorshift64 {
  unsigned long long int x = 88172645463325252ULL;
  inline unsigned short nextUShort() {
    x = x ^ (x << 7);
    return x = x ^ (x >> 9);
  }
  inline unsigned int nextUShortMod(unsigned long long int mod) {
    x = x ^ (x << 7);
    x = x ^ (x >> 9);
    return ((x & 0x000000000000ffff) * mod) >> 48;
  }
  inline unsigned int nextUInt() {
    x = x ^ (x << 7);
    return x = x ^ (x >> 9);
  }
  inline unsigned int nextUIntMod(unsigned long long int mod) {
    x = x ^ (x << 7);
    x = x ^ (x >> 9);
    return ((x & 0x00000000ffffffff) * mod) >> 32;
  }
  inline unsigned long long int nextULL() {
    x = x ^ (x << 7);
    return x = x ^ (x >> 9);
  }
  inline double nextDouble() {
    x = x ^ (x << 7);
    x = x ^ (x >> 9);
    return (double)x * 5.42101086242752217e-20;
  }
};

struct timer {
  double t = 0.0;
  timer() {
    restart();
  }
  inline void restart() {
    t = now();
  }
  inline double time() {
    return now() - t;
  }
  inline double now() {
    unsigned long long l, h;
    __asm__ ("rdtsc" : "=a"(l), "=d"(h));
    return (double)(l | h << 32) * 3.5714285714285715e-10; // 1 / 2.8e9
  }
};

using namespace std;

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

const ll mod = 1000000007;

timer theTimer;
xorshift64 theRandom;

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

  int n;
  cin >> n;
  vector<pair<double, double> > xy(n);
  for (auto &x: xy) cin >> x.first >> x.second;

  double px = 0.0;
  double py = 0.0;
  double score = 1e308;

  int iterCount = 0;
  double delta = 100.0;
  double deltaLimit = 1e-6;
  double decayRate = 1e-6;

  while (theTimer.time() < 1.990) {
    double dx = (theRandom.nextDouble() * delta * 2.0) - delta;
    double dy = (theRandom.nextDouble() * delta * 2.0) - delta;
    if (theRandom.nextDouble() < 0.001) dx = 0;
    else if (theRandom.nextDouble() < 0.001) dy = 0;

    px += dx;
    py += dy;

    double maximum = 0.0;
    for (int i = 0; i < n; i++) {
      double d = (px - xy[i].first) * (px - xy[i].first) + (py - xy[i].second) * (py - xy[i].second);
      if (d > maximum) maximum = d;
    }

    //if (iterCount % 100000 == 0) cerr << iterCount << " " << setprecision(16) << px << " " << setprecision(16) << py << " " << setprecision(16) << maximum << " " << setprecision(16) << score << " " << delta << endl;

    if (maximum <= score) {
      score = maximum;
    }
    else {
      px -= dx;
      py -= dy;
    }

    iterCount++;
    if (delta > deltaLimit) delta *= 1.0 - decayRate;
  }

  double r = 0.0;
  for (int i = 0; i < n; i++) {
    double d = sqrt((px - xy[i].first) * (px - xy[i].first) + (py - xy[i].second) * (py - xy[i].second));
    if (d > r) r = d;
  }

  cout << setprecision(16) << r << endl;

  return 0;
}


Measured memory_bytes: 384
n, m = list(map(int, input().split(' ')))
xs = list(map(int, input().split(' ')))

if n > m:
    print(0)
else:
    ranges = []
    prev_x = None
    for x in sorted(xs):
        if prev_x is not None:
            ranges.append(x - prev_x)
        prev_x = x

    ret = 0
    n_omit = n - 1
    omit = 0
    for r in sorted(ranges, reverse=True):
        if omit < n_omit:
            omit += 1
        else:
            ret += r
    print(ret)

Measured memory_bytes: 13960
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <map>
#include <iomanip>

using namespace std;

using ULL = unsigned long long;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  for (int x = x1; x < x2; ++x) {
    cout << "R";
  }
  for (int y = y1; y < y2; ++y) {
    cout << "U";
  }
  for (int x = x2; x > x1; --x) {
    cout << "L";
  }
  for (int y = y2; y > y1; --y) {
    cout << "D";
  }
  cout << "L";
  for (int y = y1; y < y2 + 1; ++y) {
    cout << "U";
  }
  for (int x = x1-1; x < x2; ++x) {
    cout << "R";
  }
  cout << "D";
  cout << "R";
  for (int y = y2; y > y1 - 1; --y) {
    cout << "D";
  }
  for (int x = x2 + 1; x > x1; --x) {
    cout << "L";
  }
  cout << "U"<<endl;
  return 0;
}

Measured memory_bytes: 256
A = []
count = [0,0,0,0]
for i in range(3):
    a,b = (int(x) for x in input().split())
    A.append(a)
    A.append(b)

ans = 0

for i in range(6):
    a = A[i]
    count[a-1] += 1

count.sort()
if count == [1,1,2,2]:
    print("YES")
else:
    print("NO")

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

const int N = 3;
int A [N] [N];
const int dx [] = {0,1,1,1,0,-1,-1,-1};
const int dy [] = {1,1,0,-1,-1,-1,0,1};
const int INF = 1e9;

bool in_range(int y,int x)
{
	return y >= 0 && y < N && x >= 0 && x < N;
}

bool put(int y,int x,int sum)
{
	FOR(i,0,4){
		int cy = y,cx = x,s = 0,cnt = 0;
		while(true){
			cy += dy [i]; cx += dx [i];
			if(in_range(cy,cx) == false || A [cy] [cx] == -INF){
				break;
			}
			cnt++;
			s += A [cy] [cx];
		}
		cy = y; cx = x;
		while(true){
			cy += dy [i + 4]; cx += dx [i + 4];
			if(in_range(cy,cx) == false || A [cy] [cx] == -INF){
				break;
			}
			cnt++;
			s += A [cy] [cx];
		}
		if(cnt == 2){
			A [y] [x] = sum - s;
			return true;
		}
	}
	return false;
}

int main()
{
	fill(A [0],A [3],-INF);
	scanf("%d%d%d",&A [0] [0],&A [0] [1],&A [1] [1]);

	int sum = A [1] [1] * 3,cnt = 3;

	while(cnt < N * N){
		FOR(i,0,N) FOR(j,0,N) if(A [i] [j] == -INF){
			if(put(i,j,sum)){
				cnt++;
			}
		}
	}

	FOR(i,0,N) FOR(j,0,N){
		printf("%d%s",A [i] [j],j == N - 1 ? "\n" : " ");
	}

	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 89;
	while (kkt) {
		string s; cin >> s; if (s == ".") break;
		string t; cin >> t;
		if (s == t) puts("IDENTICAL");
		else {
			
			vector<string> vs, vt, ss, tt;
			string tmp;
			string tmp2;
			{
				bool flag = false;
				for (int i = 0; i < s.size(); i++) {
					if (s[i] == '"') {
						if (!flag) {
							flag = true;
							ss.push_back(tmp2);
							tmp2 = "";
						}
						else {
							flag = false;
							vs.push_back(tmp);
							tmp = "";
						}
					}
					else {
						if (flag) tmp += s[i];
						else tmp2 += s[i];
					}
				}
			}
			ss.push_back(tmp2);
			tmp2 = "";
			{
				bool flag = false;
				for (int i = 0; i < t.size(); i++) {
					if (t[i] == '"') {
						if (!flag) {
							flag = true;
							tt.push_back(tmp2);
							tmp2 = "";
						}
						else {
							flag = false;
							vt.push_back(tmp);
							tmp = "";
						}
					}
					else {
						if (flag) tmp += t[i];
						else tmp2 += t[i];
					}
				}
			}
			tt.push_back(tmp2);
			//for (int i = 0; i < ss.size(); i++) cout << ss[i] << " " << tt[i] << endl;
			if (ss != tt || vs.size() != vt.size()) puts("DIFFERENT");
			else {
				int cnt = 0;
				for (int i = 0; i < vs.size(); i++) {
					if (vs[i] != vt[i]) cnt++;
				}
				if (cnt >= 2) puts("DIFFERENT");
				else puts("CLOSE");
			}
		}
	}
	return 0;

}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

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

    int a,b,c; cin >> a >> b >> c;
    c-=a+b;
    if(c>0 && c*c>4*a*b){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String line = reader.readLine();
        int x = Integer.parseInt(line);

        call(1, x, builder);
        System.out.println(builder);
    }

    public static void call(int i, int n, StringBuilder builder) {
        // 3??§?????????????????? ??????
        while (i <= n) {
            int x = i;
            if (x % 3 == 0) {
                builder.append(" " + i);
            }
            else {
                // INCLUDE3
                int y = x;
                while (y > 1) {
                    if (y % 10 == 3) {
                        builder.append(" " + i);
                        break;
                    }
                    y = y / 10;
                }
            }
            i++;
        }
    }
}

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

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

  vector<int> p(N);  // 各社員の上司を示す配列
  p.at(0) = -1;  // １番の上司は存在しないので-1を入れておく
  for (int i = 1; i < N; i++) {
    cin >> p.at(i);
    p.at(i)--;
  }

  // 社員の関係から2次元配列を作る
  vector<vector<int>> children(N);  // ある社員の部下の番号一覧
  for (int i = 1; i < N; i++) {
    int parent = p.at(i);  // i番の上司の番号
    children.at(parent).push_back(i);  // parentの部下一覧にi番を追加
  }

  // 各社員について、答えを出力
  for (int i = 0; i < N; i++) {
    cout << children.at(i).size() << endl;
  }
}

Measured memory_bytes: 14700
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)



Measured memory_bytes: 5592
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();

        for (int i = 0; i < 2000; i++) {
            if((int)(i * 0.08) == a && (int)(i * 0.10) == b){
                System.out.println(i);
                return;
            }
        }

        System.out.println(-1);
    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 22996
from collections import deque


def bfs():
    d = [[float("inf")] * w for i in range(h)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    while que:
        p = que.popleft()
        if p[0] == gx and p[1] == gy:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d[gx][gy]


h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h - 1, w - 1

# 白いマスを数える
white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            white += 1

res = bfs()
if 0 < res < float("inf"):
    # 白いマスの数から最短経路でかかるコスト分を引く
    # ゴールを黒いマスに変えることはできないためその分も引く
    print(white - res - 1)
else:
    print(-1)

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

int main() {
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    rep(a1, 101) rep(a2, 101) rep(a3, 101) {
        if (c[0][0] - a1 == c[0][1] - a2 && c[0][1] - a2 == c[0][2] - a3 &&
            c[1][0] - a1 == c[1][1] - a2 && c[1][1] - a2 == c[1][2] - a3 &&
            c[2][0] - a1 == c[2][1] - a2 && c[2][1] - a2 == c[2][2] - a3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int r, d, x;
	int i;

	scanf("%d %d %d", &r, &d, &x);

	for(i = 0; i < 10; i++) {
		x = r * x - d;
		printf("%d\n", x);
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long
#define MAX 2000000

int h, a[MAX + 1];

void maxHeapify(int i) {
    int l = 2 * i;
    int r = 2 * i + 1;
    int largest = i;

    if(l <= h && a[l] > a[largest]) largest = l;
    if(r <= h && a[r] > a[largest]) largest = r;

    if(largest != i) {
        swap(a[i], a[largest]);
        maxHeapify(largest);
    }
}

int extract() {
    if(h < 1) return -INF;
    int maxv = a[1];
    a[1] = a[h];
    h--;
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) {
    if(a[i] > key) return;
    a[i] = key;
    while(i > 1 && a[i] > a[i / 2]) {
        swap(a[i], a[i / 2]);
        i /= 2;
    }
}

void insert(int key) {
    h++;
    a[h] = -INF;
    increaseKey(h, key);
}

signed main() {
    int key;
    char com[10];

    while(true) {
        scanf("%s", com);
        if(com[0] == 'e' && com[1] == 'n') break;
        if(com[0] == 'i') {
            scanf("%lld", &key);
            insert(key);
        }
        else {
            printf("%lld\n", extract());
        }
    }

    return 0;
}



Measured memory_bytes: 10932
while True:
    n=input()
    if n==0:
        break
    dp=[[0 for i in range(n)]for j in range(n)]
    for i in range(n):
        j=0
        for c in raw_input():
            if c == ".":
                dp[i][j]=1
            j+=1
    for i in range(1,n):
        for j in range(1,n):
            if dp[i][j]==1:
                dp[i][j]=min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1
    allmax=0
    for i in range(n):
        if allmax<max(dp[i]):
            allmax=max(dp[i])
    print allmax

Measured memory_bytes: 33788
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>

#define REP(i, s, e) for (ll i = s; i < e; ++i)

using namespace std;
using ll = long long;
using ld = long double;

void dfs(ll n, const ll N, int n1, int n2, int n3, int& count)
{
    if (n > N) return;

    if (n1 && n2 && n3) ++count;
    dfs(n * 10 + 7, N, n1 + 1, n2, n3, count);
    dfs(n * 10 + 5, N, n1, n2 + 1, n3, count);
    dfs(n * 10 + 3, N, n1, n2, n3 + 1, count);
}

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

    int N;
    cin >> N;

    int count = 0;
    dfs(0, N, 0, 0, 0, count);
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>
#define INF 1001001001
#define EPS 0.000000001
#define x first
#define y second

using namespace std;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int,int> pint;

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

int main(){
	int i,j,fx,fy;
	int w,h;
	char m[30][30];
	while(1){
		cin >> w >> h;
		if(w==0 && h==0) break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				cin >> m[i][j];
				if(m[i][j]=='@'){
					fx=i;
					fy=j;
				}
			}
		}
		
		int ans=1;
		queue<pint> q;
		q.push(pint(fx,fy));
		while(!q.empty()){
			pint c = q.front(); q.pop();
			for(i=0;i<4;i++){
				int nx = c.x + dx[i];
				int ny = c.y + dy[i];
				if(0 <= nx && nx < h && 0 <= ny && ny < w && m[nx][ny]=='.'){
					m[nx][ny] = '@';
					q.push(pint(nx,ny));
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0