akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;
ll x;
ll a[1100000];
ll b[3000][3000];
ll ans = 1e15;

int main(){
  cin>>n>>x;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    b[0][i] = inf;
  }

  rep(k,n){
    ll s = k*x;
    rep(i,n){
      if(k==0) b[k][i] = a[i];
      else{
        int j = i-k;
        if(j<0) j = n+j;
        b[k][i] = min(b[k-1][i],a[j]);
    }
    s+= b[k][i];
  }
  ans = min(ans,s);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 49024
def main():
    n=int(input())
    c=sorted(list(map(int,input().split())))
    mod=10**9+7
    ans=0
    for i,j in enumerate(c):
        ans=(ans+j*(n-i+1))%mod
        
    ans=(ans*4**(n-1))%mod
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 26024
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
int main() {
    int s;
    cin >> s;
    set <int> k;
    unsigned long temp = 0;
    k.insert(s);
    int prev = s;
    for(int i = 2; i < 20000000; i++){
        temp = k.size();
        if(prev % 2 == 0){
            k.insert(prev/2);
            prev = prev/2;
        } else {
            k.insert(3 * prev + 1);
            prev = 3 * prev + 1;
        }
        if (k.size() == temp) {
            cout << i << "\n";
            break;
        }
    }
    return 0;
}


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

int main() {

	int A, B, K, i = 0;
	set<int> st;
	cin >> A >> B >> K;

	while (1) {
		if (i == K) break;
		if (A + i > B) break;
		if (B - i < A) break;
		st.insert(A + i);		
		st.insert(B - i);
		++i;
	}

	for (auto s : st) {
		cout << s << endl;
	}

	return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const int MAX = 300005;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

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

    int n, k;
    cin >> n >> k;

    segtree<int, op, e> st(MAX);
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        st.set(a, st.prod(max(a - k, 0), min(a + k + 1, MAX)) + 1);
    }
    cout << st.prod(0, MAX) << "\n";

    return 0;
}

Measured memory_bytes: 8480
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

struct Shop
{
	int i;
	string s;
	int p;

	Shop() {};
	Shop(int i, string s, int p) : i(i), s(s), p(p) {};

	bool operator<(const Shop &r) const
	{
		if(s == r.s)
		{
			return p > r.p;
		}
		else
		{
			return s < r.s;
		}
	}
};

