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

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

int main() {
    int X;
    cin >> X;
    if (X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define REP(i, n) for(int i = 0; (i) < (n); ++(i))
#define FOR(i, n) for(int i = 1; (i) <= (n); ++(i))
#define dump(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9 + 7;
// const lint LINF = 1e18;
const double eps = 0.000000001;  //もとの値の10^(-16)まで

using namespace std;

// typedef pair<int, int> P;
// priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
// cout << fixed << setprecision(10) << ans << endl;

signed main() {
  int a, b, x;
  double t;
  double ans;
  cin >> a >> b >> x;
  if(a * a * b < 2 * x) {
      x = a * a * b - x;
      t = (double)2.0 * x / a / a;
      ans = atan(t/a);
  } else {
    t = (double)2.0 * x / a / b;
    ans = atan(b/t);
  }
/*   cout << atan(1.0) << endl;
  cout << t/b << endl;
  cout << atan(1) << endl; */
  double ans2 = ans* 180 / acos(-1);
  cout << fixed << setprecision(10) << ans2 << endl;
  return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;

int main(){
    int N;
    cin >> N;
    vector<int> P(N),Q(N),R(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    rep(i,N) R[i] = i+1;

    int perm = 1;
    rep1(i,N) perm *= i;

    bool flag =true;
    int pnum = -1,qnum = -1;
    int cnt = 1;
    while(cnt <= perm){
        rep(i,N){
            if(P[i]!=R[i]) break;
            else if(i == N-1) pnum = cnt;
        }
        rep(i,N){
            if(Q[i]!=R[i]) break;
            else if(i == N-1) qnum = cnt;
        }
        next_permutation(R.begin(),R.end());
        cnt++;
    }

    cout << abs(pnum - qnum) ;
    //printf("%.15lf",ans);
    cout << endl;
    return 0;
}


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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    for ( int i = 0; i < K; i++ ) {
        vector<ll> ap(N+1);
        for ( int j = 0; j < N; j++ ) {
            ll k1 = max(j - A[j], 0LL), k2 = min(j + A[j], N-1);
            ap[k1]++;
            ap[k2+1]--;
        }
        for ( int j = 0; j < N; j++ ) {
            ap[j+1] += ap[j];
            A[j] = ap[j];
        }
        // for ( int j = 0; j < N; j++ ) {
        //     cout << A[j] << " ";
        // }
        // cout << "\n";
        bool ed = true;
        for ( int i = 0; i < N; i++ ) {
            if ( A[i] != N ) {
                ed = false;
                break;
            }
        }
        if ( ed ) break;
    }
   for ( int j = 0; j < N; j++ ) {
       if ( j > 0 ) cout << " ";
        cout << A[j];
    }
    cout << "\n";
    return 0;
}

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

Measured memory_bytes: 6424
/* ex4_2
   seira3 */

#include <stdio.h>
#include <math.h>

#define PI 3.141592653589793

int main(void){
    double lenA, lenB, hour, minute; //変数宣言
    scanf("%lf %lf %lf %lf",&lenA, &lenB, &hour, &minute); //入力
    double radA = (hour * 30 + minute * 0.5) * PI / 180; //12時のときの針と現在の短針のなす角(ラジアン)を宣言，代入
    double radB = minute * 6 *  PI / 180; //12時のときの針と現在の長針のなす角(ラジアン)を宣言，代入
    double diff = radA - radB; //短針と長針のなす角(ラジアン)を宣言，代入
    double ans = sqrt(lenA*lenA + lenB*lenB - 2*lenA*lenB*cos(diff)); //余弦定理より答えを宣言，代入(式変形はあたりまえ)
    printf("%-15.14lf\n",ans); //答えを出力
    return 0;
}

Measured memory_bytes: 2512
#include<iostream>
#include<vector>
#include<set>
#include<string>
typedef long long int lli;
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    vector<string> v;
    vector<string> v1;
    
   int a;
   int b;
   cin>>a;
  
   if(a%2!=0){
       b=(a/2)+1;
      double c= double(b);
       printf("%.9lf\n",c/a);
   }else{
       b=(a/2);
     double c= double (b);
       printf("%.9lf\n", c/a);
   }
    return 0;
}



Measured memory_bytes: 256
MOD = 10 **9 +7
 
N, K = [int(v) for v in raw_input().split()]
A = [int(v) for v in raw_input().split()]

inversions = 0
versions = 0
for i in range(N):
    for j in range(i+1, N):
        if A[i] > A[j]:
            inversions += 1
        if A[i] < A[j]:
            versions += 1



#print('Inversions =  {} '.format(inversions))
#print('Versions =  {} '.format(versions))
res = ((K + 1) * K)/2 * inversions + (K * (K-1))/2 * versions
res = res % MOD
print(res)

Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll x,n,lo=pow(10,16),res=0;
	cin>>x>>n;
	set<ll> s;
	for(ll i=0;i<n;i++){
		ll y;
		cin>>y;
		s.insert(y);
	}
	for(ll i=(-1000);i<=1000;i++)
	if(s.find(i)==s.end()&&abs(x-i)<lo){
		lo=abs(x-i);
		res=i;
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,l,r,sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d%d",&l,&r);
		sum+=r-l+1;
	}
	printf("%d\n",sum);
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P=pair<ll,ll>;
int main(){
  int n;
  int a[100000], b[100000];
  P v[100000];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    v[i] = P(a[i]+b[i], i);
  }
  sort(v, v+n,greater<P>());
  ll scorex = 0, scorey = 0;
  for(int i=0;i<n;i++){
    if(i%2 == 0) scorex += a[v[i].second];
    else scorey += b[v[i].second];
  }
  cout << scorex-scorey << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++){
    scanf("%d ",&a[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d ",&b[i]);
  }
  for(int i=0;i<n-1;i++){
    scanf("%d ",&c[i]);
  }
  int ans=b[a[0]-1];
  for(int i=1;i<n;i++){
    ans+=b[a[i]-1];
    if(a[i]==a[i-1]+1){
      ans+=c[a[i-1]-1];
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N, M;
  while(cin >>N >>M && N && M){
    int sum = 0;
    vector<int> v(N); REP(i, N) { cin >>v[i]; sum += v[i]; }
    SORT(v);
    REVERSE(v);
    for(int i = M - 1; i < N; i += M) sum -= v[i];
    cout <<sum <<endl;
  }
  return 0;
}

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


#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl


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

	int n; cin >> n;
	long double sumo = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (i % 2 != 0)
		{
			sumo++;
		}
	}
	printf("%.10Lf\n", sumo / n);
	return 0;
}

Measured memory_bytes: 3748
N,D = list(map(int, input().split()))
X = [[0]*D for _ in range(N)]
for j in range(N):
    x = list(map(int, input().split()))
    for i in range(D):
        X[j][i] = x[i]




count =0

for i in range(N):
    for j in range(i+1,N):
        n = 0
        for k in range(D):
            n += (X[i][k] - X[j][k])**2
        n_d = int(n**0.5)**2
        if n == n_d:
            count += 1
print(count)

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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> h(n), a(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  for (int i = 0; i < n; i++) cin >> a[i];

  vector<long long> bit(n + 1);
  auto query = [&](int i) {
    long long res = 0;
    while (i) {
      res = max(res, bit[i]);
      i -= i & -i;
    }
    return res;
  };
  auto modify = [&](int i, long long x) {
    while (i <= n) {
      bit[i] =max(bit[i], x);
      i += i & -i;
    }
  };

  vector<long long> dp(n);
  for (int i = 0; i < n; i++) {
    dp[i] = a[i] + query(h[i] - 1);
    modify(h[i], dp[i]);
  }
  cout << query(n) << '\n';
  return 0;
}

Measured memory_bytes: 4992
N=int(input())
A=sorted(list(map(int,input().split())))
dp=[True for i in range(A[-1])]
ans=0
i=0
j=-1
while i<N:
  if i+1<N:
    while A[i]==A[i+1]:
      i+=1
      if i+1==N:
        break
  if dp[A[i]-1] and i-j==1:
    ans+=1
  for k in range(2*A[i],A[-1]+1,A[i]):
    dp[k-1]=False
  j=i
  i+=1
print(ans)

Measured memory_bytes: 32240
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,m,c,res=0;
    cin>>n>>m>>c;
    vi b(m);
    for (int &i: b) cin>>i;
    while (n--){
        int sum=c;
        for (int i=0,a;i<m;i++){
            cin>>a;
            sum += a*b[i];
        }
        if (sum>0) res++;
    }
    cout << res << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3608
def main():
    N = int( input())
    Q = list( map( int, input().split()))
    P = [0]*N
    for i in range(N):
        P[Q[i]-1] = i+1
    A = [1]
    B = [1]
    for i in range(N-1):
        if P[i] < P[i+1]:
            A.append(A[-1] + P[i+1] - P[i] + 1)
        else:
            A.append(A[-1] + 1)
    for i in range(N-2,-1,-1):
        if P[i] > P[i+1]:
            B.append(B[-1] + P[i] - P[i+1] + 1)
        else:
            B.append(B[-1]+1)
    print(" ".join( map(str, A)))
    print(" ".join( map(str, B[::-1])))
if __name__ == '__main__':
    main()

Measured memory_bytes: 8116
#include <iostream>
#include <vector>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        cin >> x;
        v.push_back(x);
    }
    vector<int>::reverse_iterator rit = v.rbegin();
    cout << *rit; ++rit;
    for (; rit != v.rend(); ++rit) {
        cout << " " << *rit;
    }
    cout << "\n";
}

