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

template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }

    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }

    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;

constexpr int MAX_FACTORIAL = 202020;

mint fact[MAX_FACTORIAL];
mint factinv[MAX_FACTORIAL];

void init() {
    fact[0] = 1;
    for (int i = 1; i < MAX_FACTORIAL; i++) {
        fact[i] = fact[i - 1] * i;
    }
    factinv[MAX_FACTORIAL - 1] = fact[MAX_FACTORIAL - 1].inv();
    for (int i = MAX_FACTORIAL - 2; i >= 0; i--) {
        factinv[i] = factinv[i + 1] * (i + 1);
    }
    assert(factinv[0] == 1);
}

mint ncr(int n, int r) { return fact[n] * factinv[r] * factinv[n - r]; }
mint nhr(int n, int r) { return ncr(n + r - 1, n - 1); }

int main() {
    init();
    int n, k;
    cin >> n >> k;
    mint ans = 0;
    for (int i = 0; i <= min(k, n - 1); i++) {
        ans += ncr(n, i) * nhr(n - i, i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
N = int(input())
D = {}
for i in range(N):
  S = input()
  if S in D:
    D[S] += 1
  else:
    D[S] = 1

D_sorted = sorted(D.items(), key=lambda x:x[0])
D_sorted = sorted(D_sorted, key=lambda x:x[1], reverse=True)

top = D_sorted[0][1]
for k in D_sorted:
  if top == k[1]:
    print(k[0])
  else:
    exit()


Measured memory_bytes: 46684
using System;
using System.Linq;
public class Hello{
    public static void Main()
    {
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        int Alice = 0;
        int Bob = 0;
        Array.Sort(a);
        Array.Reverse(a);
        
        for(int i = 0; i < N; i++)
        {
            if(i % 2 == 0)
            {
                Alice += a[i];
            }
            else
            {
                Bob += a[i];
            }
            
        }
        
        Console.WriteLine(Alice - Bob);
        
        
    }
}


Measured memory_bytes: 13396
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

lint powmod(lint a,lint b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}

int main(void){
    int K;
    cin >> K;
    rep(i,K) cout << "ACL";
    cout << endl;
}

Measured memory_bytes: 3616
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;
//use ac_library_rs::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        dd: [[usize; 2]; n],
    }

    let mut count = 0;
    for d in dd {
        if d[0] == d[1] {
            count += 1;
        } else {
            count = 0;
        }
        if count == 3 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2200
MOD=10**9+7
S=input()
N=len(S)
if N==1:
  if S=='?' or int(S)==5:
    print(1)
  else:
    print(0)
  exit()

if S[0]=='?':
  x=[1]*10+[0]*3
else:
  x=[0]*13
  x[int(S[0])]=1

for i in range(1, N):
  if S[i]=='?':
    tmp=sum(x)
    x=[
      tmp-x[4]-x[8]-x[12],
      tmp-x[3]-x[8]-x[12],
      tmp-x[3]-x[7]-x[12],
      tmp-x[3]-x[7]-x[11],
      tmp-x[2]-x[7]-x[11],
      tmp-x[2]-x[6]-x[11],
      tmp-x[2]-x[6]-x[10],
      tmp-x[1]-x[6]-x[10],
      tmp-x[1]-x[5]-x[10],
      tmp-x[1]-x[5]-x[9],
      tmp-x[0]-x[5]-x[9],
      tmp-x[0]-x[4]-x[9],
      tmp-x[0]-x[4]-x[8]
    ]
  elif S[i]=='0':
    x=[x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6], x[10], x[1], x[5], x[9]]
  elif S[i]=='1':
    x=[x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6], x[10], x[1], x[5]]
  elif S[i]=='2':
    x=[x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6], x[10], x[1]]
  elif S[i]=='3':
    x=[x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6], x[10]]
  elif S[i]=='4':
    x=[x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6]]
  elif S[i]=='5':
    x=[x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2]]
  elif S[i]=='6':
    x=[x[2], x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11]]
  elif S[i]=='7':
    x=[x[11], x[2], x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7]]
  elif S[i]=='8':
    x=[x[7], x[11], x[2], x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3]]
  elif S[i]=='9':
    x=[x[3], x[7], x[11], x[2], x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12]]
    
  x=[x[j]%MOD for j in range(13)]

