akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

int N;
int pos;
vector<int> level;
vector<string> S;

ll compute() {
  int L = level[pos];
  char c = S[pos][level[pos]];
  ++pos;
  if(isdigit(c)) return c - '0';
  else if(c == '+') {
    ll ret = 0;
    while(pos < N && level[pos] == L + 1) {
      ret += compute();
    }
    return ret;
  }
  else {
    ll ret = 1;
    while(pos < N && level[pos] == L + 1) {
      ret *= compute();
    }
    return ret;
  }
}

int main() {
  while(true) {
    cin >> N;
    if(N == 0) break;
    level = vector<int>(N);
    S = vector<string>(N);
    for(int i = 0; i < N; ++i) {
      cin >> S[i];
      level[i] = S[i].size() - 1;
    }
    pos = 0;
    cout << compute() << endl;
  }
}

Measured memory_bytes: 3116
#include<stdio.h>
int main()
{
    int N,a;
    scanf("%d",&N);
     if(N%2==0 && N%N==0)
     {
    printf("%d",N);
     }
    else
    {

    a=N*2;
    printf("%d",a);
    }
    return 0;
}

Measured memory_bytes: 128
import math

n = []
while True:
    try:
        n.append(int(raw_input()))
    except:
        break
    
r = max(n)+100
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        for j in range(2*i+1,r,i+1):
            p[j] = 0

for a in n:
    for i in range(a,r):
       if p[i] == 1:
            lp = i+1
            break
    for i in range(a-2,0,-1):
        if p[i] == 1:
            sp = i+1
            break
    print sp, lp

Measured memory_bytes: 6208
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let mut b = a
        .into_iter()
        .enumerate()
        .map(|(i, a)| (a, i + 1))
        .collect::<Vec<_>>();
    b.sort();
    for (i, (_, x)) in b.into_iter().enumerate() {
        if i > 0 {
            print!(" ");
        }
        print!("{}", x);
    }
    println!();
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8956
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    if(s[0]==s[l-1])
	{
        if(l%2==0)
		{
            cout<<"First"<<endl;
            return 0;
        }
        else
		{
            cout<<"Second"<<endl;
            return 0;
        }
    }
    else
	{
        if(l%2==0)
		{
            cout<<"Second"<<endl;
            return 0;
        }
        else
		{
            cout<<"First"<<endl;
            return 0;
        }
    }
   return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
    long long x,ans = 2;
    scanf("%llu",&x);
    for(int i = 0 ; i < x ; i++)
        ans = (ans+1)*2;
    cout<<ans<<endl;

    return 0;

}

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

int m = 1000005;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> cnt(m);
  for (int x : a) {
    // 重複処理
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i < m; i += x) cnt[i]++;
  }
  int ans = 0;
  for (int x : a) {
    if (cnt[x] == 1) ans++;
  }
  cout << ans << endl;  
}

Measured memory_bytes: 7972
#include <iostream>
#include <vector>

using namespace std;

int main(){

                int s, sum;
                sum = 0;

                cin >> s;

                for(int i = 0; i < 3; i++){
                                sum += s % 10;
                                s = s/10;
                }

                cout << sum << endl;
                return 0;
}


Measured memory_bytes: 256
p = 10**9+7
H,W = map(int,input().split())
A = ["#"*(W+1)]
for _ in range(H):
    a = input().strip()
    a = "#"+a
    A.append(a)
dp = [[0 for _ in range(W+1)] for _ in range(H+1)]
dp[H][W] = 1
for i in range(H,0,-1):
    for j in range(W,0,-1):
        if A[i][j]=="#":continue
        if j+1<=W:
            dp[i][j] = (dp[i][j]+dp[i][j+1])%p
        if i+1<=H:
            dp[i][j] = (dp[i][j]+dp[i+1][j])%p
print(dp[1][1])

Measured memory_bytes: 54140
try:
    from math import gcd
except:
    from fractions import gcd
import operator
from collections import deque