Measured memory_bytes: 3160
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,m,ans=0;
  cin >> n >> m;
  ans += (n*(n-1))/2;
  ans += (m*(m-1))/2;
  cout << ans << endl;
}


Measured memory_bytes: 768
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[200000];
long long cnt[200000];
int main(){
  int i;
  int k;
  long long res = 0;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
    }
  }
  for(i=(0);i<(N);i++){
    cnt[A[i]]++;
  }
  for(i=(0);i<(N);i++){
    res += cnt[i] * (cnt[i]-1) / 2;
  }
  for(k=(0);k<(N);k++){
    i = A[k];
    res -= cnt[i] * (cnt[i]-1) / 2;
    cnt[i]--;
    res += cnt[i] * (cnt[i]-1) / 2;
    wt_L(res);
    wt_L('\n');
    res -= cnt[i] * (cnt[i]-1) / 2;
    cnt[i]++;
    res += cnt[i] * (cnt[i]-1) / 2;
  }
  return 0;
}
// cLay varsion 20200321-1

// --- original code ---
// int N, A[2d5];
// ll cnt[2d5];
// {
//   int i, k;
//   ll res = 0;
//   rd(N,(A--)(N));
//   rep(i,N) cnt[A[i]]++;
//   rep(i,N) res += cnt[i] * (cnt[i]-1) / 2;
//   rep(k,N){
//     i = A[k];
//     res -= cnt[i] * (cnt[i]-1) / 2;
//     cnt[i]--;
//     res += cnt[i] * (cnt[i]-1) / 2;
//     wt(res);
//     res -= cnt[i] * (cnt[i]-1) / 2;
//     cnt[i]++;
//     res += cnt[i] * (cnt[i]-1) / 2;
//   }
// }