print(x[5])

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);
  
  int M;
  cin >> M;
  vector<string> T(M);
  for (int i = 0; i < M; i++) cin >> T.at(i);
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int X = 0;
    for (int j = 0; j < N; j++) {
      if (S.at(j) == S.at(i)) X++;
    }
    for (int j = 0; j < M; j++) {
      if (T.at(j) == S.at(i)) X--;
    }
    ans = max(ans, X);
  }
  
  cout << ans << endl;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            int k = cin.ReadInt;

            long sum = k;
            for (int i = 1; i < n; i++)
                sum = (k - 1) * sum;

            Console.WriteLine(sum);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

using namespace std;

int main ()
{
    long long N;
    int mod;
    string res;
    cin >> N;
    
    for (int i=1;N>0;i++)
    {
        if (N <= pow((long long)26,(long long)i))
        {
            N -= 1;
            REPJ(i)
            {
                mod = N % 26;
                res.push_back ('a' + mod);
                N /= 26;
            }
        }
        N -= pow((long long) 26,(long long)i);
    }
    
    reverse (res.begin (), res.end ());
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4060
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
#define int long long

void solve() {
	int n; cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    int ans = 0;
    rep(i, n) {
        rep(j, n) {
            if(i == j) continue;
            ans += d[i] * d[j];
        }
    }
    cout << ans / 2 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,n);
  VEC(int,d,n);

  sort(ALL(d));
  int lb=d[0], ub=d.back();
  int ans = 0;
  FOR(i,lb,ub+1){
    if ((lower_bound(ALL(d), i) - d.begin()) == n/2) ++ans;
  }
  OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 1024
grid = []
for i in range(3):
    grid.append(list(map(int,input().split())))
for i in range(101):
    a1 = i
    b = [grid[0][0]-a1, grid[0][1]-a1, grid[0][2]-a1]
    flag = True
    for j in range(1,3):
        for k in range(2):
            if grid[j][k] - b[k] != grid[j][k+1] - b[k+1]:
                flag = False
    if flag:
        print("Yes")
        exit()
print("No")



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

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  int c = 1, l = 0;
  {
    int v = 1;
    while (ord[v] == -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }

  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}


Measured memory_bytes: 5864
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,m,a[100000][2],b=1,c=0;
    cin>>n>>m;
    c=n;
    for(int i=0;i<m;i++){
        cin>>a[i][0]>>a[i][1];
        if(b<a[i][0]){
            b=a[i][0];
        }
        if(c>a[i][1]){
            c=a[i][1];
        }
    }
    if(c>=b){
     cout<<c-b+1;
        
    }
    else{
        cout<<0;
    }
}


Measured memory_bytes: 1024
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dh[]={1,-1,0,0};
int dw[]={0,0,1,-1};
//mleしなければぜんぶllでかく。

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      ll n,m;
      cin>>n>>m;
      ll x[m];
      rep0(i,m) cin>>x[i];
      sort(x,x+m);
      ll diff[m-1];
      rep0(i,m-1) diff[i]=x[i+1]-x[i];
      sort(diff,diff+(m-1));
      reverse(diff,diff+(m-1));
      ll s=x[m-1]-x[0];
      if(n>=m){
            cout<<0<<endl;
      }
      else{
            rep0(i,n-1) s-=diff[i];
            cout<<s<<endl;
      }
      return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    v_ll a(n+1);
    irep2(i, 1, n) {
        for(int j = i; j <= n; j+=i) {
            a[j]++;
        }
    }
    
    ll ans = 0;
    irep2(i, 1, n) {
        ans += i*a[i];
    }
    cout << ans << endl;
    return 0;
}


/*atcoder*/