int main()
{
	int n;
	Shop shops[100];

	cin >> n;

	for(int i = 0; i < n; ++i)
	{
		string s;
		int p;
		cin >> s >> p;
		shops[i] = Shop(i + 1, s, p);
	}

	sort(shops, shops + n);

	for(int i = 0; i < n; ++i)
	{
		cout << shops[i].i << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
out_count = 0
score = 0
runners = [0, 0, 0]

while n:
    event = input()
    if event == "HIT":
        if runners.pop():
            score+=1
        runners = [1] + runners
    if event == "HOMERUN":
        score += 1 + sum(runners)
        runners = [0, 0, 0]
                
    if event == "OUT":
        out_count += 1
        if out_count > 2:
            n-=1
            print(score)
            score = 0
            out_count = 0
            runners = [0, 0, 0]
        

Measured memory_bytes: 7592
#include <iostream>
#include <algorithm>
#define llint long long

using namespace std;

llint a[3];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	
	if(a[0] != a[2] && (a[0] == a[1] || a[1]== a[2])) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * size
        self.rank = [1] * size
        self.groups = size

    def get_root(self, node):
        parent = self.parent[node]
        if parent == -1:
            root = node
        else:
            root = self.get_root(parent)
            self.parent[node] = root  # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく
        return root

    def in_same_group(self, node1, node2):
        root1 = self.get_root(node1)
        root2 = self.get_root(node2)
        return root1 == root2

    def unite(self, node1, node2):
        if self.in_same_group(node1, node2):
            return
        main_root = self.get_root(node1)
        sub_root = self.get_root(node2)
        if self.rank[main_root] < self.rank[sub_root]:  # rankの大きい方をmain_rootにする
            main_root, sub_root = sub_root, main_root

        self.parent[sub_root] = main_root
        self.rank[main_root] += self.rank[sub_root]
        self.groups -= 1


def main():
    n, m = map(int, input().split())
    bridges = [list(map(int, input().split())) for _ in range(m)]
    uf = UnionFind(n)
    inconvenience = n * (n-1) // 2
    ans = [inconvenience]

    for a, b in bridges[::-1]:
        if uf.in_same_group(a-1, b-1):
            ans.append(inconvenience)
            continue
        root1 = uf.get_root(a-1)
        root2 = uf.get_root(b-1)
        pattern = uf.rank[root1] * uf.rank[root2]
        inconvenience -= pattern
        ans.append(inconvenience)
        uf.unite(root1, root2)
    ans.pop()
    print(*ans[::-1], sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 36024
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int N,M;
      cin >> N >> M;
  vector<vector<char>> sheet(N,vector<char>(M));
  froop1(0,N){
	for(int j = 0;j < M;j++){
      cin >> sheet.at(i).at(j);
    }
  }
  vector<vector<int>> output(N,vector<int>(M,0));
  froop1(0,N){
    for(int j = 0;j < M;j++){
      if(sheet.at(i).at(j) == '.'){
        
        for(int k = i - 1;k <= i + 1;k++){
          for(int l = j - 1;l <= j + 1;l++){
           if(k >= 0 && l >= 0 && k < N && l < M && !(k == i && l == j)){
             if(sheet.at(k).at(l) == '#') output.at(i).at(j)++;
           }
          }
        }
      }
    }
  }
      froop1(0,N){
        for(int j = 0;j < M;j++){
          if(sheet.at(i).at(j) == '#'){
            cout << '#';
          }else{
			cout << output.at(i).at(j);
          }
        }
        cout << endl;
      }
}


Measured memory_bytes: 3616
#define USE_MATH_DEFINES 1
#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;
#define MOD 998244353ll
#define INF 1000000000000000000ll
#define EPS 1e-9

#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll N;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N;
	
	for (ll a = -2000; a <= 2000; a++) {
		for (ll b = -2000; b <= 2000; b++) {
			if (a*a*a*a*a - b*b*b*b*b == N) {
				cout << a << " " << b;
				return 0;
			}
		}
	}
	
    return 0;
}

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

typedef long long ll;
using namespace std;

int main()
{
  ll N, M; cin >> N >> M;
  vector<pair<ll, ll>> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i].first >> a[i].second;

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

  ll ans = 0;
  for (auto v : a) {
    int buy_num = min(M, v.second);
    ans += buy_num * v.first;
    M -= buy_num;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1920
#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;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	string s,t;
	cin>>s>>t;
	if(t.substr(0, (int)t.sz()-1) == s)
	cout<<"Yes\n";
	else cout<<"No\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	if (n == 1) {
		cout << "Hello World"<<endl;
	}
	else {
		int a, b; cin >> a >> b;
		cout << (a + b) << endl;
	}

	return 0;
}

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

using namespace std;
#define rep(n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
bool in(vector<int> p, int n) {
    for (int i = 0; i < p.size(); i++) {
        if(n == p[i]) {
            return true;
        }
    }

    return false;
}
int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(n) {
        cin >> p[i];
    }

    sort(p.begin(), p.end(), greater<int>());
    int ans1 = x;
    int ans2 = x;
    rep(n)
    {
        if(ans1 == p[i]) {
            while(in(p, ans1)) {
                ans1++;
            }
        }
    }

    rep(n)
    {
        if (ans2 == p[i])
        {
            while (in(p, ans2))
            {
                ans2--;
            }
        }
    }

    int ans;
    if (abs(x - ans1) > abs(x - ans2))
    {
        ans = ans2;
    }
    else if (abs(x - ans1) < abs(x - ans2))
    {
        ans = ans1;
    } else {
        ans = min(ans1, ans2);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    ll N, K; cin >> N >> K;
    vector<int> A(N); cin >> A;

    vector<int> done(N+1, -1);
    vector<int> dest(N+1, 0);

    dest[0] = 1;
    done[1] = 0;
    int l = -1, r = -1;
    for (int i = 1; i < N; i++) {
        int a = A[dest[i-1]-1];
        if (done[a] != -1) {
            l = done[a];
            r = i - 1;
            break;
        } else {
            dest[i] = a;
            done[a] = i;
        }
    }
    assert(l != -1 && r != -1);

    int ans;
    if (K < l) {
        ans = dest[K];
    } else {
        ans = dest[l + (K-l) % (r-l+1)];
    }

    cout << ans << endl;
}