Measured memory_bytes: 6016
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())
Aa = A[:]
Aa.sort()
maxa = Aa[-1]
for i in range(N):
    if A[i] != maxa:
        print(maxa)
    else:
        print(Aa[-2])

Measured memory_bytes: 14140
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;

const int MAX_N = 200000;

ll cnt = 0ll;
int n;
ll K, a[MAX_N + 10], s[MAX_N + 10], b[MAX_N + 10], t[MAX_N + 10];

void merge_sort(ll* A, int x, int y, ll* T) {
    if (y - x > 1) {
        int m = x + (y - x) / 2;
        int p = x, q = m, i = x;
        merge_sort(A, x, m, T);
        merge_sort(A, m, y, T);
        while (p < m || q < y) {
            if (q >= y || (p < m && A[p] <= A[q])) T[i++] = A[p++];
            else { T[i++] = A[q++]; cnt += m - p; }
        }
        for (i = x; i < y; i++) A[i] = T[i];
    }
}

int main() {
    scanf("%d%lld", &n, &K);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        s[i] = a[i] + (i ? s[i - 1] : 0);
        b[i] = (i ? s[i - 1] : 0) - K * i;
    }
    b[n] = s[n - 1] - n * K;
    merge_sort(b, 0, n + 1, t);
    printf("%lld\n", (ll)n * (n + 1) / 2 - cnt);
    return 0;
}