Measured memory_bytes: 81380
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  lld h, w, b = 0, d[50][50];
  char s[50][50];
  queue<tuple<lld, lld, lld>> q;
  cin >> h >> w;
  for (lld i = 0; i < h; i++) {
    cin.ignore(1);
    for (lld j = 0; j < w; j++) {
      cin >> s[j][i];
      b += s[j][i] == '#';
      d[j][i] = -1;
    }
  }

  q.push(make_tuple(0, 0, 1));
  while (!q.empty()) {
    auto next = q.front();
    lld x, y, p;
    tie(x, y, p) = next;
    q.pop();
    if (d[x][y] != -1) {
      continue;
    }
    d[x][y] = p;
    if (x > 0 && d[x - 1][y] == -1 && s[x - 1][y] != '#') q.push(make_tuple(x - 1, y, p + 1));
    if (y > 0 && d[x][y - 1] == -1 && s[x][y - 1] != '#') q.push(make_tuple(x, y - 1, p + 1));
    if (x < w - 1 && d[x + 1][y] == -1 && s[x + 1][y] != '#') q.push(make_tuple(x + 1, y, p + 1));
    if (y < h - 1 && d[x][y + 1] == -1 && s[x][y + 1] != '#') q.push(make_tuple(x, y + 1, p + 1));
  }
  
  cout << (d[w - 1][h - 1] == -1 ? -1 : h * w - b - d[w - 1][h - 1]) << "\n";
}

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

using namespace std;
#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int MOD = 1000000007;
constexpr int SIZE = 100100;

void solve() {
    int a, p;
    cin >> a >> p;

    cout << (a * 3 + p) / 2 << endl;
}

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


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())
    if A < 10 and B < 10:
        print(A * B)
    else:
        print(-1)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <queue>
#define llint long long

using namespace std;

