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

vector < int > points[100];
int n, d, cnt;
long long dp[100][100];

int main()
{
    cin >> n >> d;
    for( int i = 0; i < n;i ++ ){
        for( int j = 0; j < d; j ++ ){
            int x; cin >> x;
            points[i].push_back( x );
        }
    }
    for( int i = 0; i < n; i ++ ){
        for( int j = 0; j < i; j ++ ){
            for ( int k = 0; k < d; k ++ ){
                dp[i][j] += ( points[i][k] - points[j][k] ) * ( points[i][k] - points[j][k]);
            }
            long long b = sqrt( dp[i][j] );
            if( b * b == dp[i][j] )cnt ++;
        }
    }
    cout << cnt;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D,X;
  cin>>N>>D>>X;
  int ans = X;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j*A.at(i)+1<=D;j++){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
    
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+1>=c)cout<<b+c<<endl;
    else cout<<a+b+b+1<<endl;
    
}


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

const LL INF = 1e10;

int main() {
  int N, W;
  cin >> N >> W;
  LL w[110], v[110];
  for (int i = 0; i < N; i ++) cin >> w[i] >> v[i];

  LL dp[110][100010];
  for (int i = 0 ;i < 110; i ++) {
    for (int j = 0; j < 100010; j ++) dp[i][j] = INF;
  }

  dp[0][0] = 0;
  for (int i = 0; i < N; i ++) {
    for (int j = 0; j <= 100000; j ++) {
      if (j - v[i] >= 0) {
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  LL ans = 0;
  for (int i = 0; i < 100010; i ++) {
    if (dp[N][i] <= W) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   set<string>st;
   string s; cin >> s;
   int k; cin >> k;
   rep(i,s.size()){
      rep(j,s.size()-i){
         if (j == 5)break;
         st.insert(s.substr(i,j+1));
      }
   }
   set<string>::iterator itr = st.begin();
   rep(i,k-1)itr++;
   cout << *itr << endl;
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int n,k;
  cin>>n>>k;
  long long h[n];
  REP(i,n){
    cin>>h[i];
  }
  //iは残す。0~iまででj個残す。
  vector<vector<long long>> dp(n, vector<long long>(n+1, INF));
  REP(i,n){
    REP(j,n+1){
      if(j == 0){
        continue;
      }
      if(j == 1){
        dp[i][j] = h[i];
        continue;
      }
      REP(r,i){
        dp[i][j] = min(dp[i][j], dp[r][j-1] + max(h[i]-h[r], 0LL));
      }
    }
  }
  long long ans = INF;
  if(k>=n){
    cout<<0<<endl;
    return 0;
  }
  REP(i,n){
    for(int j = n; j>=n-k; j--){
      ans = min(ans, dp[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0; 
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  int d;
  cin >> d;
  vector<int> c(26),tmp(26);
  vector<vector<int>> s;
  for(int i=0;i<26;i++){
    cin >> c[i];
  }
  for(int i=0;i<d;i++){
    for(int j=0;j<26;j++){
      cin >> tmp[j];
    }
    s.push_back(tmp);
  }
  
  vector<int> t(d,1);
  for(int i=0;i<d;i++){
    int max_ind = 0;
    for(int j=1;j<26;j++){
      if(s[i][max_ind]<s[i][j]){
        max_ind = j;
      }
    }
    t[i] = max_ind+1;
  }
  
  for(int i=0;i<d;i++){
    cout << t[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3684
import math
import collections

N = int(input())
res = 1


n = 10 ** 6 + 5000
fl = [1] * n
fl[0] = 0
fl[1] = 0
lprime = []
for i in range(n):
    if fl[i] == 1:
        lprime.append(i)
        ti = i * 2
        while ti < n:
            fl[ti] = 0
            ti += i


def prime_factorize(n):
    global lprime
    a = []
    for p in lprime:
        if p * p > n:
            break
        while n % p == 0:
            a.append(p)
            n //= p
    if n != 1:
        a.append(n)
    return a


def yakusuu(N):
    t = math.floor(math.sqrt(N))
    res = []
    for i in range(2, t + 1):
        if N % i == 0:
            res.append(i)
    return res


tres = prime_factorize(N - 1)
ctres = collections.Counter(tres)
for s in ctres.values():
    res *= s + 1
tres = yakusuu(N)
for c in tres:
    t = N
    while t % c == 0:
        t //= c
    if t == 1 or (t - 1) % c == 0:
        res += 1
print(res)


Measured memory_bytes: 52188
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    // freopen("A.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d",max(a+b,max(a*b,a-b)));
    return 0;
}

Measured memory_bytes: 3816
/*
 * atcoder/abc108_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * a + b = 0 (mod K) である必要十分条件は、どちらか
 * 1) a mod K + b mod K = 0 <=> a mod K = 0 and b mod K = 0
 * 2) a mod K + b mod K = K
 *
 * a % K を固定すると、b の値はa + b % K = 0 より1位に決まる
 * b = (a mod K = 0) ? 0 : K - (a mod K)
 * cもa + c % K = 0 より同様
 * c = (a mod K = 0) ? 0 : K - (a mod K)
 * さらに b + c % K = 0 を満たす場合が解
 *
 * (a, b, c) の組は分かったが、mod がa, b, cとなるようなn (1<= n <= N) の数はo(N)でカウント出来る.
 *
 * カウントにO(N)、組み合わせの列挙にO(K)
 */
int N, K;
ll counter[200100] = {0};

void solve() {
  cin >> N >> K;
  ll count = 0;
  loop(n,1,N+1) counter[n%K]++;

  loop(aK,0,K) {
    int bK = aK == 0 ? 0 : K - aK;
    int cK = aK == 0 ? 0 : K - aK;
    if ((bK + cK) % K != 0) continue;
    // cout << aK << " " << bK << " " << cK << endl;
    count += counter[aK] * counter[bK] * counter[cK];
  }
  cout << count << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int ans = 1;
    while(1){
        ans *= 2;
        if(ans > N){
            break;
        }
    }
    cout << ans/2;   
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int R;
int C;
int osenbei[10][10000];
int flag[11];
int ans;

int count(void){
  int temp,res = 0;

  for(int j = 0;j <C;j++){
    temp =0;
    for(int  i =0;i <R;i++){
      if(flag[i]&&!osenbei[i][j] ||!flag[i] &&osenbei[i][j])
	temp++;
    }
    if(temp <R-temp)//j列目を裏返したほうがいい
      res +=R-temp;
    else
      res +=temp;
  }
  return res;
}
  
void solve(int idx){
  int res;
  
  if(idx ==R-1){
    res =count();
    if(ans <res)
      ans = res;
    return;
  }
  flag[idx] = 1;//idx行を裏返す
  solve(idx+1);

  flag[idx] = 0;//idx行は裏返さない
  solve(idx+1);
  return;
}

int main()
{
  while(cin >>R>>C){
    if(R==0&&C==0)
      break;
    for(int i = 0;i < R;i++){
      for(int j = 0 ;j <C;j++){
	cin >>osenbei[i][j];
      }
  }
  ans = 0;
  solve(0);
  cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1548
#include<stdio.h>
int main(){
  int n,i,j,cou=0;
  scanf("%d",&n);
  j=n-1;
  for(i=1;i<=n/2;i++,j--){
      if(i+j==n && i!=j){
        cou++;
      }
  }
  
  printf("%d\n",cou);
}


Measured memory_bytes: 128
class Point(object):
    __slots__ = ["x", "y"]

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __iter__(self):
        yield self.x
        yield self.y

    def __add__(self, other: "Point") -> "Point":
        return Point(self.x + other.x, self.y + other.y)

    def __sub__(self, other: "Point") -> "Point":
        return Point(self.x - other.x, self.y - other.y)

    def __mul__(self, s: int):
        return Point(self.x * s, self.y * s)

    def project(self, vector: "Vector") -> "Point":
        return (vector * (Vector(vector.p1, self).dot(vector) / vector.norm)).p2

    def reflect(self, vector: "Vector") -> "Point":
        return self + (self.project(vector) - self) * 2


class Vector(object):
    __slots__ = ["p1", "p2", "x", "y", "norm", "abs"]

    def __init__(self, p1: Point, p2: Point):
        self.p1 = p1
        self.p2 = p2
        self.x = p2.x - p1.x
        self.y = p2.y - p1.y
        self.norm = self.x ** 2 + self.y ** 2
        self.abs = abs(self.x + self.y)

    def __mul__(self, s):
        return Vector(self.p1, Point(self.p1.x + self.x * s, self.p1.y + self.y * s))

    def __lt__(self, other: "Vector"):
        return other.abs > self.abs

    def __gt__(self, other: "Vector"):
        return other.abs < self.abs

    def dot(self, other: "Vector"):
        return self.x * other.x + self.y * other.y

    def cross(self, other: "Vector"):
        return self.x * other.y - self.y * other.x


if __name__ == "__main__":
    a = list(map(int, input().split()))
    p1, p2 = Point(*a[:2]), Point(*a[2:])
    vector1 = Vector(p1, p2)
    for p3 in (Point(*map(int, input().split())) for _ in [0]*int(input())):
        vector2 = Vector(p1, p3)
        if vector1.cross(vector2) > 0:
            print("COUNTER_CLOCKWISE")
        elif vector1.cross(vector2) < 0:
            print("CLOCKWISE")
        elif vector1.dot(vector2) < 0:
            print("ONLINE_BACK")
        elif vector1 < vector2:
            print("ONLINE_FRONT")
        else:
            print("ON_SEGMENT")


Measured memory_bytes: 5700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

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


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    int D; cin >> D;
    int G; cin >> G;
    int p[D+1], c[D+1]; REP(i, D) {
        cin >> p[i] >> c[i];
    }

    int problems = INF32;
    int points = 0;

    int ans = 1e9;
    REP (mask, 1<<D){
        int s = 0, num = 0, rest_max = -1;
        REP(i, D) {
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            } else {
                rest_max = i;
            }
        }
        if(s < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if(need >= p[rest_max])
                continue;
            num += need;
        }
        ans = min(ans, num);
    }

    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

#define MAX (10000000)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int memo[1001][1001][5];

int sx, sy;
int gx, gy;
vector<int> px[5];
vector<int> py[5];

#define ABS(x) ((x) < 0 ? -(x) : (x))
inline int dist(int x1, int x2, int y1, int y2){
  return ABS(x1 - x2) + ABS(y1 - y2);
}

int dp(int x, int y, int now, int last){
  if(now == last){
    return memo[x][y][now] = dist(x, gx, y, gy);
  }
  if(memo[x][y][now] != MAX) return memo[x][y][now];
  int ret = MAX;
  int n = px[now].size();
  REP(i, n){
    int d = dist(x, px[now][i], y, py[now][i]);
    int tmp = d + dp(px[now][i], py[now][i], (now+1)%5, last);
    ret = min(ret, tmp);
  }
  return memo[x][y][now] = ret;
}

int main(){
  int w,h;
  while(scanf("%d%d ",&w,&h), w+h){
    REP(i,5) px[i] = vector<int>();
    REP(i,5) py[i] = vector<int>();
    REP(i,h) REP(j,w){
      char tmp;
      scanf("%c ",&tmp);
      if(isdigit(tmp)){
        px[tmp- '1'].push_back(j);
        py[tmp- '1'].push_back(i);
      }else if(tmp == 'S'){
        sx = j;
        sy = i;
      }else if(tmp == 'G'){
        gx = j;
        gy = i;
      }
    }
    int bad = 0;
    REP(i,5) if(px[i].size() == 0) bad++;
    if(bad > 1){
      puts("NA");
      continue;
    }

    int ans = MAX;
    int type = -1;
    REP(s,5){
      int x = sx;
      int y = sy;
      REP(xx,w+1) REP(yy,h+1) REP(i,5) memo[xx][yy][i] = MAX;
      int ret = dp(x, y, (s+1)%5, s);
      if(ans > ret){
        ans = ret;
        type = s;
      }
    }
    if(ans == MAX){
      puts("NA");
    }else{
      printf("%d %d\n",type+1,ans);
    }
  }
  return 0;
}

Measured memory_bytes: 20000
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int E[] = { 0,1867,1911,1925,1988 };
signed main() {
	int e, y; cin >> e >> y;
	if (e == 0) {
		if (y <= 1911)cout << "M" << y - 1867 << endl;
		else if (y <= 1925)cout << "T" << y - 1911 << endl;
		else if (y <= 1988)cout << "S" << y - 1925 << endl;
		else cout << "H" << y - 1988 << endl;
	}
	else {
		cout << E[e] + y << endl;
	}
}



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll a, b, n;
  cin >> a >> b >> n;

  ll x = min(n, b-1);
  ll ans = (a*x)/b - (a * (x/b));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int i=0;
    
    while((i*a)%b!=c){
        i++;
        if(i*a>10000) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    cout<<"YES"<<endl;
}

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

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

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(nk[0] % nk[1] > 0 ? 1 : 0);
        }
    }
}


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

int h,w;
int maps[100][100];
int check[100][100];
int ans=0;
int dy[4]={-1,0,1,0};
int dx[4]={0,-1,0,1};

void solve(int y,int x,int cnt){
  if(ans<cnt)ans=cnt;
  for(int i=0;i<4;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(maps[ny][nx]==1 && check[ny][nx]==-1  && ny>=0 && ny<h && nx>=0 && nx<w){
      check[ny][nx]=1;
      solve(ny,nx,cnt+1);
      check[ny][nx]=-1;
    }
  }
    return;
}
int main(){
  while(1){
  cin>>w>>h;
  ans=0;
  if(!(w || h))break;
  memset(maps,0,sizeof(maps));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>maps[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(maps[i][j]==1){
	memset(check,-1,sizeof(check));
	check[i][j]=1;
	solve(i,j,1);
      }
    }
  }
  cout<<ans<<endl;
  }
}

Measured memory_bytes: 1244
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	int ans = 0, a = 0, b = 0;
	bool f = true;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		for (int j = 0; j < s[i].length() - 1; j++) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B') {
				j++;
				ans++;
			}
		}

		if (s[i][s[i].length() - 1] != 'A' && s[i][0] == 'B') {
			f = false;
		} else if (s[i][s[i].length() - 1] == 'A' && s[i][0] != 'B') {
			f = false;
		}
		if (s[i][s[i].length() - 1] == 'A') {
			a++;
		}
		if (s[i][0] == 'B') {
			b++;
		}
	}

	if (min(a, b) != 0) {
		ans += min(a, b) - (f ? 1 : 0);
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	LL X;
	cin >> X;
	int ans=0;
	LL N=100;
	while(N<X){
		N+=N/100;
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int f = sc.nextInt();
        int b = sc.nextInt();
        if (m + f < b) {
            System.out.println("NA");
        } else {
            System.out.println(Math.max(0, b - m));
        }
    }
}



Measured memory_bytes: 26352
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,raw_input().split())
es = [[] for i in range(N)]
for i in range(M):
  a,b = map(int,raw_input().split())
  a,b = a-1,b-1
  es[a].append(b)
  es[b].append(a)

colors = [0 for i in range(N)]

def dfs(v,color):
  colors[v] = color
  for to in es[v]:
    if colors[to] == color:
      return False
    if colors[to] == 0 and not dfs(to, -color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite():
  b = (sum(colors) + N) // 2
  w = N-b
  print(b*w - M)
else:
  all = N*(N-1) // 2
  print(all - M)

Measured memory_bytes: 32236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
  void Solve()
  {
    var N = int.Parse(Console.ReadLine());
    var A = Console.ReadLine().Split();
    var B = Console.ReadLine().Split();
    var AA = new int[N+1];
    var BB = new int[N];
    for (int i=0;i<N+1;i++)
    {
      AA[i] = int.Parse(A[i]);
    }
    for (int i = 0; i < N; i++)
    {
      BB[i] = int.Parse(B[i]);
    }
    long r = 0;
    // N
    for (int i = 0; i < N; i++)
    {
      var a = Math.Min(AA[i], BB[i]);
      AA[i] -= a;
      BB[i] -= a;
      r += a;

      a = Math.Min(AA[i+1], BB[i]);
      AA[i+1] -= a;
      BB[i] -= a;
      r += a;
    }
    Console.WriteLine(r);
  }

  static void Main(string[] args)
  {
    new Program().Solve();
  }
}



Measured memory_bytes: 33044
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b,long long m) {
        
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

const int mod=1e9+7;

int fac[2000005];
int ncr(int n,int r)
{
    if(n<r)
        return 0;
    int z=fac[n];
    z=(z*power(fac[n-r],mod-2,mod))%mod;
    z=(z*power(fac[r],mod-2,mod))%mod;
    return z;
}

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    fac[0]=1;
    for(int i=1;i<=2000000;i++)
        fac[i]=(fac[i-1]*i)%mod;

    int k;
    cin>>k;
    string a;
    cin>>a;
    int n=a.length();
    int tot=0;
    for(int i=n;i<=n+k;i++)
    {
        int z=power(25,i-n,mod)*ncr(i-1,n-1)%mod*power(26,n+k-i,mod)%mod;
        tot+=z;
        tot%=mod;
    }    
    cout<<tot;
        

} 
    
 


Measured memory_bytes: 19836
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var result = (function(sec) {
    return [
        ~~(sec / (60 * 60))
        ,~~((sec % (60 * 60)) / 60)
        ,(sec % 60)
    ].join(':');
  }(parseInt(lines[0])
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7648
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

void func() {
  LD N;
  cin >> N;
  cout << LL(ceil(N / 2) - 1);
    
}





#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256
N,K=map(int, input().split())
int_dict={}
for a in map(int, input().split()):
	int_dict.setdefault(a,0)
	int_dict[a]+=1
diff=len(int_dict) - K
if diff <= 0:
	print("0")
else:
	print(sum(sorted(int_dict.values())[:diff]))


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

int main() {
  int w,a,b;
  cin >> w >> a >> b;
  if(a > b){
    swap(a,b);
  }
  if(a + w > b){
    cout << 0 << endl;
  }else{
    cout << b - a - w << endl;
  }
}


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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


bool solve(int H, int W, vs& a) {
    vi cnt(26,0);
    rep(i,H) rep(j,W) {
        cnt[ a[i][j] -'a' ]++;
    }
    if (H % 2 == 0) {
        if (W % 2 == 0) {
            rep(i,26) {
                if (cnt[i] % 4) return false;
            }
            return true;
        } else {
            int four=0, two=0;
            rep(i,26) {
                if (cnt[i] % 4 == 0) { ++four; continue; }
                if (cnt[i] % 2 == 0) { ++two; continue; }
                return false;
            }
            if (two <= H/2) return true;
            return false;
        }
    } else {
        if (W % 2 == 0) {
            int four=0, two=0;
            rep(i,26) {
                if (cnt[i] % 4 == 0) { ++four; continue; }
                if (cnt[i] % 2 == 0) { ++two; continue; }
                return false;
            }
            if (two <= W/2) return true;
            return false;
        } else {
            int four=0, two=0, one=0;
            rep(i,26) {
                if (cnt[i] % 2) {
                    ++one;
                    if (one == 2) return false;
                    cnt[i]--;
                }
                if (cnt[i] % 4 == 0) { ++four; continue; }
                if (cnt[i] % 2 == 0) { ++two; continue; }
                return false;
            }
            if (two <= W/2+H/2) return true;
            return false;
        }
    }

    return false;
}

int main() {
    int H, W; cin >> H >> W;
    vs a(H); rep(i,H) cin >> a[i];
    cout << (solve(H,W,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<LL> L(N); cin >> L;
  sort(L.begin(),L.end());

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int k = j + 1; k < N; ++k) {
        if (L[i] != L[j] && L[j] != L[k]
            && L[i] + L[j] > L[k]) ++cnt;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#define INF 1001001001001001001
using namespace std;
typedef long long ll;

ll H,W,a_max,a_min;
ll ary[2010][2010],lma[2010][2010],lmi[2010][2010],rma[2010][2010],rmi[2010][2010],dp[2][2010];

inline ll amax(ll a,ll b){
	if(abs(a)>(INF/2)) a=0;
	if(abs(b)>(INF/2)) b=0;
	return max(abs(a),abs(b));
}
inline ll amin(ll a,ll b){
	return min(abs(a),abs(b));
}

int main(){
	cin>>H>>W;
	a_min=INF;a_max=0;
	for(ll i=1;i<=H;i++){
		for(ll j=1;j<=W;j++){
			cin>>ary[i][j];
			a_min=min(a_min,ary[i][j]);
			a_max=max(a_max,ary[i][j]);
		}
	}

	for(ll i=1;i<=H;i++){
		lma[i][0]=0;lmi[i][0]=INF;
		for(ll j=1;j<=W;j++){
			lma[i][j]=max(lma[i][j-1],ary[i][j]);
			lmi[i][j]=min(lmi[i][j-1],ary[i][j]);
		}
	}
	for(ll i=1;i<=H;i++){
		rma[i][W+1]=0;rmi[i][W+1]=INF;
		for(ll j=W;j>=1;j--){
			rma[i][j]=max(rma[i][j+1],ary[i][j]);
			rmi[i][j]=min(rmi[i][j+1],ary[i][j]);
		}
	}
	ll res=INF;

	ll in,ou;
	in=0,ou=1;
	fill(dp[in],dp[in]+2010,INF);
	for(ll i=0;i<=W;i++){
		dp[in][i]=amax(a_max-lmi[1][i],rma[1][i+1]-a_min);
	}
	for(ll i=2;i<=H;i++){
		ll nowmin=INF;
		for(ll j=0;j<=W;j++){
			nowmin=min(nowmin,dp[in][j]);
			dp[ou][j]=max(nowmin,amax(a_max-lmi[i][j],rma[i][j+1]-a_min));
		}
		swap(in,ou);
	}
	for(ll i=0;i<=W;i++) res=min(res,dp[in][i]);

	in=0,ou=1;
	fill(dp[in],dp[in]+2010,INF);
	for(ll i=0;i<=W;i++){
		dp[in][i]=amax(a_max-rmi[1][i+1],lma[1][i]-a_min);
	}
	for(ll i=2;i<=H;i++){
		ll nowmin=INF;
		for(ll j=0;j<=W;j++){
			nowmin=min(nowmin,dp[in][j]);
			dp[ou][j]=max(nowmin,amax(a_max-rmi[i][j+1],lma[i][j]-a_min));
		}
		swap(in,ou);
	}
	for(ll i=0;i<=W;i++) res=min(res,dp[in][i]);

	in=0,ou=1;
	fill(dp[in],dp[in]+2010,INF);
	for(ll i=0;i<=W;i++){
		dp[in][i]=amax(a_max-lmi[H][i],rma[H][i+1]-a_min);
	}
	for(ll i=H-1;i>=1;i--){
		ll nowmin=INF;
		for(ll j=0;j<=W;j++){
			nowmin=min(nowmin,dp[in][j]);
			dp[ou][j]=max(nowmin,amax(a_max-lmi[i][j],rma[i][j+1]-a_min));
		}
		swap(in,ou);
	}
	for(ll i=0;i<=W;i++) res=min(res,dp[in][i]);

	in=0,ou=1;
	fill(dp[in],dp[in]+2010,INF);
	for(ll i=0;i<=W;i++){
		dp[in][i]=amax(a_max-rmi[H][i+1],lma[H][i]-a_min);
	}
	for(ll i=H-1;i>=1;i--){
		ll nowmin=INF;
		for(ll j=0;j<=W;j++){
			nowmin=min(nowmin,dp[in][j]);
			dp[ou][j]=max(nowmin,amax(a_max-rmi[i][j+1],lma[i][j]-a_min));
		}
		swap(in,ou);
	}
	for(ll i=0;i<=W;i++) res=min(res,dp[in][i]);

	cout<<res<<endl;
	return 0;
}




Measured memory_bytes: 160164
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll h,w,n;
    cin>>h>>w>>n;
    cout<<min((n+w-1)/w,(n+h-1)/h)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long gcd(long long x,long long y)
{
	if (y) return gcd(x%y,y);
	return x;
}
long long lcm(long long x,long long y)
{
	return x/gcd(x,y)*y;
}
long long n,m,i,j,ans1=1,ans2=1,x,y,t,t2,t3,t4;
int main()
{
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>x>>y;
		t=(ans1+x-1)/x*x;
		t2=t/x*y;
		if (t<ans1||t2<ans2) t=t2=6e17;
		swap(x,y);swap(ans1,ans2);
		t3=(ans1+x-1)/x*x;
		t4=t3/x*y;
		swap(ans1,ans2);
		if (t4<ans1||t3<ans2) t3=t4=6e17;
		if (t+t2<t3+t4)
		{
			ans1=t;
			ans2=t2;
		}
		else
		{
			ans1=t4;
			ans2=t3;
		}
	}
	cout<<ans1+ans2;
	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
H = [int(x) for x in input().split()]
 
def main(N,K,H):
    dp = [0]*N
    for i in range(1,N):
        L = [dp[j]+abs(H[i]-H[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)
    print(dp[-1])
main(N,K,H)

Measured memory_bytes: 13976
#include <bits/stdc++.h>
using namespace std;
int d,n,q,i,p,a[1<<18];long long ret;
main(){
	while(cin>>d>>n>>q){
		for(i=1;i<n;i++)cin>>a[i],a[i+n]=a[i]+d;a[n]=d;
		sort(a,a+2*n);
		long long ret=0;
		while(q--){cin>>i;p=lower_bound(a,a+n,i)-a;ret+=min(a[p]-i,i-a[p+n-1]+d);}
		cout<<ret<<endl;
	}
}

Measured memory_bytes: 3812
/* Linear Search */
#include<iostream>
using namespace std;
int main(){
  int n, q, cnt = 0;
  
  cin >> n;
  int s[n];
  for(int i = 0; i < n; i++) cin >> s[i];

  cin >> q;
  int t[q];
  for(int j = 0; j < q; j++) cin >> t[j];

  for(int i = 0; i < q; i++){
    for(int j = 0; j < n; j++){
      if(t[i] == s[j]){
        cnt++;
        break;
      }
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3108
def 解():
    iN = int(input())
    aA = reversed(sorted([int(_) for _ in input().split()]))
    iC = 0
    d = {}
    for a in aA:
        if a in d:
            if d[a] == 3:
                print(a*a)
                exit()
            elif iC and iC != a:
                print(iC * a)
                exit()
            else:
                iC = a
                d[a] += 1
        else:
            d[a] = 1
    print(0)
解()


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

int main() {
  int a,b,i,ans=-1;
  cin >> a;
  cin >> b;
  
  for(i=1;i<10001;i++){
    if ((int)(i*0.08)==a && (int)(i*0.1)==b){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

// ACL template
int main() {
    ll N, M;
    cin >> N >> M;
    vl A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    vl C = convolution(A, B);

    rep(i, N + M - 1) cout << C[i] << " ";
    cout << endl;
}

Measured memory_bytes: 27304
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    sort(ALL(a),greater<int>());
    
    vint v;
    REP(i,N-1){
        if(a[i]==a[i+1]){
            v.push_back(a[i]);
            i++;
        }
    }
    
    int ans=0;
    if(v.size()>=2) ans=v[0]*v[1];
    cout<<ans<<endl;

}


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

using namespace std;

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

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

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

ll S[1005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll s = 0;
    REP(i, N) {
        cin >> S[i];
        s += S[i];
    }

    if (s % 10 != 0) {
        cout << s << endl;
        return 0;
    }

    ll mn = INF;
    REP(i, N) {
        if (S[i] % 10 == 0)
            continue;
        mn = std::min(mn, S[i]);
    }

    cout << std::max(0LL, s - mn) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    int n,h,w;
    Int ans=0;
    cin>>n>>h>>w;
    ans=max(1,n-h+1)*max(1,n-w+1);


    cout<<ans;

    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim n As Long = Long.Parse(Console.ReadLine())
    Dim arrayH As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim dp(0 To n - 1) As Long
    dp(0) = 0
    For j As Long = 1 To n - 1
      If j = 1 Then 
        dp(j) = Math.Abs(arrayH(j - 1) - arrayH(j))
      Else
        Dim jump1 As Long = Math.Abs(arrayH(j - 1) - arrayH(j)) + dp(j - 1)
        Dim jump2 As Long = Math.Abs(arrayH(j - 2) - arrayH(j)) + dp(j - 2)
        dp(j) = If(jump1 < jump2, jump1, jump2)
      End If
    Next
    Console.WriteLine(dp(n - 1).ToString())
  End Sub
End Class

Measured memory_bytes: 19680
#include <cstdio>
#include <cctype>
#include <climits>
#include <vector>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	//return n; }
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

#define v vector
struct graph {
	struct node {int n, w;};
	v<v<node>> nodes;

	void read(int n) {
		nodes.resize(n);
		for (auto &x: nodes) {
			in();
			for (int k = in(); k--;) {
				int c = in();
				x.push_back({c, in()});
			}
		}
	}

	v<node> dks() {
		v<node> w(nodes.size(), {0, INT_MAX});
		w[0].w = 0;
		priority_queue<node> q;
		q.push({0, 0});
		while (!q.empty()) {
			node n = q.top();
			q.pop();
			for (node &x: nodes[n.n]) {
				w[x.n].w = min(w[x.n].w, n.w + x.w);
				if (!w[n.n].n)
					q.push({x.n, w[x.n].w});
			}
			w[n.n].n = 1;
		}
		return move(w);
	}
};

bool operator < (const graph::node &a, const graph::node &b) {
	return a.w > b.w;
}

int main() {
	graph g;
	g.read(in());
	int i = 0;
	for (auto &x: g.dks())
		out(i++, ' ', x.w, '\n');
}


Measured memory_bytes: 2680
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        int prev_type = 0;
        int answer = 1;
        int prev = A[0];
        for (int i = 0; i < N; i++) {
            int current_type = type(prev, A[i]);
            prev = A[i];
            if (prev_type == current_type) {
                continue;
            }
            if (prev_type == 0) {
                prev_type = current_type;
                continue;
            }
            if (current_type == 0) {
                continue;
            }
            prev_type = 0;
            answer += 1;
        }
        System.out.println(answer);
    }
    private int type(int prev, int current) {
        if (prev < current) {
            return 1;
        }
        if (current < prev) {
            return -1;
        }
        return 0;
    }
}


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

using namespace std;

int main()
{
    long long n,k;
    cin>>n>>k;
    int r,s,p;
    cin>>r>>s>>p;
    string com;
    cin>>com;
    vector<int> a;
    vector<int> ile;
    a.assign(n,0);
    ile.assign(n,1);
    int suma=0;
    for(int i = 0;i<n;i++)
    {
        if(com[i]=='r')a[i]=p;
        else if(com[i]=='p')a[i]=s;
        else a[i]=r;
        if(i<k)suma+=a[i];
        else{
            if(com[i]==com[i-k])
            {
                ile[i]=ile[i-k]+1;
            }
            if(com[i]!=com[i-k]||ile[i]&1)suma+=a[i];
        }
    }
    cout<<suma;
}

Measured memory_bytes: 1280
def check(h,w):
	s = A[h][w]
	if A[h].count(s) > 1 or RA[w].count(s) > 1 or A9[h/3][w/3].count(s) > 1:
		return "*"
	else:
		return " "
R = range(9)
for r in range(input()):
	if r > 0: print
	A  = [raw_input().split() for i in R]
	RA = [[A[h][w] for h in range(9)] for w in R] 
	A9 = [[A[h][w:w+3]+A[h+1][w:w+3]+A[h+2][w:w+3] for w in [0,3,6]] for h in [0,3,6]]
	P = [[check(h,w) for w in R] for h in R] 
	for h in R:
		print "".join([P[h][w]+A[h][w] for w in R])

Measured memory_bytes: 4284
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;
using ll = long long int;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll N;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
}

int F(ll a, ll b){
  string x=to_string(a);
  string y=to_string(b);
  return max(x.length(),y.length());
}

int solve(){
  int ans=1e6;
  auto dv = divisor(N);
  for(auto d:dv){
    ans = min(ans,F(d,N/d));
  }
  cout << ans << endl;
  return 0;
}   

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


Measured memory_bytes: 256