Measured memory_bytes: 6400
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <utility>
#include <queue>
using namespace std;
using int64 = long long int;
const int64 INF = 1LL << 60;

int N, M, C;
vector< pair<int64, int64> > G[100010];
int64 dist[100010];

struct Elem {
  int64 cur, cost;
  Elem() {}
  Elem(int64 a, int64 b) : cur(a), cost(b) {}
  bool operator<(const Elem &e) const {
    return cost > e.cost;
  }
};

int main() {
  cin >> N >> M >> C;
  int64 cost_sum = 0;
  for(int i=0; i<M; i++) {
    int64 a, b, d; cin >> a >> b >> d;
    a--; b--;
    G[a].emplace_back(b, d);
    G[b].emplace_back(a, d);
    cost_sum += d;
  }

  
  priority_queue<Elem> que;
  fill(dist, dist + N, INF);
  dist[0] = 0;
  que.emplace(0, 0);
  while(que.size()) {
    auto e = que.top(); que.pop();
    if(dist[e.cur] < e.cost) continue;
    for(auto edge : G[e.cur]) {
      int64 to, mon; tie(to, mon) = edge;
      if(dist[to] > e.cost + mon) {
        dist[to] = e.cost + mon;
        que.emplace(to, dist[to]);
      }
    }
  }

  vector< pair<int64, int64> > info;
  for(int i=0; i<N; i++) {
    for(auto edge : G[i]) {
      int to, cost; tie(to, cost) = edge;
      int u = i, v = to;
      if(u > v) continue;

      int64 max_dist = max(dist[u], dist[v]);
      info.emplace_back(max_dist, cost);
    }
  }
  sort(info.begin(), info.end());

  int64 ans = cost_sum;
  for(size_t i=0; i<info.size(); i++) {
    int64 a, b; tie(a, b) = info[i];
    cost_sum -= b;
    int64 sum = a * C + cost_sum;
    // fprintf(stderr, "sum: %lld\n", sum);
    ans = min(ans, sum);
  }
  cout << ans << endl;

  /*  
  vector<int64> cand;
  for(int i=0; i<N; i++) {
    // fprintf(stderr, "dist[%d] = %lld\n", i, dist[i]);
    cand.push_back(dist[i]);
  }
  sort(cand.begin(), cand.end());
  cand.erase(unique(cand.begin(), cand.end()), cand.end());
  int L = cand.size();

  auto calc = [&](int idx) {
                int64 X = cand[idx];
                int64 sum = C * X;

                for(int i=0; i<N; i++) {
                  for(auto edge : G[i]) {
                    int64 to, cost; tie(to, cost) = edge;
                    int64 u = i, v = to;
                    if(u > v) continue;
                    if(!(dist[u] <= X and dist[v] <= X)) {
                      sum += cost;
                    }
                  }
                }

                return sum;
              };

  int ub = L-1, lb = -1;
  while(ub - lb > 1) {
    int mid = (ub + lb) / 2;
    int64 vl = calc(mid), vr = calc(mid + 1);
    if(vl < vr) ub = mid;
    else lb = mid;
  }
  cout << calc(ub) << endl;
  */
  return 0;
}