Measured memory_bytes: 5632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, in, L;
int dp[100002];
vector<pi>a;

int main(){
  scanf("%d%d", &N, &L);
  rep(i, N){
    scanf("%d", &in);
    a.PB(MP(in, i+1));
  }

  sort(a.begin(), a.end(), greater<pi>());

  rep(i, N){
    if(dp[a[i].S-1] == 0 && dp[a[i].S+1] == 0){
      dp[a[i].S] = L - a[i].F;
    }else if(dp[a[i].S-1] > dp[a[i].S+1]){
      dp[a[i].S] = dp[a[i].S-1] + L - a[i].F;
    }else if(dp[a[i].S+1] > dp[a[i].S-1]){
      dp[a[i].S] = dp[a[i].S+1] + L - a[i].F;
    }
  }

  int res = 0;
  rep(i, N+2) res = max(res, dp[i]);
  //  rep(i, N+2) printf("%d ", dp[i]); puts("");
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 2448
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define rep(a,b,c) for(ll a=b;a<=c;a++)
#define per(a,b,c) for(ll a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int N = 1e5+5;
int n, m;
string s;
map<string, ll> mp;

int main(){
    cin >> n;
    rep(i,1,n){
        cin >> s;
        sort(s.begin(), s.end());
        if(mp[s] > 0) mp[s]++;
        else mp[s] = 1;
    }
    ll ans = 0;
    for(auto x : mp){
        ll y = x.second;
        //printf("y=%d\n",y);
        ans += (y*(y-1))/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
import math
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))
    q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))
    r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)
    print("{:.3f} {:.3f} {:.3f}".format(p, q, r))


Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;
Int mod = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    Int M,ans = 1;
    cin >> N >> M;
    Int C[100032][32];
    C[0][0] = 1;
    for(int a = 1;a < 100032;a ++){
        C[a][0] = 1;
        for(int b = 1;b < 32;b ++){
            C[a][b] = C[a-1][b] % mod + C[a-1][b-1] % mod;
        }
    }
    for(int i = 2;M != 1;i ++){
        int cnt = 0;
        while(M % i == 0){
            M /= i;
            cnt ++;
        }
        ans *= C[N+cnt-1][cnt];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main() {
    int n;
    while(cin >> n, n) {
        vector<string> v(n);
        map<int, int> m;
        for(int i=0; i<n; ++i) {
            cin >> v[i];
        }

        int prev_deep = 0;
        for(int i=0; i<n; ++i) {
            if(i == 0) {
                continue;
            }
            for(int j=0; j<v[i].size()-1; ++j) {
                if(v[i][j] == '.' && v[i][j+1] != '.') {
                    v[i][j] = '+';
                    if(m[j] != 0 && prev_deep > j) {
                        for(int k=m[j]+1; k<i; ++k) {
                            v[k][j] = '|';
                        }
                    }
                    m[j] = i;
                    prev_deep = j;
                } else if(v[i][j] == '.' && v[i][j+1]) {
                    v[i][j] = ' ';
                }
            }
        }

        for(auto& x : v) {
            cout << x << endl;
        }
    }
}


Measured memory_bytes: 3860
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str,tmp;
        int j,strnum;
        str = sc.next();
        while(!str.equals("-")){
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                tmp = str.substring(h);
                strnum = str.length();
                str = tmp + str;
                str = str.substring(0,strnum);
            }
            System.out.println(str);
            str = sc.next();
        }
    }
}


Measured memory_bytes: 26340
'use strict'