class Segtree:
    """
    st = Segtree(4, f=operator.add, e=0)
    st[1:] = [4, 9, 16]
    st[0] = -99
    assert st[-1] == 16
    assert st[:] == [-99, 4, 9, 16]
    assert st.grasp(1, 3) == 13
    """

    def __init__(self, n, f=operator.add, e=0):
        """all(f(v, e) == f(e, v) == v for v in data)"""
        self.r = range(n)
        self.size = 2 ** ((n - 1).bit_length())
        self.tree = [e] * (2 * self.size)
        self.f = f
        self.iden = e

    def __len__(self):
        return len(self.r)

    def __list__(self):
        return self.tree[self.size-1:self.size-1+len(self.r)]

    def __repr__(self):
        return repr(list(self))

    def grasp(self, i=0, j=None):
        """reduce(f, data[i:j], e)"""
        if j is None:
            j = len(self)
        i = self.size - 1 + max(i, 0)
        j = self.size - 1 + min(j, len(self))
        ans = self.iden
        while j - i > 0:
            if i & 1 is 0:
                ans = self.f(self.tree[i], ans)
            if j & 1 is 0:
                ans = self.f(ans, self.tree[j-1])
            i = i >> 1
            j = (j - 1) >> 1
        return ans

    def __getitem__(self, i):
        r = self.r[i]
        if isinstance(r, int):
            return self.tree[self.size - 1 + r]
        else:
            return [self.tree[self.size - 1 + ri] for ri in r]

    def __setitem__(self, i, v):
        """Extra elements will be ignored when i is a slice."""
        r = self.r[i]
        if isinstance(r, int):
            r = [r]
            v = [v]
        q = deque()
        s = set()

        def addnext(j):
            k = (j - 1) // 2
            if k >= 0 and k not in s:
                q.append(k)
                s.add(k)

        for ri, vi in zip(r, v):
            j = self.size - 1 + ri
            self.tree[j] = vi
            addnext(j)
        while len(q):
            j = q.popleft()
            s.remove(j)
            vl = self.tree[2 * j + 1]
            vr = self.tree[2 * j + 2]
            self.tree[j] = self.f(vl, vr)
            addnext(j)


N = int(input())
A = [int(s) for s in input().split()]
st = Segtree(N, f=gcd, e=0)
st[:] = A
ans = max([gcd(st.grasp(0, i), st.grasp(i+1)) for i in range(N)])
print(ans)


Measured memory_bytes: 106464
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using namespace std;