Measured memory_bytes: 21296
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int[] c = new int[26];
		Arrays.setAll(c, i -> sc.nextInt());
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++)
			Arrays.setAll(s[i], x -> sc.nextInt());
		int[] last = new int[26];
		int sat = 0;
		for(int d = 1; d <= D; d++) {
			int t = sc.nextInt()-1;
			last[t] = d;
			sat += s[d-1][t];
			for(int j = 0; j < 26; j++)
				sat -= c[j] * (d - last[j]);
			System.out.println(sat);
		}
		
	}

}


Measured memory_bytes: 47216
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//vvi(n, vector<int>(m, -1))
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()
#define out(x) cout << (x) << endl;

int main(){
  int a[3],i;
  rep(i, 3) cin >> a[i];
	
  sort(a, a+3);

  int sum = a[0] + a[1] + a[2];

  if(sum%2 == a[2]%2){
    cout << (a[2]*3 - sum)/2;
  }else{
    cout << ((a[2]+1)*3 - sum)/2; 
  }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  map<string, int> m;
  for (int i = 0; i < n; i++) {
    m[s[i]]++;
  }

  int maxx = 0;
  for (auto ms : m) {
    maxx = max(maxx, ms.second);
  }

  for (auto ms : m) {
    if (ms.second == maxx) {
      cout << ms.first << endl;
    }
  }

  return 0;
}

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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A, B;
    cin >> A >> B;

    int ans = (B-1) / (A-1);
    if((B-1)%(A-1) != 0) ans+= 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int k = sc.nextInt();
		int s = sc.nextInt();
		
		int res = 0;
		
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				int z = s-x-y;
				
				if(z >= 0 && z <= k &&  x+y+z==s) {
					res++;
				}
			}
		}
		out.println(res);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static int lcm(int a, int b) {
		return a / gcd(a, b) * b;
	}
	
	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21332
#include<iostream>
using namespace std;
int gcd(int x,int y){
int c=x%y;
if(c==0)return y;
return gcd(y,c);
}
int main(){
int a, b;
cin>>a>>b;
if(a<b){int c=a;a=b;b=c;}
cout<<gcd(a,b)<<endl;

}



Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;

#define ASC(a) a.begin(), a.end()		// 昇順ソート 例：sort(ASC(a));
#define DESC(a) a.rbegin(), a.rend()	// 降順ソート 例:sort(DESC(a));
#define rep(i, n) for(int i = 0; i < n; ++i)
//#define rep(i, a, n) for(int i = a; i < n; ++i)
#define Rep(i, n) for(int i = 1; i < n; ++i)
#define In(a) rep(i, n) cin>>a[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;
#define only_unique(vec) vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
#define souwa(vec) accumulate(ASC(vec), 0)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };


// ────────────────────────────────────────────────────

int main() {
	int x, a, b; cin >> x >> a >> b;
	if (b > x + a) cout << "dangerous" << endl;
	else if (b > a) cout << "safe" << endl;
	else cout << "delicious" << endl;
}


Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion

def factorialmod(n):
    ret = 1
    for i in range(1, n + 1):
        ret = (ret * i) % MOD
    return ret

N, M = ri_()
if N == M:
    print((2 * (factorialmod(N) ** 2)) % MOD)
elif N == M + 1 or N == M - 1:
    print((factorialmod(N) * factorialmod(M)) % MOD)