const main = arg => {
  arg = arg.trim().split("\n");

  const w = ~~(arg[0].split(" ")[0]);
  const h = ~~(arg[0].split(" ")[1]);
  const n = ~~(arg[0].split(" ")[2]);

  const points = arg.slice(1, n + 1).map(l => l.split(" ").map(n => ~~n));
  const list = [...Array(h)].map(l => [...Array(w)].fill(0));

  for(const point of points) {
    const x = point[0];
    const y = point[1];
    const a = point[2] - 1;

    const fromH = [0, 0, 0, y];
    const toH   = [h, h, y, h];
    const fromW = [0, x, 0, 0];
    const toW   = [x, w, w, w];

    for(let i = fromH[a]; i < toH[a]; i++) {
      for(let j = fromW[a]; j < toW[a]; j++) {
        list[i][j] = 1;
      }
    }
  }

  let cnt = 0;
  
  for(let i = 0; i < h; i++) {
    for(let j = 0; j < w; j++) {
      if(list[i][j] === 0) cnt++;
    }
  }

  console.log(cnt);
}

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


Measured memory_bytes: 9004
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef complex<ll> P;

void check(P a) {
  if (abs(a.real()) > 10000 ||
      abs(a.imag()) > 10000)
    throw(0);
}

char s[1000];

P expr(int &i);
P fact(int &i) {
  if (isdigit(s[i])) {
    ll t=0;
    while(isdigit(s[i])) {
      t=t*10+s[i++]-'0';
      check(P(t,0));
    }
    return P(t,0);
  } else if (s[i] == 'i') {
    i++;
    return P(0,1);
  } else {
    assert(s[i++] == '(');
    P a = expr(i);
    assert(s[i++] == ')');
    check(a);
    return a;
  }
}

P term(int &i) {
  P a = fact(i);
  while(s[i]=='*') {
    i++;
    P b = fact(i);
    a *= b;
    check(a);
  }
  check(a);
  return a;
}

P expr(int &i) {
  P a = term(i);
  while(s[i] == '+' || s[i] == '-') {
    char op = s[i++];
    P b = term(i);
    if (op == '+') a += b;
    else a -= b;
    check(a);
  }
  check(a);
  return a;
}

int main() {
  string line;
  while(getline(cin,line)) {
    strcpy(s, line.c_str());
    if (line=="") {
      cout << 0 << endl;
      continue;
    }
    try {
      int id=0;
      P p = expr(id);
      stringstream ans;
      if (p.real()==0 && p.imag()==0) {
        ans << 0;
      } else if (p.imag() == 0) {
        ans << p.real();
      } else if (p.real() == 0) {
        ans << p.imag() << "i";
      } else {
        ans << p.real();
        if (p.imag() > 0) ans << "+";
        else ans << "-";
        ans << abs(p.imag()) << "i";        
      }
      cout << ans.str() << endl;
    }
    catch(int a) {
      cout << "overflow" << endl;
    }
  }
}

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

int g = 0;

void merge(vector<string> &vs, int l, int m, int r) {
  int n1 = m - l + 1;
  int n2 = r - m;

  vector<string> L(n1);
  vector<string> R(n2);

  for (int i = 0; i < n1; i++) {
    L.at(i) = vs.at(l + i);
  }
  for (int j = 0; j < n2; j++) {
    R.at(j) = vs.at(j + m + 1);
  }

  int i = 0, j = 0, k = l;
  while (i < n1 && j < n2) {
    if (L.at(i) > R.at(j)) {
      vs.at(k) = R.at(j);
      j++;
    } else {
      vs.at(k) = L.at(i);
      i++;
    }
    k++;
  }

  while (i < n1) {
    vs.at(k) = L.at(i);
    k++;
    i++;
  }

  while (j < n2) {
    vs.at(k) = R.at(j);
    k++;
    j++;
  }
}

void mergeSort(vector<string> &vs, int l , int r) {
  if (l < r) {
    int m = l + (r - l) / 2;
    mergeSort(vs, l, m);
    mergeSort(vs, m+1, r);
    merge(vs, l, m, r);
  }
}

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

  vector<string> vs(n);
  for (int i = 0; i < n; i++) {
    cin >> vs.at(i);
  }

  mergeSort(vs, 0, n-1);

  for (int i = 0; i < n; i++) {
    cout << vs.at(i);
  }

  return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

dp = [1,1]
if 1 in a: dp[1] = 0
  
for i in range(2,n+1):
  if i in a: dp.append(0)
  else: dp.append(dp[i-1] + dp[i-2])

print(dp[n]%1000000007)