void z_algorithm(string &s, int z[])
{
	z[0] = s.size();
	
	int x = 0, y = 0;
	for(int i = 1; i < s.size(); i++){
		if(i > y){
			z[i] = 0;
			for(int j = 0; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
		else if(i + z[i-x] <= y) z[i] = z[i-x];
		else{
			z[i] = y-i+1;
			for(int j = y-i+1; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
	}
}

llint n;
string s;
int z[5005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	cin >> s;
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		z_algorithm(s, z);
		for(int j = 0; j < s.size(); j++){
			ans = max(ans, min(z[j], j));
		}
		s = s.substr(1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(void)
{
  int y,m,d;
  scanf("%d/%d/%d",&y,&m,&d);
  
  if(y > 2019) {
    printf("TBD\n");
  } else if(y < 2019) {  
    printf("Heisei\n");
  } else {
    
    if(m > 4) {
      printf("TBD\n");
    } else if(m <= 4) {
      printf("Heisei\n");
    }
  
  }
  
  return 0;
}



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

using namespace std;

int main ()
{
  int N,M,a[100000],acount=0;
  int r1,r2,res[3];

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

  cin >> N >> M;
  for (int i=0;i<M;i++)
  {
    scanf("%d",&a[i]);
  }
  
  res[0] = 1;
  
  res[1] = 1;
  if (a[acount] == 1)
  {
    res[1] = 0;
    acount++;
  }
    

  for (int i=2;i<=N;i++)
  {
    if (a[acount] == i)
    {
      res[i%3] = 0;
      acount++;
    }else
    {      
      res[i%3] = (res[(i-1)%3] + res[(i-2)%3])% 1000000007 ;
    } 
  }

  printf("%d\n",res[N%3]);

  return 0; 
}

Measured memory_bytes: 640
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<char, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    int k;
    cin >> s >> k;

    vector<P> l;
    rep(i, SZ(s)){
        if(l.empty() || l.back().first != s[i]){
            l.emplace_back(s[i], 0);
        }
        l.back().second++;
    }

    if(SZ(l) == 1){
        cout << l[0].second * k / 2 << endl;
        return 0;
    }

    int ans = 0;
    ans += l[0].second / 2 + l.back().second / 2;
    for(int i = 1; i < SZ(l) - 1; i++){
        ans += l[i].second / 2 * k;
    }
    if(l[0].first == l.back().first){
        ans += (l[0].second + l.back().second) / 2 * (k - 1);
    }else{
        ans += (l[0].second / 2 + l.back().second / 2) * (k - 1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String[] ss =s.split("",0);
    int max=0,index=0;
    for (String value : ss) {
      if (value.equals("A") || value.equals("C") || value.equals("G") || value.equals("T")) {
        index++;
        max = Math.max(max, index);
      } else {
        max = Math.max(max, index);
        index = 0;
      }

    }
    System.out.println(max);
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>

#define INF 1000000000


using namespace std; 

int search(set<int> perm, vector<vector<int> > dist, int last){
    int total = INF;
    if(perm.size() == 0){
        return 0;
    }
    for(auto it = perm.begin();it != perm.end();it++){
        cerr << *it << endl;
        if(last == -1){
            int start = *it;
            set<int> settemp = perm;
            settemp.erase(*it);
            int temp = search(settemp,dist,start);
            total = min(total,temp);
        }else{
            int start = *it;
            set<int> settemp = perm;
            settemp.erase(*it);
            int temp = search(settemp,dist,start) + dist[last][start];
            total = min(total,temp);
        }
    }
    return total;
}

int main(){
    
    int N,M,R;
    cin >> N >> M >> R;
    vector<int> rlist;
    vector<vector<int> > edge(N,vector<int>(N,INF));
    vector<vector<int> > dist(R,vector<int>(R,0));
    for(int i = 0;i < R;i++){
        int temp;
        cin >> temp;
        temp--;
        rlist.push_back(temp);
    }
    sort(rlist.begin(),rlist.end());
    for(int i = 0;i < M;i++){
        int A,B,C;
        cin >> A >> B >> C;
        edge[A-1][B-1] = C;
        edge[B-1][A-1] = C;
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
               if(edge[i][j] > edge[i][k] + edge[k][j]){
                    edge[i][j] = edge[i][k] + edge[k][j];
               } 
            }
        }
    }
    cerr << "WF end" << endl;
    set<int> perm;
    for(int i=0;i<R;i++){
        perm.insert(i);
        for(int j=0;j<R;j++){
            dist[i][j] = edge[rlist[i]][rlist[j]];
            dist[j][i] = edge[rlist[j]][rlist[i]];
        }
    }
    cerr << "dist end" << endl;
    
    cout << search(perm,dist,-1) << endl;
}


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

vector<long> ans;
long n;

int check(long x)
{
    if (x>n)
    {
        return 0;
    }
    
    int flag[] = {0,0,0};
    int temp;
    while(x!=0)
    {
        temp = x%10;
        if (temp==3)
        {
            flag[0] = 1;
        }else if (temp==5)
        {
            flag[1] = 1;
        }else if (temp==7)
        {
            flag[2] =1;
        }
        x = x/10;
    }
    int sum = 0;
    rep(i,3)
    {
        sum +=flag[i];
    }

    if (sum==3)
    {
        return 1;
    }else
    {
        return 0;
    }
    
    
}
void dfs(long x)
{
    if (check(x))
    {
        ans.push_back(x);
    }
    if (x<n)
    {
        dfs(x * 10 + 3);
        dfs(x * 10 + 5);
        dfs(x * 10 + 7);
    }
}
 
int main()
{
    cin >> n;
    dfs(0);
    cout << sz(ans)<< endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define N 11
#define H (1e18)
#define W 76
using namespace std;
typedef pair<int,int> P;
const int INF = 1LL<<55;
const int mod = (1e9)+9;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
typedef vector<int> vec;
typedef vector<vec> mat;
int w,h,n;

mat mul(mat a,mat b){
  mat res(w,vec(w,0));
  for(int i=0;i<w;i++)
    for(int j=0;j<w;j++)
      for(int k=0;k<w;k++) res[i][j] = (res[i][j] + a[i][k]*b[k][j]%mod)%mod;
  
  return res;
}

vec calc(mat a,vec b){
  vec res(w,0);
  for(int i=0;i<w;i++)
    for(int j=0;j<w;j++) res[i] = (res[i] + b[j]*a[j][i]%mod)%mod;
  return res;
}

mat doubling(mat x,int y){
  mat res(w,vec(w,0));
  for(int i=0;i<w;i++) res[i][i] = 1;
  
  while(y){
    if(y%2) res = mul(res,x);
    y/=2;
    x = mul(x,x);
  }
  return res;
}


signed main(){
  int t = 0;
  while(1){
    cin>>w>>h>>n;
    if(w == 0 && h == 0 && n == 0) break;
    priority_queue <P,vector<P>,greater<P> > ng;
    int flg = 0 ;
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;   x--,y--;
      flg |= (x == w-1) && (y == h-1);
      flg |= (x == 0) && (y == 0);
      if(y >= h) i--,n--;
      else if(y == 0) i--,n--;
      else ng.push(P(y,x));
    }
    ng.push(P(h-1,0));
    
    vector<int> ans(w,0);   ans[0] = flg == 0;
    int height = 0;
    while(!ng.empty()){
      mat num(w,vec(w,0));
      for(int i=0;i<w;i++)
        for(int j=i-1;j<=i+1;j++)if(j>=0 && j<w) num[i][j] = 1;

      int nheight = ng.top().first;
      int d = nheight - height;
      num = doubling(num,d);
      ans = calc(num,ans);
      height = nheight;

      while(!ng.empty() && nheight == ng.top().first) {
        ans[ng.top().second] = 0; ng.pop();
      }
 
    }
    assert(height == h-1);
    cout<<"Case "<<++t<<": "<<ans[w-1]<<endl;
  
  }
  return 0;
}

Measured memory_bytes: 3192
import java.util.*;
public class Main {
	void doIt(){
		Scanner sc = new Scanner(System.in);
		Person pa[][] = new Person[3][8];
		Person pa1[] = new Person[24];
		int cnt = 0;
		for(int i = 0;i < 3;i++){
			for(int k = 0;k < 8;k++){
				pa[i][k] = new Person(sc.nextInt(), sc.nextDouble(), true);
			}
			Arrays.sort(pa[i]);
			pa[i][0].flag = false;
			pa[i][1].flag = false;
			System.out.println(pa[i][0].number + " " + pa[i][0].time);
			System.out.println(pa[i][1].number + " " + pa[i][1].time);
			for(int k = 0;k < 8;k++){
				pa1[i * 8 + k] = pa[i][k];
			}
		}
		Arrays.sort(pa1);
		for(int i = 0;i < 24;i++){
			if(pa1[i].flag == true){
				System.out.println(pa1[i].number + " " + pa1[i].time);
				cnt++;		
			}
			if(cnt == 2) break;
		}
	}
	public static void main(String args[]){
		new Main().doIt();
	}
	class Person implements Comparable<Person>{ 
		int number;
		Double time;
		boolean flag;
		Person(int number, double time, boolean flag){
			this.number = number;
			this.time = time;
			this.flag = flag;
		}
		@Override
		public int compareTo(Person p){
			return time.compareTo(p.time);
		}
	}
}

Measured memory_bytes: 28236
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  int l = -1, r = -1;
  rep(i, n - 2) {
    if(s[i] == s[i + 1] || s[i + 1] == s[i + 2] || s[i + 2] == s[i]) l = i, r = i + 2;
  }
  rep(i, n - 1) {
    if(s[i] == s[i + 1]) l = i, r = i + 1;
  }
  if(l == -1) cout << l << " " << r << endl;
  else cout << l + 1 << " " << r + 1 << endl;
}

Measured memory_bytes: 512
import java.util.*;
class Main {
    static int N;
    static int[] a,b,c;
    static int[] w;
    static int score;
    static int[] dict;
    static int index;
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		a = new int[N-1];
		b = new int[N-1];
		c = new int[N];
		for(int i = 0; i<N-1; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for(int i = 0; i<N; i++) {
			c[i] = sc.nextInt();
		}

		Arrays.sort(c);

		dict = new int[N+1];
		w = new int[N+1];
		for(int i = 0; i<N+1; i++) {
			dict[i] = 1;
		}

//		dict[1] = -1;
//		w[1] = c[N-1];
		score = 0;
		index = N-1;
		dfs(1);

		for(int i = 0; i<N-1; i++) {
			score += Math.min(w[a[i]],w[b[i]]);
		}
		System.out.println(score);
		for(int i = 1; i<N+1; i++) {
			System.out.print(w[i] + " ");
		}
		System.out.println();
    }


	public static void dfs(int next) {
		if(next == -1) return;
		if(index <= -1) return;
		w[next] = c[index];
		//System.out.println(w[next]);
		index--;
		int nextnext = getNext(next);
		//System.out.println("i " + index + " next " + next + " nextnext " + nextnext);
		while(nextnext != -1) {
			dfs(nextnext);
			nextnext = getNext(next);
		}
	}

    public static int getNext(int pre) {
		for(int i = 0; i<N-1; i++) {
			if(a[i] == pre && dict[b[i]] != -1)  {
				dict[a[i]] = -1;
				dict[b[i]] = -1;
				return b[i];
			}
			if(b[i] == pre && dict[a[i]] != -1)  {
				dict[a[i]] = -1;
				dict[b[i]] = -1;
						return a[i];
					}
		}
		return -1;
    }
}

Measured memory_bytes: 43452
n, t = map(int, input().split(" "))

a = map(int, input().split(" "))

INF = 1000000000000

max_price = -1
min_price = -1

min_pos = 1
max_pos = 1
max_diff = 0
tmp = INF
ans = 0

for c in a:
    if max_price < 0 or min_price < 0:
        max_price = c
        min_price = c
        continue

    if max_price == c:
        max_pos += 1
        tmp = min(tmp, min_pos, max_pos)

    if min_price == c:
        min_pos += 1

    if max_price < c:
        max_price = c
        max_pos = 1

        if max_diff == max_price - min_price:
            tmp = min(tmp, min_pos, max_pos)

        elif max_diff < max_price - min_price:
            max_diff = max_price - min_price
            ans = 0
            tmp = min(tmp, min_pos, max_pos)

    if min_price > c:
        min_price = c
        max_price = c
        min_pos = 1
        ans += (tmp if tmp < INF else 0)
        tmp = INF

if tmp < INF:
    ans += tmp

print(ans)


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


int main() {
    int n, l;
    cin >> n >> l;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        vec.at(i) = l + i;
    }

    if (l >= 0) {
        cout << accumulate(vec.begin(), vec.end(), 0) - vec.at(0) << endl;
        return 0;
    }

    if (l + n - 1 >= 0) {
        cout << accumulate(vec.begin(), vec.end(), 0) << endl;
        return 0;
    } 

    cout << accumulate(vec.begin(), vec.end(), 0) - vec.at(vec.size()-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>s) {
		string ans = s[2]==s[3] && s[4]==s[5] ? "Yes":"No";
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 888
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

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

	vector<ll> w(N), b(N);
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			if (S[i] == '#') b[i] = 1;
		}
		else {
			if (S[i] == '#')b[i] = b[i - 1] + 1;
			else b[i] = b[i - 1];
		}
	}
	for (int i = N -1; i >= 0; i--) {
		if (i == N - 1) {
			if (S[i] == '.') w[i] = 1;
		}
		else {
			if (S[i] == '.')w[i] = w[i + 1] + 1;
			else w[i] = w[i + 1];
		}
	}

	ll mi = 1e10;
	for (int i = 0; i <= N; i++) {
		if (i == 0) mi = w[i];
		else if (i == N) mi = min(mi, b[i - 1]);
		else mi = min(mi, b[i - 1] + w[i]);
	}

	cout << mi << endl;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<pair<int,int>>p(n);
  vector<int>data(0);
  for(int i = 0;i < n;i++){
    cin >> p[i].first;
    p[i].second = 1;
  }
  sort(p.begin(),p.end());
  for(int i = 0;i < n-1;i++){
    if(p[i].first == p[i+1].first){
      if(i == n-2){
        data.push_back(p[i].second+1);
      }
      else{
        p[i+1].second += p[i].second;
      }
    }
    else{
      if(i == n-2){
        data.push_back(p[i].second);
        data.push_back(p[i+1].second);
      }
      else{
        data.push_back(p[i].second);
      }
    }
  }
  sort(data.begin(),data.end());
  if(data.size() <= k){
    cout << 0 << endl;
    return 0;
  }
  else{
    int sum = 0;
    for(int i = 0;i < data.size()-k;i++){
      sum += data[i];
    }
    cout << sum << endl;
    return 0;
  }
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
#define INF 1<<29
using namespace std;

int main(){
	map<char,char>a;
	a['i']='i';
	a['w']='w';
	a['(']=')';
	a[')']='(';
	char b[15];
	scanf("%s",b);
	int c=strlen(b);
	int s=0;
    int e=c/2;
    if(c&1)e++;
	for(int d=0;d<e;d++){
		if(a[b[d]]!=b[c-d-1])s++;
	}
	printf("%d\n",s);
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		int I = i + 1;
		if (a[i] > I) {
			cout << -1 << endl;
			return 0;
		}
	}
	V ans(n);
	for (int i = n - 1; i >= 0; i--) {
		int tmp;
		rep(j, a.size()) {
			int I = j + 1;
			if (a[j] == I) tmp = I;
		}
		ans[i] = tmp;
		a.erase(a.begin() + (tmp - 1));
	}
	rep(i, n) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int digitSum = digitSum(n);
        boolean res = (n % digitSum == 0);

        System.out.println(res ? "Yes" : "No");
    }

    private static int digitSum(int n) {
        int sum = 0;

        while (n > 0) {
            sum += n % 10;
            n /= 10;
        }

        return sum;
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; }
template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000001

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a[3];
    GET(a);
    sort(a,a+3);
    int res = 0;
    if(a[0]%2 == a[1]%2){
        res = (a[2]-a[1]+a[2]-a[0])/2;
    }
    else{
        ++res;
        ++a[2];
        ++a[0];
        res += (a[2]-a[1]+a[2]-a[0])/2;
    }
    cout << res;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N =42768;
bool prime[MAX_N];
void sieve(){
	for(int i =2;i <MAX_N;i++){
		prime[i]=true;
	}
	prime[0]=prime[1]=false;
	for(int i =2;i*i<MAX_N;i++){
		if(prime[i]){
			for(int j =i*i;j<MAX_N;j+=i){
				prime[j]=false;
			}
		}
	}
}
int main(){
	int n;
	sieve();
	while(cin>>n,n){
		int ans =0;
		for(int i =2;i<=n/2;i++){
			if(prime[i]&&prime[n-i]){
				ans++;
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1; i<=(n); i++)
const int MX = 2005;
int n, m, q, a, b, c, d, ac[MX][MX], ac2[MX][MX], ac3[MX][MX];
char s[MX][MX];
int main(){
	scanf("%d%d%d", &n, &m, &q);
	rep(i,n) scanf("\n%s", s[i]+1);
	rep(i,n) rep(j,m){
		ac[i][j] = ac[i-1][j] + ac[i][j-1] - ac[i-1][j-1] + (s[i][j] - '0') * ('1' - s[i-1][j] + '0' - s[i][j-1]);
		ac2[i][j] = ac2[i][j-1] + (s[i][j] - '0') * (s[i-1][j] - '0');
		ac3[i][j] = ac3[i-1][j] + (s[i][j] - '0') * (s[i][j-1] - '0');
	}
	rep(i,q){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		printf("%d\n", ac[c][d] + ac[a-1][b-1] - ac[c][b-1] - ac[a-1][d] + ac2[a][d] - ac2[a][b-1] + ac3[c][b] - ac3[a-1][b]);
	}
}

Measured memory_bytes: 52864