else:
    print(0)

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else if (a+b == c+d){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 768
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var t = new char[] { 'A', 'B', 'C' };
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var w = a.Max();
        var ans = t[2];
        if (w == a[0]) ans = t[0];
        else if (w == a[1]) ans = t[1];
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 18236
N = int(input())
S = [input() for i in range(N)]

alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans = []
for i in alphabet:
    tmp = 1000
    for j in range(N):
        count = S[j].count(i)
        if count < tmp:
            tmp = count
    for j in range(tmp):
        ans.append(i)
    
for i in range(len(ans)):
    print(ans[i],end="")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace testAtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b;
            //string temp = Console.ReadLine();
            string[] str = Console.ReadLine().Split();
            a = int.Parse(str[0]);
            string op = str[1];
            b = int.Parse(str[2]);

            if (op == "+")
            {
                Console.WriteLine(a + b);
            }
            else if (op == "-")
            {
                System.Console.WriteLine(a - b);
            }

            Console.ReadLine();
        }
    }
}


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())
int main(){
    int x;
    cin>>x;
    int ans=1;
    FOR(i,1,1000){
        FOR(j,2,1000){
            if (pow(i,j)<=x && pow(i,j)>ans){
                ans=pow(i,j);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.14159265359
int main(void){
    ll N=0;
    cin >>N;
    
     vector<ll> vec(N);
     
    for (ll i = 0; i < N-1; i++) {
        ll a=0;
        cin >> a;
        vec.at(a-1)++;
    }
    
    
    
    for (ll i = 0; i < N; i++) {
        cout << vec.at(i) <<endl;
    }
    
}

Measured memory_bytes: 4848
N, M = gets.split(' ').map(&:to_i)
ab = Hash.new()
M.times do
  a, b = gets.split(' ').map(&:to_i)
  ab[a] ||= []
  ab[a] << b
end

ans = 'IMPOSSIBLE'
ab[1].each do |to|
  next if ab[to] == nil

  ab[to].each do |t|
    if t == N
      ans = 'POSSIBLE'
      break
    end
  end
end

print ans

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> a(n, false);
  for(int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for(int j = 0; j < d; j++) {
      int aa;
      cin >> aa;
      a.at(aa - 1) = true;
    }
  }
  int count = 0;
  for(int i = 0; i < n; i++) {
    if(!a.at(i)) {
	  count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3628
def main():
	N = int(input())
	A = list(map(int, input().split()))
	DIV = 10**9+7
	ans = 0
	lie = False
	count = [0]*N
	odd = N % 2 == 1
	for i in range(N):
		if A[i] > N-1:
			lie = True
			break
		if (A[i]%2 == 0) ^ odd:
			lie = True
			break
		count[A[i]] += 1
		if count[A[i]] > 2:
			lie = True
			break

	if odd and count[0] != 1:
		lie = True
	if not(odd) and count[0] > 0:
		lie = True

	if lie:
		print(0)
	else:
		print((2**(N//2))%DIV)


if __name__ == '__main__':
	main()

Measured memory_bytes: 14008
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=50000+10,maxm=20+10;
int n,m;
int d[maxm],f[maxn];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		cin>>d[i];
	memset(f,0x3f,sizeof(f));
	f[0]=0,f[1]=1;
	for(int i=1;i<=m;i++)
		for(int j=0;j<=n;j++)
			if(j-d[i]>=0)
				f[j]=min(f[j],f[j-d[i]]+1);
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 1368
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>
#include <climits>

using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const i64 INFL = (1LL<<62);
const i64 MOD = 1000000007;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> i64 mod_pow(i64 a, i64 n, T mod) { mod=(i64)mod; i64 res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
void print() { std::cout << std::endl; }
template <typename T, typename... A> void print(const T& first, const A&... rest) { cout << sizeof...(rest) << endl; std::cout << first; if (sizeof...(rest)) std::cout << " "; print(rest...); }
template <typename... A> void print(const A&... rest) { print(rest...); }
template <typename A> void print(const std::vector<A>& v) { std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; }); std::cout << std::endl; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    // vector<int> d(m);
    // vector<int> c(m);
    vector<pair<i64, i64>> dc;
    i64 digitsum = 0;
    i64 ketasu = 0;
    rep(i, m){
        i64 b, c;
        cin >> b >> c;
        dc.push_back({b, c});
        digitsum += (b * c);
        ketasu += c;
    }
    cout << (digitsum) / 9 + ketasu - 1 + (digitsum % 9 == 0 ? -1 : 0) << endl;    

    return 0;
}


Measured memory_bytes: 6256
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(f, x, ...) ([&](decltype((x)) c) { return (f)(begin(c), end(c), ## __VA_ARGS__); })(x)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template <typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template <typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }
inline int lg(int x) { return 63 - __builtin_clzll(static_cast<unsigned int>(x)); }

class segment_tree {
  vector<int> xs;
public:
  segment_tree(int n) : xs(1 << (lg(2 * n - 1) + 1)) {}
  segment_tree(int n, function<int(int)> f) : segment_tree(n) {
    const int m = ::size(xs);
    dotimes(i, n)
      xs[m/2+i] = f(i);
    for (int i = m/2 - 1; i >= 1; i--)
      xs[i] = min(xs[2*i], xs[2*i+1]);
  }
  int query(const int i, const int j) {
    function<int(int, int, int)> rec;
    rec =
      [&](int k, int a, int b) {
        if (i <= a && b <= j)
          return xs[k];
        int c = a + (b - a) / 2;
        return j <= c ? rec(2*k, a, c) : c <= i ? rec(2*k+1, c, b) : min(rec(2*k, a, c), rec(2*k+1, c, b));
      };
    return rec(1, 0, ::size(xs)/2);
  }
};

signed main() {
  const int N = rint();
  const int x = rint();
  segment_tree st(N, [](int i) { return rint(); });
  int r = 1e9 * N;
  dotimes(t, N) {
    int s = 0;
    dotimes(i, N) {
      int j = i + t + 1;
      s += j > N ? min(st.query(i, N), st.query(0, j - N)) : st.query(i, j);
    }
    mins(r, s + t * x);
  }
  wint(r);
  return 0;
}


Measured memory_bytes: 3244
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
        mut a:[i64;n],
    }
    let mut asum = vec![0; n + 1];
    for i in 0..n {
        asum[i + 1] = asum[i] + a[i];
    }
    let mut mp = BTreeMap::new();
    for &x in asum.iter() {
        *mp.entry(x).or_insert(0) += 1;
    }
    let mut ans = 0i64;
    for (key, value) in mp {
        ans += value * (value - 1) / 2;
    }
    println!("{}", ans);
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  set<ll>se;
  rep(i,0,n){
    ll a;cin>>a;
    se.insert(a);
  }

  ll q;cin>>q;
  ll ans=0;
  rep(i,0,q){
    ll b;cin>>b;
    if(se.find(b)!=se.end())ans++;
  }

  out(ans);

  return 0;
}



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

int main(){
  ll N,M;cin >> N >> M;
  ll Mhalf = M/2;
  ll ans = min(Mhalf,N);
  N -= ans;
  M -= ans*2;
  ans += M/4;
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string s;
    cin >> s;
    if(s=="ARC"){
        cout << "ABC" <<endl;
    }else{
        cout << "ARC" <<endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
ll N,M;
ll x[100010], y[100010];
vector<ll> tree[100010];
ll h[100010] = {}; 
ll d[100010] = {};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i,0,M){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        tree[x[i]].push_back(y[i]);
        h[y[i]]++;
    }
    stack<ll> st;
    rep(i,0,N){
        if(h[i] == 0){
            st.push(i);
        }
    }
    vector<ll> ans;
    while(st.size()){
        ll k = st.top();
        st.pop();
        ans.push_back(k);
        for(auto &e: tree[k]){
            h[e]--;
            if(h[e] == 0) st.push(e);
        }
    }
    rep(i,0,N){
        ll v = ans[i];
        for(auto &e : tree[v]){
            d[e] = max(d[e], d[v] + 1);
        }
    }
    ll val = 0;
    rep(i,0,N){
        val = max(val, d[i]);
    }
    print(val);

}


Measured memory_bytes: 9716
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  ll N, C, K; cin >> N >> C >> K;
  vector<ll> T(N); REP(i, N) cin >> T[i];

  sort(ALL(T));

  ll t = T[0], cnt = 0, ans = 1;
  for (int i = 0; i < N; ++i) {
    cnt++;
    if (T[i]-t > K || cnt > C) {
      t = T[i];
      cnt = 1;
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

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

  ll ans;
  if (A <= 9 && B <= 9)
    ans = A * B;
  else
    ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.*;
import java.util.InputMismatchException;

public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = in.nextInt();

        int ans = n*800 - n/15*200;

        out.println(ans);
		out.flush();

	}

	// ----------------------

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int next() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public char nextChar() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
				return (char) c;
			}
			throw new InputMismatchException();
		}

		public String nextToken() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = next();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public int nextInt() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = next();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c-'0';
				c = next();
			} while (!isSpaceChar(c));
			return res*sgn;
		}

		public long nextLong() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = next();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c-'0';
				c = next();
			} while (!isSpaceChar(c));
			return res*sgn;
		}

		public double nextDouble() {
			return Double.valueOf(nextToken());
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		//public interface SpaceCharFilter {
		//	public boolean isSpaceChar(int ch);
		//}
	}
	// template
	static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r);  }
	static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r);  }

	static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t;  }
	static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t;  }
}


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

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)
using namespace std;
using ll = long long;
using P = pair<ll, int>;