Measured memory_bytes: 471816
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int count = 0;
        int[] array = new int[m + n];
        for (int a = 0; a < n; a++) {
            array[a] = 0;
        }
        for (int b = n; b < m + n; b++) {
            array[b] = 1;
        }

        for (int i = 0; i < m + n; i++) {
            for (int j = i; j < m + n; j++) {
                if (!(i == j) && (array[i] + array[j]) % 2 == 0) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22612
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 1e3+5;

char a[N][N];
int dp[N][N];

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= m; j++) {
    		cin >> a[i][j];
    	}
    }
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= m; j++) {
    		if (a[i][j] == '#') continue;
    		if (i == 1 && j == 1) continue;
    		dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
    	}
    }
    cout << dp[n][m];
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    bool flag = false;
    if (a == b && a != c)
        flag = true;
    else if (a == c && a != b)
        flag = true;
    else if (c == b && a != c)
        flag = true;
    if (flag)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

int main() {
    int W, H;
    cin >> H >> W;
    string a[50];
    rep(i, H) cin >> a[i];
    int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
    int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
    rep(i, H) {
        rep(j, W) {
            int num = 0;
            if (a[i][j] == '#') continue;
            for (int k = 0; k < 8;k++){
                int ni = i + dx[k];
                int nj = j + dy[k];
                if (ni < 0 || H <= ni) continue;
                if (nj < 0 || W <= nj) continue;
                if (a[ni][nj] == '#') num++;
            }
            a[i][j] = char(num + '0');
        }
    }
    rep(i, H) cout << a[i] << endl;
}

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

int main() {
    int a,b,c,A,B,C,E,D;
    cin >> a >> b >>c;
    A = a + b ;
    B = b + c;
    C = a +c ;
    if(A>B){
        E = B;
    }
    else {
        E =A;
    }
    if(E>C){
        D = C;
    }
    else {
        D = E;
    }
    cout << D <<endl;

    
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
void cs(int k);

int A[2000001];
int B[2000001];
int n;

// length is n
main(){

  int i,k=0;
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(A[i]>k) k=A[i];
  }
  // setting is finished

  cs(k);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");

  return 0;
}

void cs(int k){
  int C[k+1];
  int i,j,len;
  for(i=0; i<=k; i++)
    C[i] = 0;

  for(j=1; j<=n;j++)
    C[A[j]]++;

  for(i=1; i<=k; i++)
    C[i] = C[i] + C[i-1];

  for(j=n; j>=1; j--){

    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;

  }

}

Measured memory_bytes: 16000
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b&&b<=c){
		cout<<a<<" "<<b<<" "<<c<<endl;
	}
	else if(c<=a&&a<=b){
		cout<<c<<" "<<a<<" "<<b<<endl;
	}
	else if(a<=c&&c<=b){
		cout<<a<<" "<<c<<" "<<b<<endl;
	}
	else if(c<=b&&b<=a){
		cout<<c<<" "<<b<<" "<<a<<endl;
	}
	else if(b<=a&&a<=c){
		cout<<b<<" "<<a<<" "<<c<<endl;
	}
	else if(b<=c&&c<=a){
		cout<<b<<" "<<c<<" "<<a<<endl;
	}






	return 0;
}