int main() {
    long long n, l, p=-1;
    vector<long long> a;
    cin >> n >> l;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a.push_back(t);
        if (i != 0) {
            if (a[i] + a[i - 1] >= l&&p == -1)p = i;
        }
    }
    if (p != -1) {
        cout << "Possible" << endl;
        for (int i = 1; i < p; i++)cout << i << endl;
        for (int i = n - 1; i > p; i--)cout << i << endl;
        cout << p << endl;
    }
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h> 
using namespace std;
const int mod = 1e9 + 7;
long long n ,m ,a[33] ,res = 1;
int main(){
    cin >> n >> m,  a[1] = 1;
    for(int i = 2; i <= 30; i++)
        a[i] = a[mod % i] * (mod - mod/i) % mod;
    for(int i = 2 ,cnt; i * i <= m; i++){
            cnt = 0;
            while(m % i == 0)
                m /= i,cnt++;
            for(int j = 0; j < cnt; j++)
                res = res * (n + j) % mod * a[j + 1] % mod; }
    cout << (m != 1 ? res * n % mod : res) << '\n'; 
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main ( )
{

    string ss ;
    cin>>ss;
    int count = 0 ;
    int ans= 0;

    for(int i = 0; i <3; i++)
    {
        if (ss[i]=='R')


            count ++ ;
            else
                count=0 ;


        ans=max(ans,count) ;
    }
    cout<<ans<<endl ;


    return 0 ;
}




Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

const ll mod=998244353;

ll com(ll a,ll b,ll c) {
  ll d=1, e=(b*c)%mod, m_=mod-2;
  while(m_ != 0) {
    if (m_&1) d=(d*e)%mod;
    e = e*e%mod;
    m_ = m_ >> 1;
  }
  return (a*d)%mod;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,A,B,k,ans=0,j=0;cin>>n>>A>>B>>k;
  lvector f(n+10,0); f[0]=1;
  for (ll i=1;i<=n;++i) f[i]+=f[i-1]*i%mod;
  if(!(k>(A+B)*n)) {
    for(ll i=0;i<=n;++i) {
      if(k-A*i>=0 && (k-A*i)%B==0 && (k-A*i)/B<=n) {
        j=(k-A*i)/B;
        ans+=com(f[n],f[n-i],f[i])*com(f[n],f[n-j],f[j])%mod;
        ans%=mod;
      }
    }    
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

std::map<ll, int> m;

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

	ll sum = 0;
	m[sum]++;

	ll ans = 0;
	REP(i, N)
	{
		ll a;
		cin >> a;
		sum += a;
		ans += m[sum];
		m[sum]++;
	}
	cout << ans<<endl;
	return 0;
}

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

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

    vector<int> A;
    for(int i=0; i<N; ++i) {
        int a;
        cin >> a;
        A.push_back(a);
    }

    //なるべく１こつづ2で割るのがよさそう
    //配列をどこまで捜査したかを覚えておくとよさそう

    int cnt=0;
    int rec=0;

    bool flag = true;
    while(flag) {
        flag = false;
        for(int i=rec; i<N; ++i) {
            if(A[i]%2==0) {
                A[i] = A[i]/2 ;
                cnt++;
                rec=i;
                // cout << "i " << i << endl;
                // cout << "rec " << rec << endl;
                // cout << "A[i] " << A[i] << endl;
                flag = true;
                break;
            }
        }
        if(!flag) break;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
//typedef vector<int> vi;
//typedef vector<vi> vvi;
//typedef vector<string> vs;
//typedef pair<int, int> pii;
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}



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

	string s;
	cin >> s;
	if (s == "ABC") {
		puts("ARC");
	}
	else {
		puts("ABC");
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    rep(i, h)rep(j, w){
        if(s[i][j] == '#'){
            bool valid = false;
            if(0 < i){
                if(s[i - 1][j] == '#') valid = true;
            }
            if(i < h - 1){
                if(s[i + 1][j] == '#') valid = true;
            }
            if(0 < j){
                if(s[i][j - 1] == '#') valid = true;
            }
            if(j < w - 1){
                if(s[i][j + 1] == '#') valid = true;
            }
            if(!valid){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
    int a,b,C;
    double S,L,h;
    scanf("%d %d %d",&a,&b,&C);
    S=(double)(a*b*sin(C*atan(1.0)*4.0/180.0))*0.5;
    L=(double)(a+b+sqrt(a*a+b*b-2.0*a*b*cos(C*atan(1.0)*4.0/180.0)));
    h=(double)(S/a*2.0);
    printf("%lf\n%lf\n%lf\n",S,L,h);
    return 0;
}

Measured memory_bytes: 636
n,m= map(int, input().split())
x = {}
for i in range(n):
    a,b = map(int, input().split())
    if a not in x:
        x[a] = b
    else:
        x[a] += b
# print(x)
s = sorted(x.keys())
# print(s)
ans = 0
c = 0
for ss in s:
    # print(ss, ans, c)
    if c + x[ss] <= m:
        ans += ss * x[ss]
        c += x[ss]
    else:
        ans += ss * (m-c)
        break
print(ans)

Measured memory_bytes: 17876
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final String line = readLine();
        System.out.println(calc(line));
    }

    protected static String calc(String input) {
        String s[] = input.split(" ");

        int y = Integer.parseInt(s[0]);
        int x = Integer.parseInt(s[1]);

        int area = y * x;
        int circumference = y + y + x + x;

        return area + " " + circumference;
    }

    private static String readLine() {
        Scanner s = null;
        try {
            s = new Scanner(System.in);
            return s.nextLine();
        } finally {
            if (s != null) {
                s.close();
            }
        }
    }
}

Measured memory_bytes: 17124
building=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for _ in range (n):
 b,f,r,v=input().split(" ")
 building[int(b)-1][int(f)-1][int(r)-1] += int(v)
for i,b in enumerate(building):
 for f in b:
  for r in f:
   print(" %d"%(r), end="")
  print("")
 if i !=3:
  print("#"*20)

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

using i64 = std::int64_t;

#define REP(i, n) for (i64 i = 0; i < (n); ++i)

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline i64 scan() {
    i64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(i64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

using P = pair<i64, i64>;

i64 collect(const vector<vector<P>> &G, i64 u, i64 v, i64 p) {
  if (u == v) return 0;
  for (auto e : G[u]) {
    if (e.first == p) continue;
    i64 s = collect(G, e.first, v, u);
    if (s != -1) {
      return s | (1LL << e.second);
    }
  }
  return -1;
}

signed main() {
  i64 n = io::scan();
  auto G = vector<vector<P>>(n);
  REP(i, n - 1) {
    i64 a = io::scan() - 1;
    i64 b = io::scan() - 1;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }
  i64 m = io::scan();
  auto paths = vector<i64>(m, 0);
  REP(j, m) {
    i64 u = io::scan() - 1;
    i64 v = io::scan() - 1;
    paths[j] = collect(G, u, v, -1);
  }
  i64 ans = 0;
  REP(s, 1LL << m) {
    i64 mask = 0;
    REP(j, m) {
      if ((s >> j) & 1) {
        mask |= paths[j];
      }
      if (__builtin_parityll(s)) {
        ans -= 1LL << (n - 1 - __builtin_popcountll(mask));
      } else {
        ans += 1LL << (n - 1 - __builtin_popcountll(mask));
      }
    }
  }
  io::print(ans);
  io::flush();
}


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

const ll INF = 7+(1e+15);
typedef ll Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

//引数 Graph:隣接リスト,dist:各頂点から各頂点までの距離が入る,inter:最短路木の親頂点が入る
//戻値 負閉路が存在しない場合:true,そうでないとき:false
bool shortestPath(const Graph &g,vector<vector<Weight> > &dist,vector<vector<int> > &inter) {
  int n = g.size();
  dist.assign(n,vector<Weight>(n,INF));
  for(int i=0;i<n;i++){
    dist[i][i]=0;
  }
  for(int i=0;i<n;i++){
    for(auto f=g[i].begin();f!=g[i].end();f++){
      dist[i][f->dst]=f->weight;
    }
  }
  inter.assign(n, vector<int>(n,-1));
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(dist[i][k]<INF && dist[k][j]<INF && dist[i][j]>dist[i][k]+dist[k][j]){
          dist[i][j] = dist[i][k] + dist[k][j];
          inter[i][j] = k;
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    if(dist[i][i]<0){
      return false;
    }
  }
  return true;
}

void buildPath(const vector<vector<int> > &inter,int s,int t,vector<int> &path) {
  int u = inter[s][t];
  if (u < 0) path.push_back(s);
  else buildPath(inter, s, u, path), buildPath(inter, u, t, path);
}
 
//引数 inter:最短路木の親頂点,s:始点,t:終点
//戻値 path:sからtまでの最短経路
vector<int> buildPath(const vector<vector<int> > &inter,int s,int t) {
  vector<int> path;
  buildPath(inter, s, t, path);
  path.push_back(t);
  return path;
}

	
int main(){
  int v,e; cin >> v >> e;
  Graph g(v);    //頂点数vの空隣接リストgを生成
  for(int i = 0;i<e;i++){
      int s,t,w ;
      cin >>s >>t >>w; 
      g[s].push_back(Edge(s,t,w));    //隣接リストgにsからtに向かう重さwの辺を追加
  }
  vector<vector<Weight> >dist;
  vector<vector<int> > inter;
  bool negative_cycle=shortestPath(g,dist,inter);
  
  if(negative_cycle == false){
        cout << "NEGATIVE CYCLE" << endl;
  }else{
        for(int i=0;i<v;i++){
              for(int j=0;j<v;j++){
                    if(dist[i][j]==INF){
                          cout << "INF";
                    }else{
                          cout << dist[i][j];
                    }
                    if(j != v-1) cout << " ";
              }
              cout << endl;
        }
  }
}




Measured memory_bytes: 3308
import copy

s=list(input())
a=[]
for i in range(len(s)):
    a.append(s[i])
    if i !=len(s)-1:
        a.append("")

ans=0

for i in range(2**(len(s)-1)):
    l=copy.deepcopy(a)
    for j in range(len(s)-1):
        if (i>>j&1):
            l[2*j+1]="+"
    ans+=eval("".join(l))

print(ans)

Measured memory_bytes: 9260
#!/usr/bin/python
# -*- coding: UTF-8 -*-

N = int(input())
if N%10 == 3:
	print('bon')
elif N%10 == 0 or N%10 == 1 or N%10 == 6 or N%10 == 8:
	print('pon')
else:
	print('hon')

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,s="";
	cin>>a>>b;
	int l1=a.length();
	int l2=b.length();
	int dp[l1+1][l2+1]={},m[l1+1][l2+1];
	memset(m,-1,sizeof(m));
	for(int i=1;i<=l1;i++){
		for(int j=1;j<=l2;j++){
			if(a[i-1]==b[j-1]){
				m[i][j]=0;
				dp[i][j]=1+dp[i-1][j-1];
			} 
			else if(dp[i][j-1]>=dp[i-1][j]){
				dp[i][j]=dp[i][j-1];
				m[i][j]=1;
			}
			else{
				dp[i][j]=dp[i-1][j];
				m[i][j]=2;
			}
		}
	}
	int r=l1,c=l2;
	while(r>=1 && c>=1){
		if(m[r][c]==0){
			s+=a[r-1];
			r--;c--;
		}
		else if(m[r][c]==1){
			c--;
		}
		else{
			r--;
		}
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
}

Measured memory_bytes: 70656
N = int(input())
h_list = list(map(int, input().split()))

max_count = 0
count = 1
for i in range(N - 1):
    if h_list[i] >= h_list[i + 1]:
        count += 1
    else:
        max_count = max(count, max_count)
        count = 1
max_count = max(count, max_count)
print(max_count- 1)

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

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

    vector<int> v(m+1);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        while(k--){
            int a;
            cin >> a;
            v[a]++;
        }
    }
    int ans = 0;
    for(int i : v){
        if(i == n) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	string n;
	cin >> n;
    if ((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3])) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<vector<char>> s(n, vector<char>(2 * n - 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> s.at(i).at(j);
      if (j < n - 1) s.at(i).at(j + n) = s.at(i).at(j);
    }
  }
  
  int ans = 0;
  for (int j = 0; j < n; j++) {
    bool flag = true;
    for (int ii = 0; ii < n; ii++) {
      for (int jj = 0; jj < n; jj++) {
        if (s.at(ii).at(j + jj) != s.at(jj).at(j + ii)) flag = false;
      }
    }
    if (flag) ans += n;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 512
import java.util.Scanner;
  
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = Integer.parseInt(sc.nextLine());
        String[] str = sc.nextLine().split(" ");
        long max = Integer.parseInt(str[0]);
        long total = Integer.parseInt(str[0]);
        long min = Integer.parseInt(str[0]);
        for(int cnt = 1; cnt < num; cnt++){
            if(max < Integer.parseInt(str[cnt])) max = Integer.parseInt(str[cnt]);
            if(min > Integer.parseInt(str[cnt])) min = Integer.parseInt(str[cnt]);
            total += Integer.parseInt(str[cnt]);
        }
        System.out.printf("%d %d %d\n", min, max, total);
    }
  
}

Measured memory_bytes: 31492
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    long long x = 0;
    rep(i,N-1) x = A[i] * 2 - x;
    x = (A[N - 1] * 2 - x) / 2;

    rep(i,N) {
        if (i != N - 1) cout << x << " ";
        else cout << x;
        x = (A[i] - x / 2) * 2;
    }
    
    return 0;
}

Measured memory_bytes: 1664
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = []
        for i in range(2, m):
            if not a[i]:
                continue
            if not (i % 7 == 1 or i % 7 == 6):
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False

    def is_prime(self, n):
        return self.A[n]

    def division(self, n):
        d = []
        for c in self.T:
            if n < c:
                break
            if n % c == 0:
                d.append(c)
        return d

def main():
    rr = []

    pr = Prime(300000**2)

    while True:
        n = I()
        if n == 1:
            break

        d = pr.division(n)
        rr.append('{}: {}'.format(n,' '.join(map(str,d))))

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 12736
import java.util.Scanner;
 
public class Main {  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    int[] count = new int[100001];
    int amax =0, amin =100000;
    for (int i =0; i<N; i++) {
      a[i] = sc.nextInt();
      amax = Math.max(a[i],amax);
      amin = Math.min(a[i],amin);
      count[a[i]]++;
    }
    int max =0;
    for (int i =Math.max(0,amin-2); i<=Math.max(0,amax-2); i++) {
      max = Math.max(count[i] + count[i+1] + count[i+2],max);
    }
    System.out.println(max);  
  }
}

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

using namespace std;
deque<int> q;
int main()
{
    int i=0, n, a, b;
    scanf("%d",&n);
    if(n%2) scanf("%d",&a), q.push_back(a), i++;
    for(;i<n;i+=2) scanf("%d %d",&a, &b), q.push_back(a), q.push_front(b);
    for(i=0;i<n;i++) printf("%d ",q[i]);
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 205
using namespace std;

int n, s, a[N];
int main()
{
	int i;
	cin >> n;
	n *= 2;
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a + n);
	for (i = 0; i < n; i += 2) s += a[i];
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
ll dp[105][4][4][4];

int main() {
  int n;
  cin>>n;
  dp[0][3][3][3]=1LL;
  rep(i,n) rep(c3,4) rep(c2,4) rep(c1,4){
    ll pre=dp[i][c3][c2][c1];
    rep(c0,4){
      if(c0==2){
        if(c2==0 && c1==1) continue;
        if(c3==0 && c1==1) continue;
        if(c2==1 && c1==0) continue;
        if(c3==0 && c2==1) continue;
      }
      if(c2==0 && c1==2 && c0==1) continue;
      dp[i+1][c2][c1][c0]+=pre;
      dp[i+1][c2][c1][c0]%=md;
    }
  }
  ll ans=0;
  rep(c3,4) rep(c2,4) rep(c1,4){
    ans+=dp[n][c3][c2][c1];
    ans%=md;
  }
  cout<<ans<<endl;
  return 0;
}


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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<pair<int,string>> p(m);
  int ss[100005];
  int tt[100005];
  int w=0,a=0;
  for(int i=0;i<m;i++){
    tt[i]=0;
    cin>>p.at(i).first>>p.at(i).second;
  }
  for(int i=0;i<m;i++){
    int x=p.at(i).first;
    if(p.at(i).second=="WA"){
      if(ss[x]==0)tt[x]++;
    }
    else{
      if(ss[x]==0){
        ss[x]=1;
        w+=tt[x];
        a++;
      }
    }
  }
  cout<<a<<' '<<w<<endl;
  return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <stdlib.h>
#define tetra(N) N*(N+1)*(N+2)/6
#define N_MAX 1000000

int main(int argc, char* argv[]){
	int *a=malloc((N_MAX+1)*sizeof(int)), *b=malloc((N_MAX+1)*sizeof(int)), i, j;
	
	/* initialize */
	for(i=1; i<=N_MAX; i++) a[i]=N_MAX, b[i]=N_MAX;
	
	/* solve */
	for(i=1; tetra(i)<=N_MAX; i++){
		a[tetra(i)]=1;
		if(i%4==1) b[tetra(i)]=1;
	}
	for(i=1; i<=N_MAX; i++)
		for(j=1; i+tetra(j)<=N_MAX; j++){
			if(a[i+tetra(j)]>a[i]+1) a[i+tetra(j)]=a[i]+1;
			if(j%4==1 && b[i+tetra(j)]>b[i]+1) b[i+tetra(j)]=b[i]+1;
		}
	
	/* show */
	while(scanf("%d",&i), i!=0) printf("%d %d\n",a[i],b[i]);
	
	free(a), free(b);
	
	return 0;
}

Measured memory_bytes: 8136
import math
import sys
import numpy as np
from collections import defaultdict, deque, Counter 
from itertools import accumulate, product, permutations,combinations, combinations_with_replacement
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd

max_value = 1000000000
min_value = -1000000000
sys.setrecursionlimit(max_value)

N = int(input())
counter = defaultdict(int)

value = 0
for i in range(N):
    sorted_str = ''.join(sorted(input()))
    value += counter[sorted_str]
    counter[sorted_str] += 1
print(value)


Measured memory_bytes: 28476
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  vector<char> alp = {'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'};
  ll n;
  cin >> n;

  string ans = "";
  while(n) {
    --n;
    ans += alp[n % 26];
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
<?php

fscanf(STDIN, "%d%d%d", $a, $b, $c);

if($a > $c || $b > $c){
    echo "No";
    exit;
}
$temp = intdiv(pow(($c - $a - $b) ,2)+3,4);
if($a * $b < $temp){
    echo "Yes";
}else{
    echo "No";
}
//111,111,111

Measured memory_bytes: 4728
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define X first
#define Y second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

ll x, y;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> x >> y;
	if (x % y == 0)
		return cout << -1 << endl, 0;
	cout << x << endl;
}



Measured memory_bytes: 256
#include <iostream>

int main() {
    int N;
    std::cin >> N;
    char c;

    long character[300] = {};

    long cnt = 1;

    for (int i = 0; i < N; i++) {
        std::cin >> c;

        character[c - 'a']++;
    }

    // std::cout << (long)(1e9+7) << std::endl;
    for (int i = 0; i < 100; i++) {
        cnt = (cnt * (character[i] + 1)) % (long)(1e9 + 7);
    }

    std::cout << cnt - 1 << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define sz(a) (int)(a).size()
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e4+5;
int cas=1;
void solve()
{
    int a, b;
    cin >> a >> b;
    if (a % b == 0) cout << -1 << endl;
    else cout << a << endl;
}
int main()
{
   //  freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main{
  String YES = "YES", NO= "NO";
  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int i =  s.lastIndexOf("s");
    if(i == s.length()-1){
      System.out.println(s + "es");
    }
    else{
      System.out.println(s +"s");
    }
  }

  static class Scanner {
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s) {
      br = new BufferedReader(new InputStreamReader(s));
    }

    public Scanner(FileReader s) throws FileNotFoundException {
      br = new BufferedReader(s);
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens())
        st = new StringTokenizer(br.readLine());
      return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {
      return br.readLine();
    }

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

    public boolean ready() throws IOException {
      return br.ready();
    }
  }
}

Measured memory_bytes: 36584
N = int(input())
A = [int(input()) for _ in range(N)]

MOD = 10**9 + 7

dp = [0] * N
prev_i = [-1] * (2 * 10**5 + 1)

dp[0] = 1
prev_i[A[0]] = 0

for i in range(1, N):
  a = A[i]
  if prev_i[a] >= 0:
    if prev_i[a] == i - 1:
      dp[i] = dp[i - 1]
    else:
      dp[i] = dp[i - 1] + dp[prev_i[a]]
  else:
    dp[i] = dp[i - 1]
  prev_i[a] = i
  #print(i, dp, prev_i)

print(dp[-1] % MOD)

Measured memory_bytes: 766644
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = (int)s.size();
    for(int i = l-2;i>0;i-=2){
        int l2 = i/2;
        if(s.substr(0,l2)==s.substr(l2,l2)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	unsigned long long int N,M;
	cin>>N>>M;
	if(N>M){
		swap(N,M);
	}//N<=M
	if(M==1){
		cout<<"1"<<endl;
	}else if(N==1){
		cout<<M-2<<endl;
	}else{
		cout<<(N-2)*(M-2)<<endl;
	}
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def ni(): return int(stdin.readline())

n = ni()
a = na()
st = set()
for i in a:
    if(i not in st):
        st.add(i)

c = len(st)
if(c%2 == 0):c=c-1

print(c)


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

bool BinarySearch(long key, long n, long S[]){
	long right = n;
	long left = 0;
	while(right > left){
		long mid = (right+left)/2;
		if(key == S[mid]){
			return true;
		}else if(key > S[mid]){
			left = mid+1;
		}else{
			right = mid;
		}
	}

	return false;
}

int main(){
	long n,q,key;
	cin >> n;
	long S[1000000];
	for(long i=0; i<n; i++) scanf("%d", &S[i]);
	cin >> q;

	long count = 0;
	for(long i=0; i<q; i++){
		scanf("%d", &key);
		if(BinarySearch(key, n, S)) count++;
	}

	cout << count << endl;
	return 0;

}



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

#define int long long
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; }

signed main(){
	int n, a; 
	int ans[200010] = {};
	cin >> n;

	for(int i = 0;i < n-1;i++){
		int a;
		cin >> a;
		ans[a-1]++;
	}

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


	return 0;
}


Measured memory_bytes: 5196
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<P>pa;
	rep(i, m) {
		int a, b; cin >> a >> b;
		pa.push_back(make_pair(a, b));
	}
	sort(ALL(pa), compare_by_b);
	int now = -1;
	int ans = 0;
	rep(i, m) {
		if (pa[i].first <= now) {
			
		}
		else {
			ans++;
			now = pa[i].second - 1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> ans(h, vector<int>(w, 0));
    int cnt = 0;
    int M = 0;
    rep(i, h){
        cnt = 0;
        rep(j, w){
            if(s[i][j] == '.'){
                cnt++;
                ans[i][j] += cnt;
            }else{
                cnt = 0;
            }
        }
        cnt = 0;
        rrep(j, w){
            if(s[i][j] == '.'){
                cnt++;
                ans[i][j] += cnt;
            }else{
                cnt = 0;
            }
        }
    }
    rep(i, w){
        cnt = 0;
        rep(j, h){
            if(s[j][i] == '.'){
                cnt++;
                ans[j][i] += cnt;
            }else{
                cnt = 0;
            }
        }
        cnt = 0;
        rrep(j, h){
            if(s[j][i] == '.'){
                cnt++;
                ans[j][i] += cnt;
                M = max(M, ans[j][i] - 3);
            }else{
                cnt = 0;
            }
        }
    }
    cout << M << endl;
}


Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
// #define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 1e16
#define N 10000004

int32_t main()
{
    IOS;

    int n;
    cin >> n;
    map<string,int> m;
    vector<int> v(n);
    for(int i = 0;i < n;i++)
    {
        string s;
        cin >> s >> v[i];
        m[s] = i;
    }
    string s;
    cin >> s;
    int ans = 0;
    for(int i = m[s] + 1;i < n;i++ )
        ans += v[i];
    cout << ans;

    return 0;

}
 


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
	string s,t;
	cin>>s>>t;
//	cout<<s<<endl<<t<<endl;
	int in=-1;
	if(s.size()>=t.size()){
	for(int i=0;i<=s.size()-t.size();i++){
		int flag=1;
		for(int j=0;j<t.size();j++){
			if(s[i+j]!=t[j]){
				if(s[i+j]!='?'){
				flag=0;
				}
			}
		}
		if(flag){
			in=i;
		}
	}
	}
	if(in>=0){
//		for(int i=0;i<in;i++){
//			if(s[i]=='?'){
//				s[i]='a';
//			}
//		}
//		for(int i=in;i<in+t.size();i++){
//			s[i]=t[i-in];
//		}
//		for(int i=in+t.size();i<s.size();i++){
//			if(s[i]=='?'){
//				s[i]='a';
//			}
//		}
		  for(int i=0;i<s.size();i++) {
		    if (i < in || i >= in + t.size())
		      cout << (s[i] == '?' ? 'a' : s[i]);
		    else
		      cout << t[i - in];
		  }
		  cout<<endl;
//		cout<<s<<endl;
	}else{
		cout<<"UNRESTORABLE"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 1e9+7;
const ll N = 1e7+10;
ll f[N], rf[N];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % MOD;
    rf[N - 1] = inv(f[N - 1]);
    for(int i = N-2; i >= 0; i--) rf[i] = (rf[i + 1] * (i + 1)) % MOD;
}
ll C(int n, int k) {
    if(k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!^(-1)
    ll c = rf[k]; // = k!^(-1)
    ll bc = (b * c) % MOD;
    return (a * bc) % MOD;
}
ll p(int n, int k) {
    if (k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n - k]; // = (n-k)!^(-1)
    return (a * b) % MOD;
}
ll H(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return C(n + k - 1, k);
}
ll mod_pow(ll x, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main()
{
    init();
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    int m = k + n;
    vector<ll> tf(m+1, 0);
    vector<ll> ts(m+1, 0);
    tf[0] = 1;
    ts[0] = 1;
    for(int i = 0; i < m; i++)
    {
        tf[i+1] = tf[i] * 25 % MOD;
        ts[i+1] = ts[i] * 26 % MOD;
    }
    ll ans = 0;
    for(int i = 0; i <= k; i++)
    {
        ll tmp = (C(m-i-1, n-1) * tf[k-i]) % MOD;
        tmp = (tmp * ts[i]) % MOD;
        ans = (ans+tmp) % MOD;
    }
    cout << (ans+MOD) % MOD << endl;
}


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

map<string,int>mp;

int main() {
  int n;
  cin >> n;
  string s;;
  rep(i,n) {
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = (ll)0;
  for(auto &p :mp){
    int s = p.second;
    ans += (ll)s*(s-1)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>

static const int N=100;

int min(int a,int b)
{
  return a<b?a:b;
}

int main()
{
  int n,p[N+1],m[N+1][N+1];
  int i,j,k,z;

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d %d",&p[i-1],&p[i]);
    }
  for(i=1;i<=n;i++) m[i][i]=0;
  for(k=2;k<=n;k++)
    {
      for(i=1;i<=n-k+1;i++)
	{
	  j=i+k-1;
	  m[i][j]=(1<<21);
	  for(z=i;z<=j-1;z++)
	    {
	      m[i][j]=min(m[i][j],m[i][z]+m[z+1][j]+p[i-1]*p[z]*p[j]);
	    }
	}
    }

  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    bool flag = false;
    int x = 7 % K, ans = 0;
    REP(i, K+1){
        if (x == 0) {
            flag = true;
            ans = i+1;
            break;
        }
        x = (x*10 + 7) % K;
    }
    
    if(flag) cout << ans << endl;
    else cout << -1 << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

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


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

    vector<int> k(m), p(m);
    vector<vector<int>> s(m);
    rep(i, m){
        cin >> k[i];

        rep(j, k[i]){
            int x;
            cin >> x;
            s[i].push_back(x);
        }
    }

    rep(i, m) cin >> p[i];

    int ans = 0;
    rep(swi, (1 << n)){     
        vector<bool> lamp(m, false);
        rep(i, m){
            int cnt = 0;
            rep(j, k[i]){
                if(swi & (1 << s[i][j]-1)){
                    cnt++;
                }
            }
            if(cnt % 2 == p[i]) lamp[i] = true;
        }

        bool ok = true;
        rep(i, m){
            if(lamp[i] == false){
                ok = false;
            }
        }
        if(ok) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256