void Main() {
  int n;
	cin >> n;
  vector<int> A(n);
  vector<P> ord;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
    ord.emplace_back(A[i], i);
	}

  ll ans = 0;
  vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
	sort(ord.begin(), ord.end(), greater<P>());
  rep(i, n+1) REP(j, 0, n+1-i) {
    if (i==0 && j==0) continue;
    auto const [a, pos] = ord[i+j-1];
    if (i>0) dp[i][j] = max(dp[i][j], dp[i-1][j] + a*abs(pos - i + 1));
    if (j>0) dp[i][j] = max(dp[i][j], dp[i][j-1] + a*abs(n - j - pos));
    ans = max(ans, dp[i][j]);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 34620
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        int n = sc.nextInt();
        String x = sc.next();
        if (n == 1) {
            if ("0".equals(x)) {
                pw.println(1);
                return;
            } else {
                pw.println(0);
                return;
            }
        }
        int totalOne = 0;
        for (int i = 0; i < n; i++) {
            totalOne += x.charAt(i) == '1' ? 1 : 0;
        }
        long[] totalOneMinus1 = new long[n + 1];
        long[] totalOnePlus1 = new long[n + 1];
        totalOneMinus1[0] = totalOnePlus1[0] = 1;
        for (int i = 1; i < n; i++) {
            if (totalOne > 1) {
                totalOneMinus1[i] = totalOneMinus1[i - 1] * 2L % (totalOne - 1);
            }
            totalOnePlus1[i] = totalOnePlus1[i - 1] * 2L % (totalOne + 1);
        }

        long remainderMinus1 = 0;
        long remainderPlus1 = 0;
        for (int i = 0; i < n; i++) {
            int index = n - 1 - i;
            if (x.charAt(index) == '1') {
                if (totalOne > 1) {
                    remainderMinus1 = (remainderMinus1 + totalOneMinus1[i]) % (totalOne - 1);
                }
                remainderPlus1 = (remainderPlus1 + totalOnePlus1[i]) % (totalOne + 1);
            }
        }

        for (int i = n - 1; i >= 0; i--) {
            int index = n - 1 - i;
            // 1 -> 0
            long total;
            long result = -1;
            if (x.charAt(index) == '1') {
                if (totalOne <= 1) {
                    result = 0;
                } else {
                    total = (remainderMinus1 - totalOneMinus1[i] + (totalOne - 1)) % (totalOne - 1);
                    result = func(total) + 1;
                }
            } else {
                total = (remainderPlus1 + totalOnePlus1[i] + (totalOne + 1)) % (totalOne + 1);
                result = func(total) + 1;
            }
            pw.println(result);
        }
    }

    private long func(long total) {
        if (total == 0) {
            return 0;
        }
        return 1 + func(total % Long.bitCount(total));
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


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

int main()
{
    int n;
    int x=0;
    int max1=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='I')
        {
            x++;
            if(x>max1)
            {
                max1=x;
            }
        }
        else if(s[i]=='D')
        {
            x--;
            if(x>max1)
            {
                max1=x;
            }
        }
    }
        cout<<max1;


    return 0;

}


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

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

    sort(X.begin(),X.end());
    int l = X.at(N/2);
    int r = X.at(N/2+1);

    for(int i=0; i<N; i++){
        if(A.at(i) >= r ){
            cout << l << endl;
        }else{
            cout << r << endl;
        }
    }
    
}

Measured memory_bytes: 5004