Measured memory_bytes: 3068
rooms = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    rooms[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(-3, 0):
        print("", *rooms[i][j])
    if i != 3:
        print("#"*20)


Measured memory_bytes: 5628
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(int argc, char const *argv[])
{
	int graph[10][10];
	int d[10][10];
	int A[200][200];
	int H, W;
	cin >> H >> W;
	REP(i,10){
		REP(j,10){
			cin >> graph[i][j];
			d[i][j]  = graph[i][j];
		}
	}
	REP(i,H){
		REP(j,W){
			cin >> A[i][j];
		}
	}

	REP(k,10){
		REP(i,10){
			REP(j,10){
				if(d[i][j] > d[i][k] + d[k][j]){
					d[i][j]=d[i][k] + d[k][j];
				}
			}
		}
	}
	int mp = 0;
	REP(i,H){
		REP(j, W){
			if(A[i][j] != -1){
				//out d[A[i][j]][1]
				// cout << d[A[i][j]][1] << " ";
				mp += d[A[i][j]][1];
			}
		}
	}
	cout << mp << endl;	
	return 0;
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int n;
  cin >> n;
  if (n%2 == 0){
      cout << ".5";
  }else{
      cout << (double)(n/2+1)/(n);
  }
  return 0; 
}


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

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

char a[1005][1005];
vector<pair<int, int> > v;
queue<pair<int, int> > Q, nq;
int vs[1005][1005];

int main(void)
{
	int h, w, sy, sx, ey, ex, i, j, dir, magic;

	scanf("%d %d %d %d %d %d", &h, &w, &sy, &sx, &ey, &ex);
	for (i = 1; i <= h; i++)
		scanf("%s", a[i] + 1);

	Q.push(make_pair(sy, sx));
	vs[sy][sx] = 1;

	for (magic = 0; ; magic++)
	{
		if (Q.empty())
			break;

		v.clear();

		while (!Q.empty())
		{
			int nowy = Q.front().first;
			int nowx = Q.front().second;
			Q.pop();

			v.push_back(make_pair(nowy, nowx));

			if (nowy == ey && nowx == ex)
			{
				printf("%d", magic);
				return 0;
			}
			// printf("%d %d\n", nowy, nowx);
			for (dir = 0; dir < 4; dir++)
			{
				int nexty = nowy + dy[dir];
				int nextx = nowx + dx[dir];
				// printf("> %d %d\n", nexty, nextx);
				if (!(1 <= nexty && nexty <= h && 1 <= nextx && nextx <= w && a[nexty][nextx] == '.' && !vs[nexty][nextx]))
					continue;

				Q.push(make_pair(nexty, nextx));
				vs[nexty][nextx] = 1;
			}
		}

		for (pair<int, int> val : v)
		{
			for (i = -2; i <= 2; i++)
				for (j = -2; j <= 2; j++)
				{
					int nexty = val.first + i;
					int nextx = val.second + j;
					// printf("> %d %d\n", nexty, nextx);
					if (!(1 <= nexty && nexty <= h && 1 <= nextx && nextx <= w && a[nexty][nextx] == '.' && !vs[nexty][nextx]))
						continue;

					nq.push(make_pair(nexty, nextx));
					vs[nexty][nextx] = 1;
				}
		}

		while (!nq.empty())
		{
			// printf("> %d %d\n", nq.front().first, nq.front().second);
			Q.push(nq.front());
			nq.pop();
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 8740
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || '9'<fr_ch) {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while('0'<=fr_ch && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max (T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min (T &a, T b) {if(b<a) a=b;}
template< typename T > inline void Swap(T &a, T &b) {T c=a;a=b;b=c;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double   pi = acos(-1.0) ;
const int     MOD = (int)1e9+7 ;
const int     INF = (int)0x3f3f3f3f ;
const LL     LINF = (LL)INF<<32|INF ;
const int    SINF = (uint)(-1)>>1 ;
const LL    SLINF = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double  eps = 1e-8 ;
const int    maxn = (int) 2e5+20 ;
const int    maxm = (int) 8e5+20 ;
const int    maxk = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

void work()
{
    int x; read(x);
    if(x < 1200) puts("ABC");
    else if(x < 2800) puts("ARC");
    else puts("AGC");
}


//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int city_number, way_number;
	static int[][] way;
	static int[] Array = new int[4];
	static int start, goal, reward, cost;
	static final int INF = 10000000;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		read();
		slove();
	}
	static boolean read(){
		city_number = sc.nextInt();
		way_number = sc.nextInt();
		way = new int[city_number+1][city_number+1];
		
		for (int i = 0; i <= city_number; i++) {
			Arrays.fill(way[i], INF);
			way[i][i] = 0;
		}
		
		sc.nextLine();

		String line;
		for(int i = 1; i < way_number + 1; i++){
			int a, b, c, d;
			line = sc.nextLine();
			String[] ss = line.split(",");
			a = Integer.parseInt(ss[0].trim());
			b = Integer.parseInt(ss[1].trim());
			c = Integer.parseInt(ss[2].trim());
			d = Integer.parseInt(ss[3].trim());

			way[a][b] = c;
			way[b][a] = d;
		}
		
		line = sc.nextLine();
		String[] aa = line.split(",");
		start = Integer.parseInt(aa[0]);
		goal = Integer.parseInt(aa[1]);
		reward = Integer.parseInt(aa[2]);
		cost = Integer.parseInt(aa[3]);

		return true;
	}
	static void slove(){
		for (int t = 1; t <= city_number; t++) {
			for (int u = 1; u <= city_number; u++) {
				for (int v = 1; v <= city_number; v++) {
					way[u][v] = Math.min(way[u][v], way[u][t] + way[t][v]);
				}
			}
		}

		/*
		for (int u = 1; u <= city_number; u++) {
			for (int v = 1; v <= city_number; v++) {
				System.out.print(way[u][v] + "     ");
			}
			System.out.println();
		}
		*/
		int s = Array[0], g = Array[1], wage = Array[2], f = Array[3]; 
		System.out.println(reward - cost - way[start][goal] - way[goal][start]);
	}

}

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

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    int n = Integer.parseInt(r.readLine());
    //int v = Integer.parseInt(s);

    //String[] sl = s.split("[\\s]+");
    //int n = Integer.parseInt(sl[0]);
    //int x = Integer.parseInt(sl[1]);
    
    String s = r.readLine();
    
    int max = 0;

    for (int i = 1; i < n; i++)
    {
      String s1 = s.substring(0, i);
      String s2 = s.substring(i, n);
      int v = 0;
      for(Character c = 'a'; c <= 'z'; c++)
      {
        if(s1.contains(c.toString()) && s2.contains(c.toString()))
        {
          v++;
        }
      }
      max = Math.max(max, v);
    }

    System.out.println(max);

  }

}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int>B(M);
    for (int i=0; i<M; i++){
        cin >> B.at(i);
    }

    int count = 0;
    for (int i=0; i < N; i++) {
        int res = 0;
        for (int j=0; j<M; j++) {
            int s;
            cin >> s;
            res += s * B[j];
        }

        if (res + C > 0) {
            count += 1;
        }
    }

    cout << count << endl;
    return 0;
}

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

#define N 2000000

typedef long int lint;

int size;

void maxHeap(lint H[], int i, int n){
  lint left,right;
  lint largeVal;
  lint temp;
  
  left = i*2;
  right = i*2+1;

  if(left <= n && H[left] > H[i]){
    largeVal = left;
  }
  else{
    largeVal = i;
  }

  if(right <= n && H[right] > H[largeVal]){
    largeVal = right;
  }

  if(largeVal != i){
    temp = H[i];
    H[i] = H[largeVal];
    H[largeVal] = temp;

    maxHeap(H, largeVal, n);
  }
}

void buildMaxHeap(lint H[], int n){
  int i;
  for(i = n/2;i > 0;i--){
    maxHeap(H, i, n);
  }
}

void insert(lint H[], lint key){
  
  H[++size] = key;

  int i = size;
  int temp;
  
  while(i > 1 && H[i] > H[i/2]){
    temp = H[i];
    H[i] = H[i/2];
    H[i/2] = temp;
    i /= 2;
  }
}

void extractMax(lint H[]){
  if(size < 1){
    fprintf(stderr,"cannot extract.\n");
    return;
  }
  
  printf("%ld\n", H[1]);

  H[1] = H[size--];

  maxHeap(H, 1, size);
}

int main()
{
  int key;
  char order[10];

  lint H[N+1]={};
  
  while(1){
    scanf("%s",order);

    if(strcmp(order,"insert") == 0){
      scanf("%d",&key);
      insert(H, key);
    }
    else if(strcmp(order, "extract") == 0) extractMax(H);
    else if(strcmp(order, "end") == 0) break;
  }
  return 0;
}



Measured memory_bytes: 17392
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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 l,r,d;cin>>l>>r>>d;
    int count=0;
    for(int i =1;i<=100;i++){

        if(i>=l&&i<=r&&i%d==0)count++;
    }
    cout<<count<<endl;

}

Measured memory_bytes: 3592
n=int(input())
l=[]
for _ in range(n-1):
  c,s,f=map(int,input().split())
  for i,t in enumerate(l):
    if t>s: t=-(-t//f)*f
    else: t=s
    l[i]=t+c
  l+=[s+c]
for i in l+[0]:
  print(i)

Measured memory_bytes: 9124
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
    long long N,K,tmp;
    cin >> N >> K;
    tmp = N%K;
    if(tmp>=K-tmp){
        cout << K-tmp << endl;
    }else{
        cout << tmp << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int INF = 10000;
int dfs(vector<int> d, int p){
  if (p == d.size()){
    return 0;
  }
  if (d[p] == 0){
    return dfs(d, p + 1);
  }
  int add = 10 - d[p];
  int n = d.size();
  int ans = INF;
  for (int i = p + 1; i <= n; i++){
    vector<int> d2 = d;
    for (int j = p; j < i; j++){
      d2[j] += add;
      d2[j] %= 10;
    }
    ans = min(ans, dfs(d2, p + 1) + 1);
  }
  return ans;
}
int main(){
  while (1){
    int k;
    cin >> k;
    if (k == 0){
      break;
    }
    vector<int> A(k, 0);
    for (int i = 0; i < k; i++){
      char c;
      cin >> c;
      A[i] = c - '0';
    }
    vector<int> B(k, 0);
    for (int i = 0; i < k; i++){
      char c;
      cin >> c;
      B[i] = c - '0';
    }
    vector<int> d(k);
    for (int i = 0; i < k; i++){
      d[i] = (B[i] - A[i] + 10) % 10;
    }
    cout << dfs(d, 0) << endl;
  }
}


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

int main()
{
  int n,w;
  cin>>n;
  cin>>w;
  if(n==0){
  cout<<"0"<<endl;
  return 0;
  }
  vector<unsigned long long> wt(n);
  vector<unsigned long long> val(n);
  int sumv=0;
  for(int i=0;i<n;i++){
    cin>>wt[i]>>val[i];
  }
  for(int x:val)
    sumv+=x;
  vector<unsigned long long> dp(sumv+1,1e18L);
  //min weight of value v
  dp[0]=0;
  //dp[1]=abs(v[1]-v[0]);
  for(int i=1;i<=n;i++)
  {
      for(int j=sumv;j>=0;j--)
      {
        if(val[i-1]<=j)
        dp[j]=min({dp[j],dp[j-val[i-1]]+wt[i-1]});
      }
  }
  int ans=0;
  for(int i=0;i<=sumv;i++)
  {
      if(dp[i]<=w)
      ans=max(ans,i);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main() {
    int N;

    std::cin >> N;

    int H;
    int max_height = 0, count = 0;
    for (int i = 0; i < N; i++) {
        std::cin >> H;
        if (max_height <= H) {
            count++;
            max_height = H;
        }
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d %d" @@ fun n l ->
  let apples = Array.init n @@ ( + ) l in
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 apples
  - Array.fold_left (fun acc a ->
    if abs acc <= abs a then acc else a) max_int apples

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
int N,M,n;
int main()
{
	scanf("%d",&N);
	for(n=1;n<=N;)
	{
		if(n*n<N)
			n++;
		else if(n*n==N)
		{
			printf("%d",N);
			break;
		}
		else if(n*n>N)
		{
			printf("%d",(n-1)*(n-1));
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B + C >= 22) {
		cout << "bust" << endl;
	} else {
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
// Aizu Vol-1 0101: Aizu PR
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define MAX  1000
char buf[MAX+20];
char *gets(char *);

#define HO "Hoshino"

int main()
{
	int i, n;
	char *p, *e;

	gets(buf), n = atoi(buf);
	for (i = 0; i < n; i++) {
		gets(p = buf); e = p + strlen(p);
		while (p < e) {
			if (*p == 'H' && !memcmp(p, HO, 7)) p += 6, *p++ = 'a';
			else p++;
		}
		puts(buf);
	}
	return 0;
}

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

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

    cin >> a >> b >> c;

    if((a < b) &&
       (a < c) &&
       (b < c))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

    return 0;
}



Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            if(65<=N&&N<= 90)
            {
                WriteLine(1);
            }
            else if (97 <= N && N <= 122)
            {
                WriteLine(2);
            }
            else
            {
                WriteLine(0);
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  if (a > 9 || b > 9) {
    cout << -1 << endl;
  } else {
    cout << a * b << endl;
  }
}

int main() {
  answer1();
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int N = 2e5 + 10;
 
int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int ans = (b - 1) / (a - 1);
  if ((b - 1) % (a - 1) != 0) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256